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

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

Issue 328903003: [webcrypto] Remove support for AES 192-bit keys (2 of 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto master Created 6 years, 6 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 | « no previous file | content/child/webcrypto/shared_crypto_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/shared_crypto.cc
diff --git a/content/child/webcrypto/shared_crypto.cc b/content/child/webcrypto/shared_crypto.cc
index c63d9d3bedd3f96b67db7719715e43ce6ea19278..65559b04c826f3f36bf81d40606016abceb4317c 100644
--- a/content/child/webcrypto/shared_crypto.cc
+++ b/content/child/webcrypto/shared_crypto.cc
@@ -40,11 +40,13 @@ bool KeyUsageAllows(const blink::WebCryptoKey& key,
}
bool IsValidAesKeyLengthBits(unsigned int length_bits) {
- return length_bits == 128 || length_bits == 192 || length_bits == 256;
+ // 192-bit AES is disallowed.
+ return length_bits == 128 || length_bits == 256;
}
bool IsValidAesKeyLengthBytes(unsigned int length_bytes) {
- return length_bytes == 16 || length_bytes == 24 || length_bytes == 32;
+ // 192-bit AES is disallowed.
+ return length_bytes == 16 || length_bytes == 32;
}
const size_t kAesBlockSizeBytes = 16;
@@ -217,8 +219,11 @@ Status ImportKeyRaw(const CryptoData& key_data,
case blink::WebCryptoAlgorithmIdAesCbc:
case blink::WebCryptoAlgorithmIdAesGcm:
case blink::WebCryptoAlgorithmIdAesKw:
- if (!IsValidAesKeyLengthBytes(key_data.byte_length()))
- return Status::ErrorImportAesKeyLength();
+ if (!IsValidAesKeyLengthBytes(key_data.byte_length())) {
+ return key_data.byte_length() == 24
+ ? Status::ErrorAes192BitUnsupported()
+ : Status::ErrorImportAesKeyLength();
+ }
// Fallthrough intentional!
case blink::WebCryptoAlgorithmIdHmac:
return platform::ImportKeyRaw(
@@ -628,8 +633,11 @@ Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
case blink::WebCryptoAlgorithmIdAesCbc:
case blink::WebCryptoAlgorithmIdAesGcm:
case blink::WebCryptoAlgorithmIdAesKw: {
- if (!IsValidAesKeyLengthBits(algorithm.aesKeyGenParams()->lengthBits()))
- return Status::ErrorGenerateKeyLength();
+ if (!IsValidAesKeyLengthBits(algorithm.aesKeyGenParams()->lengthBits())) {
+ return algorithm.aesKeyGenParams()->lengthBits() == 192
+ ? Status::ErrorAes192BitUnsupported()
+ : Status::ErrorGenerateKeyLength();
+ }
keylen_bytes = algorithm.aesKeyGenParams()->lengthBits() / 8;
break;
}
« no previous file with comments | « no previous file | content/child/webcrypto/shared_crypto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698