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

Unified Diff: content/child/webcrypto/platform_crypto_nss.cc

Issue 205913002: [webcrypto] Add JWK RSA public key export for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
« no previous file with comments | « content/child/webcrypto/platform_crypto.h ('k') | content/child/webcrypto/platform_crypto_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/platform_crypto_nss.cc
diff --git a/content/child/webcrypto/platform_crypto_nss.cc b/content/child/webcrypto/platform_crypto_nss.cc
index 242db07a23a1c52fb866cd4840eee4510fae7294..13f5735bcc1c4354b3b8c19c6a5e9cc882af4dd7 100644
--- a/content/child/webcrypto/platform_crypto_nss.cc
+++ b/content/child/webcrypto/platform_crypto_nss.cc
@@ -542,6 +542,10 @@ Status DoUnwrapSymKeyAesKw(const CryptoData& wrapped_key_data,
return Status::Success();
}
+void CopySECItemToVector(const SECItem& item, std::vector<uint8>* out) {
+ out->assign(item.data, item.data + item.len);
+}
+
// From PKCS#1 [http://tools.ietf.org/html/rfc3447]:
//
// RSAPrivateKey ::= SEQUENCE {
@@ -795,6 +799,20 @@ Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer) {
return Status::Success();
}
+Status ExportRsaPublicKey(PublicKey* key,
+ std::vector<uint8>* modulus,
+ std::vector<uint8>* public_exponent) {
+ DCHECK(key);
+ DCHECK(key->key());
+ if (key->key()->keyType != rsaKey)
+ return Status::ErrorUnsupported();
+ CopySECItemToVector(key->key()->u.rsa.modulus, modulus);
+ CopySECItemToVector(key->key()->u.rsa.publicExponent, public_exponent);
+ if (modulus->empty() || public_exponent->empty())
+ return Status::ErrorUnexpected();
+ return Status::Success();
+}
+
Status ExportKeyPkcs8(PrivateKey* key,
const blink::WebCryptoKeyAlgorithm& key_algorithm,
blink::WebArrayBuffer* buffer) {
« no previous file with comments | « content/child/webcrypto/platform_crypto.h ('k') | content/child/webcrypto/platform_crypto_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698