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.
}
/* 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)
memset(validity, 0, sizeof(*validity));
e_dlist_init(&validity->children);
+ e_dlist_init(&validity->sign.signers);
+ e_dlist_init(&validity->encrypt.encrypters);
}
gboolean
{
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);
camel_cipher_validity_clone(CamelCipherValidity *vin)
{
CamelCipherValidity *vo;
+ CamelCipherCertInfo *info;
vo = camel_cipher_validity_new();
vo->sign.status = vin->sign.status;
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:
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
/* 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
/* 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? */
}
camel_cipher_validity_free (CamelCipherValidity *validity)
{
CamelCipherValidity *child;
+ CamelCipherCertInfo *info;
if (validity == NULL)
return;
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);
}
#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,
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;
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;
};
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);