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 <vector> | 5 #include <vector> |
6 #include <openssl/evp.h> | 6 #include <openssl/evp.h> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/child/webcrypto/crypto_data.h" | 9 #include "content/child/webcrypto/crypto_data.h" |
10 #include "content/child/webcrypto/openssl/aes_key_openssl.h" | 10 #include "content/child/webcrypto/openssl/aes_key_openssl.h" |
11 #include "content/child/webcrypto/openssl/key_openssl.h" | 11 #include "content/child/webcrypto/openssl/key_openssl.h" |
12 #include "content/child/webcrypto/openssl/util_openssl.h" | 12 #include "content/child/webcrypto/openssl/util_openssl.h" |
13 #include "content/child/webcrypto/status.h" | 13 #include "content/child/webcrypto/status.h" |
14 #include "content/child/webcrypto/webcrypto_util.h" | 14 #include "content/child/webcrypto/webcrypto_util.h" |
15 #include "crypto/openssl_util.h" | 15 #include "crypto/openssl_util.h" |
16 #include "crypto/scoped_openssl_types.h" | 16 #include "crypto/scoped_openssl_types.h" |
17 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 17 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 namespace webcrypto { | 21 namespace webcrypto { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 const EVP_AEAD* GetAesGcmAlgorithmFromKeySize(unsigned int key_size_bytes) { | 25 const EVP_AEAD* GetAesGcmAlgorithmFromKeySize(unsigned int key_size_bytes) { |
26 switch (key_size_bytes) { | 26 switch (key_size_bytes) { |
27 case 16: | 27 case 16: |
28 return EVP_aead_aes_128_gcm(); | 28 return EVP_aead_aes_128_gcm(); |
29 // TODO(eroman): Hook up 256-bit support when it is available. | 29 case 32: |
| 30 return EVP_aead_aes_256_gcm(); |
30 default: | 31 default: |
31 return NULL; | 32 return NULL; |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
35 Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, | 36 Status AesGcmEncryptDecrypt(EncryptOrDecrypt mode, |
36 const blink::WebCryptoAlgorithm& algorithm, | 37 const blink::WebCryptoAlgorithm& algorithm, |
37 const blink::WebCryptoKey& key, | 38 const blink::WebCryptoKey& key, |
38 const CryptoData& data, | 39 const CryptoData& data, |
39 std::vector<uint8_t>* buffer) { | 40 std::vector<uint8_t>* buffer) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 } // namespace | 136 } // namespace |
136 | 137 |
137 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { | 138 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { |
138 return new AesGcmImplementation; | 139 return new AesGcmImplementation; |
139 } | 140 } |
140 | 141 |
141 } // namespace webcrypto | 142 } // namespace webcrypto |
142 | 143 |
143 } // namespace content | 144 } // namespace content |
OLD | NEW |