changeset 19076:daa68185a018

- Add purple_certificate_signed_by - Modify ssl-gnutls to expose its support for above
author William Ehlhardt <williamehlhardt@gmail.com>
date Tue, 07 Aug 2007 04:31:01 +0000
parents a0138be8d725
children 8275c3cbc9da
files libpurple/certificate.c libpurple/certificate.h libpurple/plugins/ssl/ssl-gnutls.c
diffstat 3 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/certificate.c	Tue Aug 07 04:06:48 2007 +0000
+++ b/libpurple/certificate.c	Tue Aug 07 04:31:01 2007 +0000
@@ -151,6 +151,22 @@
 	g_list_free(crt_list);
 }
 
+gboolean
+purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer)
+{
+	PurpleCertificateScheme *scheme;
+
+	g_return_val_if_fail(crt, FALSE);
+	g_return_val_if_fail(issuer, FALSE);
+
+	scheme = crt->scheme;
+	g_return_val_if_fail(scheme, FALSE);
+	/* We can't compare two certs of unrelated schemes, obviously */
+	g_return_val_if_fail(issuer->scheme == scheme, FALSE);
+
+	return (scheme->signed_by)(crt, issuer);
+}
+
 PurpleCertificate *
 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename)
 {
--- a/libpurple/certificate.h	Tue Aug 07 04:06:48 2007 +0000
+++ b/libpurple/certificate.h	Tue Aug 07 04:31:01 2007 +0000
@@ -188,6 +188,9 @@
 	 */
 	void (* destroy_certificate)(PurpleCertificate * crt);
 
+	/** Find whether "crt" has a valid signature from issuer "issuer"
+	 *  @see purple_certificate_signed_by() */
+	gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer);
 	/**
 	 * Retrieves the certificate public key fingerprint using SHA1
 	 *
@@ -408,6 +411,19 @@
 purple_certificate_destroy_list (GList * crt_list);
 
 /**
+ * Check whether 'crt' has a valid signature made by 'issuer'
+ *
+ * @param crt        Certificate instance to check signature of
+ * @param issuer     Certificate thought to have signed 'crt'
+ *
+ * @return TRUE if 'crt' has a valid signature made by 'issuer',
+ *         otherwise FALSE
+ * @TODO Find a way to give the reason (bad signature, not the issuer, etc.) 
+ */
+gboolean
+purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer);
+
+/**
  * Imports a PurpleCertificate from a file
  *
  * @param scheme      Scheme to import under
--- a/libpurple/plugins/ssl/ssl-gnutls.c	Tue Aug 07 04:06:48 2007 +0000
+++ b/libpurple/plugins/ssl/ssl-gnutls.c	Tue Aug 07 04:31:01 2007 +0000
@@ -818,6 +818,7 @@
 	x509_export_certificate,         /* Certificate export function */
 	x509_copy_certificate,           /* Copy */
 	x509_destroy_certificate,        /* Destroy cert */
+	x509_certificate_signed_by,      /* Signature checker */
 	x509_sha1sum,                    /* SHA1 fingerprint */
 	NULL,                            /* Unique ID */
 	NULL,                            /* Issuer Unique ID */