| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | |
| 10 #include "base/logging.h" | 7 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 12 #include "crypto/openssl_util.h" | 9 #include "crypto/openssl_util.h" |
| 13 #include "crypto/symmetric_key.h" | 10 #include "crypto/symmetric_key.h" |
| 11 #include "third_party/boringssl/src/include/openssl/aes.h" |
| 12 #include "third_party/boringssl/src/include/openssl/cipher.h" |
| 14 | 13 |
| 15 namespace crypto { | 14 namespace crypto { |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { | 18 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { |
| 20 switch (key->key().length()) { | 19 switch (key->key().length()) { |
| 21 case 16: return EVP_aes_128_cbc(); | 20 case 16: return EVP_aes_128_cbc(); |
| 22 case 32: return EVP_aes_256_cbc(); | 21 case 32: return EVP_aes_256_cbc(); |
| 23 default: return NULL; | 22 default: return NULL; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 167 |
| 169 // AES_ctr128_encrypt() updates |ivec|. Update the |counter_| here. | 168 // AES_ctr128_encrypt() updates |ivec|. Update the |counter_| here. |
| 170 SetCounter(base::StringPiece(reinterpret_cast<const char*>(ivec), | 169 SetCounter(base::StringPiece(reinterpret_cast<const char*>(ivec), |
| 171 AES_BLOCK_SIZE)); | 170 AES_BLOCK_SIZE)); |
| 172 | 171 |
| 173 output->swap(result); | 172 output->swap(result); |
| 174 return true; | 173 return true; |
| 175 } | 174 } |
| 176 | 175 |
| 177 } // namespace crypto | 176 } // namespace crypto |
| OLD | NEW |