Bug 1073330 - Support set nickname of imported certificates. r=rrelyea
authorChuck Lee <chulee@mozilla.com>
Mon, 20 Oct 2014 22:41:17 +0200
changeset 11295 575919285e2bc440659c585c0a0ed219ce60fda6
parent 11294 d63d3b5212becea34d3e58be40d00565638dc1fe
child 11296 7f496fc97e755660a6be823d5baaae6fad643e63
push id506
push userkaie@kuix.de
push dateMon, 20 Oct 2014 20:41:25 +0000
reviewersrrelyea
bugs1073330
Bug 1073330 - Support set nickname of imported certificates. r=rrelyea
lib/nss/nss.def
lib/pk11wrap/pk11cert.c
lib/pk11wrap/pk11pub.h
--- a/lib/nss/nss.def
+++ b/lib/nss/nss.def
@@ -617,16 +617,17 @@ PK11_GetSymKeyNickname;
 PK11_ImportDERPrivateKeyInfoAndReturnKey;
 PK11_ImportPrivateKeyInfoAndReturnKey;
 PK11_ImportPublicKey;
 PK11_ImportSymKeyWithFlags;
 PK11_ListFixedKeysInSlot;
 PK11_ListPrivKeysInSlot;
 PK11_ListPublicKeysInSlot;
 PK11_ProtectedAuthenticationPath;
+PK11_SetCertificateNickname;
 PK11_SetPrivateKeyNickname;
 PK11_SetPublicKeyNickname;
 PK11_SetSymKeyNickname;
 SECKEY_DecodeDERSubjectPublicKeyInfo;
 SECKEY_DestroyPublicKeyList;
 ;+# for debugging
 nss_DumpCertificateCacheInfo;
 ;+    local:
--- a/lib/pk11wrap/pk11cert.c
+++ b/lib/pk11wrap/pk11cert.c
@@ -2681,8 +2681,19 @@ PK11_GetAllSlotsForCert(CERTCertificate 
 	PK11_FreeSlotList(slotList);
 	PORT_SetError(SEC_ERROR_NO_TOKEN);
 	slotList = NULL;
     }
 
     nssCryptokiObjectArray_Destroy(instances);
     return slotList;
 }
+
+SECStatus
+PK11_SetCertificateNickname(CERTCertificate *cert, const char *nickname)
+{
+    /* Can't set nickname of temp cert. */
+    if (!cert->slot || cert->pkcs11ID == CK_INVALID_HANDLE) {
+        return SEC_ERROR_INVALID_ARGS;
+    }
+    return PK11_SetObjectNickname(cert->slot, cert->pkcs11ID, nickname);
+}
+
--- a/lib/pk11wrap/pk11pub.h
+++ b/lib/pk11wrap/pk11pub.h
@@ -453,16 +453,18 @@ SECKEYPrivateKey * PK11_LoadPrivKey(PK11
 char * PK11_GetSymKeyNickname(PK11SymKey *symKey);
 char * PK11_GetPrivateKeyNickname(SECKEYPrivateKey *privKey);
 char * PK11_GetPublicKeyNickname(SECKEYPublicKey *pubKey);
 SECStatus PK11_SetSymKeyNickname(PK11SymKey *symKey, const char *nickname);
 SECStatus PK11_SetPrivateKeyNickname(SECKEYPrivateKey *privKey, 
 							const char *nickname);
 SECStatus PK11_SetPublicKeyNickname(SECKEYPublicKey *pubKey, 
 							const char *nickname);
+SECStatus PK11_SetCertificateNickname(CERTCertificate *cert,
+                                      const char *nickname);
 
 /* size to hold key in bytes */
 unsigned int PK11_GetKeyLength(PK11SymKey *key);
 /* size of actual secret parts of key in bits */
 /* algid is because RC4 strength is determined by the effective bits as well
  * as the key bits */
 unsigned int PK11_GetKeyStrength(PK11SymKey *key,SECAlgorithmID *algid);
 SECStatus PK11_ExtractKeyValue(PK11SymKey *symKey);