Mercurial > dropbear
comparison common-algo.c @ 766:d1575fdc29a6 ecc
start on ecdsa keys
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 09 Apr 2013 00:36:04 +0800 |
parents | a78a38e402d1 |
children | 7f604f9b3756 |
comparison
equal
deleted
inserted
replaced
765:5503e05ab3a4 | 766:d1575fdc29a6 |
---|---|
31 #include "ecc.h" | 31 #include "ecc.h" |
32 | 32 |
33 /* This file (algo.c) organises the ciphers which can be used, and is used to | 33 /* This file (algo.c) organises the ciphers which can be used, and is used to |
34 * decide which ciphers/hashes/compression/signing to use during key exchange*/ | 34 * decide which ciphers/hashes/compression/signing to use during key exchange*/ |
35 | 35 |
36 #ifdef DROPBEAR_LTC_PRNG | |
37 int dropbear_ltc_prng = -1; | |
38 #endif | |
39 | |
40 | |
41 | |
42 static int void_cipher(const unsigned char* in, unsigned char* out, | 36 static int void_cipher(const unsigned char* in, unsigned char* out, |
43 unsigned long len, void* UNUSED(cipher_state)) { | 37 unsigned long len, void* UNUSED(cipher_state)) { |
44 if (in != out) { | 38 if (in != out) { |
45 memmove(out, in, len); | 39 memmove(out, in, len); |
46 } | 40 } |
252 #endif | 246 #endif |
253 {"diffie-hellman-group1-sha1", 0, &kex_dh_group1, 1, NULL}, | 247 {"diffie-hellman-group1-sha1", 0, &kex_dh_group1, 1, NULL}, |
254 {"diffie-hellman-group14-sha1", 0, &kex_dh_group14, 1, NULL}, | 248 {"diffie-hellman-group14-sha1", 0, &kex_dh_group14, 1, NULL}, |
255 {NULL, 0, NULL, 0, NULL} | 249 {NULL, 0, NULL, 0, NULL} |
256 }; | 250 }; |
257 | |
258 | |
259 /* Register the compiled in ciphers. | |
260 * This should be run before using any of the ciphers/hashes */ | |
261 void crypto_init() { | |
262 | |
263 const struct ltc_cipher_descriptor *regciphers[] = { | |
264 #ifdef DROPBEAR_AES | |
265 &aes_desc, | |
266 #endif | |
267 #ifdef DROPBEAR_BLOWFISH | |
268 &blowfish_desc, | |
269 #endif | |
270 #ifdef DROPBEAR_TWOFISH | |
271 &twofish_desc, | |
272 #endif | |
273 #ifdef DROPBEAR_3DES | |
274 &des3_desc, | |
275 #endif | |
276 NULL | |
277 }; | |
278 | |
279 const struct ltc_hash_descriptor *reghashes[] = { | |
280 /* we need sha1 for hostkey stuff regardless */ | |
281 &sha1_desc, | |
282 #ifdef DROPBEAR_MD5_HMAC | |
283 &md5_desc, | |
284 #endif | |
285 #ifdef DROPBEAR_SHA256 | |
286 &sha256_desc, | |
287 #endif | |
288 #ifdef DROPBEAR_SHA384 | |
289 &sha384_desc, | |
290 #endif | |
291 #ifdef DROPBEAR_SHA512 | |
292 &sha512_desc, | |
293 #endif | |
294 NULL | |
295 }; | |
296 int i; | |
297 | |
298 for (i = 0; regciphers[i] != NULL; i++) { | |
299 if (register_cipher(regciphers[i]) == -1) { | |
300 dropbear_exit("Error registering crypto"); | |
301 } | |
302 } | |
303 | |
304 for (i = 0; reghashes[i] != NULL; i++) { | |
305 if (register_hash(reghashes[i]) == -1) { | |
306 dropbear_exit("Error registering crypto"); | |
307 } | |
308 } | |
309 | |
310 #ifdef DROPBEAR_LTC_PRNG | |
311 dropbear_ltc_prng = register_prng(&dropbear_prng_desc); | |
312 if (dropbear_ltc_prng == -1) { | |
313 dropbear_exit("Error registering crypto"); | |
314 } | |
315 #endif | |
316 | |
317 #ifdef DROPBEAR_ECC | |
318 ltc_mp = ltm_desc; | |
319 #endif | |
320 } | |
321 | 251 |
322 /* algolen specifies the length of algo, algos is our local list to match | 252 /* algolen specifies the length of algo, algos is our local list to match |
323 * against. | 253 * against. |
324 * Returns DROPBEAR_SUCCESS if we have a match for algo, DROPBEAR_FAILURE | 254 * Returns DROPBEAR_SUCCESS if we have a match for algo, DROPBEAR_FAILURE |
325 * otherwise */ | 255 * otherwise */ |