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

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

Issue 203303006: [webcrypto] Add length parameter to HmacKeyAlgorithm. (chromium) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add bound check 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/webcrypto_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/webcrypto_util.cc
diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc
index 5e5fc8e4c3d2b7857e438bdb0c32e5af6f59f2f0..4574d3c136bb4816ab33c8bf6ecc85e45e683017 100644
--- a/content/child/webcrypto/webcrypto_util.cc
+++ b/content/child/webcrypto/webcrypto_util.cc
@@ -377,15 +377,24 @@ unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id) {
}
bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm,
- unsigned keylen_bytes,
+ unsigned int keylen_bytes,
blink::WebCryptoKeyAlgorithm* key_algorithm) {
switch (algorithm.id()) {
case blink::WebCryptoAlgorithmIdHmac: {
blink::WebCryptoAlgorithm hash = GetInnerHashAlgorithm(algorithm);
if (hash.isNull())
return false;
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH)
+ if (keylen_bytes > UINT_MAX / 8)
+ return false;
+#endif
*key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate(
- algorithm.id(), new blink::WebCryptoHmacKeyAlgorithmParams(hash));
+ algorithm.id(),
+#if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH)
+ new blink::WebCryptoHmacKeyAlgorithmParams(hash, keylen_bytes * 8));
+#else
+ new blink::WebCryptoHmacKeyAlgorithmParams(hash));
+#endif
return true;
}
case blink::WebCryptoAlgorithmIdAesKw:
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698