From af2670833017f798196b1e894625e1a9dfa338d1 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Fri, 21 Apr 2017 11:40:50 -0600 Subject: [PATCH] Fix leading zero in wc_BuildEccKeyDer --- wolfcrypt/src/asn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 0d56df3f42..c6b592fb55 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -9681,8 +9681,9 @@ static int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 inLen, pubidx += SetLength(pubSz + ASN_ECC_CONTEXT_SZ + 2, pub+pubidx); else /* leading zero */ pubidx += SetLength(pubSz + ASN_ECC_CONTEXT_SZ + 1, pub+pubidx); + + /* SetBitString adds leading zero */ pubidx += SetBitString(pubSz, 0, pub + pubidx); - pub[pubidx++] = (byte)0; /* leading zero */ ret = wc_ecc_export_x963(key, pub + pubidx, &pubSz); if (ret != 0) { XFREE(prv, key->heap, DYNAMIC_TYPE_TMP_BUFFER);