Chromium Code Reviews| 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, |