Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-03-23 02:38:21 +0300
committerAdam Langley <agl@google.com>2015-04-01 02:08:53 +0300
commitc2b45a164acac1b255a7e13a270fb953c882471f (patch)
tree2ce82b06ace52cb575457b8efc1e935c0a26f061 /crypto/test
parent1d77e56b29c0d519cf8eaa1fead1a12895f5cc54 (diff)
Convert evp_test to C++.
Change-Id: I6e51815db2f600f4d9fb4d8b01cc92e128b31bbb Reviewed-on: https://boringssl-review.googlesource.com/4122 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/scoped_types.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h
index 63006219..ed8fa959 100644
--- a/crypto/test/scoped_types.h
+++ b/crypto/test/scoped_types.h
@@ -21,6 +21,8 @@
#include <openssl/dh.h>
#include <openssl/evp.h>
#include <openssl/mem.h>
+#include <openssl/rsa.h>
+#include <openssl/x509.h>
#include "stl_compat.h"
@@ -42,9 +44,39 @@ struct OpenSSLFree {
template<typename T, void (*func)(T*)>
using ScopedOpenSSLType = bssl::unique_ptr<T, OpenSSLDeleter<T, func>>;
+template<typename T, typename CleanupRet, void (*init_func)(T*),
+ CleanupRet (*cleanup_func)(T*)>
+class ScopedOpenSSLContext {
+ public:
+ ScopedOpenSSLContext() {
+ init_func(&ctx_);
+ }
+ ~ScopedOpenSSLContext() {
+ cleanup_func(&ctx_);
+ }
+
+ T *get() { return &ctx_; }
+ const T *get() const { return &ctx_; }
+
+ void Reset() {
+ cleanup_func(&ctx_);
+ init_func(&ctx_);
+ }
+
+ private:
+ T ctx_;
+};
+
using ScopedBIO = ScopedOpenSSLType<BIO, BIO_vfree>;
using ScopedDH = ScopedOpenSSLType<DH, DH_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 ScopedRSA = ScopedOpenSSLType<RSA, RSA_free>;
+using ScopedX509_ALGOR = ScopedOpenSSLType<X509_ALGOR, X509_ALGOR_free>;
+
+using ScopedEVP_MD_CTX = ScopedOpenSSLContext<EVP_MD_CTX, int, EVP_MD_CTX_init,
+ EVP_MD_CTX_cleanup>;
using ScopedOpenSSLBytes = bssl::unique_ptr<uint8_t, OpenSSLFree<uint8_t>>;