diff options
author | Malfurious <m@lfurio.us> | 2024-10-22 02:54:02 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-10-24 06:41:41 -0400 |
commit | a01e8dfb054fae877e4b94ece6b6f18dd5fd67f8 (patch) | |
tree | 236f1b9b977949a6da4777b76152e336214f635c /Cryptor.cpp | |
parent | d96e828be83f7adf0fe88001da865169cfd573c7 (diff) | |
download | compass-a01e8dfb054fae877e4b94ece6b6f18dd5fd67f8.tar.gz compass-a01e8dfb054fae877e4b94ece6b6f18dd5fd67f8.zip |
Refactor SHA256 function to use mbedtls
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'Cryptor.cpp')
-rw-r--r-- | Cryptor.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Cryptor.cpp b/Cryptor.cpp index fc27caf..25a2ae9 100644 --- a/Cryptor.cpp +++ b/Cryptor.cpp @@ -226,10 +226,9 @@ void Cryptor::rekey() { }
void Cryptor::sha256(std::string str) {
- CryptoPP::SHA256 hash;
- std::string rtr;
- CryptoPP::StringSource(str, true, new CryptoPP::HashFilter(hash, new CryptoPP::StringSink(rtr), false, CryptoPP::AES::DEFAULT_KEYLENGTH));
- memcpy(key, rtr.c_str(), rtr.size());
+ unsigned char hashbuf[32];
+ mbedtls_sha256((const unsigned char *)str.c_str(), str.size(), hashbuf, 0);
+ memcpy(key, hashbuf, sizeof(key));
haveKey = true;
}
|