Mercurial > dropbear
comparison 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 |
comparison
equal
deleted
inserted
replaced
1691:2d3745d58843 | 1692:1051e4eea25a |
---|---|
865 if (!ecc) { | 865 if (!ecc) { |
866 errmsg = "Error parsing ECC key"; | 866 errmsg = "Error parsing ECC key"; |
867 goto error; | 867 goto error; |
868 } | 868 } |
869 m_mp_alloc_init_multi((mp_int**)&ecc->k, NULL); | 869 m_mp_alloc_init_multi((mp_int**)&ecc->k, NULL); |
870 if (mp_read_unsigned_bin(ecc->k, private_key_bytes, private_key_len) | 870 if (mp_from_ubin(ecc->k, private_key_bytes, private_key_len) |
871 != MP_OKAY) { | 871 != MP_OKAY) { |
872 errmsg = "Error parsing ECC key"; | 872 errmsg = "Error parsing ECC key"; |
873 goto error; | 873 goto error; |
874 } | 874 } |
875 | 875 |
1140 int curve_oid_len = 0; | 1140 int curve_oid_len = 0; |
1141 const void* curve_oid = NULL; | 1141 const void* curve_oid = NULL; |
1142 unsigned long pubkey_size = 2*curve_size+1; | 1142 unsigned long pubkey_size = 2*curve_size+1; |
1143 int k_size; | 1143 int k_size; |
1144 int err = 0; | 1144 int err = 0; |
1145 size_t written; | |
1145 | 1146 |
1146 /* version. less than 10 bytes */ | 1147 /* version. less than 10 bytes */ |
1147 buf_incrwritepos(seq_buf, | 1148 buf_incrwritepos(seq_buf, |
1148 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 2, 1, 0)); | 1149 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 2, 1, 0)); |
1149 buf_putbyte(seq_buf, 1); | 1150 buf_putbyte(seq_buf, 1); |
1150 | 1151 |
1151 /* privateKey */ | 1152 /* privateKey */ |
1152 k_size = mp_unsigned_bin_size((*eck)->k); | 1153 k_size = mp_ubin_size((*eck)->k); |
1153 dropbear_assert(k_size <= curve_size); | 1154 dropbear_assert(k_size <= curve_size); |
1154 buf_incrwritepos(seq_buf, | 1155 buf_incrwritepos(seq_buf, |
1155 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0)); | 1156 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0)); |
1156 mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size)); | 1157 if (mp_to_ubin((*eck)->k, buf_getwriteptr(seq_buf, k_size), k_size, &written) != MP_OKAY) { |
1157 buf_incrwritepos(seq_buf, k_size); | 1158 dropbear_exit("ECC error"); |
1159 } | |
1160 buf_incrwritepos(seq_buf, written); | |
1158 | 1161 |
1159 /* SECGCurveNames */ | 1162 /* SECGCurveNames */ |
1160 switch (key->type) | 1163 switch (key->type) |
1161 { | 1164 { |
1162 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: | 1165 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: |