Mercurial > dropbear
comparison keyimport.c @ 1251:52a456a3add0
Merge branch '20151231_indent' of https://github.com/fperrad/dropbear into fperrad-20151231_indent
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Mar 2016 21:41:06 +0800 |
parents | 2bb4c662d1c2 |
children | 56aba7dedbea 34e6127ef02e |
comparison
equal
deleted
inserted
replaced
1248:739b3909c499 | 1251:52a456a3add0 |
---|---|
192 /* cpl has to be less than 100 */ | 192 /* cpl has to be less than 100 */ |
193 static void base64_encode_fp(FILE * fp, unsigned char *data, | 193 static void base64_encode_fp(FILE * fp, unsigned char *data, |
194 int datalen, int cpl) | 194 int datalen, int cpl) |
195 { | 195 { |
196 unsigned char out[100]; | 196 unsigned char out[100]; |
197 int n; | 197 int n; |
198 unsigned long outlen; | 198 unsigned long outlen; |
199 int rawcpl; | 199 int rawcpl; |
200 rawcpl = cpl * 3 / 4; | 200 rawcpl = cpl * 3 / 4; |
201 dropbear_assert((unsigned int)cpl < sizeof(out)); | 201 dropbear_assert((unsigned int)cpl < sizeof(out)); |
202 | 202 |
203 while (datalen > 0) { | 203 while (datalen > 0) { |
204 n = (datalen < rawcpl ? datalen : rawcpl); | 204 n = (datalen < rawcpl ? datalen : rawcpl); |
205 outlen = sizeof(out); | 205 outlen = sizeof(out); |
206 base64_encode(data, n, out, &outlen); | 206 base64_encode(data, n, out, &outlen); |
207 data += n; | 207 data += n; |
208 datalen -= n; | 208 datalen -= n; |
209 fwrite(out, 1, outlen, fp); | 209 fwrite(out, 1, outlen, fp); |
210 fputc('\n', fp); | 210 fputc('\n', fp); |
211 } | 211 } |
212 } | 212 } |
213 /* | 213 /* |
214 * Read an ASN.1/BER identifier and length pair. | 214 * Read an ASN.1/BER identifier and length pair. |
215 * | 215 * |
216 * Flags are a combination of the #defines listed below. | 216 * Flags are a combination of the #defines listed below. |
1054 /* privateKey */ | 1054 /* privateKey */ |
1055 k_size = mp_unsigned_bin_size((*eck)->k); | 1055 k_size = mp_unsigned_bin_size((*eck)->k); |
1056 dropbear_assert(k_size <= curve_size); | 1056 dropbear_assert(k_size <= curve_size); |
1057 buf_incrwritepos(seq_buf, | 1057 buf_incrwritepos(seq_buf, |
1058 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0)); | 1058 ber_write_id_len(buf_getwriteptr(seq_buf, 10), 4, k_size, 0)); |
1059 mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size)); | 1059 mp_to_unsigned_bin((*eck)->k, buf_getwriteptr(seq_buf, k_size)); |
1060 buf_incrwritepos(seq_buf, k_size); | 1060 buf_incrwritepos(seq_buf, k_size); |
1061 | 1061 |
1062 /* SECGCurveNames */ | 1062 /* SECGCurveNames */ |
1063 switch (key->type) | 1063 switch (key->type) |
1064 { | 1064 { |