[gmime] updated cipher context API



commit 9154cb8df63911bda4de3a3621892adc9412a2b3
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sat Jul 4 08:43:13 2009 -0400

    updated cipher context API
    
    2009-07-04  Jeffrey Stedfast  <fejj novell com>
    
    	* gmime/gmime-gpg-context.c (gpg_ctx_parse_signer_info): Updated
    	for API changes to the GMimeSigner stuff.
    
    	* gmime/gmime-cipher-context.c (g_mime_signer_new): Initialize the
    	newly added fields.
    	(g_mime_signer_free): Free the newly added fields.
    	(g_mime_signer_set_issuer_serial): New field accessor.
    	(g_mime_signer_get_issuer_serial): Same.
    	(g_mime_signer_set_issuer_name): Another new accessor.
    	(g_mime_signer_get_issuer_name): Same.
    	(g_mime_signer_set_email): And another...
    	(g_mime_signer_get_email): Same.
    	(g_mime_signer_set_sig_created): Renamed from
    	g_mime_signer_set_created().
    	(g_mime_signer_get_sig_created): Renamed from
    	g_mime_signer_get_created().
    	(g_mime_signer_set_sig_expires): Renamed from
    	g_mime_signer_set_expires().
    	(g_mime_signer_get_sig_expires): Renamed from
    	g_mime_signer_get_expires().
    	(g_mime_signer_set_key_created): New field accesor.
    	(g_mime_signer_get_key_created): Same.
    	(g_mime_signer_set_key_expires): Same.
    	(g_mime_signer_get_key_expires): Same.

 ChangeLog                    |   27 ++++++
 gmime/gmime-cipher-context.c |  214 ++++++++++++++++++++++++++++++++++++++----
 gmime/gmime-cipher-context.h |   54 ++++++++---
 gmime/gmime-gpg-context.c    |    6 +-
 tests/test-pgpmime.c         |    8 +-
 5 files changed, 270 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 961f6fa..b37926e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2009-07-04  Jeffrey Stedfast  <fejj novell com>
+
+	* gmime/gmime-gpg-context.c (gpg_ctx_parse_signer_info): Updated
+	for API changes to the GMimeSigner stuff.
+
+	* gmime/gmime-cipher-context.c (g_mime_signer_new): Initialize the
+	newly added fields.
+	(g_mime_signer_free): Free the newly added fields.
+	(g_mime_signer_set_issuer_serial): New field accessor.
+	(g_mime_signer_get_issuer_serial): Same.
+	(g_mime_signer_set_issuer_name): Another new accessor.
+	(g_mime_signer_get_issuer_name): Same.
+	(g_mime_signer_set_email): And another...
+	(g_mime_signer_get_email): Same.
+	(g_mime_signer_set_sig_created): Renamed from
+	g_mime_signer_set_created().
+	(g_mime_signer_get_sig_created): Renamed from
+	g_mime_signer_get_created().
+	(g_mime_signer_set_sig_expires): Renamed from
+	g_mime_signer_set_expires().
+	(g_mime_signer_get_sig_expires): Renamed from
+	g_mime_signer_get_expires().
+	(g_mime_signer_set_key_created): New field accesor.
+	(g_mime_signer_get_key_created): Same.
+	(g_mime_signer_set_key_expires): Same.
+	(g_mime_signer_get_key_expires): Same.
+
 2009-07-02  Stanislav Brabec  <sbrabec sue cz>
 
 	* configure.in: Simplified configuring of gmime in a
diff --git a/gmime/gmime-cipher-context.c b/gmime/gmime-cipher-context.c
index fad29dc..e885db3 100644
--- a/gmime/gmime-cipher-context.c
+++ b/gmime/gmime-cipher-context.c
@@ -457,10 +457,15 @@ g_mime_signer_new (void)
 	signer->status = GMIME_SIGNER_STATUS_NONE;
 	signer->errors = GMIME_SIGNER_ERROR_NONE;
 	signer->trust = GMIME_SIGNER_TRUST_NONE;
