From 90846ad7d75e042b4617ed8be0bcfc110ee97398 Mon Sep 17 00:00:00 2001 From: "relyea%netscape.com" Date: Fri, 16 Nov 2001 02:37:41 +0000 Subject: [PATCH] Call Ian's privatekey verify options. git-svn-id: svn://10.0.0.236/branches/NSS_3_3_BRANCH@108248 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/softoken/pkcs11.c | 10 ++++++++++ mozilla/security/nss/lib/softoken/rsawrapr.c | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mozilla/security/nss/lib/softoken/pkcs11.c b/mozilla/security/nss/lib/softoken/pkcs11.c index 4930af907c3..06247b66d72 100644 --- a/mozilla/security/nss/lib/softoken/pkcs11.c +++ b/mozilla/security/nss/lib/softoken/pkcs11.c @@ -976,6 +976,8 @@ pk11_handlePrivateKeyObject(PK11Object *object,CK_KEY_TYPE key_type) &ckfalse,sizeof(CK_BBOOL)); if (crv != CKR_OK) return crv; + /* should we check the non-token RSA private keys? */ + if (pk11_isTrue(object,CKA_TOKEN)) { SECKEYLowPrivateKey *privKey; char *label; @@ -984,6 +986,13 @@ pk11_handlePrivateKeyObject(PK11Object *object,CK_KEY_TYPE key_type) privKey=pk11_mkPrivKey(object,key_type); if (privKey == NULL) return CKR_HOST_MEMORY; + + if (key_type == CKK_RSA) { + rv = RSA_PrivateKeyCheck(&privKey->u.rsa); + if (rv == SECFailure) { + goto fail; + } + } label = object->label = pk11_getString(object,CKA_LABEL); crv = pk11_Attribute2SecItem(NULL,&pubKey,object,CKA_NETSCAPE_DB); @@ -1003,6 +1012,7 @@ pk11_handlePrivateKeyObject(PK11Object *object,CK_KEY_TYPE key_type) rv = SECFailure; } +fail: SECKEY_LowDestroyPrivateKey(privKey); if (rv != SECSuccess) return CKR_DEVICE_ERROR; object->inDB = PR_TRUE; diff --git a/mozilla/security/nss/lib/softoken/rsawrapr.c b/mozilla/security/nss/lib/softoken/rsawrapr.c index 7c818dad5bb..83fe6cea751 100644 --- a/mozilla/security/nss/lib/softoken/rsawrapr.c +++ b/mozilla/security/nss/lib/softoken/rsawrapr.c @@ -33,7 +33,7 @@ * may use your version of this file under either the MPL or the * GPL. * - * $Id: rsawrapr.c,v 1.1 2000-03-31 19:29:42 relyea%netscape.com Exp $ + * $Id: rsawrapr.c,v 1.1.86.1 2001-11-16 02:37:41 relyea%netscape.com Exp $ */ #include "blapi.h" @@ -632,7 +632,7 @@ RSA_Sign(SECKEYLowPrivateKey *key, if (rv != SECSuccess) goto done; - rv = RSA_PrivateKeyOp(&key->u.rsa, output, formatted.data); + rv = RSA_PrivateKeyOpDoubleChecked(&key->u.rsa, output, formatted.data); *output_len = modulus_len; goto done; @@ -888,7 +888,7 @@ RSA_SignRaw(SECKEYLowPrivateKey *key, if (rv != SECSuccess) goto done; - rv = RSA_PrivateKeyOp(&key->u.rsa, output, formatted.data); + rv = RSA_PrivateKeyOpDoubleChecked(&key->u.rsa, output, formatted.data); *output_len = modulus_len; done: