diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-01-27 20:43:40 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-01-27 23:02:24 +0100 |
commit | 938bd7bbf0f617d44ed9659addca3a4879948551 (patch) | |
tree | 5b933789f04a7a8e933a710483f5335a3a996ac2 | |
parent | 79db3b2e02f2482e93060eef2ca1db22092bfe15 (diff) |
fix: allocation of object' variable
-rw-r--r-- | include/sha256.h | 2 | ||||
-rw-r--r-- | src/sha256.cc | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/include/sha256.h b/include/sha256.h index 18fba6a..c02eb40 100644 --- a/include/sha256.h +++ b/include/sha256.h @@ -18,6 +18,8 @@ public: SHA256(const std::string&); + ~SHA256(); + // get digest as array of bytes uint8_t* digest(); diff --git a/src/sha256.cc b/src/sha256.cc index 7790f8a..7ef467e 100644 --- a/src/sha256.cc +++ b/src/sha256.cc @@ -8,6 +8,7 @@ hmacsha256::SHA256::SHA256(const uint8_t* data, uint32_t length) { } void hmacsha256::SHA256::init(const uint8_t* data, uint32_t length) { + digest_ = new uint8_t[32]; message_l_ = bit_len_ = 0; vars_[0] = 0x6a09e667; vars_[1] = 0xbb67ae85; @@ -29,6 +30,10 @@ void hmacsha256::SHA256::init(const uint8_t* data, uint32_t length) { } } +hmacsha256::SHA256::~SHA256() { + delete digest_; +} + hmacsha256::SHA256::SHA256(const std::string& data) { init(reinterpret_cast<const uint8_t*> (data.c_str()), data.size()); } |