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

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

Issue 108653015: [webcrypto] Some fixes for HMAC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 9d2df880cc2de6980f7e699a564784a4275fa5ae..fd0e12fdbfa553c31df05b6ab96aff57b0b7319b 100644
--- a/content/renderer/webcrypto/webcrypto_impl_openssl.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
@@ -51,27 +51,6 @@ const EVP_CIPHER* GetAESCipherByKeyLength(unsigned key_length_bytes) {
}
}
-// 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()) {
- case blink::WebCryptoAlgorithmIdSha1:
- return SHA_DIGEST_LENGTH / 8;
- case blink::WebCryptoAlgorithmIdSha224:
- return SHA224_DIGEST_LENGTH / 8;
- case blink::WebCryptoAlgorithmIdSha256:
- return SHA256_DIGEST_LENGTH / 8;
- case blink::WebCryptoAlgorithmIdSha384:
- return SHA384_DIGEST_LENGTH / 8;
- case blink::WebCryptoAlgorithmIdSha512:
- return SHA512_DIGEST_LENGTH / 8;
- default:
- return 0;
- }
-}
-
// OpenSSL constants for EVP_CipherInit_ex(), do not change
enum CipherOperation {
kDoDecrypt = 0,
@@ -295,7 +274,7 @@ bool WebCryptoImpl::GenerateKeyInternal(
if (params->hasLengthBytes()) {
keylen_bytes = params->optionalLengthBytes();
} else {
- keylen_bytes = WebCryptoHmacParamsToBlockSizeBytes(params);
+ keylen_bytes = webcrypto::ShaBlockSizeBytes(params->hash().id());
}
key_type = blink::WebCryptoKeyTypeSecret;
break;
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | content/renderer/webcrypto/webcrypto_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698