summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cryptor.cpp7
-rw-r--r--Cryptor.h1
2 files changed, 4 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;
}
diff --git a/Cryptor.h b/Cryptor.h
index 1fcac36..f1448b0 100644
--- a/Cryptor.h
+++ b/Cryptor.h
@@ -16,6 +16,7 @@
#include "mbedtls/cipher.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/entropy.h"
+#include "mbedtls/sha256.h"
#include "Socket.h"