[gnome-keyring: 5/6] gcr: Fix creation of fingerprints, make tests pass.



commit 0f84906348a2a7654847c3ca679fff816657846c
Author: Stef Walter <stefw collabora co uk>
Date:   Sat Apr 9 08:54:50 2011 +0200

    gcr: Fix creation of fingerprints, make tests pass.
    
     * Fix encoding of test files.
     * Always encode NULL in RSA keys as the parameter.

 egg/pk.asn                      |    2 ++
 gcr/gcr-fingerprint.c           |   15 +++++++++++++--
 gcr/tests/files/client.crt      |  Bin 1054 -> 736 bytes
 gcr/tests/files/client.pem      |   18 ++++++++++++++++++
 gcr/tests/files/generic-dsa.crt |  Bin 1298 -> 918 bytes
 gcr/tests/files/generic-dsa.pem |   22 ++++++++++++++++++++++
 gcr/tests/test-fingerprint.c    |    8 ++++----
 7 files changed, 59 insertions(+), 6 deletions(-)
---
diff --git a/egg/pk.asn b/egg/pk.asn
index f347c19..347323c 100644
--- a/egg/pk.asn
+++ b/egg/pk.asn
@@ -32,6 +32,8 @@ RSAPrivateKey ::= SEQUENCE {
 Version ::= INTEGER { two-prime(0), multi(1) }
 -- version must be multi if otherPrimeInfos present --
 
+RSAParameters ::= NULL
+
 OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
 
 OtherPrimeInfo ::= SEQUENCE {
diff --git a/gcr/gcr-fingerprint.c b/gcr/gcr-fingerprint.c
index 47dc3da..4f93d61 100644
--- a/gcr/gcr-fingerprint.c
+++ b/gcr/gcr-fingerprint.c
@@ -83,14 +83,18 @@ rsa_subject_public_key_from_attributes (GckAttributes *attrs, GNode *info_asn)
 {
 	GckAttribute *attr;
 	GNode *key_asn;
-	gpointer key;
-	gsize n_key;
+	GNode *params_asn;
+	gpointer key, params;
+	gsize n_key, n_params;
 
 	init_quarks ();
 
 	key_asn = egg_asn1x_create (pk_asn1_tab, "RSAPublicKey");
 	g_return_val_if_fail (key_asn, FALSE);
 
+	params_asn = egg_asn1x_create (pk_asn1_tab, "RSAParameters");
+	g_return_val_if_fail (params_asn, FALSE);
+
 	attr = gck_attributes_find (attrs, CKA_MODULUS);
 	g_return_val_if_fail (attr, FALSE);
 	egg_asn1x_set_integer_as_raw (egg_asn1x_node (key_asn, "modulus", NULL),
@@ -104,10 +108,17 @@ rsa_subject_public_key_from_attributes (GckAttributes *attrs, GNode *info_asn)
 	key = egg_asn1x_encode (key_asn, g_realloc, &n_key);
 	egg_asn1x_destroy (key_asn);
 
+	egg_asn1x_set_null (params_asn);
+
+	params = egg_asn1x_encode (params_asn, g_realloc, &n_params);
+	egg_asn1x_destroy (params_asn);
+
 	egg_asn1x_set_bits_as_raw (egg_asn1x_node (info_asn, "subjectPublicKey", NULL),
 	                           key, n_key * 8, g_free);
 
 	egg_asn1x_set_oid_as_quark (egg_asn1x_node (info_asn, "algorithm", "algorithm", NULL), OID_PKIX1_RSA);
+	egg_asn1x_set_raw_element (egg_asn1x_node (info_asn, "algorithm", "parameters", NULL),
+	                           params, n_params, g_free);
 
 	return TRUE;
 }
diff --git a/gcr/tests/files/client.crt b/gcr/tests/files/client.crt
index 04bc8ac..a4bc2fc 100644
Binary files a/gcr/tests/files/client.crt and b/gcr/tests/files/client.crt differ
diff --git a/gcr/tests/files/client.pem b/gcr/tests/files/client.pem
new file mode 100644
index 0000000..04bc8ac
--- /dev/null
+++ b/gcr/tests/files/client.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC3DCCAkUCAQkwDQYJKoZIhvcNAQEFBQAwgYYxEzARBgoJkiaJk/IsZAEZFgND
+T00xFzAVBgoJkiaJk/IsZAEZFgdFWEFNUExFMR4wHAYDVQQLExVDZXJ0aWZpY2F0
+ZSBBdXRob3JpdHkxFzAVBgNVBAMTDmNhLmV4YW1wbGUuY29tMR0wGwYJKoZIhvcN
+AQkBFg5jYUBleGFtcGxlLmNvbTAeFw0xMTAxMTgwNjA0MTFaFw0yMTAxMTUwNjA0
+MTFaMGIxEzARBgoJkiaJk/IsZAEZFgNDT00xFzAVBgoJkiaJk/IsZAEZFgdFWEFN
+UExFMQ8wDQYDVQQDEwZDbGllbnQxITAfBgkqhkiG9w0BCQEWEmNsaWVudEBleGFt
+cGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMEgNDM/dg3t
+9DHNAPz/b87LSxEaKhoZ8AcNBym3LEOdCnXGEnKf0b9lkT5caXu5GAM84ahTCJ7n
+79RVNrqGKM7jbBdSX+ZUfkqJQPhOXD2+0niYQicH92nz78kxmjlbizvd3fM1BlO+
+C/++NWf2EAhORVAjvJrHNokJp3PTNRJ1WWteHeU9PwfGmWHKVc1IgvRFMH08604I
+ZzX5CcxIg/b56g27A7CBPh/KO/qKTDLFFNGc1T2asvY/P3+PeN6y+leFHStCTu7R
+Bi/l4hczZdnwq3BGT6mnjEN7wau2s7pA067SXimNOkYi5fgwspMHi8fJWmYyBypU
+mQBRzwfm77ECAwEAATANBgkqhkiG9w0BAQUFAAOBgQA3LuElj2QB9wQvmIxk2Jmb
+IPP2/WS8dwPoCv/N3+6nTx8yRsrILf4QsnEbbsxoYO5jW4r9Kt8m8B/M7YgnBDE9
+zlm7JbXKZf2isSm5TyT627Ymzxrzs5d+7o2eS7SN1DB6PyvRh2ye7EMbyEYD8ULi
+itDUkYkssNCVivYwVvJoMg==
+-----END CERTIFICATE-----
diff --git a/gcr/tests/files/generic-dsa.crt b/gcr/tests/files/generic-dsa.crt
index 0d81ef2..5658a20 100644
Binary files a/gcr/tests/files/generic-dsa.crt and b/gcr/tests/files/generic-dsa.crt differ
diff --git a/gcr/tests/files/generic-dsa.pem b/gcr/tests/files/generic-dsa.pem
new file mode 100644
index 0000000..0d81ef2
--- /dev/null
+++ b/gcr/tests/files/generic-dsa.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDkjCCAvugAwIBAgIBBDANBgkqhkiG9w0BAQUFADCBhjETMBEGCgmSJomT8ixk
+ARkWA0NPTTEXMBUGCgmSJomT8ixkARkWB0VYQU1QTEUxHjAcBgNVBAsTFUNlcn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ZUlYmpHQ+gA+E9weeFNQWP1QOATmFQ+r18eNH0rUONnR3G0XUYQTgd1
+LgEYxM4t
+-----END CERTIFICATE-----
diff --git a/gcr/tests/test-fingerprint.c b/gcr/tests/test-fingerprint.c
index c52fc9e..55377e5 100644
--- a/gcr/tests/test-fingerprint.c
+++ b/gcr/tests/test-fingerprint.c
@@ -63,10 +63,10 @@ setup (Test *test, gconstpointer unused)
 		g_assert_not_reached ();
 	g_assert (test->key_rsa);
 
-	if (!g_file_get_contents ("files/generic-dsa.crt", (gchar**)&test->key_dsa,
-	                          &test->n_key_dsa, NULL))
+	if (!g_file_get_contents ("files/generic-dsa.crt", (gchar**)&test->cert_dsa,
+	                          &test->n_cert_dsa, NULL))
 		g_assert_not_reached ();
-	g_assert (test->key_dsa);
+	g_assert (test->cert_dsa);
 
 	if (!g_file_get_contents ("files/generic-dsa.key", (gchar**)&test->key_dsa,
 	                          &test->n_key_dsa, NULL))
@@ -80,7 +80,7 @@ teardown (Test *test, gconstpointer unused)
 	g_free (test->cert_rsa);
 	g_free (test->key_rsa);
 	g_free (test->cert_dsa);
-	g_free (test->key_rsa);
+	g_free (test->key_dsa);
 }
 
 static GckAttributes*



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]