diff options
Diffstat (limited to 'keyimport.c')
-rw-r--r-- | keyimport.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/keyimport.c b/keyimport.c index 52ddf6e..2b80770 100644 --- a/keyimport.c +++ b/keyimport.c @@ -867,7 +867,7 @@ static sign_key *openssh_read(const char *filename, const char * UNUSED(passphra 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 @@ static int openssh_write(const char *filename, sign_key *key, 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 @@ static int openssh_write(const char *filename, sign_key *key, 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) |