From cd2fc3625d09f2f3f062648ff9963414e0140e2a Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 25 Jul 2018 01:22:05 -0400 Subject: ... --- include/salticidae/crypto.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/salticidae/crypto.h') diff --git a/include/salticidae/crypto.h b/include/salticidae/crypto.h index c329c63..79e9377 100644 --- a/include/salticidae/crypto.h +++ b/include/salticidae/crypto.h @@ -31,14 +31,13 @@ namespace salticidae { class SHA256 { - SHA256_CTX *ctx; + SHA256_CTX ctx; public: - SHA256(): ctx(new SHA256_CTX()) { reset(); } - ~SHA256() { delete ctx; } + SHA256() { reset(); } void reset() { - if (!SHA256_Init(ctx)) + if (!SHA256_Init(&ctx)) throw std::runtime_error("openssl SHA256 init error"); } @@ -52,12 +51,12 @@ class SHA256 { } void update(const uint8_t *ptr, size_t length) { - if (!SHA256_Update(ctx, ptr, length)) + if (!SHA256_Update(&ctx, ptr, length)) throw std::runtime_error("openssl SHA256 update error"); } void _digest(bytearray_t &md) { - if (!SHA256_Final(&*md.begin(), ctx)) + if (!SHA256_Final(&*md.begin(), &ctx)) throw std::runtime_error("openssl SHA256 error"); } -- cgit v1.2.3