Mercurial > dropbear
diff keyimport.c @ 1692:1051e4eea25a
Update LibTomMath to 1.2.0 (#84)
* update C files
* update other files
* update headers
* update makefiles
* remove mp_set/get_double()
* use ltm 1.2.0 API
* update ltm_desc
* use bundled tommath if system-tommath is too old
* XMALLOC etc. were changed to MP_MALLOC etc.
author | Steffen Jaeckel <s@jaeckel.eu> |
---|---|
date | Tue, 26 May 2020 17:36:47 +0200 |
parents | ba6fc7afe1c5 |
children | 064f5be2fc45 |
line wrap: on
line diff
--- a/keyimport.c Tue May 26 23:27:26 2020 +0800 +++ b/keyimport.c Tue May 26 17:36:47 2020 +0200 @@ -867,7 +867,7 @@ goto error; } m_mp_alloc_init_multi((mp_int**)&ecc->k, NULL); - if (mp_read_unsigned_bin(ecc->k, private_key_bytes, private_key_len) + if (mp_from_ubin(ecc->k, private_key_bytes, private_key_len) != MP_OKAY) { errmsg = "Error parsing ECC key"; goto error; @@ -1142,6 +1142,7 @@ unsigned long pubkey_size = 2*curve_size+1; int k_size; int err = 0; + size_t written; /* version. less than 10 bytes */ buf_incrwritepos(seq_buf, @@ -1149,12 +1150,14 @@ buf_putbyte(seq_buf, 1); /* privateKey */ - k_size = mp_unsigned_bin_size((*eck)->k); + k_size = mp_ubin_size((*eck)->k); dropbear_assert(k_size <= curve_size); buf_incrwritepos(seq_buf, ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0)); - mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size)); - buf_incrwritepos(seq_buf, k_size); + if (mp_to_ubin((*eck)->k, buf_getwriteptr(seq_buf, k_size), k_size, &written) != MP_OKAY) { + dropbear_exit("ECC error"); + } + buf_incrwritepos(seq_buf, written); /* SECGCurveNames */ switch (key->type)