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

Unified Diff: content/renderer/webcrypto/webcrypto_impl_openssl.cc

Issue 100593002: [webcrypto] Add symmetric key export for NSS and OpenSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjusted #ifdef to fix android (openssl) build Created 7 years 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/renderer/webcrypto/webcrypto_impl_openssl.cc
diff --git a/content/renderer/webcrypto/webcrypto_impl_openssl.cc b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
index 3170b28b987aac50f1045c9088816e453c59cb05..9faf51da7be1d463314f350038b260be8055af95 100644
--- a/content/renderer/webcrypto/webcrypto_impl_openssl.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
@@ -157,6 +157,24 @@ bool AesCbcEncryptDecrypt(CipherOperation cipher_operation,
return true;
}
+bool ExportKeyInternalRaw(
+ const blink::WebCryptoKey& key,
+ blink::WebArrayBuffer* buffer) {
+
+ DCHECK(key.handle());
+ DCHECK(buffer);
+
+ if (key.type() != blink::WebCryptoKeyTypeSecret || !key.extractable())
+ return false;
+
+ const SymKeyHandle* sym_key = reinterpret_cast<SymKeyHandle*>(key.handle());
+
+ *buffer = webcrypto::CreateArrayBuffer(
+ webcrypto::Uint8VectorStart(sym_key->key()), sym_key->key().size());
+
+ return true;
+}
+
} // namespace
void WebCryptoImpl::Init() { crypto::EnsureOpenSSLInit(); }
@@ -370,10 +388,18 @@ bool WebCryptoImpl::ExportKeyInternal(
blink::WebCryptoKeyFormat format,
const blink::WebCryptoKey& key,
blink::WebArrayBuffer* buffer) {
- // TODO(padolph): Implement raw export
- // TODO(padolph): Implement spki export
- // TODO(padolph): Implement pkcs8 export
- // TODO(padolph): Implement jwk export
+ switch (format) {
+ case blink::WebCryptoKeyFormatRaw:
+ return ExportKeyInternalRaw(key, buffer);
+ case blink::WebCryptoKeyFormatSpki:
+ // TODO(padolph): Implement spki export
+ return false;
+ case blink::WebCryptoKeyFormatPkcs8:
+ // TODO(padolph): Implement pkcs8 export
+ return false;
+ default:
+ return false;
+ }
return false;
}
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | content/renderer/webcrypto/webcrypto_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698