mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
introduce MAX_ADDR_RAW_SIZE and MAX_WIF_RAW_SIZE macros
This commit is contained in:
parent
d10ec230c0
commit
430a5087c8
4
ecdsa.c
4
ecdsa.c
@ -879,7 +879,7 @@ void ecdsa_get_address_raw(const uint8_t *pub_key, uint32_t version, uint8_t *ad
|
||||
|
||||
void ecdsa_get_address(const uint8_t *pub_key, uint32_t version, char *addr, int addrsize)
|
||||
{
|
||||
uint8_t raw[20+4];
|
||||
uint8_t raw[MAX_ADDR_RAW_SIZE];
|
||||
ecdsa_get_address_raw(pub_key, version, raw);
|
||||
if (version <= 0xFF) {
|
||||
base58_encode_check(raw, 21, addr, addrsize);
|
||||
@ -896,7 +896,7 @@ void ecdsa_get_address(const uint8_t *pub_key, uint32_t version, char *addr, int
|
||||
|
||||
void ecdsa_get_wif(const uint8_t *priv_key, uint32_t version, char *wif, int wifsize)
|
||||
{
|
||||
uint8_t wif_raw[4 + 32 + 1];
|
||||
uint8_t wif_raw[MAX_WIF_RAW_SIZE];
|
||||
|
||||
if (version <= 0xFF) {
|
||||
wif_raw[0] = version;
|
||||
|
3
ecdsa.h
3
ecdsa.h
@ -48,6 +48,9 @@ typedef struct {
|
||||
|
||||
} ecdsa_curve;
|
||||
|
||||
#define MAX_ADDR_RAW_SIZE (4 + 20)
|
||||
#define MAX_WIF_RAW_SIZE (4 + 32 + 1)
|
||||
|
||||
// rfc6979 pseudo random number generator state
|
||||
typedef struct {
|
||||
uint8_t v[32], k[32];
|
||||
|
5
tests.c
5
tests.c
@ -2150,9 +2150,8 @@ END_TEST
|
||||
START_TEST(test_address_decode)
|
||||
{
|
||||
int res;
|
||||
uint8_t decode[21];
|
||||
// byte 0 : address type
|
||||
// bytes 1-20 : pubkey hash 160
|
||||
uint8_t decode[MAX_ADDR_RAW_SIZE];
|
||||
|
||||
res = ecdsa_address_decode("1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T", decode);
|
||||
ck_assert_int_eq(res, 1);
|
||||
ck_assert_mem_eq(decode, fromhex("00c4c5d791fcb4654a1ef5e03fe0ad3d9c598f9827"), 21);
|
||||
|
Loading…
Reference in New Issue
Block a user