OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // On destruction this class will cleanup the ctx, and also clear the OpenSSL | 28 // On destruction this class will cleanup the ctx, and also clear the OpenSSL |
29 // ERR stack as a convenience. | 29 // ERR stack as a convenience. |
30 class ScopedCipherCTX { | 30 class ScopedCipherCTX { |
31 public: | 31 public: |
32 explicit ScopedCipherCTX() { | 32 explicit ScopedCipherCTX() { |
33 EVP_CIPHER_CTX_init(&ctx_); | 33 EVP_CIPHER_CTX_init(&ctx_); |
34 } | 34 } |
35 ~ScopedCipherCTX() { | 35 ~ScopedCipherCTX() { |
36 EVP_CIPHER_CTX_cleanup(&ctx_); | 36 EVP_CIPHER_CTX_cleanup(&ctx_); |
37 ClearOpenSSLERRStack(); | 37 ClearOpenSSLERRStack(FROM_HERE); |
38 } | 38 } |
39 EVP_CIPHER_CTX* get() { return &ctx_; } | 39 EVP_CIPHER_CTX* get() { return &ctx_; } |
40 | 40 |
41 private: | 41 private: |
42 EVP_CIPHER_CTX ctx_; | 42 EVP_CIPHER_CTX ctx_; |
43 }; | 43 }; |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 Encryptor::Encryptor() | 47 Encryptor::Encryptor() |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 out_len += tail_len; | 118 out_len += tail_len; |
119 DCHECK_LE(out_len, static_cast<int>(output_size)); | 119 DCHECK_LE(out_len, static_cast<int>(output_size)); |
120 result.resize(out_len); | 120 result.resize(out_len); |
121 | 121 |
122 output->swap(result); | 122 output->swap(result); |
123 return true; | 123 return true; |
124 } | 124 } |
125 | 125 |
126 } // namespace base | 126 } // namespace base |
OLD | NEW |