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

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
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 478c7aaff73fbb6c873cdcab6465c6de80a146ec..f44cd7172e36644db24ff1c65b31be276413ab62 100644
--- a/content/child/webcrypto/platform_crypto_nss.cc
+++ b/content/child/webcrypto/platform_crypto_nss.cc
@@ -695,6 +695,30 @@ Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer) {
return Status::Success();
}
+Status ExportRsaPublicKey(PublicKey* key,
+ blink::WebArrayBuffer* modulus,
+ blink::WebArrayBuffer* public_exponent) {
+ DCHECK(key);
+ DCHECK(key->key());
+
+ if (key->key()->keyType != rsaKey)
+ return Status::ErrorUnsupported();
+
+ SECItem modulus_item = key->key()->u.rsa.modulus;
+ DCHECK(modulus_item.data);
eroman 2014/03/21 02:30:51 Do these need to be proper returns?
padolph 2014/03/24 04:24:06 Yes.
+ DCHECK(modulus_item.len);
+
+ SECItem public_exponent_item = key->key()->u.rsa.publicExponent;
+ DCHECK(public_exponent_item.data);
+ DCHECK(public_exponent_item.len);
+
+ *modulus = CreateArrayBuffer(modulus_item.data, modulus_item.len);
+ *public_exponent =
+ CreateArrayBuffer(public_exponent_item.data, public_exponent_item.len);
+
+ return Status::Success();
+}
+
Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm,
const CryptoData& key_data,
bool extractable,

Powered by Google App Engine
This is Rietveld 408576698