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

Unified Diff: components/webcrypto/algorithms/aes_gcm.cc

Issue 1355873002: [refactor] More post-NSS WebCrypto cleanups (utility functions). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address David's comments Created 5 years, 3 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 | « components/webcrypto/algorithms/aes.cc ('k') | components/webcrypto/algorithms/hkdf.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/aes_gcm.cc
diff --git a/components/webcrypto/algorithms/aes_gcm.cc b/components/webcrypto/algorithms/aes_gcm.cc
index b4e7c3d55ad1343bac3cd1d5fe22b7e36d3e34ca..57fa77f71cc82eeb3867b4e4ba0de2f551aab175 100644
--- a/components/webcrypto/algorithms/aes_gcm.cc
+++ b/components/webcrypto/algorithms/aes_gcm.cc
@@ -40,10 +40,18 @@ Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode,
const std::vector<uint8_t>& raw_key = GetSymmetricKeyData(key);
const blink::WebCryptoAesGcmParams* params = algorithm.aesGcmParams();
- unsigned int tag_length_bits;
- Status status = GetAesGcmTagLengthInBits(params, &tag_length_bits);
- if (status.IsError())
- return status;
+ // The WebCrypto spec defines the default value for the tag length, as well as
+ // the allowed values for tag length.
+ unsigned int tag_length_bits = 128;
+ if (params->hasTagLengthBits()) {
+ tag_length_bits = params->optionalTagLengthBits();
+ if (tag_length_bits != 32 && tag_length_bits != 64 &&
+ tag_length_bits != 96 && tag_length_bits != 104 &&
+ tag_length_bits != 112 && tag_length_bits != 120 &&
+ tag_length_bits != 128) {
+ return Status::ErrorInvalidAesGcmTagLength();
+ }
+ }
return AeadEncryptDecrypt(
mode, raw_key, data, tag_length_bits / 8, CryptoData(params->iv()),
« no previous file with comments | « components/webcrypto/algorithms/aes.cc ('k') | components/webcrypto/algorithms/hkdf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698