Add CTRDBG_STATE to bssl::UniquePtr
Change-Id: I18596751776262be09d8ba09ed258e1f66d90654
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/58046
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/fipsmodule/rand/ctrdrbg_test.cc b/crypto/fipsmodule/rand/ctrdrbg_test.cc
index e6ebbca..50f4297 100644
--- a/crypto/fipsmodule/rand/ctrdrbg_test.cc
+++ b/crypto/fipsmodule/rand/ctrdrbg_test.cc
@@ -63,13 +63,11 @@
TEST(CTRDRBGTest, Allocated) {
const uint8_t kSeed[CTR_DRBG_ENTROPY_LEN] = {0};
- CTR_DRBG_STATE *allocated = CTR_DRBG_new(kSeed, nullptr, 0);
+ bssl::UniquePtr<CTR_DRBG_STATE> allocated(CTR_DRBG_new(kSeed, nullptr, 0));
ASSERT_TRUE(allocated);
- CTR_DRBG_free(allocated);
- allocated = CTR_DRBG_new(kSeed, nullptr, 1<<20);
+ allocated.reset(CTR_DRBG_new(kSeed, nullptr, 1<<20));
ASSERT_FALSE(allocated);
- CTR_DRBG_free(allocated);
}
TEST(CTRDRBGTest, Large) {
diff --git a/include/openssl/ctrdrbg.h b/include/openssl/ctrdrbg.h
index 62afe0c..5440fb4 100644
--- a/include/openssl/ctrdrbg.h
+++ b/include/openssl/ctrdrbg.h
@@ -71,6 +71,12 @@
#if defined(__cplusplus)
} // extern C
+
+extern "C++" {
+BSSL_NAMESPACE_BEGIN
+BORINGSSL_MAKE_DELETER(CTR_DRBG_STATE, CTR_DRBG_free)
+BSSL_NAMESPACE_END
+} // extern C++
#endif
#endif // OPENSSL_HEADER_CTRDRBG_H