From 1db880b6bf46c395f2e5457e5c2da76c6b831bd0 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 21 Jun 2016 15:55:17 -0700 Subject: [PATCH] Fixed issue with compressed keys and custom curves. The inLen adjustment for compressed curves was only be done for built-in curves. --- wolfcrypt/src/ecc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index b6f7baee5..b2b19aa2c 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -3014,6 +3014,9 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, } if (err == MP_OKAY) { + if (compressed) + inLen = (inLen-1)*2 + 1; /* used uncompressed len */ + /* determine the idx */ if (dp) { /* set the idx */ @@ -3022,9 +3025,6 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, key->type = ECC_PUBLICKEY; } else { - if (compressed) - inLen = (inLen-1)*2 + 1; /* used uncompressed len */ - for (x = 0; ecc_sets[x].size != 0; x++) { if ((unsigned)ecc_sets[x].size >= ((inLen-1)>>1)) { break;