OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_QUIC_CRYPTO_SCOPED_EVP_CIPHER_CTX_H_ |
| 6 #define NET_QUIC_CRYPTO_SCOPED_EVP_CIPHER_CTX_H_ |
| 7 |
| 8 #include <openssl/evp.h> |
| 9 |
| 10 #include "base/logging.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 // TODO(wtc): this is the same as the ScopedCipherCTX class defined in |
| 15 // crypto/encryptor_openssl.cc. Eliminate the duplicate code. |
| 16 // crypto::ScopedOpenSSL is not suitable for EVP_CIPHER_CTX because |
| 17 // there are no EVP_CIPHER_CTX_create and EVP_CIPHER_CTX_destroy |
| 18 // functions. |
| 19 class ScopedEVPCipherCtx { |
| 20 public: |
| 21 ScopedEVPCipherCtx() { |
| 22 EVP_CIPHER_CTX_init(&ctx_); |
| 23 } |
| 24 |
| 25 ~ScopedEVPCipherCtx() { |
| 26 int rv = EVP_CIPHER_CTX_cleanup(&ctx_); |
| 27 DCHECK_EQ(rv, 1); |
| 28 } |
| 29 |
| 30 EVP_CIPHER_CTX* get() { return &ctx_; } |
| 31 |
| 32 private: |
| 33 EVP_CIPHER_CTX ctx_; |
| 34 }; |
| 35 |
| 36 } // namespace net |
| 37 |
| 38 #endif // NET_QUIC_CRYPTO_SCOPED_EVP_CIPHER_CTX_H_ |
OLD | NEW |