Skip to content

Commit dc6a012

Browse files
authored
Merge pull request #606 from padelsbach/fix-ecc-verify
Minor fixes in ecc-verify example
2 parents 478701b + 8eebbe0 commit dc6a012

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

ecc/ecc-verify.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include <wolfssl/wolfcrypt/random.h>
2626
#include <wolfssl/wolfcrypt/ecc.h>
2727
#include <wolfssl/wolfcrypt/asn_public.h>
28+
#include <wolfssl/wolfcrypt/error-crypt.h>
29+
30+
#include <stdio.h>
2831

2932
#if defined(WOLFSSL_CUSTOM_CURVES) && defined(HAVE_ECC_KOBLITZ)
3033

@@ -45,12 +48,18 @@ int hash_firmware_verify(const byte* fwAddr, word32 fwLen, const byte* sigBuf, w
4548
0x1c, 0x8a, 0x80, 0x0d, 0x79, 0x57, 0xe6, 0x6e, 0x3d, 0x73, 0x4a, 0xf1, 0xe1, 0xd2, 0x6f, 0x2b,
4649
0x51, 0xd0, 0xa8, 0x89, 0xa0, 0x58, 0xff, 0xbd
4750
};
48-
int pos, verify;
51+
int pos, verify = 0;
4952

5053
ret = wc_InitSha256(&sha);
5154
if (ret != 0)
5255
return ret;
5356

57+
ret = wc_ecc_init(&eccKey);
58+
if (ret != 0) {
59+
wc_Sha256Free(&sha);
60+
return ret;
61+
}
62+
5463
pos = 0;
5564
while (fwLen > 0) {
5665
word32 len = fwLen;
@@ -83,7 +92,12 @@ int hash_firmware_verify(const byte* fwAddr, word32 fwLen, const byte* sigBuf, w
8392
if (ret < 0)
8493
goto exit;
8594

95+
/* a good return code only means the check ran, not that it passed */
96+
if (verify != 1)
97+
ret = SIG_VERIFY_E;
98+
8699
exit:
100+
wc_ecc_free(&eccKey);
87101
wc_Sha256Free(&sha);
88102

89103
return ret;

0 commit comments

Comments
 (0)