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

Unified Diff: content/renderer/webcrypto/webcrypto_impl_nss.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 | « no previous file | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webcrypto/webcrypto_impl_nss.cc
diff --git a/content/renderer/webcrypto/webcrypto_impl_nss.cc b/content/renderer/webcrypto/webcrypto_impl_nss.cc
index 105bfbe9f89218d3978e8b6207d02d02b97447c1..107c27b0cc135023af09961f6af002aff2a05933 100644
--- a/content/renderer/webcrypto/webcrypto_impl_nss.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_nss.cc
@@ -202,7 +202,8 @@ CK_MECHANISM_TYPE WebCryptoAlgorithmToGenMechanism(
}
}
-unsigned int WebCryptoHmacAlgorithmToBlockSize(
+// TODO(eroman): This is duplicated in OpenSSL version.
+unsigned int WebCryptoHmacAlgorithmToBlockSizeBits(
const blink::WebCryptoAlgorithm& algorithm) {
DCHECK_EQ(algorithm.id(), blink::WebCryptoAlgorithmIdHmac);
const blink::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams();
@@ -668,17 +669,19 @@ bool WebCryptoImpl::GenerateKeyInternal(
const blink::WebCryptoAesKeyGenParams* params =
algorithm.aesKeyGenParams();
DCHECK(params);
- keylen_bytes = params->length() / 8;
- if (params->length() % 8)
+ if (params->lengthBits() % 8)
return false;
+ keylen_bytes = params->lengthBits() / 8;
key_type = blink::WebCryptoKeyTypeSecret;
break;
}
case blink::WebCryptoAlgorithmIdHmac: {
const blink::WebCryptoHmacKeyParams* params = algorithm.hmacKeyParams();
DCHECK(params);
- if (!params->getLength(keylen_bytes)) {
- keylen_bytes = WebCryptoHmacAlgorithmToBlockSize(algorithm) / 8;
+ if (params->hasLengthBytes()) {
+ keylen_bytes = params->optionalLengthBytes();
+ } else {
+ keylen_bytes = WebCryptoHmacAlgorithmToBlockSizeBits(algorithm) / 8;
}
key_type = blink::WebCryptoKeyTypeSecret;
@@ -730,7 +733,7 @@ bool WebCryptoImpl::GenerateKeyPairInternal(
crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot());
unsigned long public_exponent;
- if (!slot || !params->modulusLength() ||
+ if (!slot || !params->modulusLengthBits() ||
!BigIntegerToLong(params->publicExponent().data(),
params->publicExponent().size(),
&public_exponent) ||
@@ -739,7 +742,7 @@ bool WebCryptoImpl::GenerateKeyPairInternal(
}
PK11RSAGenParams rsa_gen_params;
- rsa_gen_params.keySizeInBits = params->modulusLength();
+ rsa_gen_params.keySizeInBits = params->modulusLengthBits();
rsa_gen_params.pe = public_exponent;
// Flags are verified at the Blink layer; here the flags are set to all
« no previous file with comments | « no previous file | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698