| 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()),
|
|
|