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

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..1769c52c73fb7886e2f3b660fd54d3fbc317eab0 100644
--- a/content/child/webcrypto/platform_crypto_nss.cc
+++ b/content/child/webcrypto/platform_crypto_nss.cc
@@ -695,6 +695,29 @@ 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();
+
+ SECItem modulus_item = key->key()->u.rsa.modulus;
+ if (!modulus_item.data || !modulus_item.len)
eroman 2014/03/24 22:05:51 Consider extracting this to a function: CopySECIt
padolph 2014/03/25 01:10:28 Done.
+ return Status::ErrorUnexpected();
+
+ SECItem public_exponent_item = key->key()->u.rsa.publicExponent;
+ if (!public_exponent_item.data || !public_exponent_item.len)
+ return Status::ErrorUnexpected();
+
+ modulus->assign(modulus_item.data, modulus_item.data + modulus_item.len);
+ public_exponent->assign(public_exponent_item.data,
+ 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