tinyCrypt: Bind RNG wrapper to tinyCrypt in mbedtls_ssl_setup()
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 582c9fd..c3c99c1 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -3533,8 +3533,6 @@
{
const struct uECC_Curve_t * uecc_curve = uECC_secp256r1();
- uECC_set_rng( &mbetls_uecc_rng_wrapper );
-
if( !uECC_make_key( ssl->handshake->ecdh_ownpubkey,
ssl->handshake->ecdh_privkey,
uecc_curve ) )
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 8f75f6a..2562a57 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -3384,8 +3384,6 @@
*/
#if defined(MBEDTLS_USE_TINYCRYPT)
- uECC_set_rng( &mbetls_uecc_rng_wrapper );
-
if( ssl->handshake->curve_tls_id != 23 )
return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index a1c26d0..752c172 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -55,6 +55,13 @@
#include "mbedtls/oid.h"
#endif
+#if defined(MBEDTLS_USE_TINYCRYPT)
+static int uecc_rng_wrapper( uint8_t *dest, unsigned int size )
+{
+ return( mbedtls_ssl_conf_rng_func( NULL, dest, size ) );
+}
+#endif /* MBEDTLS_USE_TINYCRYPT */
+
static void ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl );
static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl );
@@ -8234,6 +8241,10 @@
ssl->conf = conf;
+#if defined(MBEDTLS_USE_TINYCRYPT)
+ uECC_set_rng( &uecc_rng_wrapper );
+#endif
+
/*
* Prepare base structures
*/
@@ -12165,13 +12176,6 @@
}
}
-#if defined(MBEDTLS_USE_TINYCRYPT)
-int mbetls_uecc_rng_wrapper( uint8_t *dest, unsigned int size )
-{
- return( mbedtls_ssl_conf_rng_func( NULL, dest, size ) );
-}
-#endif /* MBEDTLS_USE_TINYCRYPT */
-
#if defined(MBEDTLS_ECP_C)
/*
* Check if a curve proposed by the peer is in our list.