Mercurial > dropbear
comparison crypto_desc.c @ 1748:34d9d3c022ce
Use Dropbear's random source rather than libtommath's platform
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 19 Oct 2020 22:49:19 +0800 |
parents | 750ec4ec4cbe |
children | 13cb8cc1b0e4 |
comparison
equal
deleted
inserted
replaced
1747:ff51d5967e2d | 1748:34d9d3c022ce |
---|---|
1 #include "includes.h" | 1 #include "includes.h" |
2 #include "dbutil.h" | 2 #include "dbutil.h" |
3 #include "crypto_desc.h" | 3 #include "crypto_desc.h" |
4 #include "ltc_prng.h" | 4 #include "ltc_prng.h" |
5 #include "ecc.h" | 5 #include "ecc.h" |
6 #include "dbrandom.h" | |
6 | 7 |
7 #if DROPBEAR_LTC_PRNG | 8 #if DROPBEAR_LTC_PRNG |
8 int dropbear_ltc_prng = -1; | 9 int dropbear_ltc_prng = -1; |
9 #endif | 10 #endif |
11 | |
12 /* Wrapper for libtommath */ | |
13 static mp_err dropbear_rand_source(void* out, size_t size) { | |
14 genrandom((unsigned char*)out, (unsigned int)size); | |
15 return MP_OKAY; | |
16 } | |
10 | 17 |
11 | 18 |
12 /* Register the compiled in ciphers. | 19 /* Register the compiled in ciphers. |
13 * This should be run before using any of the ciphers/hashes */ | 20 * This should be run before using any of the ciphers/hashes */ |
14 void crypto_init() { | 21 void crypto_init() { |
65 if (dropbear_ltc_prng == -1) { | 72 if (dropbear_ltc_prng == -1) { |
66 dropbear_exit("Error registering crypto"); | 73 dropbear_exit("Error registering crypto"); |
67 } | 74 } |
68 #endif | 75 #endif |
69 | 76 |
77 mp_rand_source(dropbear_rand_source); | |
78 | |
70 #if DROPBEAR_ECC | 79 #if DROPBEAR_ECC |
71 ltc_mp = ltm_desc; | 80 ltc_mp = ltm_desc; |
72 dropbear_ecc_fill_dp(); | 81 dropbear_ecc_fill_dp(); |
73 #endif | 82 #endif |
74 } | 83 } |