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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 case 32: return EVP_aes_256_cbc(); | 25 case 32: return EVP_aes_256_cbc(); |
26 default: | 26 default: |
27 return nullptr; | 27 return nullptr; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 // On destruction this class will cleanup the ctx, and also clear the OpenSSL | 31 // On destruction this class will cleanup the ctx, and also clear the OpenSSL |
32 // ERR stack as a convenience. | 32 // ERR stack as a convenience. |
33 class ScopedCipherCTX { | 33 class ScopedCipherCTX { |
34 public: | 34 public: |
35 explicit ScopedCipherCTX() { | 35 ScopedCipherCTX() { |
36 EVP_CIPHER_CTX_init(&ctx_); | 36 EVP_CIPHER_CTX_init(&ctx_); |
37 } | 37 } |
38 ~ScopedCipherCTX() { | 38 ~ScopedCipherCTX() { |
39 EVP_CIPHER_CTX_cleanup(&ctx_); | 39 EVP_CIPHER_CTX_cleanup(&ctx_); |
40 ClearOpenSSLERRStack(FROM_HERE); | 40 ClearOpenSSLERRStack(FROM_HERE); |
41 } | 41 } |
42 EVP_CIPHER_CTX* get() { return &ctx_; } | 42 EVP_CIPHER_CTX* get() { return &ctx_; } |
43 | 43 |
44 private: | 44 private: |
45 EVP_CIPHER_CTX ctx_; | 45 EVP_CIPHER_CTX ctx_; |
(...skipping 171 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 |