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 "base/crypto/encryptor.h" | 5 #include "base/crypto/encryptor.h" |
6 | 6 |
7 #include <openssl/aes.h> | 7 #include <openssl/aes.h> |
8 #include <openssl/evp.h> | 8 #include <openssl/evp.h> |
9 | 9 |
10 #include "base/crypto/symmetric_key.h" | 10 #include "base/crypto/symmetric_key.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/openssl_util.h" | 12 #include "base/openssl_util.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 | 14 |
15 namespace base { | 15 namespace crypto { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { | 19 const EVP_CIPHER* GetCipherForKey(SymmetricKey* key) { |
20 switch (key->key().length()) { | 20 switch (key->key().length()) { |
21 case 16: return EVP_aes_128_cbc(); | 21 case 16: return EVP_aes_128_cbc(); |
22 case 24: return EVP_aes_192_cbc(); | 22 case 24: return EVP_aes_192_cbc(); |
23 case 32: return EVP_aes_256_cbc(); | 23 case 32: return EVP_aes_256_cbc(); |
24 default: return NULL; | 24 default: return NULL; |
25 } | 25 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return false; | 117 return false; |
118 | 118 |
119 out_len += tail_len; | 119 out_len += tail_len; |
120 DCHECK_LE(out_len, static_cast<int>(output_size)); | 120 DCHECK_LE(out_len, static_cast<int>(output_size)); |
121 result.resize(out_len); | 121 result.resize(out_len); |
122 | 122 |
123 output->swap(result); | 123 output->swap(result); |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 } // namespace base | 127 } // namespace crypto |
OLD | NEW |