Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(876)

Unified Diff: nss/lib/pk11wrap/pk11obj.c

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: nss/lib/pk11wrap/pk11obj.c
diff --git a/nss/lib/pk11wrap/pk11obj.c b/nss/lib/pk11wrap/pk11obj.c
index 848b45a017919918b3c66ac0aeba55a66b381efc..260aeed69873e8878e385a8d8e1067c7a747ae49 100644
--- a/nss/lib/pk11wrap/pk11obj.c
+++ b/nss/lib/pk11wrap/pk11obj.c
@@ -25,6 +25,8 @@ SECItem *
PK11_BlockData(SECItem *data,unsigned long size) {
SECItem *newData;
+ if (size == 0u) return NULL;
+
newData = (SECItem *)PORT_Alloc(sizeof(SECItem));
if (newData == NULL) return NULL;
@@ -666,6 +668,18 @@ SECStatus
PK11_Verify(SECKEYPublicKey *key, const SECItem *sig, const SECItem *hash,
void *wincx)
{
+ CK_MECHANISM_TYPE mech = PK11_MapSignKeyType(key->keyType);
+ return PK11_VerifyWithMechanism(key, mech, NULL, sig, hash, wincx);
+}
+
+/*
+ * Verify a signature from its hash using the given algorithm.
+ */
+SECStatus
+PK11_VerifyWithMechanism(SECKEYPublicKey *key, CK_MECHANISM_TYPE mechanism,
+ const SECItem *param, const SECItem *sig,
+ const SECItem *hash, void *wincx)
+{
PK11SlotInfo *slot = key->pkcs11Slot;
CK_OBJECT_HANDLE id = key->pkcs11ID;
CK_MECHANISM mech = {0, NULL, 0 };
@@ -673,7 +687,11 @@ PK11_Verify(SECKEYPublicKey *key, const SECItem *sig, const SECItem *hash,
CK_SESSION_HANDLE session;
CK_RV crv;
- mech.mechanism = PK11_MapSignKeyType(key->keyType);
+ mech.mechanism = mechanism;
+ if (param) {
+ mech.pParameter = param->data;
+ mech.ulParameterLen = param->len;
+ }
if (slot == NULL) {
unsigned int length = 0;
@@ -737,6 +755,17 @@ PK11_Verify(SECKEYPublicKey *key, const SECItem *sig, const SECItem *hash,
SECStatus
PK11_Sign(SECKEYPrivateKey *key, SECItem *sig, const SECItem *hash)
{
+ CK_MECHANISM_TYPE mech = PK11_MapSignKeyType(key->keyType);
+ return PK11_SignWithMechanism(key, mech, NULL, sig, hash);
+}
+
+/*
+ * Sign a hash using the given algorithm.
+ */
+SECStatus
+PK11_SignWithMechanism(SECKEYPrivateKey *key, CK_MECHANISM_TYPE mechanism,
+ const SECItem *param, SECItem *sig, const SECItem *hash)
+{
PK11SlotInfo *slot = key->pkcs11Slot;
CK_MECHANISM mech = {0, NULL, 0 };
PRBool owner = PR_TRUE;
@@ -745,7 +774,11 @@ PK11_Sign(SECKEYPrivateKey *key, SECItem *sig, const SECItem *hash)
CK_ULONG len;
CK_RV crv;
- mech.mechanism = PK11_MapSignKeyType(key->keyType);
+ mech.mechanism = mechanism;
+ if (param) {
+ mech.pParameter = param->data;
+ mech.ulParameterLen = param->len;
+ }
if (SECKEY_HAS_ATTRIBUTE_SET(key,CKA_PRIVATE)) {
PK11_HandlePasswordCheck(slot, key->wincx);
« no previous file with comments | « nss/lib/pk11wrap/pk11mech.c ('k') | nss/lib/pk11wrap/pk11pars.c » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698