Skip to content

Commit

Permalink
Use the new PK11_ExportDERPrivateKeyInfo function when using bundled …
Browse files Browse the repository at this point in the history
…NSS.

Update nss_revision to r259440, which includes the following CL:

Add PK11_ExportDERPrivateKeyInfo and PK11_ExportPrivKeyInfo.
https://codereview.chromium.org/205343004

R=eroman@chromium.org,rsleevi@chromium.org
BUG=245025

Review URL: https://codereview.chromium.org/197873040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259797 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
wtc@chromium.org committed Mar 27, 2014
1 parent 1c9b1cc commit 796d76d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ vars = {
# and V8 without interference from each other.
"webrtc_revision": "5793",
"jsoncpp_revision": "248",
"nss_revision": "258808",
"nss_revision": "259440",
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling swarming_client
# and whatever else without interference from each other.
Expand Down
13 changes: 12 additions & 1 deletion content/child/webcrypto/platform_crypto_nss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <pk11pub.h>
#include <secerr.h>
#include <sechash.h>
#include <secoid.h>

#include <vector>

Expand All @@ -26,6 +25,7 @@

#if defined(USE_NSS)
#include <dlfcn.h>
#include <secoid.h>
#endif

// At the time of this writing:
Expand Down Expand Up @@ -546,6 +546,10 @@ void CopySECItemToVector(const SECItem& item, std::vector<uint8>* out) {
out->assign(item.data, item.data + item.len);
}

// The system NSS library doesn't have the new PK11_ExportDERPrivateKeyInfo
// function yet (https://bugzilla.mozilla.org/show_bug.cgi?id=519255). So we
// provide a fallback implementation.
#if defined(USE_NSS)
// From PKCS#1 [http://tools.ietf.org/html/rfc3447]:
//
// RSAPrivateKey ::= SEQUENCE {
Expand Down Expand Up @@ -655,6 +659,7 @@ struct FreeRsaPrivateKey {
SECITEM_FreeItem(&out->coefficient, PR_FALSE);
}
};
#endif // defined(USE_NSS)

} // namespace

Expand Down Expand Up @@ -821,6 +826,8 @@ Status ExportKeyPkcs8(PrivateKey* key,
key_algorithm.id() != blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5)
return Status::ErrorUnsupported();

#if defined(USE_NSS)
// PK11_ExportDERPrivateKeyInfo isn't available. Use our fallback code.
const SECOidTag algorithm = SEC_OID_PKCS1_RSA_ENCRYPTION;
const int kPrivateKeyInfoVersion = 0;

Expand Down Expand Up @@ -856,6 +863,10 @@ Status ExportKeyPkcs8(PrivateKey* key,
NULL,
&private_key_info,
SEC_ASN1_GET(SECKEY_PrivateKeyInfoTemplate)));
#else // defined(USE_NSS)
crypto::ScopedSECItem encoded_key(
PK11_ExportDERPrivateKeyInfo(key->key(), NULL));
#endif // defined(USE_NSS)

if (!encoded_key.get())
return Status::Error();
Expand Down

0 comments on commit 796d76d

Please sign in to comment.