1
0
mirror of https://github.com/GOSTSec/vanitygen synced 2025-02-07 12:24:20 +00:00

Fix a serious bug in the private key encoder.

This commit is contained in:
samr7 2011-08-06 13:52:47 -07:00
parent 5b80709a3e
commit 570e081546

View File

@ -124,9 +124,13 @@ vg_encode_privkey(EC_KEY *pkey, int addrtype, char *result)
bn = EC_KEY_get0_private_key(pkey);
eckey_buf[0] = addrtype;
nbytes = BN_bn2bin(bn, &eckey_buf[1]);
nbytes = BN_num_bytes(bn);
assert(nbytes <= 32);
if (nbytes < 32)
memset(eckey_buf + 1, 0, 32 - nbytes);
BN_bn2bin(bn, &eckey_buf[33 - nbytes]);
encode_b58_check(eckey_buf, nbytes + 1, result);
encode_b58_check(eckey_buf, 33, result);
}