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 /camel/camel-cipher-context.c | |
parent | ad454163140688485032c256a447fde8089b7e6b (diff) | |
download | gsoc2013-evolution-d940c0dad4a4dd5e9b4c5014893c111ebf28e9e7.tar.gz 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
Diffstat (limited to 'camel/camel-cipher-context.c')
-rw-r--r-- | camel/camel-cipher-context.c | 67 |
1 files changed, 67 insertions, 0 deletions
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); } |