Harden recovery authentication and signed OTA admission
This commit is contained in:
1 parent
74bc91bf69
commit
5fa06ea49b
40 files changed
+3631
-2107
No files matched your search
+19
@@ -0,0 +1,19 @@
|
||||
#include <Identity.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
// Real Ed25519 behind the firmware Identity API for host OTA-policy fixtures.
|
||||
namespace mesh {
|
||||
unsigned signature_checks = 0;
|
||||
bool Identity::verify(const uint8_t* signature, const uint8_t* message, int length) const {
|
||||
++signature_checks;
|
||||
if (!signature || !message || length < 0) return false;
|
||||
EVP_PKEY* public_key = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, nullptr,
|
||||
pub_key, sizeof(pub_key));
|
||||
EVP_MD_CTX* context = EVP_MD_CTX_new();
|
||||
const bool valid = public_key && context &&
|
||||
EVP_DigestVerifyInit(context, nullptr, nullptr, nullptr, public_key) == 1 &&
|
||||
EVP_DigestVerify(context, signature, SIGNATURE_SIZE, message, length) == 1;
|
||||
EVP_MD_CTX_free(context); EVP_PKEY_free(public_key);
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user