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

Unified Diff: content/child/webcrypto/test/hmac_unittest.cc

Issue 508793002: Check for integer overflow when HMAC key length as bits cannot fit in an unsigned int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/openssl/hmac_openssl.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/test/hmac_unittest.cc
diff --git a/content/child/webcrypto/test/hmac_unittest.cc b/content/child/webcrypto/test/hmac_unittest.cc
index e7669b9bb38ab601c631afa3712cfef08ad67ef2..e9bd0819c139d51560617b311b64c5b038039176 100644
--- a/content/child/webcrypto/test/hmac_unittest.cc
+++ b/content/child/webcrypto/test/hmac_unittest.cc
@@ -523,6 +523,22 @@ TEST(WebCryptoHmacTest, ExportJwkEmptyKey) {
EXPECT_EQ(0u, exported_key_data.size());
}
+// Import a huge hmac key (UINT_MAX bytes). This will fail before actually
+// reading the bytes, as the key is too large.
+TEST(WebCryptoHmacTest, ImportRawKeyTooLarge) {
+ CryptoData big_data(NULL, UINT_MAX); // Invalid data of big length.
+
+ blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
+ EXPECT_EQ(
+ Status::ErrorDataTooLarge(),
+ ImportKey(blink::WebCryptoKeyFormatRaw,
+ CryptoData(big_data),
+ CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha1),
+ true,
+ blink::WebCryptoKeyUsageSign,
+ &key));
+}
+
} // namespace
} // namespace webcrypto
« no previous file with comments | « content/child/webcrypto/openssl/hmac_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698