| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/webcrypto/shared_crypto.h" | 5 #include "content/renderer/webcrypto/shared_crypto.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/webcrypto/crypto_data.h" | 8 #include "content/renderer/webcrypto/crypto_data.h" |
| 9 #include "content/renderer/webcrypto/platform_crypto.h" | 9 #include "content/renderer/webcrypto/platform_crypto.h" |
| 10 #include "content/renderer/webcrypto/webcrypto_util.h" | 10 #include "content/renderer/webcrypto/webcrypto_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 blink::WebArrayBuffer* buffer) { | 87 blink::WebArrayBuffer* buffer) { |
| 88 platform::SymKey* sym_key; | 88 platform::SymKey* sym_key; |
| 89 Status status = ToPlatformSymKey(key, &sym_key); | 89 Status status = ToPlatformSymKey(key, &sym_key); |
| 90 if (status.IsError()) | 90 if (status.IsError()) |
| 91 return status; | 91 return status; |
| 92 | 92 |
| 93 const blink::WebCryptoAesGcmParams* params = algorithm.aesGcmParams(); | 93 const blink::WebCryptoAesGcmParams* params = algorithm.aesGcmParams(); |
| 94 if (!params) | 94 if (!params) |
| 95 return Status::ErrorUnexpected(); | 95 return Status::ErrorUnexpected(); |
| 96 | 96 |
| 97 // TODO(eroman): The spec doesn't define the default value. Assume 128 for now | |
| 98 // since that is the maximum tag length: | |
| 99 // http://www.w3.org/2012/webcrypto/track/issues/46 | |
| 100 unsigned int tag_length_bits = 128; | 97 unsigned int tag_length_bits = 128; |
| 101 if (params->hasTagLengthBits()) | 98 if (params->hasTagLengthBits()) |
| 102 tag_length_bits = params->optionalTagLengthBits(); | 99 tag_length_bits = params->optionalTagLengthBits(); |
| 103 if (tag_length_bits > 128) | 100 |
| 101 if (tag_length_bits != 32 && tag_length_bits != 64 && tag_length_bits != 96 && |
| 102 tag_length_bits != 104 && tag_length_bits != 112 && |
| 103 tag_length_bits != 120 && tag_length_bits != 128) |
| 104 return Status::ErrorInvalidAesGcmTagLength(); | 104 return Status::ErrorInvalidAesGcmTagLength(); |
| 105 | 105 |
| 106 return platform::EncryptDecryptAesGcm( | 106 return platform::EncryptDecryptAesGcm( |
| 107 mode, | 107 mode, |
| 108 sym_key, | 108 sym_key, |
| 109 data, | 109 data, |
| 110 CryptoData(params->iv()), | 110 CryptoData(params->iv()), |
| 111 CryptoData(params->optionalAdditionalData()), | 111 CryptoData(params->optionalAdditionalData()), |
| 112 tag_length_bits, | 112 tag_length_bits, |
| 113 buffer); | 113 buffer); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return VerifyRsaSsaPkcs1v1_5( | 478 return VerifyRsaSsaPkcs1v1_5( |
| 479 algorithm, key, signature, data, signature_match); | 479 algorithm, key, signature, data, signature_match); |
| 480 default: | 480 default: |
| 481 return Status::ErrorUnsupported(); | 481 return Status::ErrorUnsupported(); |
| 482 } | 482 } |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace webcrypto | 485 } // namespace webcrypto |
| 486 | 486 |
| 487 } // namespace content | 487 } // namespace content |
| OLD | NEW |