| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "crypto/encryptor.h" | 5 #include "crypto/encryptor.h" |
| 6 | 6 |
| 7 #include <openssl/aes.h> | |
| 8 #include <openssl/evp.h> | |
| 9 #include <stddef.h> | 7 #include <stddef.h> |
| 10 #include <stdint.h> | 8 #include <stdint.h> |
| 11 | 9 |
| 12 #include "base/logging.h" | 10 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 14 #include "base/sys_byteorder.h" | 12 #include "base/sys_byteorder.h" |
| 15 #include "crypto/openssl_util.h" | 13 #include "crypto/openssl_util.h" |
| 16 #include "crypto/symmetric_key.h" | 14 #include "crypto/symmetric_key.h" |
| 15 #include "third_party/boringssl/src/include/openssl/aes.h" |
| 16 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 17 | 17 |
| 18 namespace crypto { | 18 namespace crypto { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { | 22 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { |
| 23 switch (key->key().length()) { | 23 switch (key->key().length()) { |
| 24 case 16: return EVP_aes_128_cbc(); | 24 case 16: return EVP_aes_128_cbc(); |
| 25 case 32: return EVP_aes_256_cbc(); | 25 case 32: return EVP_aes_256_cbc(); |
| 26 default: | 26 default: |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 // AES_ctr128_encrypt() updates |ivec|. Update the |counter_| here. | 218 // AES_ctr128_encrypt() updates |ivec|. Update the |counter_| here. |
| 219 SetCounter(base::StringPiece(reinterpret_cast<const char*>(ivec), | 219 SetCounter(base::StringPiece(reinterpret_cast<const char*>(ivec), |
| 220 AES_BLOCK_SIZE)); | 220 AES_BLOCK_SIZE)); |
| 221 | 221 |
| 222 output->swap(result); | 222 output->swap(result); |
| 223 return true; | 223 return true; |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace crypto | 226 } // namespace crypto |
| OLD | NEW |