gnome-keyring [PATCH] Fix algorithm check in prepare_and_encode_pkcs8_cipher



Hello,

The attached patch fixes the broken algorithm check in
prepare_and_encode_pkcs8_cipher.

The end goal is to import a pkcs#12 into gnome-keyring via the pkcs#11
module.  Right now, firefox 4 fails with: "The PKCS #12 operation
failed for unknown reasons."  pk12util says: "pk12util: PKCS12 decode
import bags failed: Unable to import.  Error attempting to import
private key."  The pk12util command happened to hit this function
which promptly failed with a lovely assertion...

After this patch, iff I have the p12 password the same as the "Gnome2
Key Storage" slot, pk12util says: "pk12util: PKCS12 decoding failed:
security library: improperly formatted DER-encoded message."
`gnome-keyring import' barfs with an assertion before seeming to do
anything.  Help!

Thanks,

Josh Roys
From 94ad9ba82e3d4ec9dd4b4ae7fdb771fa639da43a Mon Sep 17 00:00:00 2001
From: Joshua Roys <roysjosh gmail com>
Date: Tue, 31 May 2011 22:49:26 -0400
Subject: [PATCH] Fix algorithm check in prepare_and_encode_pkcs8_cipher

---
 pkcs11/gkm/gkm-data-der.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkcs11/gkm/gkm-data-der.c b/pkcs11/gkm/gkm-data-der.c
index 4421ef6..8e60651 100644
--- a/pkcs11/gkm/gkm-data-der.c
+++ b/pkcs11/gkm/gkm-data-der.c
@@ -957,8 +957,8 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password,
 	init_quarks ();
 
 	/* Make sure the encryption algorithm works */
-	g_return_val_if_fail (gcry_cipher_algo_info (OID_PKCS12_PBE_3DES_SHA1,
-	                                             GCRYCTL_TEST_ALGO, NULL, 0), NULL);
+	g_return_val_if_fail (gcry_cipher_algo_info (gcry_cipher_map_name (g_quark_to_string (OID_PKCS12_PBE_3DES_SHA1)),
+	                                             GCRYCTL_TEST_ALGO, NULL, 0) == 0, NULL);
 
 	/* The encryption algorithm */
 	if(!egg_asn1x_set_oid_as_quark (egg_asn1x_node (asn, "encryptionAlgorithm", "algorithm", NULL),
-- 
1.7.5.2



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