summaryrefslogtreecommitdiffstats
path: root/pki/base/symkey/src/com/netscape
diff options
context:
space:
mode:
authoralee <alee@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2009-06-18 15:29:36 +0000
committeralee <alee@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2009-06-18 15:29:36 +0000
commit546af162c1ad036aafc4c495aff8a895d94700b1 (patch)
tree6b441223658c152ce1ef155eed8ede8bce4675f2 /pki/base/symkey/src/com/netscape
parente2b36131f8b4e72d9a5dd2171f8ace0e531f2b00 (diff)
downloadpki-546af162c1ad036aafc4c495aff8a895d94700b1.tar.gz
pki-546af162c1ad036aafc4c495aff8a895d94700b1.tar.xz
pki-546af162c1ad036aafc4c495aff8a895d94700b1.zip
Bugzilla Bug 500698 - TPS/CA/TKS : segmentation fault after many(30000) enrollments
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@626 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/symkey/src/com/netscape')
-rw-r--r--pki/base/symkey/src/com/netscape/symkey/SymKey.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/pki/base/symkey/src/com/netscape/symkey/SymKey.cpp b/pki/base/symkey/src/com/netscape/symkey/SymKey.cpp
index 11e363436..70a3dfbc6 100644
--- a/pki/base/symkey/src/com/netscape/symkey/SymKey.cpp
+++ b/pki/base/symkey/src/com/netscape/symkey/SymKey.cpp
@@ -440,6 +440,12 @@ PK11SymKey *ComputeCardKey(PK11SymKey *masterKey, unsigned char *data, PK11SlotI
keyData[i] = 0x0;
}
+ if (masterKey == NULL)
+ {
+ printf("ComputeCardKey: master key is null\n");
+ goto done;
+ }
+
context = PK11_CreateContextBySymKey(CKM_DES3_ECB, CKA_ENCRYPT,
masterKey,
&noParams);
@@ -482,10 +488,20 @@ PK11SymKey *ComputeCardKey(PK11SymKey *masterKey, unsigned char *data, PK11SlotI
(CKF_WRAP | CKF_UNWRAP | CKF_ENCRYPT | CKF_DECRYPT) & CKF_KEY_OPERATION_FLAGS,
PR_FALSE, &pwdata);
+ if (tmpkey == NULL) {
+ printf("failed to keygen \n");
+ goto done;
+ }
+
context = PK11_CreateContextBySymKey(CKM_DES3_ECB, CKA_ENCRYPT,
tmpkey,
&noParams);
+ if (context == NULL) {
+ printf("failed to set context \n");
+ goto done;
+ }
+
/* encrypt the key with the master key */
s = PK11_CipherOp(context, wrappedkey, &len, 24, keyData, 24);
if (s != SECSuccess)
@@ -512,6 +528,11 @@ done:
PK11_DestroyContext(context, PR_TRUE);
context = NULL;
}
+ if (tmpkey != NULL)
+ {
+ PK11_FreeSymKey(tmpkey);
+ tmpkey = NULL;
+ }
return key;
}
@@ -536,6 +557,11 @@ PRStatus EncryptDataWithCardKey(PK11SymKey *card_key, Buffer &input, Buffer &out
static SECItem noParams = { siBuffer, 0, 0 };
unsigned char result[8];
+ if (card_key == NULL) {
+ printf("EncryptDataWithCardKey: card_key is null\n");
+ goto done;
+ }
+
context = PK11_CreateContextBySymKey(CKM_DES3_ECB, CKA_ENCRYPT, card_key,
&noParams);
if (context == NULL)
@@ -603,6 +629,7 @@ PRStatus EncryptData(Buffer &kek_key, Buffer &input, Buffer &output)
CKF_ENCRYPT, PR_FALSE, 0);
if( master == NULL)
{
+ printf("EncryptData: master is null\n");
goto done;
}