CSR generation (gen_key, cert_req)
endef
+define Package/mbedtls-benchmark
+$(call Package/mbedtls/Default)
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE+= (benchmark)
+ DEPENDS:=+libmbedtls
+endef
+
PKG_INSTALL:=1
TARGET_CFLAGS += -ffunction-sections -fdata-sections
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
endef
+define Package/mbedtls-benchmark/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/benchmark $(1)/usr/bin/
+endef
+
$(eval $(call BuildPackage,libmbedtls))
$(eval $(call BuildPackage,mbedtls-util))
+$(eval $(call BuildPackage,mbedtls-benchmark))
--- /dev/null
+diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
+index cecf3e36..f756ed39 100644
+--- a/programs/test/benchmark.c
++++ b/programs/test/benchmark.c
+@@ -45,6 +45,10 @@ int main( void )
+
+ #include <string.h>
+ #include <stdlib.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <unistd.h>
+
+ #include "mbedtls/timing.h"
+
+@@ -160,7 +164,7 @@ do { \
+ \
+ mbedtls_printf( HEADER_FORMAT, TITLE ); \
+ fflush( stdout ); \
+- mbedtls_set_alarm( 3 ); \
++ mbedtls_set_alarm( 10 ); \
+ \
+ ret = 0; \
+ for( ii = 1; ! mbedtls_timing_alarmed && ! ret ; ii++ ) \
+@@ -174,31 +178,21 @@ do { \
+ } \
+ else \
+ { \
+- mbedtls_printf( "%6lu " TYPE "/s", ii / 3 ); \
++ mbedtls_printf( "%6f " TYPE "/s", ((double)ii) / 10 ); \
+ MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \
+ mbedtls_printf( "\n" ); \
+ } \
+ } while( 0 )
+
++static int urandom_fd;
++
+ static int myrand( void *rng_state, unsigned char *output, size_t len )
+ {
+- size_t use_len;
+- int rnd;
+
+ if( rng_state != NULL )
+ rng_state = NULL;
+
+- while( len > 0 )
+- {
+- use_len = len;
+- if( use_len > sizeof(int) )
+- use_len = sizeof(int);
+-
+- rnd = rand();
+- memcpy( output, &rnd, use_len );
+- output += use_len;
+- len -= use_len;
+- }
++ read(urandom_fd, output, len);
+
+ return( 0 );
+ }
+@@ -308,6 +302,7 @@ int main( int argc, char *argv[] )
+ }
+ }
+
++ urandom_fd = open("/dev/urandom", O_RDONLY);
+ mbedtls_printf( "\n" );
+
+ #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+@@ -639,7 +634,9 @@ int main( int argc, char *argv[] )
+ mbedtls_snprintf( title, sizeof( title ), "RSA-%d", keysize );
+
+ mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
++printf("before mbedtls_rsa_gen_key\n");
+ mbedtls_rsa_gen_key( &rsa, myrand, NULL, keysize, 65537 );
++printf("after mbedtls_rsa_gen_key\n");
+
+ TIME_PUBLIC( title, " public",
+ buf[0] = 0;