diff options
author | David Benjamin <davidben@chromium.org> | 2015-05-09 10:31:09 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-05-11 21:51:13 +0300 |
commit | 353d7cba246052a8bcbade6f81452fc14b99264e (patch) | |
tree | 37f183670276201e94af7e9a2048a5b3c20b88f7 /crypto/test | |
parent | 6610118d65200184f11a65d16672dc78d18547ec (diff) |
Convert pkcs12_test to C++.
Change-Id: If5caf6bb17a5efc9d0cb2c6c52194685d90614d9
Reviewed-on: https://boringssl-review.googlesource.com/4700
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/scoped_types.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h index 697dfbf3..9f5a8db3 100644 --- a/crypto/test/scoped_types.h +++ b/crypto/test/scoped_types.h @@ -27,7 +27,9 @@ #include <openssl/evp.h> #include <openssl/hmac.h> #include <openssl/mem.h> +#include <openssl/pkcs8.h> #include <openssl/rsa.h> +#include <openssl/stack.h> #include <openssl/x509.h> #include "stl_compat.h" @@ -40,6 +42,14 @@ struct OpenSSLDeleter { } }; +template<typename StackType, typename T, void (*func)(T*)> +struct OpenSSLStackDeleter { + void operator()(StackType *obj) { + sk_pop_free(reinterpret_cast<_STACK*>(obj), + reinterpret_cast<void (*)(void *)>(func)); + } +}; + template<typename T> struct OpenSSLFree { void operator()(T *buf) { @@ -50,6 +60,10 @@ struct OpenSSLFree { template<typename T, void (*func)(T*)> using ScopedOpenSSLType = bssl::unique_ptr<T, OpenSSLDeleter<T, func>>; +template<typename StackType, typename T, void (*func)(T*)> +using ScopedOpenSSLStack = + bssl::unique_ptr<StackType, OpenSSLStackDeleter<StackType, T, func>>; + template<typename T, typename CleanupRet, void (*init_func)(T*), CleanupRet (*cleanup_func)(T*)> class ScopedOpenSSLContext { @@ -86,9 +100,13 @@ using ScopedEC_POINT = ScopedOpenSSLType<EC_POINT, EC_POINT_free>; using ScopedEVP_PKEY = ScopedOpenSSLType<EVP_PKEY, EVP_PKEY_free>; using ScopedPKCS8_PRIV_KEY_INFO = ScopedOpenSSLType<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free>; +using ScopedPKCS12 = ScopedOpenSSLType<PKCS12, PKCS12_free>; using ScopedRSA = ScopedOpenSSLType<RSA, RSA_free>; +using ScopedX509 = ScopedOpenSSLType<X509, X509_free>; using ScopedX509_ALGOR = ScopedOpenSSLType<X509_ALGOR, X509_ALGOR_free>; +using ScopedX509Stack = ScopedOpenSSLStack<STACK_OF(X509), X509, X509_free>; + using ScopedEVP_MD_CTX = ScopedOpenSSLContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>; using ScopedHMAC_CTX = ScopedOpenSSLContext<HMAC_CTX, void, HMAC_CTX_init, |