-	signer->created = (time_t) 0;
-	signer->expires = (time_t) 0;
+	signer->sig_created = (time_t) 0;
+	signer->sig_expires = (time_t) 0;
+	signer->key_created = (time_t) 0;
+	signer->key_expires = (time_t) 0;
+	signer->issuer_serial = NULL;
+	signer->issuer_name = NULL;
 	signer->fingerprint = NULL;
 	signer->keyid = NULL;
+	signer->email = NULL;
 	signer->name = NULL;
 	signer->next = NULL;
 	
@@ -477,8 +482,11 @@ g_mime_signer_new (void)
 void
 g_mime_signer_free (GMimeSigner *signer)
 {
+	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_slice_free (GMimeSigner, signer);
@@ -602,6 +610,74 @@ g_mime_signer_get_trust (GMimeSigner *signer)
 
 
 /**
+ * g_mime_signer_set_issuer_serial:
+ * @signer: a #GMimeSigner
+ * @name: signer's issuer serial
+ *
+ * Set the signer's issuer serial.
+ **/
+void
+g_mime_signer_set_issuer_serial (GMimeSigner *signer, const char *issuer_serial)
+{
+	g_return_if_fail (signer != NULL);
+	
+	g_free (signer->issuer_serial);
+	signer->issuer_serial = g_strdup (issuer_serial);
+}
+
+
+/**
+ * g_mime_signer_get_issuer_serial:
+ * @signer: a #GMimeSigner
+ *
+ * Get the signer's issuer serial.
+ *
+ * Returns: the signer's issuer serial.
+ **/
+const char *
+g_mime_signer_get_issuer_serial (GMimeSigner *signer)
+{
+	g_return_val_if_fail (signer != NULL, NULL);
+	
+	return signer->issuer_serial;
+}
+
+
+/**
+ * g_mime_signer_set_issuer_name:
+ * @signer: a #GMimeSigner
+ * @name: signer's issuer name
+ *
+ * Set the signer's issuer name.
+ **/
+void
+g_mime_signer_set_issuer_name (GMimeSigner *signer, const char *issuer_name)
+{
+	g_return_if_fail (signer != NULL);
+	
+	g_free (signer->issuer_name);
+	signer->issuer_name = g_strdup (issuer_name);
+}
+
+
+/**
+ * g_mime_signer_get_issuer_name:
+ * @signer: a #GMimeSigner
+ *
+ * Get the signer's issuer name.
+ *
+ * Returns: the signer's issuer name.
+ **/
+const char *
+g_mime_signer_get_issuer_name (GMimeSigner *signer)
+{
+	g_return_val_if_fail (signer != NULL, NULL);
+	
+	return signer->issuer_name;
+}
+
+
+/**
  * g_mime_signer_set_fingerprint:
  * @signer: a #GMimeSigner
  * @fingerprint: fingerprint string
@@ -670,6 +746,40 @@ g_mime_signer_get_key_id (GMimeSigner *signer)
 
 
 /**
+ * g_mime_signer_set_email:
+ * @signer: a #GMimeSigner
+ * @name: signer's email
+ *
+ * Set the signer's email.
+ **/
+void
+g_mime_signer_set_email (GMimeSigner *signer, const char *email)
+{
+	g_return_if_fail (signer != NULL);
+	
+	g_free (signer->email);
+	signer->email = g_strdup (email);
+}
+
+
+/**
+ * g_mime_signer_get_email:
+ * @signer: a #GMimeSigner
+ *
+ * Get the signer's email.
+ *
+ * Returns: the signer's email.
+ **/
+const char *
+g_mime_signer_get_email (GMimeSigner *signer)
+{
+	g_return_val_if_fail (signer != NULL, NULL);
+	
+	return signer->email;
+}
+
+
+/**
  * g_mime_signer_set_name:
  * @signer: a #GMimeSigner
  * @name: signer's name
@@ -690,9 +800,9 @@ g_mime_signer_set_name (GMimeSigner *signer, const char *name)
  * g_mime_signer_get_name:
  * @signer: a #GMimeSigner
  *
- * Get the signer trust.
+ * Get the signer's name.
  *
- * Returns: the signer trust.
+ * Returns: the signer's name.
  **/
 const char *
 g_mime_signer_get_name (GMimeSigner *signer)
@@ -704,23 +814,89 @@ g_mime_signer_get_name (GMimeSigner *signer)
 
 
 /**
- * g_mime_signer_set_created:
+ * g_mime_signer_set_sig_created:
+ * @signer: a #GMimeSigner
+ * @created: creation date
+ *
+ * Set the creation date of the signer's signature.
+ **/
+void
+g_mime_signer_set_sig_created (GMimeSigner *signer, time_t created)
+{
+	g_return_if_fail (signer != NULL);
+	
+	signer->sig_created = created;
+}
+
+
+/**
+ * g_mime_signer_get_sig_created:
+ * @signer: a #GMimeSigner
+ *
+ * Get the creation date of the signer's signature.
+ *
+ * Returns: the creation date of the signer's signature.
+ **/
+time_t
+g_mime_signer_get_sig_created (GMimeSigner *signer)
+{
+	g_return_val_if_fail (signer != NULL, (time_t) -1);
+	
+	return signer->sig_created;
+}
+
+
+/**
+ * g_mime_signer_set_sig_expires:
+ * @signer: a #GMimeSigner
+ * @expires: expiration date
+ *
+ * Set the expiration date of the signer's signature.
+ **/
+void
+g_mime_signer_set_sig_expires (GMimeSigner *signer, time_t expires)
+{
+	g_return_if_fail (signer != NULL);
+	
+	signer->sig_expires = expires;
+}
+
+
+/**
+ * g_mime_signer_get_sig_expires:
+ * @signer: a #GMimeSigner
+ *
+ * Get the expiration date of the signer's signature.
+ *
+ * Returns: the expiration date of the signer's signature.
+ **/
+time_t
+g_mime_signer_get_sig_expires (GMimeSigner *signer)
+{
+	g_return_val_if_fail (signer != NULL, (time_t) -1);
+	
+	return signer->sig_expires;
+}
+
+
+/**
+ * g_mime_signer_set_key_created:
  * @signer: a #GMimeSigner
  * @created: creation date
  *
- * Set the signer's key creation date.
+ * Set the creation date of the signer's key.
  **/
 void
-g_mime_signer_set_created (GMimeSigner *signer, time_t created)
+g_mime_signer_set_key_created (GMimeSigner *signer, time_t created)
 {
 	g_return_if_fail (signer != NULL);
 	
-	signer->created = created;
+	signer->key_created = created;
 }
 
 
 /**
- * g_mime_signer_get_created:
+ * g_mime_signer_get_key_created:
  * @signer: a #GMimeSigner
  *
  * Get the creation date of the signer's key.
@@ -728,32 +904,32 @@ g_mime_signer_set_created (GMimeSigner *signer, time_t created)
  * Returns: the creation date of the signer's key.
  **/
 time_t
-g_mime_signer_get_created (GMimeSigner *signer)
+g_mime_signer_get_key_created (GMimeSigner *signer)
 {
 	g_return_val_if_fail (signer != NULL, (time_t) -1);
 	
-	return signer->created;
+	return signer->key_created;
 }
 
 
 /**
- * g_mime_signer_set_expires:
+ * g_mime_signer_set_key_expires:
  * @signer: a #GMimeSigner
  * @expires: expiration date
  *
- * Set the signer's key expiration date.
+ * Set the expiration date of the signer's key.
  **/
 void
-g_mime_signer_set_expires (GMimeSigner *signer, time_t expires)
+g_mime_signer_set_key_expires (GMimeSigner *signer, time_t expires)
 {
 	g_return_if_fail (signer != NULL);
 	
-	signer->expires = expires;
+	signer->key_expires = expires;
 }
 
 
 /**
- * g_mime_signer_get_expires:
+ * g_mime_signer_get_key_expires:
  * @signer: a #GMimeSigner
  *
  * Get the expiration date of the signer's key.
@@ -761,11 +937,11 @@ g_mime_signer_set_expires (GMimeSigner *signer, time_t expires)
  * Returns: the expiration date of the signer's key.
  **/
 time_t
-g_mime_signer_get_expires (GMimeSigner *signer)
+g_mime_signer_get_key_expires (GMimeSigner *signer)
 {
 	g_return_val_if_fail (signer != NULL, (time_t) -1);
 	
-	return signer->expires;
+	return signer->key_expires;
 }
 
 
@@ -911,7 +1087,7 @@ g_mime_signature_validity_get_signers (const GMimeSignatureValidity *validity)
  * Adds @signer to the list of signers on @validity.
  **/
 void
-g_mime_signature_validity_add_signer  (GMimeSignatureValidity *validity, GMimeSigner *signer)
+g_mime_signature_validity_add_signer (GMimeSignatureValidity *validity, GMimeSigner *signer)
 {
 	GMimeSigner *s;
 	
diff --git a/gmime/gmime-cipher-context.h b/gmime/gmime-cipher-context.h
index a76a740..d609404 100644
--- a/gmime/gmime-cipher-context.h
+++ b/gmime/gmime-cipher-context.h
@@ -225,6 +225,7 @@ typedef enum {
  * GMimeSignerError:
  * @GMIME_SIGNER_ERROR_NONE: No error.
  * @GMIME_SIGNER_ERROR_EXPSIG: Expired signature.
+ * @GMIME_SIGNER_ERROR_REVSIG: Revoked signature.
  * @GMIME_SIGNER_ERROR_NO_PUBKEY: No public key found.
  * @GMIME_SIGNER_ERROR_EXPKEYSIG: Expired signature key.
  * @GMIME_SIGNER_ERROR_REVKEYSIG: Revoked signature key.
@@ -233,10 +234,11 @@ typedef enum {
  **/
 typedef enum {
 	GMIME_SIGNER_ERROR_NONE,
-	GMIME_SIGNER_ERROR_EXPSIG     = (1 << 0),  /* expire signature */
-	GMIME_SIGNER_ERROR_NO_PUBKEY  = (1 << 1),  /* no public key */
-	GMIME_SIGNER_ERROR_EXPKEYSIG  = (1 << 2),  /* expired key */
-	GMIME_SIGNER_ERROR_REVKEYSIG  = (1 << 3)   /* revoked key */
+	GMIME_SIGNER_ERROR_EXPSIG      = (1 << 0),  /* expire signature */
+	GMIME_SIGNER_ERROR_REVSIG      = (1 << 1),  /* revoked signature */
+	GMIME_SIGNER_ERROR_NO_PUBKEY   = (1 << 2),  /* no public key */
+	GMIME_SIGNER_ERROR_EXPKEYSIG   = (1 << 3),  /* expired key */
+	GMIME_SIGNER_ERROR_REVKEYSIG   = (1 << 4)   /* revoked key */
 } GMimeSignerError;
 
 
@@ -247,10 +249,15 @@ typedef enum {
  * @errors: A bitfield of #GMimeSignerError values.
  * @trust: A #GMimeSignerTrust.
  * @unused: Unused expansion bits for future use; ignore this.
- * @created: The creation date of the signature.
- * @expires: The expiration date of the signature.
+ * @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.
  *
  * A structure containing useful information about a signer.
@@ -258,13 +265,18 @@ typedef enum {
 struct _GMimeSigner {
 	GMimeSigner *next;
 	unsigned int status:2;    /* GMimeSignerStatus */
-	unsigned int errors:4;    /* bitfield of GMimeSignerError's */
+	unsigned int errors:5;    /* bitfield of GMimeSignerError's */
 	unsigned int trust:3;     /* GMimeSignerTrust */
-	unsigned int unused:23;   /* unused expansion bits */
+	unsigned int unused:22;   /* unused expansion bits */
+	char *issuer_serial;
+	char *issuer_name;
 	char *fingerprint;
-	time_t created;
-	time_t expires;
+	time_t sig_created;
+	time_t sig_expires;
+	time_t key_created;
+	time_t key_expires;
 	char *keyid;
+	char *email;
 	char *name;
 };
 
@@ -283,21 +295,35 @@ GMimeSignerError g_mime_signer_get_errors (GMimeSigner *signer);
 void g_mime_signer_set_trust (GMimeSigner *signer, GMimeSignerTrust trust);
 GMimeSignerTrust g_mime_signer_get_trust (GMimeSigner *signer);
 
+void g_mime_signer_set_issuer_serial (GMimeSigner *signer, const char *issuer_serial);
+const char *g_mime_signer_get_issuer_serial (GMimeSigner *signer);
+
+void g_mime_signer_set_issuer_name (GMimeSigner *signer, const char *issuer_name);
+const char *g_mime_signer_get_issuer_name (GMimeSigner *signer);
+
 void g_mime_signer_set_fingerprint (GMimeSigner *signer, const char *fingerprint);
 const char *g_mime_signer_get_fingerprint (GMimeSigner *signer);
 
 void g_mime_signer_set_key_id (GMimeSigner *signer, const char *key_id);
 const char *g_mime_signer_get_key_id (GMimeSigner *signer);
 
+void g_mime_signer_set_email (GMimeSigner *signer, const char *email);
+const char *g_mime_signer_get_email (GMimeSigner *signer);
+
 void g_mime_signer_set_name (GMimeSigner *signer, const char *name);
 const char *g_mime_signer_get_name (GMimeSigner *signer);
 
-void g_mime_signer_set_created (GMimeSigner *signer, time_t created);
-time_t g_mime_signer_get_created (GMimeSigner *signer);
+void g_mime_signer_set_sig_created (GMimeSigner *signer, time_t created);
+time_t g_mime_signer_get_sig_created (GMimeSigner *signer);
+
+void g_mime_signer_set_sig_expires (GMimeSigner *signer, time_t expires);
+time_t g_mime_signer_get_sig_expires (GMimeSigner *signer);
 
-void g_mime_signer_set_expires (GMimeSigner *signer, time_t expires);
-time_t g_mime_signer_get_expires (GMimeSigner *signer);
+void g_mime_signer_set_key_created (GMimeSigner *signer, time_t created);
+time_t g_mime_signer_get_key_created (GMimeSigner *signer);
 
+void g_mime_signer_set_key_expires (GMimeSigner *signer, time_t expires);
+time_t g_mime_signer_get_key_expires (GMimeSigner *signer);
 
 
 /**
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index a61b0b9..3447cb0 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -841,7 +841,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->expires = strtoul (status, NULL, 10);
+		signer->sig_expires = strtoul (status, NULL, 10);
 		status = next_token (status, NULL);
 		
 		/* the last token is the 'rc' which we don't care about */
@@ -871,14 +871,14 @@ gpg_ctx_parse_signer_info (struct _GpgCtx *gpg, char *status)
 		status = next_token (status, NULL);
 		
 		/* the third token is the signature creation date (or 0 for unknown?) */
-		signer->created = strtoul (status, &inend, 10);
+		signer->sig_created = strtoul (status, &inend, 10);
 		if (inend == status || *inend != ' ')
 			return;
 		
 		status = inend + 1;
 		
 		/* the fourth token is the signature expiration date (or 0 for never) */
-		signer->expires = strtoul (status, NULL, 10);
+		signer->sig_expires = strtoul (status, NULL, 10);
 		
 		/* ignore the rest... */
 	} else if (!strncmp (status, "TRUST_", 6)) {
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index 674a234..5dc9fb3 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -114,9 +114,9 @@ print_verify_results (const GMimeSignatureValidity *validity)
 			break;
 		}
 		
-		fprintf (stdout, "\tSignature made on %s", ctime (&signer->created));
-		if (signer->expires != (time_t) 0)
-			fprintf (stdout, "\tSignature expires on %s", ctime (&signer->expires));
+		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));
 		else
 			fprintf (stdout, "\tSignature never expires\n");
 		
@@ -124,6 +124,8 @@ print_verify_results (const GMimeSignatureValidity *validity)
 			fprintf (stdout, "\tErrors: ");
 			if (signer->errors & GMIME_SIGNER_ERROR_EXPSIG)
 				fputs ("Expired, ", stdout);
+			if (signer->errors & GMIME_SIGNER_ERROR_REVSIG)
+				fputs ("Revoked, ", stdout);
 			if (signer->errors & GMIME_SIGNER_ERROR_NO_PUBKEY)
 				fputs ("No Pub Key, ", stdout);
 			if (signer->errors & GMIME_SIGNER_ERROR_EXPKEYSIG)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]