[gmime] Split out GMimeSigner's key info into GMimeCryptoKey
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Split out GMimeSigner's key info into GMimeCryptoKey
- Date: Fri, 4 Mar 2011 16:26:46 +0000 (UTC)
commit d133488390e56b6ba98db3325f830e9c9fd4e878
Author: Jeffrey Stedfast <fejj gnome org>
Date: Fri Mar 4 11:25:45 2011 -0500
Split out GMimeSigner's key info into GMimeCryptoKey
2011-03-04 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-crypto-context.c: Moved GMimeSigner's key info out
of GMimeSigner and into a new struct, GMimeCryptoKey. This is
the
first step in solving bug #641319.
* gmime/gmime-pkcs7-context.c: Updated for above changes.
* gmime/gmime-gpg-context.c: Updated for above changes.
ChangeLog | 10 +
docs/reference/gmime-sections.txt | 59 ++--
gmime/gmime-crypto-context.c | 615 ++++++++++++++++++++-----------------
gmime/gmime-crypto-context.h | 184 ++++++-----
gmime/gmime-gpg-context.c | 24 +-
gmime/gmime-pkcs7-context.c | 25 +-
mono/GMime.metadata | 22 ++-
mono/gmime-api.raw | 204 +++++++------
tests/test-pgpmime.c | 12 +-
tests/test-smime.c | 12 +-
10 files changed, 641 insertions(+), 526 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f1b2a29..22fc187 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-03-04 Jeffrey Stedfast <fejj novell com>
+ * gmime/gmime-crypto-context.c: Moved GMimeSigner's key info out
+ of GMimeSigner and into a new struct, GMimeCryptoKey. This is the
+ first step in solving bug #641319.
+
+ * gmime/gmime-pkcs7-context.c: Updated for above changes.
+
+ * gmime/gmime-gpg-context.c: Updated for above changes.
+
+2011-03-04 Jeffrey Stedfast <fejj novell com>
+
API cleanup as well as preparing for the possibility of a
multi-protocol CryptoContext.
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 033f238..13b1787 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -1139,11 +1139,6 @@ g_mime_iconv_locale_to_utf8_length
GMimePasswordRequestFunc
GMimeCryptoHash
GMimeCryptoContext
-GMimeSignatureValidity
-GMimeSignerStatus
-GMimeSignerTrust
-GMimeSignerError
-GMimeSigner
g_mime_crypto_context_set_request_password
g_mime_crypto_context_get_signature_protocol
g_mime_crypto_context_get_encryption_protocol
@@ -1157,6 +1152,31 @@ g_mime_crypto_context_decrypt
g_mime_crypto_context_import_keys
g_mime_crypto_context_export_keys
<SUBSECTION>
+GMimeCryptoPubKeyAlgo
+GMimeCryptoKey
+g_mime_crypto_key_get_creation_date
+g_mime_crypto_key_set_creation_date
+g_mime_crypto_key_get_expiration_date
+g_mime_crypto_key_set_expiration_date
+g_mime_crypto_key_get_pubkey_algo
+g_mime_crypto_key_set_pubkey_algo
+g_mime_crypto_key_get_issuer_serial
+g_mime_crypto_key_set_issuer_serial
+g_mime_crypto_key_get_issuer_name
+g_mime_crypto_key_set_issuer_name
+g_mime_crypto_key_get_fingerprint
+g_mime_crypto_key_set_fingerprint
+g_mime_crypto_key_get_key_id
+g_mime_crypto_key_set_key_id
+g_mime_crypto_key_get_email
+g_mime_crypto_key_set_email
+g_mime_crypto_key_get_name
+g_mime_crypto_key_set_name
+<SUBSECTION>
+GMimeSignerStatus
+GMimeSignerTrust
+GMimeSignerError
+GMimeSigner
g_mime_signer_new
g_mime_signer_free
g_mime_signer_next
@@ -1168,32 +1188,17 @@ g_mime_signer_get_trust
g_mime_signer_set_trust
g_mime_signer_get_hash_algo
g_mime_signer_set_hash_algo
-g_mime_signer_get_pubkey_algo
-g_mime_signer_set_pubkey_algo
-g_mime_signer_get_issuer_serial
-g_mime_signer_set_issuer_serial
-g_mime_signer_get_issuer_name
-g_mime_signer_set_issuer_name
-g_mime_signer_get_fingerprint
-g_mime_signer_set_fingerprint
g_mime_signer_get_sig_class
g_mime_signer_set_sig_class
g_mime_signer_get_sig_version
g_mime_signer_set_sig_version
-g_mime_signer_get_sig_created
-g_mime_signer_set_sig_created
-g_mime_signer_get_sig_expires
-g_mime_signer_set_sig_expires
-g_mime_signer_get_key_created
-g_mime_signer_set_key_created
-g_mime_signer_get_key_expires
-g_mime_signer_set_key_expires
-g_mime_signer_get_key_id
-g_mime_signer_set_key_id
-g_mime_signer_get_email
-g_mime_signer_set_email
-g_mime_signer_get_name
-g_mime_signer_set_name
+g_mime_signer_get_creation_date
+g_mime_signer_set_creation_date
+g_mime_signer_get_expiration_date
+g_mime_signer_set_expiration_date
+g_mime_signer_get_key
+<SUBSECTION>
+GMimeSignatureValidity
g_mime_signature_validity_new
g_mime_signature_validity_free
g_mime_signature_validity_set_details
diff --git a/gmime/gmime-crypto-context.c b/gmime/gmime-crypto-context.c
index 7e1b516..3397653 100644
--- a/gmime/gmime-crypto-context.c
+++ b/gmime/gmime-crypto-context.c
@@ -522,648 +522,705 @@ g_mime_crypto_context_export_keys (GMimeCryptoContext *ctx, GPtrArray *keys,
/**
- * g_mime_signer_new:
- * @status: A #GMimeSignerStatus
+ * g_mime_crypto_key_new:
+ * @key_id: The key id or %NULL if unspecified.
*
- * Allocates an new #GMimeSigner with the designated @status. This
+ * Allocates an new #GMimeCryptoKey with the designated @key_id. This
* function is meant to be used in #GMimeCryptoContext subclasses when
- * allocating signers to add to a #GMimeSignatureValidity.
+ * creating keys to be used with #GMimeSigner.
*
- * Returns: a new #GMimeSigner with the designated @status.
+ * Returns: a new #GMimeCryptoKey.
**/
-GMimeSigner *
-g_mime_signer_new (GMimeSignerStatus status)
+static GMimeCryptoKey *
+g_mime_crypto_key_new (const char *key_id)
{
- GMimeSigner *signer;
+ GMimeCryptoKey *key;
- signer = g_slice_new (GMimeSigner);
- signer->pubkey_algo = GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT;
- signer->hash_algo = GMIME_CRYPTO_HASH_DEFAULT;
- signer->status = status;
- signer->errors = GMIME_SIGNER_ERROR_NONE;
- signer->trust = GMIME_SIGNER_TRUST_NONE;
- signer->sig_created = (time_t) -1;
- signer->sig_expires = (time_t) -1;
- signer->key_created = (time_t) -1;
- signer->key_expires = (time_t) -1;
- signer->issuer_serial = NULL;
- signer->issuer_name = NULL;
- signer->fingerprint = NULL;
- signer->keyid = NULL;
- signer->email = NULL;
- signer->name = NULL;
- signer->next = NULL;
+ key = g_slice_new (GMimeCryptoKey);
+ key->pubkey_algo = GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT;
+ key->created = (time_t) -1;
+ key->expires = (time_t) -1;
+ key->issuer_serial = NULL;
+ key->issuer_name = NULL;
+ key->fingerprint = NULL;
+ key->keyid = NULL;
+ key->email = NULL;
+ key->name = NULL;
- return signer;
+ return key;
}
/**
- * g_mime_signer_free:
- * @signer: signer
+ * g_mime_crypto_key_free:
+ * @key: a #GMimeCryptoKey
*
- * Frees the singleton signer. Should NOT be used to free signers
- * returned from g_mime_signature_validity_get_signers().
+ * Frees the crypto key.
+ **/
+static void
+g_mime_crypto_key_free (GMimeCryptoKey *key)
+{
+ if (key != NULL) {
+ g_free (key->issuer_serial);
+ g_free (key->issuer_name);
+ g_free (key->fingerprint);
+ g_free (key->keyid);
+ g_free (key->email);
+ g_free (key->name);
+
+ g_slice_free (GMimeCryptoKey, key);
+ }
+}
+
+
+/**
+ * g_mime_crypto_key_set_pubkey_algo:
+ * @key: a #GMimeCryptoKey
+ * @pubkey_algo: a #GMimeCryptoPubKeyAlgo
+ *
+ * Set the public-key algorithm associated with the key.
**/
void
-g_mime_signer_free (GMimeSigner *signer)
+g_mime_crypto_key_set_pubkey_algo (GMimeCryptoKey *key, GMimeCryptoPubKeyAlgo pubkey_algo)
{
- g_free (signer->issuer_serial);
- g_free (signer->issuer_name);
- g_free (signer->fingerprint);
- g_free (signer->keyid);
- g_free (signer->email);
- g_free (signer->name);
+ g_return_if_fail (key != NULL);
- g_slice_free (GMimeSigner, signer);
+ key->pubkey_algo = pubkey_algo;
}
/**
- * g_mime_signer_next:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_pubkey_algo:
+ * @key: a #GMimeCryptoKey
*
- * Advance to the next signer.
+ * Get the public-key algorithm associated with @key.
*
- * Returns: the next #GMimeSigner or %NULL when complete.
+ * Returns: the public-key algorithm associated with the key.
**/
-GMimeSigner *
-g_mime_signer_next (GMimeSigner *signer)
+GMimeCryptoPubKeyAlgo
+g_mime_crypto_key_get_pubkey_algo (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (key != NULL, GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT);
- return signer->next;
+ return key->pubkey_algo;
}
/**
- * g_mime_signer_set_status:
- * @signer: a #GMimeSigner
- * @status: a #GMimeSignerStatus
+ * g_mime_crypto_key_set_issuer_serial:
+ * @key: a #GMimeCryptoKey
+ * @issuer_serial: issuer serial
*
- * Set the status on the signer.
+ * Set the key's issuer serial.
**/
void
-g_mime_signer_set_status (GMimeSigner *signer, GMimeSignerStatus status)
+g_mime_crypto_key_set_issuer_serial (GMimeCryptoKey *key, const char *issuer_serial)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->status = status;
+ g_free (key->issuer_serial);
+ key->issuer_serial = g_strdup (issuer_serial);
}
/**
- * g_mime_signer_get_status:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_issuer_serial:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer status.
+ * Get the key's issuer serial.
*
- * Returns: the signer status.
+ * Returns: the key's issuer serial.
**/
-GMimeSignerStatus
-g_mime_signer_get_status (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_issuer_serial (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, GMIME_SIGNER_STATUS_BAD);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->status;
+ return key->issuer_serial;
}
/**
- * g_mime_signer_set_errors:
- * @signer: a #GMimeSigner
- * @error: a #GMimeSignerError
+ * g_mime_crypto_key_set_issuer_name:
+ * @key: a #GMimeCryptoKey
+ * @issuer_name: issuer name
*
- * Set the errors on the signer.
+ * Set the key's issuer name.
**/
void
-g_mime_signer_set_errors (GMimeSigner *signer, GMimeSignerError errors)
+g_mime_crypto_key_set_issuer_name (GMimeCryptoKey *key, const char *issuer_name)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->errors = errors;
+ g_free (key->issuer_name);
+ key->issuer_name = g_strdup (issuer_name);
}
/**
- * g_mime_signer_get_errors:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_issuer_name:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer errors. If the #GMimeSignerStatus returned from
- * g_mime_signer_get_status() is not #GMIME_SIGNER_STATUS_GOOD, then
- * the errors may provide a clue as to why.
+ * Get the key's issuer name.
*
- * Returns: the signer errors.
+ * Returns: the key's issuer name.
**/
-GMimeSignerError
-g_mime_signer_get_errors (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_issuer_name (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, GMIME_SIGNER_ERROR_NONE);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->errors;
+ return key->issuer_name;
}
/**
- * g_mime_signer_set_trust:
- * @signer: a #GMimeSigner
- * @trust: a #GMimeSignerTrust
+ * g_mime_crypto_key_set_fingerprint:
+ * @key: a #GMimeCryptoKey
+ * @fingerprint: fingerprint string
*
- * Set the signer trust.
+ * Set the key's fingerprint.
**/
void
-g_mime_signer_set_trust (GMimeSigner *signer, GMimeSignerTrust trust)
+g_mime_crypto_key_set_fingerprint (GMimeCryptoKey *key, const char *fingerprint)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->trust = trust;
+ g_free (key->fingerprint);
+ key->fingerprint = g_strdup (fingerprint);
}
/**
- * g_mime_signer_get_trust:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_fingerprint:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer trust.
+ * Get the key's fingerprint.
*
- * Returns: the signer trust.
+ * Returns: the key's fingerprint.
**/
-GMimeSignerTrust
-g_mime_signer_get_trust (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_fingerprint (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, GMIME_SIGNER_TRUST_NONE);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->trust;
+ return key->fingerprint;
}
/**
- * g_mime_signer_set_sig_class:
- * @signer: a #GMimeSigner
- * @sig_class: signature class
+ * g_mime_crypto_key_set_key_id:
+ * @key: a #GMimeCryptoKey
+ * @key_id: key id
*
- * Set the signer's signature class.
+ * Set the key's id.
**/
void
-g_mime_signer_set_sig_class (GMimeSigner *signer, int sig_class)
+g_mime_crypto_key_set_key_id (GMimeCryptoKey *key, const char *key_id)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->sig_class = (unsigned int) (sig_class & 0xff);
+ g_free (key->keyid);
+ key->keyid = g_strdup (key_id);
}
/**
- * g_mime_signer_get_sig_class:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_key_id:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer's signature class.
+ * Get the key's id.
*
- * Returns: the signer's signature class.
+ * Returns: the key's id.
**/
-int
-g_mime_signer_get_sig_class (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_key_id (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, 0);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->sig_class;
+ return key->keyid;
}
/**
- * g_mime_signer_set_sig_version:
- * @signer: a #GMimeSigner
- * @sig_class: signature version
+ * g_mime_crypto_key_set_email:
+ * @key: a #GMimeCryptoKey
+ * @email: email address
*
- * Set the signer's signature version.
+ * Set the key's email address.
**/
void
-g_mime_signer_set_sig_version (GMimeSigner *signer, int version)
+g_mime_crypto_key_set_email (GMimeCryptoKey *key, const char *email)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->sig_ver = (unsigned int) (version & 0xff);
+ g_free (key->email);
+ key->email = g_strdup (email);
}
/**
- * g_mime_signer_get_sig_version:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_email:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer's signature version.
+ * Get the key's email address.
*
- * Returns: the signer's signature version.
+ * Returns: the key's email address.
**/
-int
-g_mime_signer_get_sig_version (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_email (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, 0);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->sig_ver;
+ return key->email;
}
/**
- * g_mime_signer_set_pubkey_algo:
- * @signer: a #GMimeSigner
- * @pubkey_algo: a #GMimeCryptoPubKeyAlgo
+ * g_mime_crypto_key_set_name:
+ * @key: a #GMimeCryptoKey
+ * @name: key's name
*
- * Set the public-key algorithm used by the signer.
+ * Set the key's name.
**/
void
-g_mime_signer_set_pubkey_algo (GMimeSigner *signer, GMimeCryptoPubKeyAlgo pubkey_algo)
+g_mime_crypto_key_set_name (GMimeCryptoKey *key, const char *name)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->pubkey_algo = pubkey_algo;
+ g_free (key->name);
+ key->name = g_strdup (name);
}
/**
- * g_mime_signer_get_pubkey_algo:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_name:
+ * @key: a #GMimeCryptoKey
*
- * Get the public-key algorithm used by the signer.
+ * Get the key's name.
*
- * Returns: the public-key algorithm used by the signer.
+ * Returns: the key's name.
**/
-GMimeCryptoPubKeyAlgo
-g_mime_signer_get_pubkey_algo (const GMimeSigner *signer)
+const char *
+g_mime_crypto_key_get_name (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT);
+ g_return_val_if_fail (key != NULL, NULL);
- return signer->pubkey_algo;
+ return key->name;
}
/**
- * g_mime_signer_set_hash_algo:
- * @signer: a #GMimeSigner
- * @hash: a #GMimeCryptoHash
+ * g_mime_crypto_key_set_creation_date:
+ * @key: a #GMimeCryptoKey
+ * @created: creation date
*
- * Set the hash algorithm used by the signer.
+ * Set the creation date of the key.
**/
void
-g_mime_signer_set_hash_algo (GMimeSigner *signer, GMimeCryptoHash hash)
+g_mime_crypto_key_set_creation_date (GMimeCryptoKey *key, time_t created)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- signer->hash_algo = hash;
+ key->created = created;
}
/**
- * g_mime_signer_get_hash_algo:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_creation_date:
+ * @key: a #GMimeCryptoKey
*
- * Get the hash algorithm used by the signer.
+ * Get the creation date of the key.
*
- * Returns: the hash algorithm used by the signer.
+ * Returns: the creation date of the key or %-1 if unknown.
**/
-GMimeCryptoHash
-g_mime_signer_get_hash_algo (const GMimeSigner *signer)
+time_t
+g_mime_crypto_key_get_creation_date (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, GMIME_CRYPTO_HASH_DEFAULT);
+ g_return_val_if_fail (key != NULL, (time_t) -1);
- return signer->hash_algo;
+ return key->created;
}
/**
- * g_mime_signer_set_issuer_serial:
- * @signer: a #GMimeSigner
- * @issuer_serial: signer's issuer serial
+ * g_mime_crypto_key_set_expiration_date:
+ * @key: a #GMimeCryptoKey
+ * @expires: expiration date
*
- * Set the signer's issuer serial.
+ * Set the expiration date of the key.
**/
void
-g_mime_signer_set_issuer_serial (GMimeSigner *signer, const char *issuer_serial)
+g_mime_crypto_key_set_expiration_date (GMimeCryptoKey *key, time_t expires)
{
- g_return_if_fail (signer != NULL);
+ g_return_if_fail (key != NULL);
- g_free (signer->issuer_serial);
- signer->issuer_serial = g_strdup (issuer_serial);
+ key->expires = expires;
}
/**
- * g_mime_signer_get_issuer_serial:
- * @signer: a #GMimeSigner
+ * g_mime_crypto_key_get_expiration_date:
+ * @key: a #GMimeCryptoKey
*
- * Get the signer's issuer serial.
+ * Get the expiration date of the key.
*
- * Returns: the signer's issuer serial.
+ * Returns: the expiration date of the key or %-1 if unknown.
**/
-const char *
-g_mime_signer_get_issuer_serial (const GMimeSigner *signer)
+time_t
+g_mime_crypto_key_get_expiration_date (const GMimeCryptoKey *key)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (key != NULL, (time_t) -1);
+
+ return key->expires;
+}
+
+
+/**
+ * g_mime_signer_new:
+ * @status: A #GMimeSignerStatus
+ *
+ * Allocates an new #GMimeSigner with the designated @status. This
+ * function is meant to be used in #GMimeCryptoContext subclasses when
+ * allocating signers to add to a #GMimeSignatureValidity.
+ *
+ * Returns: a new #GMimeSigner with the designated @status.
+ **/
+GMimeSigner *
+g_mime_signer_new (GMimeSignerStatus status)
+{
+ GMimeSigner *signer;
- return signer->issuer_serial;
+ signer = g_slice_new (GMimeSigner);
+ signer->key = g_mime_crypto_key_new (NULL);
+ signer->hash_algo = GMIME_CRYPTO_HASH_DEFAULT;
+ signer->status = status;
+ signer->errors = GMIME_SIGNER_ERROR_NONE;
+ signer->trust = GMIME_SIGNER_TRUST_NONE;
+ signer->created = (time_t) -1;
+ signer->expires = (time_t) -1;
+ signer->next = NULL;
+
+ return signer;
}
/**
- * g_mime_signer_set_issuer_name:
+ * g_mime_signer_free:
* @signer: a #GMimeSigner
- * @issuer_name: signer's issuer name
*
- * Set the signer's issuer name.
+ * Frees the singleton signer. Should NOT be used to free signers
+ * returned from g_mime_signature_validity_get_signers().
**/
void
-g_mime_signer_set_issuer_name (GMimeSigner *signer, const char *issuer_name)
+g_mime_signer_free (GMimeSigner *signer)
{
- g_return_if_fail (signer != NULL);
-
- g_free (signer->issuer_name);
- signer->issuer_name = g_strdup (issuer_name);
+ if (signer != NULL) {
+ g_mime_crypto_key_free (signer->key);
+ g_slice_free (GMimeSigner, signer);
+ }
}
/**
- * g_mime_signer_get_issuer_name:
+ * g_mime_signer_next:
* @signer: a #GMimeSigner
*
- * Get the signer's issuer name.
+ * Advance to the next signer.
*
- * Returns: the signer's issuer name.
+ * Returns: the next #GMimeSigner or %NULL when complete.
**/
-const char *
-g_mime_signer_get_issuer_name (const GMimeSigner *signer)
+GMimeSigner *
+g_mime_signer_next (GMimeSigner *signer)
{
g_return_val_if_fail (signer != NULL, NULL);
- return signer->issuer_name;
+ return signer->next;
}
/**
- * g_mime_signer_set_fingerprint:
+ * g_mime_signer_set_status:
* @signer: a #GMimeSigner
- * @fingerprint: fingerprint string
+ * @status: a #GMimeSignerStatus
*
- * Set the signer's key fingerprint.
+ * Set the status on the signer.
**/
void
-g_mime_signer_set_fingerprint (GMimeSigner *signer, const char *fingerprint)
+g_mime_signer_set_status (GMimeSigner *signer, GMimeSignerStatus status)
{
g_return_if_fail (signer != NULL);
- g_free (signer->fingerprint);
- signer->fingerprint = g_strdup (fingerprint);
+ signer->status = status;
}
/**
- * g_mime_signer_get_fingerprint:
+ * g_mime_signer_get_status:
* @signer: a #GMimeSigner
*
- * Get the signer's key fingerprint.
+ * Get the signer status.
*
- * Returns: the signer's key fingerprint.
+ * Returns: the signer status.
**/
-const char *
-g_mime_signer_get_fingerprint (const GMimeSigner *signer)
+GMimeSignerStatus
+g_mime_signer_get_status (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (signer != NULL, GMIME_SIGNER_STATUS_BAD);
- return signer->fingerprint;
+ return signer->status;
}
/**
- * g_mime_signer_set_key_id:
+ * g_mime_signer_set_errors:
* @signer: a #GMimeSigner
- * @key_id: key id
+ * @error: a #GMimeSignerError
*
- * Set the signer's key id.
+ * Set the errors on the signer.
**/
void
-g_mime_signer_set_key_id (GMimeSigner *signer, const char *key_id)
+g_mime_signer_set_errors (GMimeSigner *signer, GMimeSignerError errors)
{
g_return_if_fail (signer != NULL);
- g_free (signer->keyid);
- signer->keyid = g_strdup (key_id);
+ signer->errors = errors;
}
/**
- * g_mime_signer_get_key_id:
+ * g_mime_signer_get_errors:
* @signer: a #GMimeSigner
*
- * Get the signer's key id.
+ * Get the signer errors. If the #GMimeSignerStatus returned from
+ * g_mime_signer_get_status() is not #GMIME_SIGNER_STATUS_GOOD, then
+ * the errors may provide a clue as to why.
*
- * Returns: the signer's key id.
+ * Returns: the signer errors.
**/
-const char *
-g_mime_signer_get_key_id (const GMimeSigner *signer)
+GMimeSignerError
+g_mime_signer_get_errors (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (signer != NULL, GMIME_SIGNER_ERROR_NONE);
- return signer->keyid;
+ return signer->errors;
}
/**
- * g_mime_signer_set_email:
+ * g_mime_signer_set_trust:
* @signer: a #GMimeSigner
- * @email: signer's email
+ * @trust: a #GMimeSignerTrust
*
- * Set the signer's email.
+ * Set the signer trust.
**/
void
-g_mime_signer_set_email (GMimeSigner *signer, const char *email)
+g_mime_signer_set_trust (GMimeSigner *signer, GMimeSignerTrust trust)
{
g_return_if_fail (signer != NULL);
- g_free (signer->email);
- signer->email = g_strdup (email);
+ signer->trust = trust;
}
/**
- * g_mime_signer_get_email:
+ * g_mime_signer_get_trust:
* @signer: a #GMimeSigner
*
- * Get the signer's email.
+ * Get the signer trust.
*
- * Returns: the signer's email.
+ * Returns: the signer trust.
**/
-const char *
-g_mime_signer_get_email (const GMimeSigner *signer)
+GMimeSignerTrust
+g_mime_signer_get_trust (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (signer != NULL, GMIME_SIGNER_TRUST_NONE);
- return signer->email;
+ return signer->trust;
}
/**
- * g_mime_signer_set_name:
+ * g_mime_signer_set_sig_class:
* @signer: a #GMimeSigner
- * @name: signer's name
+ * @sig_class: signature class
*
- * Set the signer's name.
+ * Set the signer's signature class.
**/
void
-g_mime_signer_set_name (GMimeSigner *signer, const char *name)
+g_mime_signer_set_sig_class (GMimeSigner *signer, int sig_class)
{
g_return_if_fail (signer != NULL);
- g_free (signer->name);
- signer->name = g_strdup (name);
+ signer->sig_class = (unsigned int) (sig_class & 0xff);
}
/**
- * g_mime_signer_get_name:
+ * g_mime_signer_get_sig_class:
* @signer: a #GMimeSigner
*
- * Get the signer's name.
+ * Get the signer's signature class.
*
- * Returns: the signer's name.
+ * Returns: the signer's signature class.
**/
-const char *
-g_mime_signer_get_name (const GMimeSigner *signer)
+int
+g_mime_signer_get_sig_class (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, NULL);
+ g_return_val_if_fail (signer != NULL, 0);
- return signer->name;
+ return signer->sig_class;
}
/**
- * g_mime_signer_set_sig_created:
+ * g_mime_signer_set_sig_version:
* @signer: a #GMimeSigner
- * @created: creation date
+ * @sig_class: signature version
*
- * Set the creation date of the signer's signature.
+ * Set the signer's signature version.
**/
void
-g_mime_signer_set_sig_created (GMimeSigner *signer, time_t created)
+g_mime_signer_set_sig_version (GMimeSigner *signer, int version)
{
g_return_if_fail (signer != NULL);
- signer->sig_created = created;
+ signer->sig_ver = (unsigned int) (version & 0xff);
}
/**
- * g_mime_signer_get_sig_created:
+ * g_mime_signer_get_sig_version:
* @signer: a #GMimeSigner
*
- * Get the creation date of the signer's signature.
+ * Get the signer's signature version.
*
- * Returns: the creation date of the signer's signature or %-1 if
- * unknown.
+ * Returns: the signer's signature version.
**/
-time_t
-g_mime_signer_get_sig_created (const GMimeSigner *signer)
+int
+g_mime_signer_get_sig_version (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, (time_t) -1);
+ g_return_val_if_fail (signer != NULL, 0);
- return signer->sig_created;
+ return signer->sig_ver;
}
/**
- * g_mime_signer_set_sig_expires:
+ * g_mime_signer_set_hash_algo:
* @signer: a #GMimeSigner
- * @expires: expiration date
+ * @hash: a #GMimeCryptoHash
*
- * Set the expiration date of the signer's signature.
+ * Set the hash algorithm used by the signer.
**/
void
-g_mime_signer_set_sig_expires (GMimeSigner *signer, time_t expires)
+g_mime_signer_set_hash_algo (GMimeSigner *signer, GMimeCryptoHash hash)
{
g_return_if_fail (signer != NULL);
- signer->sig_expires = expires;
+ signer->hash_algo = hash;
}
/**
- * g_mime_signer_get_sig_expires:
+ * g_mime_signer_get_hash_algo:
* @signer: a #GMimeSigner
*
- * Get the expiration date of the signer's signature.
+ * Get the hash algorithm used by the signer.
*
- * Returns: the expiration date of the signer's signature or %-1 if
- * unknown.
+ * Returns: the hash algorithm used by the signer.
**/
-time_t
-g_mime_signer_get_sig_expires (const GMimeSigner *signer)
+GMimeCryptoHash
+g_mime_signer_get_hash_algo (const GMimeSigner *signer)
{
- g_return_val_if_fail (signer != NULL, (time_t) -1);
+ g_return_val_if_fail (signer != NULL, GMIME_CRYPTO_HASH_DEFAULT);
+
+ return signer->hash_algo;
+}
+
+
+/**
+ * g_mime_signer_get_key:
+ * @signer: a #GMimeSigner
+ *
+ * Get the #GMimeCryptoKey used by the signer.
+ *
+ * Returns: the key used by the signer.
+ **/
+const GMimeCryptoKey *
+g_mime_signer_get_key (const GMimeSigner *signer)
+{
+ g_return_val_if_fail (signer != NULL, NULL);
- return signer->sig_expires;
+ return signer->key;
}
/**
- * g_mime_signer_set_key_created:
+ * g_mime_signer_set_creation_date:
* @signer: a #GMimeSigner
* @created: creation date
*
- * Set the creation date of the signer's key.
+ * Set the creation date of the signer's signature.
**/
void
-g_mime_signer_set_key_created (GMimeSigner *signer, time_t created)
+g_mime_signer_set_creation_date (GMimeSigner *signer, time_t created)
{
g_return_if_fail (signer != NULL);
- signer->key_created = created;
+ signer->created = created;
}
/**
- * g_mime_signer_get_key_created:
+ * g_mime_signer_get_creation_date:
* @signer: a #GMimeSigner
*
- * Get the creation date of the signer's key.
+ * Get the creation date of the signer's signature.
*
- * Returns: the creation date of the signer's key or %-1 if unknown.
+ * Returns: the creation date of the signer's signature or %-1 if
+ * unknown.
**/
time_t
-g_mime_signer_get_key_created (const GMimeSigner *signer)
+g_mime_signer_get_creation_date (const GMimeSigner *signer)
{
g_return_val_if_fail (signer != NULL, (time_t) -1);
- return signer->key_created;
+ return signer->created;
}
/**
- * g_mime_signer_set_key_expires:
+ * g_mime_signer_set_expiration_date:
* @signer: a #GMimeSigner
* @expires: expiration date
*
- * Set the expiration date of the signer's key.
+ * Set the expiration date of the signer's signature.
**/
void
-g_mime_signer_set_key_expires (GMimeSigner *signer, time_t expires)
+g_mime_signer_set_expiration_date (GMimeSigner *signer, time_t expires)
{
g_return_if_fail (signer != NULL);
- signer->key_expires = expires;
+ signer->expires = expires;
}
/**
- * g_mime_signer_get_key_expires:
+ * g_mime_signer_get_expiration_date:
* @signer: a #GMimeSigner
*
- * Get the expiration date of the signer's key.
+ * Get the expiration date of the signer's signature.
*
- * Returns: the expiration date of the signer's key or %-1 if unknown.
+ * Returns: the expiration date of the signer's signature or %-1 if
+ * unknown.
**/
time_t
-g_mime_signer_get_key_expires (const GMimeSigner *signer)
+g_mime_signer_get_expiration_date (const GMimeSigner *signer)
{
g_return_val_if_fail (signer != NULL, (time_t) -1);
- return signer->key_expires;
+ return signer->expires;
}
diff --git a/gmime/gmime-crypto-context.h b/gmime/gmime-crypto-context.h
index 4f1ddb6..b6fd159 100644
--- a/gmime/gmime-crypto-context.h
+++ b/gmime/gmime-crypto-context.h
@@ -42,6 +42,7 @@ typedef struct _GMimeCryptoContext GMimeCryptoContext;
typedef struct _GMimeCryptoContextClass GMimeCryptoContextClass;
typedef struct _GMimeSigner GMimeSigner;
+typedef struct _GMimeCryptoKey GMimeCryptoKey;
typedef struct _GMimeSignatureValidity GMimeSignatureValidity;
@@ -63,30 +64,6 @@ typedef gboolean (* GMimePasswordRequestFunc) (GMimeCryptoContext *ctx, const ch
gboolean reprompt, GMimeStream *response, GError **err);
-
-/**
- * GMimeCryptoPubKeyAlgo:
- * @GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT: The default public-key algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_RSA: The RSA algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_RSA_E: An encryption-only RSA algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_RSA_S: A signature-only RSA algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_ELG: The ElGamal algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_ELG_E: An encryption-only ElGamal algorithm.
- * @GMIME_CRYPTO_PUBKEY_ALGO_DSA: The DSA algorithm.
- *
- * A public-key algorithm.
- **/
-typedef enum {
- GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT,
- GMIME_CRYPTO_PUBKEY_ALGO_RSA,
- GMIME_CRYPTO_PUBKEY_ALGO_RSA_E,
- GMIME_CRYPTO_PUBKEY_ALGO_RSA_S,
- GMIME_CRYPTO_PUBKEY_ALGO_ELG,
- GMIME_CRYPTO_PUBKEY_ALGO_ELG_E,
- GMIME_CRYPTO_PUBKEY_ALGO_DSA
-} GMimeCryptoPubKeyAlgo;
-
-
/**
* GMimeCryptoHash:
* @GMIME_CRYPTO_HASH_DEFAULT: The default hash algorithm.
@@ -211,6 +188,89 @@ int g_mime_crypto_context_export_keys (GMimeCryptoContext *ctx,
GMimeStream *ostream, GError **err);
+/* crypto key structures and functions */
+
+/**
+ * GMimeCryptoPubKeyAlgo:
+ * @GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT: The default public-key algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_RSA: The RSA algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_RSA_E: An encryption-only RSA algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_RSA_S: A signature-only RSA algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_ELG: The ElGamal algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_ELG_E: An encryption-only ElGamal algorithm.
+ * @GMIME_CRYPTO_PUBKEY_ALGO_DSA: The DSA algorithm.
+ *
+ * A public-key algorithm.
+ **/
+typedef enum {
+ GMIME_CRYPTO_PUBKEY_ALGO_DEFAULT,
+ GMIME_CRYPTO_PUBKEY_ALGO_RSA,
+ GMIME_CRYPTO_PUBKEY_ALGO_RSA_E,
+ GMIME_CRYPTO_PUBKEY_ALGO_RSA_S,
+ GMIME_CRYPTO_PUBKEY_ALGO_ELG,
+ GMIME_CRYPTO_PUBKEY_ALGO_ELG_E,
+ GMIME_CRYPTO_PUBKEY_ALGO_DSA
+} GMimeCryptoPubKeyAlgo;
+
+
+/**
+ * GMimeCryptoKey:
+ * @pubkey_algo: The public-key algorithm associated with the key.
+ * @issuer_serial: The issuer of the certificate, if known.
+ * @issuer_name: The issuer of the certificate, if known.
+ * @fingerprint: A hex string representing the key's fingerprint.
+ * @created: The creation date of the key.
+ * @expires: The expiration date of the key.
+ * @keyid: The key id.
+ * @email: The email address of the person or entity.
+ * @name: The name of the person or entity.
+ *
+ * A structure containing useful information about a key.
+ **/
+struct _GMimeCryptoKey {
+ GMimeCryptoPubKeyAlgo pubkey_algo;
+ char *issuer_serial;
+ char *issuer_name;
+ char *fingerprint;
+ time_t created;
+ time_t expires;
+ char *keyid;
+ char *email;
+ char *name;
+};
+
+
+/*GMimeCryptoKey *g_mime_crypto_key_new (const char *key_id);*/
+/*void g_mime_crypto_key_free (GMimeCryptoKey *key);*/
+
+void g_mime_crypto_key_set_pubkey_algo (GMimeCryptoKey *key, GMimeCryptoPubKeyAlgo pubkey_algo);
+GMimeCryptoPubKeyAlgo g_mime_crypto_key_get_pubkey_algo (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_issuer_serial (GMimeCryptoKey *key, const char *issuer_serial);
+const char *g_mime_crypto_key_get_issuer_serial (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_issuer_name (GMimeCryptoKey *key, const char *issuer_name);
+const char *g_mime_crypto_key_get_issuer_name (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_fingerprint (GMimeCryptoKey *key, const char *fingerprint);
+const char *g_mime_crypto_key_get_fingerprint (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_key_id (GMimeCryptoKey *key, const char *key_id);
+const char *g_mime_crypto_key_get_key_id (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_email (GMimeCryptoKey *key, const char *email);
+const char *g_mime_crypto_key_get_email (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_name (GMimeCryptoKey *key, const char *name);
+const char *g_mime_crypto_key_get_name (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_creation_date (GMimeCryptoKey *key, time_t created);
+time_t g_mime_crypto_key_get_creation_date (const GMimeCryptoKey *key);
+
+void g_mime_crypto_key_set_expiration_date (GMimeCryptoKey *key, time_t expires);
+time_t g_mime_crypto_key_get_expiration_date (const GMimeCryptoKey *key);
+
+
/* signature status structures and functions */
/**
@@ -279,41 +339,25 @@ typedef enum {
* @unused: Unused expansion bits for future use; ignore this.
* @sig_class: Crypto-specific signature class.
* @sig_ver: Crypto-specific signature version.
- * @pubkey_algo: The public-key algorithm used by the signer, if known.
* @hash_algo: The hash algorithm used by the signer, if known.
- * @issuer_serial: The issuer of the certificate, if known.
- * @issuer_name: The issuer of the certificate, if known.
- * @fingerprint: A hex string representing the signer's fingerprint.
- * @sig_created: The creation date of the signature.
- * @sig_expires: The expiration date of the signature.
- * @key_created: The creation date of the signature key.
- * @key_expires: The expiration date of the signature key.
- * @keyid: The signer's key id.
- * @email: The email address of the person or entity.
- * @name: The name of the person or entity.
+ * @key: The #GMimeCryptoKey used by the signer.
+ * @created: The creation date of the signature.
+ * @expires: The expiration date of the signature.
*
* A structure containing useful information about a signer.
**/
struct _GMimeSigner {
GMimeSigner *next;
- unsigned int status:2; /* GMimeSignerStatus */
- unsigned int errors:6; /* bitfield of GMimeSignerError's */
- unsigned int trust:3; /* GMimeSignerTrust */
- unsigned int unused:5; /* unused expansion bits */
- unsigned int sig_class:8; /* crypto-specific signature class */
- unsigned int sig_ver:8; /* crypto-specific signature version */
- GMimeCryptoPubKeyAlgo pubkey_algo;
+ unsigned int status:2; /* GMimeSignerStatus */
+ unsigned int errors:6; /* bitfield of GMimeSignerError's */
+ unsigned int trust:3; /* GMimeSignerTrust */
+ unsigned int unused:5; /* unused expansion bits */
+ unsigned int sig_class:8; /* crypto-specific signature class */
+ unsigned int sig_ver:8; /* crypto-specific signature version */
GMimeCryptoHash hash_algo;
- char *issuer_serial;
- char *issuer_name;
- char *fingerprint;
- time_t sig_created;
- time_t sig_expires;
- time_t key_created;
- time_t key_expires;
- char *keyid;
- char *email;
- char *name;
+ GMimeCryptoKey *key;
+ time_t created;
+ time_t expires;
};
@@ -337,41 +381,17 @@ int g_mime_signer_get_sig_class (const GMimeSigner *signer);
void g_mime_signer_set_sig_version (GMimeSigner *signer, int version);
int g_mime_signer_get_sig_version (const GMimeSigner *signer);
-void g_mime_signer_set_pubkey_algo (GMimeSigner *signer, GMimeCryptoPubKeyAlgo pubkey_algo);
-GMimeCryptoPubKeyAlgo g_mime_signer_get_pubkey_algo (const GMimeSigner *signer);
-
void g_mime_signer_set_hash_algo (GMimeSigner *signer, GMimeCryptoHash hash);
GMimeCryptoHash g_mime_signer_get_hash_algo (const GMimeSigner *signer);
-void g_mime_signer_set_issuer_serial (GMimeSigner *signer, const char *issuer_serial);
-const char *g_mime_signer_get_issuer_serial (const GMimeSigner *signer);
-
-void g_mime_signer_set_issuer_name (GMimeSigner *signer, const char *issuer_name);
-const char *g_mime_signer_get_issuer_name (const GMimeSigner *signer);
-
-void g_mime_signer_set_fingerprint (GMimeSigner *signer, const char *fingerprint);
-const char *g_mime_signer_get_fingerprint (const GMimeSigner *signer);
-
-void g_mime_signer_set_key_id (GMimeSigner *signer, const char *key_id);
-const char *g_mime_signer_get_key_id (const GMimeSigner *signer);
-
-void g_mime_signer_set_email (GMimeSigner *signer, const char *email);
-const char *g_mime_signer_get_email (const GMimeSigner *signer);
-
-void g_mime_signer_set_name (GMimeSigner *signer, const char *name);
-const char *g_mime_signer_get_name (const GMimeSigner *signer);
-
-void g_mime_signer_set_sig_created (GMimeSigner *signer, time_t created);
-time_t g_mime_signer_get_sig_created (const GMimeSigner *signer);
-
-void g_mime_signer_set_sig_expires (GMimeSigner *signer, time_t expires);
-time_t g_mime_signer_get_sig_expires (const GMimeSigner *signer);
+/*void g_mime_signer_set_key (GMimeSigner *signer, GMimeCryptoKey *key);*/
+const GMimeCryptoKey *g_mime_signer_get_key (const GMimeSigner *signer);
-void g_mime_signer_set_key_created (GMimeSigner *signer, time_t created);
-time_t g_mime_signer_get_key_created (const GMimeSigner *signer);
+void g_mime_signer_set_creation_date (GMimeSigner *signer, time_t created);
+time_t g_mime_signer_get_creation_date (const GMimeSigner *signer);
-void g_mime_signer_set_key_expires (GMimeSigner *signer, time_t expires);
-time_t g_mime_signer_get_key_expires (const GMimeSigner *signer);
+void g_mime_signer_set_expiration_date (GMimeSigner *signer, time_t expires);
+time_t g_mime_signer_get_expiration_date (const GMimeSigner *signer);
/**
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index 69efcad..00d2503 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -862,10 +862,10 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
gpg->signer = signer;
/* get the key id of the signer */
- status = next_token (status, &signer->keyid);
+ status = next_token (status, &signer->key->keyid);
/* the rest of the string is the signer's name */
- signer->name = g_strdup (status);
+ signer->key->name = g_strdup (status);
} else if (!strncmp (status, "BADSIG ", 7)) {
status += 7;
@@ -874,10 +874,10 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
gpg->signer = signer;
/* get the key id of the signer */
- status = next_token (status, &signer->keyid);
+ status = next_token (status, &signer->key->keyid);
/* the rest of the string is the signer's name */
- signer->name = g_strdup (status);
+ signer->key->name = g_strdup (status);
} else if (!strncmp (status, "ERRSIG ", 7)) {
/* Note: NO_PUBKEY often comes after an ERRSIG */
status += 7;
@@ -887,7 +887,7 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
gpg->signer = signer;
/* get the key id of the signer */
- status = next_token (status, &signer->keyid);
+ status = next_token (status, &signer->key->keyid);
/* skip the pubkey_algo */
status = next_token (status, NULL);
@@ -899,7 +899,7 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
status = next_token (status, NULL);
/* get the signature expiration date (or 0 for never) */
- signer->sig_expires = strtoul (status, &inend, 10);
+ signer->expires = strtoul (status, &inend, 10);
status = inend + 1;
/* get the return code */
@@ -923,24 +923,24 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
status += 9;
/* the first token is the fingerprint */
- status = next_token (status, &signer->fingerprint);
+ status = next_token (status, &signer->key->fingerprint);
/* the second token is the date the stream was signed YYYY-MM-DD */
status = next_token (status, NULL);
/* the third token is the signature creation date (or 0 for unknown?) */
- signer->sig_created = strtoul (status, &inend, 10);
+ signer->created = strtoul (status, &inend, 10);
if (inend == status || *inend != ' ') {
- signer->sig_created = 0;
+ signer->created = 0;
return;
}
status = inend + 1;
/* the fourth token is the signature expiration date (or 0 for never) */
- signer->sig_expires = strtoul (status, &inend, 10);
+ signer->expires = strtoul (status, &inend, 10);
if (inend == status || *inend != ' ') {
- signer->sig_expires = 0;
+ signer->expires = 0;
return;
}
@@ -959,7 +959,7 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
status = next_token (status, NULL);
/* the seventh token is the public-key algorithm id */
- signer->pubkey_algo = gpg_pubkey_algo (strtoul (status, &inend, 10));
+ signer->key->pubkey_algo = gpg_pubkey_algo (strtoul (status, &inend, 10));
if (inend == status || *inend != ' ')
return;
diff --git a/gmime/gmime-pkcs7-context.c b/gmime/gmime-pkcs7-context.c
index fb4afa2..8dc9aa3 100644
--- a/gmime/gmime-pkcs7-context.c
+++ b/gmime/gmime-pkcs7-context.c
@@ -566,11 +566,12 @@ pkcs7_get_validity (Pkcs7Ctx *pkcs7, gboolean verify)
signers->next = signer;
signers = signer;
- g_mime_signer_set_pubkey_algo (signer, pkcs7_pubkey_algo (sig->pubkey_algo));
+ g_mime_crypto_key_set_pubkey_algo (signer->key, pkcs7_pubkey_algo (sig->pubkey_algo));
+ g_mime_crypto_key_set_fingerprint (signer->key, sig->fpr);
+
g_mime_signer_set_hash_algo (signer, pkcs7_hash_algo (sig->hash_algo));
- g_mime_signer_set_sig_expires (signer, sig->exp_timestamp);
- g_mime_signer_set_sig_created (signer, sig->timestamp);
- g_mime_signer_set_fingerprint (signer, sig->fpr);
+ g_mime_signer_set_expiration_date (signer, sig->exp_timestamp);
+ g_mime_signer_set_creation_date (signer, sig->timestamp);
if (sig->exp_timestamp != 0 && sig->exp_timestamp <= time (NULL)) {
/* signature expired, automatically results in a BAD signature */
@@ -580,23 +581,23 @@ pkcs7_get_validity (Pkcs7Ctx *pkcs7, gboolean verify)
if (gpgme_get_key (pkcs7->ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR && key) {
/* get more signer info from their signing key */
+ g_mime_crypto_key_set_issuer_serial (signer->key, key->issuer_serial);
+ g_mime_crypto_key_set_issuer_name (signer->key, key->issuer_name);
g_mime_signer_set_trust (signer, pkcs7_trust (key->owner_trust));
- g_mime_signer_set_issuer_serial (signer, key->issuer_serial);
- g_mime_signer_set_issuer_name (signer, key->issuer_name);
/* get the keyid, name, and email address */
uid = key->uids;
while (uid) {
if (uid->name && *uid->name)
- g_mime_signer_set_name (signer, uid->name);
+ g_mime_crypto_key_set_name (signer->key, uid->name);
if (uid->email && *uid->email)
- g_mime_signer_set_email (signer, uid->email);
+ g_mime_crypto_key_set_email (signer->key, uid->email);
if (uid->uid && *uid->uid)
- g_mime_signer_set_key_id (signer, uid->uid);
+ g_mime_crypto_key_set_key_id (signer->key, uid->uid);
- if (signer->name && signer->email && signer->keyid)
+ if (signer->key->name && signer->key->email && signer->key->keyid)
break;
uid = uid->next;
@@ -608,8 +609,8 @@ pkcs7_get_validity (Pkcs7Ctx *pkcs7, gboolean verify)
subkey = subkey->next;
if (subkey) {
- g_mime_signer_set_key_created (signer, subkey->timestamp);
- g_mime_signer_set_key_expires (signer, subkey->expires);
+ g_mime_crypto_key_set_creation_date (signer->key, subkey->timestamp);
+ g_mime_crypto_key_set_expiration_date (signer->key, subkey->expires);
if (subkey->revoked) {
/* signer's key has been revoked, automatic BAD status */
diff --git a/mono/GMime.metadata b/mono/GMime.metadata
index 4a97300..840c664 100644
--- a/mono/GMime.metadata
+++ b/mono/GMime.metadata
@@ -35,10 +35,10 @@
<remove-node path="/api/namespace/object[ cname='GMimeContentDisposition']/field[ cname='params']"/>
<!-- ContentEncoding -->
- <attr path="/api/namespace/class[ name='Content']/method[ name='EncodingFromString']" name="name">ContentEncodingFromString</attr>
+ <!--<attr path="/api/namespace/class[ name='Content']/method[ name='EncodingFromString']" name="name">ContentEncodingFromString</attr>
<attr path="/api/namespace/class[ name='Content']/method[ name='EncodingToString']" name="name">ContentEncodingToString</attr>
<move-node path="/api/namespace/class[ name='Content']/method[ name='ContentEncodingFromString']">/api/namespace/class[ name='Utils']</move-node>
- <move-node path="/api/namespace/class[ name='Content']/method[ name='ContentEncodingToString']">/api/namespace/class[ name='Utils']</move-node>
+ <move-node path="/api/namespace/class[ name='Content']/method[ name='ContentEncodingToString']">/api/namespace/class[ name='Utils']</move-node>-->
<remove-node path="/api/namespace/class[ name='Content']"/>
<!-- ContentType -->
@@ -49,9 +49,25 @@
<!-- CryptoContext -->
<remove-node path="/api/namespace/struct[ cname='GMimeSignatureValidity']/field[ cname='signers']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='pubkey_algo']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='issuer_serial']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='issuer_name']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='fingerprint']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='created']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='expires']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='keyid']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='email']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeCryptoKey']/field[ cname='name']"/>
<remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='next']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='status']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='errors']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='trust']"/>
<remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='unused']"/>
- <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='keyid']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='sig_ver']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='hash_algo']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='key']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='created']"/>
+ <remove-node path="/api/namespace/struct[ cname='GMimeSigner']/field[ cname='expires']"/>
<!-- DataWrapper -->
<attr path="/api/namespace/object[ cname='GMimeDataWrapper']/method[ name='GetStream']" name="name">GetGMimeStream</attr>
diff --git a/mono/gmime-api.raw b/mono/gmime-api.raw
index 0ef0b8c..528ee50 100644
--- a/mono/gmime-api.raw
+++ b/mono/gmime-api.raw
@@ -2238,6 +2238,98 @@
</parameters>
</method>
</struct>
+ <struct name="CryptoKey" cname="GMimeCryptoKey">
+ <field name="PubkeyAlgo" cname="pubkey_algo" type="GMimeCryptoPubKeyAlgo" />
+ <field name="IssuerSerial" cname="issuer_serial" type="char*" />
+ <field name="IssuerName" cname="issuer_name" type="char*" />
+ <field name="Fingerprint" cname="fingerprint" type="char*" />
+ <field name="Created" cname="created" type="time_t" />
+ <field name="Expires" cname="expires" type="time_t" />
+ <field name="Keyid" cname="keyid" type="char*" />
+ <field name="Email" cname="email" type="char*" />
+ <field name="Name" cname="name" type="char*" />
+ <method name="GetCreationDate" cname="g_mime_crypto_key_get_creation_date">
+ <return-type type="time_t" />
+ </method>
+ <method name="GetEmail" cname="g_mime_crypto_key_get_email">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetExpirationDate" cname="g_mime_crypto_key_get_expiration_date">
+ <return-type type="time_t" />
+ </method>
+ <method name="GetFingerprint" cname="g_mime_crypto_key_get_fingerprint">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetIssuerName" cname="g_mime_crypto_key_get_issuer_name">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetIssuerSerial" cname="g_mime_crypto_key_get_issuer_serial">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetKeyId" cname="g_mime_crypto_key_get_key_id">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetName" cname="g_mime_crypto_key_get_name">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetPubkeyAlgo" cname="g_mime_crypto_key_get_pubkey_algo">
+ <return-type type="GMimeCryptoPubKeyAlgo" />
+ </method>
+ <method name="SetCreationDate" cname="g_mime_crypto_key_set_creation_date">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="created" />
+ </parameters>
+ </method>
+ <method name="SetEmail" cname="g_mime_crypto_key_set_email">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="email" />
+ </parameters>
+ </method>
+ <method name="SetExpirationDate" cname="g_mime_crypto_key_set_expiration_date">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="time_t" name="expires" />
+ </parameters>
+ </method>
+ <method name="SetFingerprint" cname="g_mime_crypto_key_set_fingerprint">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="fingerprint" />
+ </parameters>
+ </method>
+ <method name="SetIssuerName" cname="g_mime_crypto_key_set_issuer_name">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="issuer_name" />
+ </parameters>
+ </method>
+ <method name="SetIssuerSerial" cname="g_mime_crypto_key_set_issuer_serial">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="issuer_serial" />
+ </parameters>
+ </method>
+ <method name="SetKeyId" cname="g_mime_crypto_key_set_key_id">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="key_id" />
+ </parameters>
+ </method>
+ <method name="SetName" cname="g_mime_crypto_key_set_name">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="name" />
+ </parameters>
+ </method>
+ <method name="SetPubkeyAlgo" cname="g_mime_crypto_key_set_pubkey_algo">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="GMimeCryptoPubKeyAlgo" name="pubkey_algo" />
+ </parameters>
+ </method>
+ </struct>
<struct name="Encoding" cname="GMimeEncoding" opaque="true">
<method name="Base64DecodeStep" cname="g_mime_encoding_base64_decode_step" shared="true">
<return-type type="size_t" />
@@ -2612,63 +2704,31 @@
<field name="Unused" cname="unused" bits="5" type="unsigned int" access="public" writeable="true" />
<field name="SigClass" cname="sig_class" bits="8" type="unsigned int" access="public" writeable="true" />
<field name="SigVer" cname="sig_ver" bits="8" type="unsigned int" access="public" writeable="true" />
- <field name="PubkeyAlgo" cname="pubkey_algo" type="GMimeCryptoPubKeyAlgo" access="public" writeable="true" />
<field name="HashAlgo" cname="hash_algo" type="GMimeCryptoHash" access="public" writeable="true" />
- <field name="IssuerSerial" cname="issuer_serial" type="char*" access="public" writeable="true" />
- <field name="IssuerName" cname="issuer_name" type="char*" access="public" writeable="true" />
- <field name="Fingerprint" cname="fingerprint" type="char*" access="public" writeable="true" />
- <field name="SigCreated" cname="sig_created" type="time_t" access="public" writeable="true" />
- <field name="SigExpires" cname="sig_expires" type="time_t" access="public" writeable="true" />
- <field name="KeyCreated" cname="key_created" type="time_t" access="public" writeable="true" />
- <field name="KeyExpires" cname="key_expires" type="time_t" access="public" writeable="true" />
- <field name="Keyid" cname="keyid" type="char*" access="public" writeable="true" />
- <field name="Email" cname="email" type="char*" access="public" writeable="true" />
- <field name="Name" cname="name" type="char*" access="public" writeable="true" />
+ <field name="Key" cname="key" type="GMimeCryptoKey*" access="public" writeable="true" />
+ <field name="Created" cname="created" type="time_t" access="public" writeable="true" />
+ <field name="Expires" cname="expires" type="time_t" access="public" writeable="true" />
<method name="Free" cname="g_mime_signer_free">
<return-type type="void" />
</method>
- <method name="GetEmail" cname="g_mime_signer_get_email">
- <return-type type="const-char*" />
+ <method name="GetCreationDate" cname="g_mime_signer_get_creation_date">
+ <return-type type="time_t" />
</method>
<method name="GetErrors" cname="g_mime_signer_get_errors">
<return-type type="GMimeSignerError" />
</method>
- <method name="GetFingerprint" cname="g_mime_signer_get_fingerprint">
- <return-type type="const-char*" />
+ <method name="GetExpirationDate" cname="g_mime_signer_get_expiration_date">
+ <return-type type="time_t" />
</method>
<method name="GetHashAlgo" cname="g_mime_signer_get_hash_algo">
<return-type type="GMimeCryptoHash" />
</method>
- <method name="GetIssuerName" cname="g_mime_signer_get_issuer_name">
- <return-type type="const-char*" />
- </method>
- <method name="GetIssuerSerial" cname="g_mime_signer_get_issuer_serial">
- <return-type type="const-char*" />
- </method>
- <method name="GetKeyCreated" cname="g_mime_signer_get_key_created">
- <return-type type="time_t" />
- </method>
- <method name="GetKeyExpires" cname="g_mime_signer_get_key_expires">
- <return-type type="time_t" />
- </method>
- <method name="GetKeyId" cname="g_mime_signer_get_key_id">
- <return-type type="const-char*" />
- </method>
- <method name="GetName" cname="g_mime_signer_get_name">
- <return-type type="const-char*" />
- </method>
- <method name="GetPubkeyAlgo" cname="g_mime_signer_get_pubkey_algo">
- <return-type type="GMimeCryptoPubKeyAlgo" />
+ <method name="GetKey" cname="g_mime_signer_get_key">
+ <return-type type="const-GMimeCryptoKey*" />
</method>
<method name="GetSigClass" cname="g_mime_signer_get_sig_class">
<return-type type="int" />
</method>
- <method name="GetSigCreated" cname="g_mime_signer_get_sig_created">
- <return-type type="time_t" />
- </method>
- <method name="GetSigExpires" cname="g_mime_signer_get_sig_expires">
- <return-type type="time_t" />
- </method>
<method name="GetSigVersion" cname="g_mime_signer_get_sig_version">
<return-type type="int" />
</method>
@@ -2686,10 +2746,10 @@
<method name="Next" cname="g_mime_signer_next">
<return-type type="GMimeSigner*" />
</method>
- <method name="SetEmail" cname="g_mime_signer_set_email">
+ <method name="SetCreationDate" cname="g_mime_signer_set_creation_date">
<return-type type="void" />
<parameters>
- <parameter type="const-char*" name="email" />
+ <parameter type="time_t" name="created" />
</parameters>
</method>
<method name="SetErrors" cname="g_mime_signer_set_errors">
@@ -2698,10 +2758,10 @@
<parameter type="GMimeSignerError" name="error" />
</parameters>
</method>
- <method name="SetFingerprint" cname="g_mime_signer_set_fingerprint">
+ <method name="SetExpirationDate" cname="g_mime_signer_set_expiration_date">
<return-type type="void" />
<parameters>
- <parameter type="const-char*" name="fingerprint" />
+ <parameter type="time_t" name="expires" />
</parameters>
</method>
<method name="SetHashAlgo" cname="g_mime_signer_set_hash_algo">
@@ -2710,66 +2770,12 @@
<parameter type="GMimeCryptoHash" name="hash" />
</parameters>
</method>
- <method name="SetIssuerName" cname="g_mime_signer_set_issuer_name">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="issuer_name" />
- </parameters>
- </method>
- <method name="SetIssuerSerial" cname="g_mime_signer_set_issuer_serial">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="issuer_serial" />
- </parameters>
- </method>
- <method name="SetKeyCreated" cname="g_mime_signer_set_key_created">
- <return-type type="void" />
- <parameters>
- <parameter type="time_t" name="created" />
- </parameters>
- </method>
- <method name="SetKeyExpires" cname="g_mime_signer_set_key_expires">
- <return-type type="void" />
- <parameters>
- <parameter type="time_t" name="expires" />
- </parameters>
- </method>
- <method name="SetKeyId" cname="g_mime_signer_set_key_id">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="key_id" />
- </parameters>
- </method>
- <method name="SetName" cname="g_mime_signer_set_name">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="name" />
- </parameters>
- </method>
- <method name="SetPubkeyAlgo" cname="g_mime_signer_set_pubkey_algo">
- <return-type type="void" />
- <parameters>
- <parameter type="GMimeCryptoPubKeyAlgo" name="pubkey_algo" />
- </parameters>
- </method>
<method name="SetSigClass" cname="g_mime_signer_set_sig_class">
<return-type type="void" />
<parameters>
<parameter type="int" name="sig_class" />
</parameters>
</method>
- <method name="SetSigCreated" cname="g_mime_signer_set_sig_created">
- <return-type type="void" />
- <parameters>
- <parameter type="time_t" name="created" />
- </parameters>
- </method>
- <method name="SetSigExpires" cname="g_mime_signer_set_sig_expires">
- <return-type type="void" />
- <parameters>
- <parameter type="time_t" name="expires" />
- </parameters>
- </method>
<method name="SetSigVersion" cname="g_mime_signer_set_sig_version">
<return-type type="void" />
<parameters>
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index 881043b..a15976b 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -87,9 +87,9 @@ print_verify_results (const GMimeSignatureValidity *validity)
fputs ("\nSigners:\n", stdout);
signer = validity->signers;
while (signer != NULL) {
- fprintf (stdout, "\tName: %s\n", signer->name ? signer->name : "(null)");
- fprintf (stdout, "\tKeyId: %s\n", signer->keyid ? signer->keyid : "(null)");
- fprintf (stdout, "\tFingerprint: %s\n", signer->fingerprint ? signer->fingerprint : "(null)");
+ fprintf (stdout, "\tName: %s\n", signer->key->name ? signer->key->name : "(null)");
+ fprintf (stdout, "\tKeyId: %s\n", signer->key->keyid ? signer->key->keyid : "(null)");
+ fprintf (stdout, "\tFingerprint: %s\n", signer->key->fingerprint ? signer->key->fingerprint : "(null)");
fprintf (stdout, "\tTrust: ");
switch (signer->trust) {
@@ -126,9 +126,9 @@ print_verify_results (const GMimeSignatureValidity *validity)
break;
}
- fprintf (stdout, "\tSignature made on %s", ctime (&signer->sig_created));
- if (signer->sig_expires != (time_t) 0)
- fprintf (stdout, "\tSignature expires on %s", ctime (&signer->sig_expires));
+ fprintf (stdout, "\tSignature made on %s", ctime (&signer->created));
+ if (signer->expires != (time_t) 0)
+ fprintf (stdout, "\tSignature expires on %s", ctime (&signer->expires));
else
fprintf (stdout, "\tSignature never expires\n");
diff --git a/tests/test-smime.c b/tests/test-smime.c
index b1a088f..4deb0e2 100644
--- a/tests/test-smime.c
+++ b/tests/test-smime.c
@@ -88,9 +88,9 @@ print_verify_results (const GMimeSignatureValidity *validity)
fputs ("\nSigners:\n", stdout);
signer = validity->signers;
while (signer != NULL) {
- fprintf (stdout, "\tName: %s\n", signer->name ? signer->name : "(null)");
- fprintf (stdout, "\tKeyId: %s\n", signer->keyid ? signer->keyid : "(null)");
- fprintf (stdout, "\tFingerprint: %s\n", signer->fingerprint ? signer->fingerprint : "(null)");
+ fprintf (stdout, "\tName: %s\n", signer->key->name ? signer->key->name : "(null)");
+ fprintf (stdout, "\tKeyId: %s\n", signer->key->keyid ? signer->key->keyid : "(null)");
+ fprintf (stdout, "\tFingerprint: %s\n", signer->key->fingerprint ? signer->key->fingerprint : "(null)");
fprintf (stdout, "\tTrust: ");
switch (signer->trust) {
@@ -127,9 +127,9 @@ print_verify_results (const GMimeSignatureValidity *validity)
break;
}
- fprintf (stdout, "\tSignature made on %s", ctime (&signer->sig_created));
- if (signer->sig_expires != (time_t) 0)
- fprintf (stdout, "\tSignature expires on %s", ctime (&signer->sig_expires));
+ fprintf (stdout, "\tSignature made on %s", ctime (&signer->created));
+ if (signer->expires != (time_t) 0)
+ fprintf (stdout, "\tSignature expires on %s", ctime (&signer->expires));
else
fprintf (stdout, "\tSignature never expires\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]