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

Unified Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 187103003: [webcrypto] Change HMAC key generation length from bytes to bits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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/child/webcrypto/shared_crypto.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/shared_crypto_unittest.cc
diff --git a/content/child/webcrypto/shared_crypto_unittest.cc b/content/child/webcrypto/shared_crypto_unittest.cc
index c21289ee940446212a5e7258791e113fcc0da479..8ded2c43ccab3203894aa22c7256bbef236e462f 100644
--- a/content/child/webcrypto/shared_crypto_unittest.cc
+++ b/content/child/webcrypto/shared_crypto_unittest.cc
@@ -106,16 +106,20 @@ blink::WebCryptoAlgorithm CreateAesGcmAlgorithm(
// Creates an HMAC algorithm whose parameters struct is compatible with key
// generation. It is an error to call this with a hash_id that is not a SHA*.
-// The key_length_bytes parameter is optional, with zero meaning unspecified.
+// The key_length_bits parameter is optional, with zero meaning unspecified.
blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
blink::WebCryptoAlgorithmId hash_id,
- unsigned int key_length_bytes) {
+ unsigned int key_length_bits) {
+#if !defined(WEBCRYPTO_HMAC_BITS)
+ // TODO(eroman): Delete
+ key_length_bits /= 8;
+#endif
DCHECK(IsHashAlgorithm(hash_id));
// key_length_bytes == 0 means unspecified
return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
blink::WebCryptoAlgorithmIdHmac,
new blink::WebCryptoHmacKeyGenParams(
- CreateAlgorithm(hash_id), (key_length_bytes != 0), key_length_bytes));
+ CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits));
}
// Returns a slightly modified version of the input vector.
@@ -865,7 +869,7 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmac)) {
blink::WebArrayBuffer key_bytes;
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
blink::WebCryptoAlgorithm algorithm =
- CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 64);
+ CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 512);
ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key));
EXPECT_FALSE(key.isNull());
EXPECT_TRUE(key.handle());
« no previous file with comments | « content/child/webcrypto/shared_crypto.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698