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

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

Issue 178073007: [webcrypto] Update to use the KeyAlgorithm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unrelated change that makes public keys extractable Created 6 years, 10 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/renderer/webcrypto/platform_crypto_nss.cc ('k') | content/renderer/webcrypto/shared_crypto.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webcrypto/platform_crypto_openssl.cc
diff --git a/content/renderer/webcrypto/platform_crypto_openssl.cc b/content/renderer/webcrypto/platform_crypto_openssl.cc
index 45ba541541a2dec7b6cc7e36bcdadd49ec17afaf..9ebea0ff4037fa9250d57bc9a5647c208b17e17d 100644
--- a/content/renderer/webcrypto/platform_crypto_openssl.cc
+++ b/content/renderer/webcrypto/platform_crypto_openssl.cc
@@ -18,6 +18,9 @@
#include "third_party/WebKit/public/platform/WebArrayBuffer.h"
#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
#include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
+#ifdef WEBCRYPTO_HAS_KEY_ALGORITHM
+#include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
+#endif
namespace content {
@@ -222,10 +225,18 @@ Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
if (!(RAND_bytes(&random_bytes[0], keylen_bytes)))
return Status::Error();
+#ifdef WEBCRYPTO_HAS_KEY_ALGORITHM
+ blink::WebCryptoKeyAlgorithm key_algorithm;
+ if (!CreateSecretKeyAlgorithm(algorithm, keylen_bytes, &key_algorithm))
+ return Status::ErrorUnexpected();
+#else
+ const blink::WebCryptoAlgorithm key_algorithm = algorithm;
+#endif
+
*key = blink::WebCryptoKey::create(new SymKey(CryptoData(random_bytes)),
blink::WebCryptoKeyTypeSecret,
extractable,
- algorithm,
+ key_algorithm,
usage_mask);
return Status::Success();
@@ -234,6 +245,9 @@ Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
Status GenerateRsaKeyPair(const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
+ unsigned int modulus_length_bits,
+ const CryptoData& public_exponent,
+ const blink::WebCryptoAlgorithm& hash,
blink::WebCryptoKey* public_key,
blink::WebCryptoKey* private_key) {
// TODO(padolph): Placeholder for OpenSSL implementation.
@@ -246,10 +260,20 @@ Status ImportKeyRaw(const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
blink::WebCryptoKey* key) {
+
+#ifdef WEBCRYPTO_HAS_KEY_ALGORITHM
+ blink::WebCryptoKeyAlgorithm key_algorithm;
+ if (!CreateSecretKeyAlgorithm(
+ algorithm, key_data.byte_length(), &key_algorithm))
+ return Status::ErrorUnexpected();
+#else
+ const blink::WebCryptoAlgorithm key_algorithm = algorithm;
+#endif
+
*key = blink::WebCryptoKey::create(new SymKey(key_data),
blink::WebCryptoKeyTypeSecret,
extractable,
- algorithm,
+ key_algorithm,
usage_mask);
return Status::Success();
« no previous file with comments | « content/renderer/webcrypto/platform_crypto_nss.cc ('k') | content/renderer/webcrypto/shared_crypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698