diff 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
line wrap: on
line diff
--- a/crypto_desc.c	Mon Oct 19 21:38:20 2020 +0800
+++ b/crypto_desc.c	Mon Oct 19 22:49:19 2020 +0800
@@ -3,11 +3,18 @@
 #include "crypto_desc.h"
 #include "ltc_prng.h"
 #include "ecc.h"
+#include "dbrandom.h"
 
 #if DROPBEAR_LTC_PRNG
 	int dropbear_ltc_prng = -1;
 #endif
 
+/* Wrapper for libtommath */
+static mp_err dropbear_rand_source(void* out, size_t size) {
+	genrandom((unsigned char*)out, (unsigned int)size);
+	return MP_OKAY;
+}
+
 
 /* Register the compiled in ciphers.
  * This should be run before using any of the ciphers/hashes */
@@ -67,6 +74,8 @@
 	}
 #endif
 
+	mp_rand_source(dropbear_rand_source);
+
 #if DROPBEAR_ECC
 	ltc_mp = ltm_desc;
 	dropbear_ecc_fill_dp();