# HG changeset patch # User Matt Johnston # Date 1385559165 -28800 # Node ID 463e2b70be14fb4e94275bfe93f697b3f7821940 # Parent 12d5f40894ecdbab73cdcc826e9512c30cb484dd# Parent d2d624c951cae0999e8f98d54a86cc8236d185e0 merge diff -r 12d5f40894ec -r 463e2b70be14 keyimport.c --- a/keyimport.c Mon Nov 25 23:39:15 2013 +0800 +++ b/keyimport.c Wed Nov 27 21:32:45 2013 +0800 @@ -1033,6 +1033,7 @@ int curve_oid_len = 0; const void* curve_oid = NULL; unsigned long pubkey_size = 2*curve_size+1; + unsigned int k_size; /* version. less than 10 bytes */ buf_incrwritepos(seq_buf, @@ -1040,11 +1041,12 @@ buf_putbyte(seq_buf, 1); /* privateKey */ - dropbear_assert(mp_unsigned_bin_size((*eck)->k) == curve_size); + k_size = mp_unsigned_bin_size((*eck)->k); + dropbear_assert(k_size <= curve_size); buf_incrwritepos(seq_buf, - ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, curve_size, 0)); - mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, curve_size)); - buf_incrwritepos(seq_buf, curve_size); + 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); /* SECGCurveNames */ switch (key->type) @@ -1085,7 +1087,7 @@ buf_setpos(seq_buf, 0); - outblob = (unsigned char*)m_malloc(200); + outblob = (unsigned char*)m_malloc(1000); pos = 0; pos += ber_write_id_len(outblob+pos, 16, seq_buf->len, ASN1_CONSTRUCTED);