Bug 1429148 - Add nsIPK11Token.isInternalKeyToken. r=keeler,MattN
authorFelipe Gomes <felipc@gmail.com>
Tue, 20 Feb 2018 20:43:41 -0300
changeset 404710 ffe15fb2541cc5999f6fcee6c13e6075e4f0feb7
parent 404709 0c3184f918f0da21aa730d0577c2bdd8810ce2dc
child 404711 c9dc10752a478322dc99201b0b215c7fd1d7a44b
push id100073
push userncsoregi@mozilla.com
push dateWed, 21 Feb 2018 21:53:43 +0000
treeherdermozilla-inbound@210554e2bad4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler, MattN
bugs1429148
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1429148 - Add nsIPK11Token.isInternalKeyToken. r=keeler,MattN MozReview-Commit-ID: Gdd7MxDXoTC
security/manager/ssl/nsIPK11Token.idl
security/manager/ssl/nsPK11TokenDB.cpp
security/manager/ssl/tests/unit/test_pkcs11_slot.js
security/manager/ssl/tests/unit/test_pkcs11_token.js
security/nss.symbols
--- a/security/manager/ssl/nsIPK11Token.idl
+++ b/security/manager/ssl/nsIPK11Token.idl
@@ -11,16 +11,18 @@ interface nsIPK11Token : nsISupports
 {
   /*
    * The name of the token
    */
   [must_use]
   readonly attribute AUTF8String tokenName;
   [must_use]
   readonly attribute AUTF8String tokenLabel;
+  [must_use]
+  readonly attribute boolean isInternalKeyToken;
   /**
    * Manufacturer ID of the token.
    */
   [must_use]
   readonly attribute AUTF8String tokenManID;
   /**
    * Hardware version of the token.
    */
--- a/security/manager/ssl/nsPK11TokenDB.cpp
+++ b/security/manager/ssl/nsPK11TokenDB.cpp
@@ -102,16 +102,24 @@ nsPK11Token::GetTokenName(/*out*/ nsACSt
 
 NS_IMETHODIMP
 nsPK11Token::GetTokenLabel(/*out*/ nsACString& tokenLabel)
 {
   return GetAttributeHelper(mTokenLabel, tokenLabel);
 }
 
 NS_IMETHODIMP
+nsPK11Token::GetIsInternalKeyToken(/*out*/ bool* _retval)
+{
+  NS_ENSURE_ARG_POINTER(_retval);
+  *_retval = PK11_IsInternalKeySlot(mSlot.get());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsPK11Token::GetTokenManID(/*out*/ nsACString& tokenManufacturerID)
 {
   return GetAttributeHelper(mTokenManufacturerID, tokenManufacturerID);
 }
 
 NS_IMETHODIMP
 nsPK11Token::GetTokenHWVersion(/*out*/ nsACString& tokenHWVersion)
 {
--- a/security/manager/ssl/tests/unit/test_pkcs11_slot.js
+++ b/security/manager/ssl/tests/unit/test_pkcs11_slot.js
@@ -30,14 +30,15 @@ function run_test() {
         "Actual and expected status should match");
   equal(testSlot.tokenName, "Test PKCS11 TokeƱ 2 Label",
         "Actual and expected token name should match");
 
   let testToken = testSlot.getToken();
   notEqual(testToken, null, "getToken() should succeed");
   equal(testToken.tokenLabel, "Test PKCS11 TokeƱ 2 Label",
         "Spot check: the actual and expected test token labels should be equal");
+  ok(!testToken.isInternalKeyToken, "This token is not the internal key token");
 
   testSlot = testModule.findSlotByName("Empty PKCS11 Slot");
   equal(testSlot.tokenName, null, "Empty slot is empty");
   equal(testSlot.status, Ci.nsIPKCS11Slot.SLOT_NOT_PRESENT,
         "Actual and expected status should match");
 }
--- a/security/manager/ssl/tests/unit/test_pkcs11_token.js
+++ b/security/manager/ssl/tests/unit/test_pkcs11_token.js
@@ -72,16 +72,17 @@ function checkPasswordFeaturesAndResetPa
   ok(!token.isLoggedIn(), "Token should be logged out of after reset");
 }
 
 function run_test() {
   let tokenDB = Cc["@mozilla.org/security/pk11tokendb;1"]
                   .getService(Ci.nsIPK11TokenDB);
   let token = tokenDB.getInternalKeyToken();
   notEqual(token, null, "The internal token should be present");
+  ok(token.isInternalKeyToken, "The internal token should be represented as such");
 
   checkBasicAttributes(token);
 
   ok(!token.isLoggedIn(), "Token should not be logged into yet");
   // Test that attempting to log out even when the token was not logged into
   // does not result in an error.
   token.logoutSimple();
   ok(!token.isLoggedIn(), "Token should still not be logged into");
--- a/security/nss.symbols
+++ b/security/nss.symbols
@@ -394,16 +394,17 @@ PK11_ImportEncryptedPrivateKeyInfoAndRet
 PK11_ImportPublicKey
 PK11_ImportSymKey
 PK11_InitPin
 PK11_IsDisabled
 PK11_IsFIPS
 PK11_IsFriendly
 PK11_IsHW
 PK11_IsInternal
+PK11_IsInternalKeySlot
 PK11_IsLoggedIn
 PK11_IsPresent
 PK11_IsReadOnly
 PK11_IsRemovable
 PK11_KeyForCertExists
 PK11_KeyGen
 PK11_KeyGenWithTemplate
 PK11_ListCerts