| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CRYPTO_SCOPED_OPENSSL_TYPES_H_ | 5 #ifndef CRYPTO_SCOPED_OPENSSL_TYPES_H_ |
| 6 #define CRYPTO_SCOPED_OPENSSL_TYPES_H_ | 6 #define CRYPTO_SCOPED_OPENSSL_TYPES_H_ |
| 7 | 7 |
| 8 #include <openssl/bio.h> | |
| 9 #include <openssl/bn.h> | |
| 10 #include <openssl/dsa.h> | |
| 11 #include <openssl/ec.h> | |
| 12 #include <openssl/ecdsa.h> | |
| 13 #include <openssl/evp.h> | |
| 14 #include <openssl/mem.h> | |
| 15 #include <openssl/rsa.h> | |
| 16 | |
| 17 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "third_party/boringssl/src/include/openssl/bio.h" |
| 10 #include "third_party/boringssl/src/include/openssl/bn.h" |
| 11 #include "third_party/boringssl/src/include/openssl/digest.h" |
| 12 #include "third_party/boringssl/src/include/openssl/dsa.h" |
| 13 #include "third_party/boringssl/src/include/openssl/ec.h" |
| 14 #include "third_party/boringssl/src/include/openssl/ec_key.h" |
| 15 #include "third_party/boringssl/src/include/openssl/ecdsa.h" |
| 16 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 17 #include "third_party/boringssl/src/include/openssl/mem.h" |
| 18 #include "third_party/boringssl/src/include/openssl/rsa.h" |
| 18 | 19 |
| 19 namespace crypto { | 20 namespace crypto { |
| 20 | 21 |
| 21 // Simplistic helper that wraps a call to a deleter function. In a C++11 world, | 22 // Simplistic helper that wraps a call to a deleter function. In a C++11 world, |
| 22 // this would be std::function<>. An alternative would be to re-use | 23 // this would be std::function<>. An alternative would be to re-use |
| 23 // base::internal::RunnableAdapter<>, but that's far too heavy weight. | 24 // base::internal::RunnableAdapter<>, but that's far too heavy weight. |
| 24 template <typename Type, void (*Destroyer)(Type*)> | 25 template <typename Type, void (*Destroyer)(Type*)> |
| 25 struct OpenSSLDestroyer { | 26 struct OpenSSLDestroyer { |
| 26 using AllowSelfReset = void; | 27 using AllowSelfReset = void; |
| 27 void operator()(Type* ptr) const { Destroyer(ptr); } | 28 void operator()(Type* ptr) const { Destroyer(ptr); } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 using ScopedEVP_PKEY = ScopedOpenSSL<EVP_PKEY, EVP_PKEY_free>; | 52 using ScopedEVP_PKEY = ScopedOpenSSL<EVP_PKEY, EVP_PKEY_free>; |
| 52 using ScopedEVP_PKEY_CTX = ScopedOpenSSL<EVP_PKEY_CTX, EVP_PKEY_CTX_free>; | 53 using ScopedEVP_PKEY_CTX = ScopedOpenSSL<EVP_PKEY_CTX, EVP_PKEY_CTX_free>; |
| 53 using ScopedRSA = ScopedOpenSSL<RSA, RSA_free>; | 54 using ScopedRSA = ScopedOpenSSL<RSA, RSA_free>; |
| 54 | 55 |
| 55 // The bytes must have been allocated with OPENSSL_malloc. | 56 // The bytes must have been allocated with OPENSSL_malloc. |
| 56 using ScopedOpenSSLBytes = scoped_ptr<uint8_t, OpenSSLFree>; | 57 using ScopedOpenSSLBytes = scoped_ptr<uint8_t, OpenSSLFree>; |
| 57 | 58 |
| 58 } // namespace crypto | 59 } // namespace crypto |
| 59 | 60 |
| 60 #endif // CRYPTO_SCOPED_OPENSSL_TYPES_H_ | 61 #endif // CRYPTO_SCOPED_OPENSSL_TYPES_H_ |
| OLD | NEW |