summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--soft/SoftGateKeeper.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/soft/SoftGateKeeper.h b/soft/SoftGateKeeper.h
index f646f70..ddd0cff 100644
--- a/soft/SoftGateKeeper.h
+++ b/soft/SoftGateKeeper.h
@@ -21,6 +21,7 @@
extern "C" {
#include <openssl/rand.h>
#include <openssl/sha.h>
+#include <openssl/hmac.h>
#include <crypto_scrypt.h>
}
@@ -32,6 +33,8 @@ extern "C" {
#include <unordered_map>
#include <memory>
+#define HMAC_SHA_256_KEY_SIZE 32
+
namespace gatekeeper {
struct fast_hash_t {
@@ -92,9 +95,15 @@ public:
}
virtual void ComputeSignature(uint8_t *signature, uint32_t signature_length,
- const uint8_t *, uint32_t, const uint8_t *, const uint32_t) const {
+ const uint8_t *key, uint32_t key_length, const uint8_t *message, const uint32_t length) const {
if (signature == NULL) return;
+ uint8_t buf[HMAC_SHA_256_KEY_SIZE];
+ size_t buf_len;
+ HMAC(EVP_sha256(), key, key_length, message, length, buf, (unsigned int *)&buf_len);
+ size_t to_write = buf_len;
+ if (buf_len > signature_length) to_write = signature_length;
memset(signature, 0, signature_length);
+ memcpy(signature, buf, to_write);
}
virtual uint64_t GetMillisecondsSinceBoot() const {