tinyCrypt: Bind RNG wrapper to tinyCrypt in mbedtls_ssl_setup()
diff --git a/include/mbedtls/ssl_internal.h b/include/mbedtls/ssl_internal.h
index 0e95756..8b44170 100644
--- a/include/mbedtls/ssl_internal.h
+++ b/include/mbedtls/ssl_internal.h
@@ -902,10 +902,6 @@
 int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl );
 void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
 
-#if defined(MBEDTLS_USE_TINYCRYPT)
-int mbetls_uecc_rng_wrapper( uint8_t *dest, unsigned int size );
-#endif
-
 /**
  * \brief       Update record layer
  *
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.