Merge pull request #869 from cconlon/ecckeytoder

Fix leading zero in wc_BuildEccKeyDer
This commit is contained in:
dgarske 2017-04-24 09:02:41 -07:00 committed by GitHub
commit dd2915f4fa

View File

@ -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);