aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2016-08-23 11:24:23 +0200
committerJoakim Bech <joakim.bech@linaro.org>2016-08-23 11:24:23 +0200
commitb70e191c4728b463f40ec2014aa2bf9421bc9c4e (patch)
tree6273ebe4ea094d97ec065475c506e5571c64f2b2
parent9ecf0b05385e0e4f4df2fe6eba1763fcefff9422 (diff)
downloadtinycrypt-signature_problem.tar.gz
Add bytes2native to successfully verify the signaturesignature_problem
Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
-rw-r--r--source/main.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/source/main.c b/source/main.c
index a9eb79e..15ffa37 100644
--- a/source/main.c
+++ b/source/main.c
@@ -416,6 +416,7 @@ uint32_t dfu_init_prevalidate(uint8_t *p_init_data, uint32_t init_data_len)
uint8_t digest[NUM_ECC_BYTES];
uint32_t r[NUM_ECC_DIGITS];
uint32_t s[NUM_ECC_DIGITS];
+ uint32_t tmp[NUM_ECC_DIGITS];
// In order to support encryption then any init packet decryption function / library
// should be called from here or implemented at this location.
@@ -518,8 +519,11 @@ uint32_t dfu_init_prevalidate(uint8_t *p_init_data, uint32_t init_data_len)
ecc_bytes2native(s, signature.p_s);
hash_data(init_data.p_data, digest, init_data.length);
- if (ecdsa_verify(&pub, (uint32_t *)digest, r, s) != TC_SUCCESS)
+ ecc_bytes2native(tmp, digest);
+ if (ecdsa_verify(&pub, tmp, r, s) != TC_SUCCESS)
perror("Verification failed\n");
+ else
+ printf("Successfully verified the signature!\n");
/*
* FIXME: Remove this, just to check that we have the correct key
@@ -527,16 +531,6 @@ uint32_t dfu_init_prevalidate(uint8_t *p_init_data, uint32_t init_data_len)
*/
fs_write_public_key("nrd_test_pub.key", &pub, sizeof(pub));
- memset(r, 0, sizeof(r));
- memset(s, 0, sizeof(s));
- ecc_bytes2native(r, openssl_r);
- ecc_bytes2native(s, openssl_s);
-
- if (ecdsa_verify(&pub, (uint32_t *)digest, r, s) != TC_SUCCESS)
- perror("Failed!\n");
- else
- printf("OK\n");
-
return err_code;
}