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

Unified Diff: content/renderer/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: 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
Index: content/renderer/webcrypto/shared_crypto_unittest.cc
diff --git a/content/renderer/webcrypto/shared_crypto_unittest.cc b/content/renderer/webcrypto/shared_crypto_unittest.cc
index c02b8aa783158c7379972499a251f49444e24376..e5806e18fec54724b263d9ed7da2c8d8fdbd588b 100644
--- a/content/renderer/webcrypto/shared_crypto_unittest.cc
+++ b/content/renderer/webcrypto/shared_crypto_unittest.cc
@@ -108,16 +108,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) {
+#ifndef WEBCRYPTO_HMAC_BITS
Ryan Sleevi 2014/03/06 21:51:37 !defined
eroman 2014/03/06 21:54:18 Done.
+ // 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());
« content/renderer/webcrypto/shared_crypto.cc ('K') | « content/renderer/webcrypto/shared_crypto.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698