diff options
author | Determinant <tederminant@gmail.com> | 2018-07-25 01:22:05 -0400 |
---|---|---|
committer | Determinant <tederminant@gmail.com> | 2018-07-25 01:22:05 -0400 |
commit | cd2fc3625d09f2f3f062648ff9963414e0140e2a (patch) | |
tree | 77d6d06b5dd66dffe724be3a68cb151b973f8e26 /include/salticidae/crypto.h | |
parent | 5cea500b410f8e34e3ad4aeef64fb0e88dce4126 (diff) |
...
Diffstat (limited to 'include/salticidae/crypto.h')
-rw-r--r-- | include/salticidae/crypto.h | 11 |
1 files changed, 5 insertions, 6 deletions
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"); } |