diff options
author | Not Zed <NotZed@Ximian.com> | 2003-12-10 13:25:24 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-12-10 13:25:24 +0800 |
commit | d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7 (patch) | |
tree | 887d349d4b1c0a1a25068ec2d8dd41a688ae1449 | |
parent | ad454163140688485032c256a447fde8089b7e6b (diff) | |
download | gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.gz gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.bz2 gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.lz gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.xz gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.zst gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.zip |
put the camel-smime-context.[ch] back in here, remove it from EXTRA_DIST,
2003-12-10 Not Zed <NotZed@Ximian.com>
* Makefile.am (libcamel_la_SOURCES): put the
camel-smime-context.[ch] back in here, remove it from EXTRA_DIST,
and make it compile optinally the same way camel-tcp-stream-ssl.c
does (#ifdef ...).
* camel-smime-context.c (sm_verify_cmsg): add signer info to
certvalidity.
* camel-cipher-context.c (CamelCipherValidity): Added certinfo to
validity for signing and encrypting, so we can find the keys later
for a gui.
(camel_cipher_validity_add_certinfo): add signer or
encrypter info to the validity.
(camel_cipher_validity_envelope): add sign/encrypt keys.
svn path=/trunk/; revision=23904
-rw-r--r-- | camel/ChangeLog | 17 | ||||
-rw-r--r-- | camel/Makefile.am | 14 | ||||
-rw-r--r-- | camel/camel-cipher-context.c | 67 | ||||
-rw-r--r-- | camel/camel-cipher-context.h | 17 | ||||
-rw-r--r-- | camel/camel-smime-context.c | 6 |
5 files changed, 109 insertions, 12 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 9f02d6f680..2b143cf31a 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,22 @@ 2003-12-10 Not Zed <NotZed@Ximian.com> + * Makefile.am (libcamel_la_SOURCES): put the + camel-smime-context.[ch] back in here, remove it from EXTRA_DIST, + and make it compile optinally the same way camel-tcp-stream-ssl.c + does (#ifdef ...). + + * camel-smime-context.c (sm_verify_cmsg): add signer info to + certvalidity. + + * camel-cipher-context.c (CamelCipherValidity): Added certinfo to + validity for signing and encrypting, so we can find the keys later + for a gui. + (camel_cipher_validity_add_certinfo): add signer or + encrypter info to the validity. + (camel_cipher_validity_envelope): add sign/encrypt keys. + +2003-12-10 Not Zed <NotZed@Ximian.com> + * camel-stream-process.c (do_exec_command): remove dthe clearenv stuff, not sure why its there. s/setenv/putenv/ for portability. See Bug #51767. diff --git a/camel/Makefile.am b/camel/Makefile.am index 3924e0cd80..07bfdbaead 100644 --- a/camel/Makefile.am +++ b/camel/Makefile.am @@ -17,14 +17,6 @@ INCLUDES = -I.. -I$(srcdir)/.. \ -DG_LOG_DOMAIN=\"camel\" \ $(CAMEL_CFLAGS) -if ENABLE_SMIME -SMIME_SOURCES_C = camel-smime-context.c -SMIME_SOURCES_H = camel-smime-context.h -else -SMIME_SOURCES_C = -SMIME_SOURCES_H = -endif - libcamel_la_SOURCES = \ broken-date-parser.c \ camel-address.c \ @@ -100,7 +92,7 @@ libcamel_la_SOURCES = \ camel-seekable-substream.c \ camel-service.c \ camel-session.c \ - $(SMIME_SOURCES_C) \ + camel-smime-context.c \ camel-store.c \ camel-store-summary.c \ camel-stream-buffer.c \ @@ -201,7 +193,7 @@ libcamelinclude_HEADERS = \ camel-seekable-substream.h \ camel-service.h \ camel-session.h \ - $(SMIME_SOURCES_H) \ + camel-smime-context.h \ camel-store.h \ camel-store-summary.h \ camel-stream-buffer.h \ @@ -291,6 +283,4 @@ noinst_HEADERS = \ EXTRA_DIST = \ ChangeLog.pre-1-4 \ - camel-smime-context.h \ - camel-smime-context.c \ README diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c index b730d927c8..5725470855 100644 --- a/camel/camel-cipher-context.c +++ b/camel/camel-cipher-context.c @@ -339,6 +339,13 @@ camel_cipher_hash_to_id(CamelCipherContext *context, CamelCipherHash hash) } /* Cipher Validity stuff */ +static void +ccv_certinfo_free(CamelCipherCertInfo *info) +{ + g_free(info->name); + g_free(info->email); + g_free(info); +} CamelCipherValidity * camel_cipher_validity_new (void) @@ -358,6 +365,8 @@ camel_cipher_validity_init (CamelCipherValidity *validity) memset(validity, 0, sizeof(*validity)); e_dlist_init(&validity->children); + e_dlist_init(&validity->sign.signers); + e_dlist_init(&validity->encrypt.encrypters); } gboolean @@ -398,6 +407,7 @@ camel_cipher_validity_clear (CamelCipherValidity *validity) { g_assert (validity != NULL); + /* TODO: this doesn't free children/clear key lists */ g_free(validity->sign.description); g_free(validity->encrypt.description); camel_cipher_validity_init(validity); @@ -407,6 +417,7 @@ CamelCipherValidity * camel_cipher_validity_clone(CamelCipherValidity *vin) { CamelCipherValidity *vo; + CamelCipherCertInfo *info; vo = camel_cipher_validity_new(); vo->sign.status = vin->sign.status; @@ -414,10 +425,47 @@ camel_cipher_validity_clone(CamelCipherValidity *vin) vo->encrypt.status = vin->encrypt.status; vo->encrypt.description = g_strdup(vin->encrypt.description); + info = (CamelCipherCertInfo *)vin->sign.signers.head; + while (info->next) { + camel_cipher_validity_add_certinfo(vo, CAMEL_CIPHER_VALIDITY_SIGN, info->name, info->email); + info = info->next; + } + + info = (CamelCipherCertInfo *)vin->encrypt.encrypters.head; + while (info->next) { + camel_cipher_validity_add_certinfo(vo, CAMEL_CIPHER_VALIDITY_ENCRYPT, info->name, info->email); + info = info->next; + } + return vo; } /** + * camel_cipher_validity_add_certinfo: + * @vin: + * @mode: + * @name: + * @email: + * + * Add a cert info to the signer or encrypter info. + **/ +void +camel_cipher_validity_add_certinfo(CamelCipherValidity *vin, enum _camel_cipher_validity_mode_t mode, const char *name, const char *email) +{ + CamelCipherCertInfo *info; + EDList *list; + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(name); + info->email = g_strdup(email); + + list = (mode==CAMEL_CIPHER_VALIDITY_SIGN)?&vin->sign.signers:&vin->encrypt.encrypters; + e_dlist_addtail(list, (EDListNode *)info); + + printf("adding certinfo %s <%s>\n", name?name:"unset", email?email:"unset"); +} + +/** * camel_cipher_validity_envelope: * @validity: * @outer: @@ -428,6 +476,8 @@ camel_cipher_validity_clone(CamelCipherValidity *vin) void camel_cipher_validity_envelope(CamelCipherValidity *parent, CamelCipherValidity *valid) { + CamelCipherCertInfo *info; + if (parent->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE && parent->encrypt.status == CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE && valid->sign.status == CAMEL_CIPHER_VALIDITY_SIGN_NONE @@ -435,6 +485,11 @@ camel_cipher_validity_envelope(CamelCipherValidity *parent, CamelCipherValidity /* case 1: only signed inside only encrypted -> merge both */ parent->encrypt.status = valid->encrypt.status; parent->encrypt.description = g_strdup(valid->encrypt.description); + info = (CamelCipherCertInfo *)valid->encrypt.encrypters.head; + while (info->next) { + camel_cipher_validity_add_certinfo(parent, CAMEL_CIPHER_VALIDITY_ENCRYPT, info->name, info->email); + info = info->next; + } } else if (parent->sign.status == CAMEL_CIPHER_VALIDITY_SIGN_NONE && parent->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE && valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE @@ -442,6 +497,11 @@ camel_cipher_validity_envelope(CamelCipherValidity *parent, CamelCipherValidity /* case 2: only encrypted inside only signed */ parent->sign.status = valid->sign.status; parent->sign.description = g_strdup(valid->sign.description); + info = (CamelCipherCertInfo *)valid->sign.signers.head; + while (info->next) { + camel_cipher_validity_add_certinfo(parent, CAMEL_CIPHER_VALIDITY_SIGN, info->name, info->email); + info = info->next; + } } /* Otherwise, I dunno - what do you do? */ } @@ -450,6 +510,7 @@ void camel_cipher_validity_free (CamelCipherValidity *validity) { CamelCipherValidity *child; + CamelCipherCertInfo *info; if (validity == NULL) return; @@ -457,6 +518,12 @@ camel_cipher_validity_free (CamelCipherValidity *validity) while ((child = (CamelCipherValidity *)e_dlist_remhead(&validity->children))) camel_cipher_validity_free(child); + while ((info = (CamelCipherCertInfo *)e_dlist_remhead(&validity->sign.signers))) + ccv_certinfo_free(info); + + while ((info = (CamelCipherCertInfo *)e_dlist_remhead(&validity->encrypt.encrypters))) + ccv_certinfo_free(info); + camel_cipher_validity_clear(validity); g_free(validity); } diff --git a/camel/camel-cipher-context.h b/camel/camel-cipher-context.h index 1a7387ac2c..4b5dbaed42 100644 --- a/camel/camel-cipher-context.h +++ b/camel/camel-cipher-context.h @@ -43,6 +43,7 @@ extern "C" { #define CAMEL_IS_CIPHER_CONTEXT(o) (CAMEL_CHECK_TYPE((o), CAMEL_CIPHER_CONTEXT_TYPE)) typedef struct _CamelCipherValidity CamelCipherValidity; +typedef struct _CamelCipherCertInfo CamelCipherCertInfo; typedef enum { CAMEL_CIPHER_HASH_DEFAULT, @@ -68,6 +69,19 @@ enum _camel_cipher_validity_encrypt_t { CAMEL_CIPHER_VALIDITY_ENCRYPT_STRONG, }; +enum _camel_cipher_validity_mode_t { + CAMEL_CIPHER_VALIDITY_SIGN, + CAMEL_CIPHER_VALIDITY_ENCRYPT, +}; + +struct _CamelCipherCertInfo { + struct _CamelCipherCertInfo *next; + struct _CamelCipherCertInfo *prev; + + char *name; /* common name */ + char *email; +}; + struct _CamelCipherValidity { struct _CamelCipherValidity *next; struct _CamelCipherValidity *prev; @@ -76,10 +90,12 @@ struct _CamelCipherValidity { struct { enum _camel_cipher_validity_sign_t status; char *description; + EDList signers; /* CamelCipherCertInfo's */ } sign; struct { enum _camel_cipher_validity_encrypt_t status; char *description; + EDList encrypters; /* CamelCipherCertInfo's */ } encrypt; }; @@ -161,6 +177,7 @@ char *camel_cipher_validity_get_description (CamelCipherValidity void camel_cipher_validity_set_description (CamelCipherValidity *validity, const char *description); void camel_cipher_validity_clear (CamelCipherValidity *validity); CamelCipherValidity *camel_cipher_validity_clone(CamelCipherValidity *vin); +void camel_cipher_validity_add_certinfo(CamelCipherValidity *vin, enum _camel_cipher_validity_mode_t mode, const char *name, const char *email); void camel_cipher_validity_envelope(CamelCipherValidity *valid, CamelCipherValidity *outer); void camel_cipher_validity_free (CamelCipherValidity *validity); diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c index dd7ed68b3f..64bf07d74c 100644 --- a/camel/camel-smime-context.c +++ b/camel/camel-smime-context.c @@ -30,6 +30,8 @@ #include <config.h> #endif +#ifdef HAVE_NSS + #include "nss.h" #include <cms.h> #include <cert.h> @@ -635,6 +637,8 @@ sm_verify_cmsg(CamelCipherContext *context, NSSCMSMessage *cmsg, CamelStream *ex cn?cn:"<unknown>", em?em:"<unknown>", sm_status_description(status)); + camel_cipher_validity_add_certinfo(valid, CAMEL_CIPHER_VALIDITY_SIGN, cn, em); + if (cn) PORT_Free(cn); if (em) @@ -1059,3 +1063,5 @@ camel_smime_context_get_type(void) return type; } + +#endif /* HAVE_NSS */ |