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

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

Issue 113003002: [webcrypto] Use new parameter names (that end in "bits" vs "bytes"). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9faf51da7be1d463314f350038b260be8055af95..9d2df880cc2de6980f7e699a564784a4275fa5ae 100644
--- a/content/renderer/webcrypto/webcrypto_impl_openssl.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
@@ -51,7 +51,9 @@ const EVP_CIPHER* GetAESCipherByKeyLength(unsigned key_length_bytes) {
}
}
-unsigned WebCryptoHmacParamsToBlockSize(
+// TODO(eroman): This is wrong. These constants are bytes not bits. Moreover
+// this doesn't match the NSS version.
+unsigned WebCryptoHmacParamsToBlockSizeBytes(
const blink::WebCryptoHmacKeyParams* params) {
DCHECK(params);
switch (params->hash().id()) {
@@ -278,9 +280,9 @@ bool WebCryptoImpl::GenerateKeyInternal(
const blink::WebCryptoAesKeyGenParams* params =
algorithm.aesKeyGenParams();
DCHECK(params);
- if (params->length() % 8)
+ if (params->lengthBits() % 8)
return false;
- keylen_bytes = params->length() / 8;
+ keylen_bytes = params->lengthBits() / 8;
if (!GetAESCipherByKeyLength(keylen_bytes)) {
return false;
}
@@ -290,8 +292,10 @@ bool WebCryptoImpl::GenerateKeyInternal(
case blink::WebCryptoAlgorithmIdHmac: {
const blink::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams();
DCHECK(params);
- if (!params->getLength(keylen_bytes)) {
- keylen_bytes = WebCryptoHmacParamsToBlockSize(params);
+ if (params->hasLengthBytes()) {
+ keylen_bytes = params->optionalLengthBytes();
+ } else {
+ keylen_bytes = WebCryptoHmacParamsToBlockSizeBytes(params);
}
key_type = blink::WebCryptoKeyTypeSecret;
break;
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698