[gnome-keyring/dbus-api: 7/7] Merge branch 'master' into dbus-api
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api: 7/7] Merge branch 'master' into dbus-api
- Date: Mon, 9 Nov 2009 17:12:44 +0000 (UTC)
commit 20554475915e2ab019f9441cb643afe650471f5d
Merge: 2a04edf... 70b4a23...
Author: Stef Walter <stef memberwebs com>
Date: Mon Nov 9 17:08:08 2009 +0000
Merge branch 'master' into dbus-api
pkcs11/gck/gck-certificate.c | 48 +-
pkcs11/gck/gck-data-der.c | 1 +
pkcs11/gck/tests/test-data/ca-certificates.crt | 3601 ++++++++++++++++++++++++
pkcs11/gck/tests/unit-test-data-der.c | 40 +
4 files changed, 3675 insertions(+), 15 deletions(-)
---
diff --cc pkcs11/gck/gck-certificate.c
index 727fa3c,4794d43..9292651
--- a/pkcs11/gck/gck-certificate.c
+++ b/pkcs11/gck/gck-certificate.c
@@@ -551,7 -549,28 +552,30 @@@ gck_certificate_real_load (GckSerializa
/* Now create us a nice public key with that identifier */
res = gck_data_der_read_public_key_info (keydata, n_keydata, &sexp);
g_free (keydata);
- if (res != GCK_DATA_SUCCESS) {
+
+ switch (res) {
+
+ /* Create ourselves a public key with that */
+ case GCK_DATA_SUCCESS:
+ wrapper = gck_sexp_new (sexp);
+ if (!self->pv->key)
- self->pv->key = gck_certificate_key_new (gck_object_get_module (GCK_OBJECT (self)), self);
++ self->pv->key = gck_certificate_key_new (gck_object_get_module (GCK_OBJECT (self)),
++ gck_object_get_manager (GCK_OBJECT (self)),
++ self);
+ gck_key_set_base_sexp (GCK_KEY (self->pv->key), wrapper);
+ gck_sexp_unref (wrapper);
+ break;
+
+ /* Unknown type of public key for this certificate, just ignore */
+ case GCK_DATA_UNRECOGNIZED:
+ if (self->pv->key)
+ g_object_unref (self->pv->key);
+ self->pv->key = NULL;
+ break;
+
+ /* Bad key, drop certificate */
+ case GCK_DATA_FAILURE:
+ case GCK_DATA_LOCKED:
g_warning ("couldn't parse certificate key data");
g_free (copy);
asn1_delete_structure (&asn1);
diff --cc pkcs11/gck/tests/unit-test-data-der.c
index b641dd0,fc4ba03..46804f5
--- a/pkcs11/gck/tests/unit-test-data-der.c
+++ b/pkcs11/gck/tests/unit-test-data-der.c
@@@ -276,6 -278,44 +278,44 @@@ DEFINE_TEST(write_certificate
g_free (data);
}
+ static void
+ on_ca_certificate_public_key_info (GQuark type, const guchar *data, gsize n_data,
+ GHashTable *headers, gpointer user_data)
+ {
+ ASN1_TYPE asn1 = ASN1_TYPE_EMPTY;
+ GckDataResult res;
+ gpointer keydata;
+ gsize n_keydata;
+ gcry_sexp_t sexp;
+
+ g_assert (g_quark_try_string ("CERTIFICATE") == type);
+
+ /* Parse the ASN1 data */
+ res = gck_data_der_read_certificate (data, n_data, &asn1);
+ g_assert (res == GCK_DATA_SUCCESS);
+
+ /* Generate a raw public key from our certificate */
+ keydata = egg_asn1_encode (asn1, "tbsCertificate.subjectPublicKeyInfo", &n_keydata, NULL);
+ g_assert (keydata);
+
+ /* Now create us a nice public key with that identifier */
+ res = gck_data_der_read_public_key_info (keydata, n_keydata, &sexp);
+ g_assert (res == GCK_DATA_SUCCESS || res == GCK_DATA_UNRECOGNIZED);
+
+ gcry_sexp_release (sexp);
+ g_free (keydata);
+ }
+
+ DEFINE_TEST(read_ca_certificates_public_key_info)
+ {
+ gpointer data;
+ gsize n_data;
+
- data = test_read_testdata ("ca-certificates.crt", &n_data);
++ data = test_data_read ("ca-certificates.crt", &n_data);
+ egg_openssl_pem_parse (data, n_data, on_ca_certificate_public_key_info, NULL);
+ g_free (data);
+ }
+
static const guchar*
find_extension (ASN1_TYPE asn, const guchar *data, gsize n_data, const gchar *oid, gsize *n_extension)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]