mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-03-06 04:23:01 +00:00
- Changed the used random function pointer to more flexible format. Renamed havege_rand() to havege_random() to prevent mistakes. Lots of changes as a consequence in library code and programs
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "polarssl/net.h"
|
||||
#include "polarssl/ssl.h"
|
||||
#include "polarssl/havege.h"
|
||||
#include "polarssl/error.h"
|
||||
|
||||
#define SERVER_PORT 4433
|
||||
#define SERVER_NAME "localhost"
|
||||
@@ -116,7 +117,7 @@ int main( int argc, char *argv[] )
|
||||
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, stdout );
|
||||
ssl_set_bio( &ssl, net_recv, &server_fd,
|
||||
net_send, &server_fd );
|
||||
@@ -183,6 +184,15 @@ int main( int argc, char *argv[] )
|
||||
|
||||
exit:
|
||||
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
if( ret != 0 )
|
||||
{
|
||||
char error_buf[100];
|
||||
error_strerror( ret, error_buf, 100 );
|
||||
printf("Last error was: %d - %s\n\n", ret, error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
net_close( server_fd );
|
||||
ssl_free( &ssl );
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "polarssl/havege.h"
|
||||
#include "polarssl/certs.h"
|
||||
#include "polarssl/x509.h"
|
||||
#include "polarssl/error.h"
|
||||
|
||||
#define DFL_SERVER_NAME "localhost"
|
||||
#define DFL_SERVER_PORT 4433
|
||||
@@ -328,7 +329,7 @@ int main( int argc, char *argv[] )
|
||||
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_OPTIONAL );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, stdout );
|
||||
ssl_set_bio( &ssl, net_recv, &server_fd,
|
||||
net_send, &server_fd );
|
||||
@@ -452,6 +453,15 @@ int main( int argc, char *argv[] )
|
||||
|
||||
exit:
|
||||
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
if( ret != 0 )
|
||||
{
|
||||
char error_buf[100];
|
||||
error_strerror( ret, error_buf, 100 );
|
||||
printf("Last error was: %d - %s\n\n", ret, error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( server_fd )
|
||||
net_close( server_fd );
|
||||
x509_free( &clicert );
|
||||
|
||||
@@ -333,7 +333,7 @@ int main( int argc, char *argv[] )
|
||||
ssl_set_endpoint( &ssl, SSL_IS_SERVER );
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, stdout );
|
||||
ssl_set_bio( &ssl, net_recv, &client_fd,
|
||||
net_send, &client_fd );
|
||||
|
||||
@@ -581,7 +581,7 @@ int main( int argc, char *argv[] )
|
||||
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_OPTIONAL );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, stdout );
|
||||
ssl_set_bio( &ssl, net_recv, &server_fd,
|
||||
net_send, &server_fd );
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "polarssl/x509.h"
|
||||
#include "polarssl/ssl.h"
|
||||
#include "polarssl/net.h"
|
||||
#include "polarssl/error.h"
|
||||
|
||||
#define HTTP_RESPONSE \
|
||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
|
||||
@@ -261,7 +262,6 @@ int main( int argc, char *argv[] )
|
||||
printf( " . Setting up the RNG and SSL data...." );
|
||||
fflush( stdout );
|
||||
|
||||
memset( &ssl, 0, sizeof( ssl ) );
|
||||
havege_init( &hs );
|
||||
|
||||
if( ( ret = ssl_init( &ssl ) ) != 0 )
|
||||
@@ -273,7 +273,7 @@ int main( int argc, char *argv[] )
|
||||
ssl_set_endpoint( &ssl, SSL_IS_SERVER );
|
||||
ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
|
||||
|
||||
ssl_set_rng( &ssl, havege_rand, &hs );
|
||||
ssl_set_rng( &ssl, havege_random, &hs );
|
||||
ssl_set_dbg( &ssl, my_debug, stdout );
|
||||
|
||||
ssl_set_scb( &ssl, my_get_session,
|
||||
@@ -291,6 +291,15 @@ int main( int argc, char *argv[] )
|
||||
printf( " ok\n" );
|
||||
|
||||
reset:
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
if( ret != 0 )
|
||||
{
|
||||
char error_buf[100];
|
||||
error_strerror( ret, error_buf, 100 );
|
||||
printf("Last error was: %d - %s\n\n", ret, error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( client_fd != -1 )
|
||||
net_close( client_fd );
|
||||
|
||||
@@ -420,12 +429,22 @@ reset:
|
||||
|
||||
len = ret;
|
||||
printf( " %d bytes written\n\n%s\n", len, (char *) buf );
|
||||
|
||||
|
||||
ssl_close_notify( &ssl );
|
||||
ret = 0;
|
||||
goto reset;
|
||||
|
||||
exit:
|
||||
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
if( ret != 0 )
|
||||
{
|
||||
char error_buf[100];
|
||||
error_strerror( ret, error_buf, 100 );
|
||||
printf("Last error was: %d - %s\n\n", ret, error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
net_close( client_fd );
|
||||
x509_free( &srvcert );
|
||||
rsa_free( &rsa );
|
||||
|
||||
Reference in New Issue
Block a user