Index: nss_oaep.c =================================================================== RCS file: /cvsroot/gaim-encryption/encrypt/nss_oaep.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- nss_oaep.c 29 Jun 2003 21:25:28 -0000 1.2 +++ nss_oaep.c 1 Jan 2004 20:46:07 -0000 1.3 @@ -20,7 +20,6 @@ */ #include "pk11func.h" -#include "secrng.h" #include "keyhi.h" /* for g_assert; PORT_Assert seems disabled... */ Index: nss_pss.c =================================================================== RCS file: /cvsroot/gaim-encryption/encrypt/nss_pss.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- nss_pss.c 4 Jul 2003 23:30:29 -0000 1.3 +++ nss_pss.c 1 Jan 2004 20:46:07 -0000 1.4 @@ -20,7 +20,6 @@ */ #include "pk11func.h" -#include "secrng.h" #include "keyhi.h" /* for g_assert; PORT_Assert seems disabled... */ Index: rsa_nss.c =================================================================== RCS file: /cvsroot/gaim-encryption/encrypt/rsa_nss.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- rsa_nss.c 20 Dec 2003 14:57:45 -0000 1.24 +++ rsa_nss.c 1 Jan 2004 20:46:07 -0000 1.25 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -440,8 +439,9 @@ const CK_MECHANISM_TYPE SymEncryptionType = CKM_DES3_CBC_PAD; PK11SlotInfo *symSlot; PK11SymKey *symKey; + SECItem *pubKeyValue; SECItem symKeyItem; /* storage space for binary key import */ - unsigned char symKeyData[32] = {0}; + unsigned char symKeyData[24] = {0}; SECItem *iv = 0, *wrappedKey = 0, label; CK_ATTRIBUTE_TYPE attribs[3] = { CKA_SIGN, CKA_DECRYPT, CKA_SIGN_RECOVER }; const int NumAttribs = 3; @@ -454,6 +454,7 @@ /* NNNN is the Base64 encoding of the IV, and */ /* MMMM is the Base64 encoding of the encrypted private key */ + key->proto = rsa_nss_proto; split_key = g_strsplit(key_str, ",", 3); @@ -546,6 +547,8 @@ return 0; } + pubKeyValue = SECITEM_DupItem(&key->store.rsa_nss.pub->u.rsa.modulus); + symSlot = PK11_GetBestSlot(SymEncryptionType, NULL); g_assert(symSlot != 0); @@ -554,17 +557,30 @@ symKey = PK11_ImportSymKey(symSlot, PK11_GetKeyGen(SymEncryptionType), PK11_OriginUnwrap, CKA_WRAP, &symKeyItem, NULL); - + + if (!symKey) { + gaim_debug(GAIM_DEBUG_ERROR, "gaim-encryption", + "Error creating symmetric key: unable to load private key\n"); + g_strfreev(split_key); + + SECKEY_DestroyPublicKey(key->store.rsa_nss.pub); + SECITEM_FreeItem (pubKeyValue, PR_TRUE); + g_free(key); + return 0; + } + label.data = NULL; label.len = 0; key->store.rsa_nss.priv = PK11_UnwrapPrivKey(symSlot, symKey, SymEncryptionType, iv, - wrappedKey, &label, &(key->store.rsa_nss.pub->u.rsa.modulus), + wrappedKey, &label, pubKeyValue, PR_FALSE, PR_FALSE, CKK_RSA, attribs, NumAttribs, 0); + SECITEM_FreeItem (pubKeyValue, PR_TRUE); + if (key->store.rsa_nss.priv == 0) { gaim_debug(GAIM_DEBUG_ERROR, "gaim-encryption", - "Error decoding RSANSS Public key\n"); + "Error decoding RSANSS Private key\n"); g_strfreev(split_key); SECKEY_DestroyPublicKey(key->store.rsa_nss.pub);