Wessel
1 day ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
2 additions and
1 deletions
-
src/Utils.cpp
|
|
@ -1,5 +1,6 @@ |
|
|
#include "Utils.h" |
|
|
#include "Utils.h" |
|
|
#include <AES.h> |
|
|
#include <AES.h> |
|
|
|
|
|
#include <Crypto.h> |
|
|
#include <SHA256.h> |
|
|
#include <SHA256.h> |
|
|
|
|
|
|
|
|
#ifdef ARDUINO |
|
|
#ifdef ARDUINO |
|
|
@ -81,7 +82,7 @@ int Utils::MACThenDecrypt(const uint8_t* shared_secret, uint8_t* dest, const uin |
|
|
sha.update(src + CIPHER_MAC_SIZE, src_len - CIPHER_MAC_SIZE); |
|
|
sha.update(src + CIPHER_MAC_SIZE, src_len - CIPHER_MAC_SIZE); |
|
|
sha.finalizeHMAC(shared_secret, PUB_KEY_SIZE, hmac, CIPHER_MAC_SIZE); |
|
|
sha.finalizeHMAC(shared_secret, PUB_KEY_SIZE, hmac, CIPHER_MAC_SIZE); |
|
|
} |
|
|
} |
|
|
if (memcmp(hmac, src, CIPHER_MAC_SIZE) == 0) { |
|
|
if (secure_compare(hmac, src, CIPHER_MAC_SIZE)) { |
|
|
return decrypt(shared_secret, dest, src + CIPHER_MAC_SIZE, src_len - CIPHER_MAC_SIZE); |
|
|
return decrypt(shared_secret, dest, src + CIPHER_MAC_SIZE, src_len - CIPHER_MAC_SIZE); |
|
|
} |
|
|
} |
|
|
return 0; // invalid HMAC
|
|
|
return 0; // invalid HMAC
|
|
|
|