- First replacement of xyssl by polarssl where needed

This commit is contained in:
Paul Bakker 2009-01-03 21:51:57 +00:00
parent 8e831edc24
commit 40e46940df
70 changed files with 833 additions and 1201 deletions

View file

@ -4,7 +4,7 @@
CFLAGS = -I../include -D_FILE_OFFSET_BITS=64
OFLAGS = -O
LDFLAGS = -L../library -lxyssl
LDFLAGS = -L../library -lpolarssl
APPS = aes/aescrypt2 hash/hello \
hash/md5sum hash/sha1sum \
@ -20,75 +20,75 @@ APPS = aes/aescrypt2 hash/hello \
all: $(APPS)
aes/aescrypt2: aes/aescrypt2.c ../library/libxyssl.a
aes/aescrypt2: aes/aescrypt2.c ../library/libpolarssl.a
echo " CC aes/aescrypt2.c"
$(CC) $(CFLAGS) $(OFLAGS) aes/aescrypt2.c $(LDFLAGS) -o $@
hash/hello: hash/hello.c ../library/libxyssl.a
hash/hello: hash/hello.c ../library/libpolarssl.a
echo " CC hash/hello.c"
$(CC) $(CFLAGS) $(OFLAGS) hash/hello.c $(LDFLAGS) -o $@
hash/md5sum: hash/md5sum.c ../library/libxyssl.a
hash/md5sum: hash/md5sum.c ../library/libpolarssl.a
echo " CC hash/md5sum.c"
$(CC) $(CFLAGS) $(OFLAGS) hash/md5sum.c $(LDFLAGS) -o $@
hash/sha1sum: hash/sha1sum.c ../library/libxyssl.a
hash/sha1sum: hash/sha1sum.c ../library/libpolarssl.a
echo " CC hash/sha1sum.c"
$(CC) $(CFLAGS) $(OFLAGS) hash/sha1sum.c $(LDFLAGS) -o $@
hash/sha2sum: hash/sha2sum.c ../library/libxyssl.a
hash/sha2sum: hash/sha2sum.c ../library/libpolarssl.a
echo " CC hash/sha2sum.c"
$(CC) $(CFLAGS) $(OFLAGS) hash/sha2sum.c $(LDFLAGS) -o $@
pkey/dh_client: pkey/dh_client.c ../library/libxyssl.a
pkey/dh_client: pkey/dh_client.c ../library/libpolarssl.a
echo " CC pkey/dh_client.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/dh_client.c $(LDFLAGS) -o $@
pkey/dh_genprime: pkey/dh_genprime.c ../library/libxyssl.a
pkey/dh_genprime: pkey/dh_genprime.c ../library/libpolarssl.a
echo " CC pkey/dh_genprime.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/dh_genprime.c $(LDFLAGS) -o $@
pkey/dh_server: pkey/dh_server.c ../library/libxyssl.a
pkey/dh_server: pkey/dh_server.c ../library/libpolarssl.a
echo " CC pkey/dh_server.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/dh_server.c $(LDFLAGS) -o $@
pkey/mpi_demo: pkey/mpi_demo.c ../library/libxyssl.a
pkey/mpi_demo: pkey/mpi_demo.c ../library/libpolarssl.a
echo " CC pkey/mpi_demo.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/mpi_demo.c $(LDFLAGS) -o $@
pkey/rsa_genkey: pkey/rsa_genkey.c ../library/libxyssl.a
pkey/rsa_genkey: pkey/rsa_genkey.c ../library/libpolarssl.a
echo " CC pkey/rsa_genkey.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/rsa_genkey.c $(LDFLAGS) -o $@
pkey/rsa_sign: pkey/rsa_sign.c ../library/libxyssl.a
pkey/rsa_sign: pkey/rsa_sign.c ../library/libpolarssl.a
echo " CC pkey/rsa_sign.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/rsa_sign.c $(LDFLAGS) -o $@
pkey/rsa_verify: pkey/rsa_verify.c ../library/libxyssl.a
pkey/rsa_verify: pkey/rsa_verify.c ../library/libpolarssl.a
echo " CC pkey/rsa_verify.c"
$(CC) $(CFLAGS) $(OFLAGS) pkey/rsa_verify.c $(LDFLAGS) -o $@
ssl/ssl_client1: ssl/ssl_client1.c ../library/libxyssl.a
ssl/ssl_client1: ssl/ssl_client1.c ../library/libpolarssl.a
echo " CC ssl/ssl_client1.c"
$(CC) $(CFLAGS) $(OFLAGS) ssl/ssl_client1.c $(LDFLAGS) -o $@
ssl/ssl_client2: ssl/ssl_client2.c ../library/libxyssl.a
ssl/ssl_client2: ssl/ssl_client2.c ../library/libpolarssl.a
echo " CC ssl/ssl_client2.c"
$(CC) $(CFLAGS) $(OFLAGS) ssl/ssl_client2.c $(LDFLAGS) -o $@
ssl/ssl_server: ssl/ssl_server.c ../library/libxyssl.a
ssl/ssl_server: ssl/ssl_server.c ../library/libpolarssl.a
echo " CC ssl/ssl_server.c"
$(CC) $(CFLAGS) $(OFLAGS) ssl/ssl_server.c $(LDFLAGS) -o $@
test/benchmark: test/benchmark.c ../library/libxyssl.a
test/benchmark: test/benchmark.c ../library/libpolarssl.a
echo " CC test/benchmark.c"
$(CC) $(CFLAGS) $(OFLAGS) test/benchmark.c $(LDFLAGS) -o $@
test/selftest: test/selftest.c ../library/libxyssl.a
test/selftest: test/selftest.c ../library/libpolarssl.a
echo " CC test/selftest.c"
$(CC) $(CFLAGS) $(OFLAGS) test/selftest.c $(LDFLAGS) -o $@
test/ssl_test: test/ssl_test.c ../library/libxyssl.a
test/ssl_test: test/ssl_test.c ../library/libpolarssl.a
echo " CC test/ssl_test.c"
$(CC) $(CFLAGS) $(OFLAGS) test/ssl_test.c $(LDFLAGS) -o $@

View file

@ -35,8 +35,8 @@
#include <stdio.h>
#include <time.h>
#include "xyssl/aes.h"
#include "xyssl/sha2.h"
#include "polarssl/aes.h"
#include "polarssl/sha2.h"
#define MODE_ENCRYPT 0
#define MODE_DECRYPT 1

View file

@ -24,7 +24,7 @@
#include <stdio.h>
#include "xyssl/md5.h"
#include "polarssl/md5.h"
int main( void )
{

View file

@ -25,7 +25,7 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/md5.h"
#include "polarssl/md5.h"
static int md5_wrapper( char *filename, unsigned char *sum )
{

View file

@ -25,7 +25,7 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/sha1.h"
#include "polarssl/sha1.h"
static int sha1_wrapper( char *filename, unsigned char *sum )
{

View file

@ -25,7 +25,7 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/sha2.h"
#include "polarssl/sha2.h"
static int sha2_wrapper( char *filename, unsigned char *sum )
{

View file

@ -25,12 +25,12 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/net.h"
#include "xyssl/aes.h"
#include "xyssl/dhm.h"
#include "xyssl/rsa.h"
#include "xyssl/sha1.h"
#include "xyssl/havege.h"
#include "polarssl/net.h"
#include "polarssl/aes.h"
#include "polarssl/dhm.h"
#include "polarssl/rsa.h"
#include "polarssl/sha1.h"
#include "polarssl/havege.h"
#define SERVER_NAME "localhost"
#define SERVER_PORT 11999

View file

@ -24,9 +24,9 @@
#include <stdio.h>
#include "xyssl/bignum.h"
#include "xyssl/config.h"
#include "xyssl/havege.h"
#include "polarssl/bignum.h"
#include "polarssl/config.h"
#include "polarssl/havege.h"
/*
* Note: G = 4 is always a quadratic residue mod P,
@ -39,7 +39,7 @@ int main( void )
{
int ret = 1;
#if defined(XYSSL_GENPRIME)
#if defined(POLARSSL_GENPRIME)
mpi G, P, Q;
havege_state hs;
FILE *fout;

View file

@ -25,12 +25,12 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/net.h"
#include "xyssl/aes.h"
#include "xyssl/dhm.h"
#include "xyssl/rsa.h"
#include "xyssl/sha1.h"
#include "xyssl/havege.h"
#include "polarssl/net.h"
#include "polarssl/aes.h"
#include "polarssl/dhm.h"
#include "polarssl/rsa.h"
#include "polarssl/sha1.h"
#include "polarssl/havege.h"
#define SERVER_PORT 11999
#define PLAINTEXT "==Hello there!=="

View file

@ -24,7 +24,7 @@
#include <stdio.h>
#include "xyssl/bignum.h"
#include "polarssl/bignum.h"
int main( void )
{

View file

@ -24,10 +24,10 @@
#include <stdio.h>
#include "xyssl/havege.h"
#include "xyssl/bignum.h"
#include "xyssl/x509.h"
#include "xyssl/rsa.h"
#include "polarssl/havege.h"
#include "polarssl/bignum.h"
#include "polarssl/x509.h"
#include "polarssl/rsa.h"
#define KEY_SIZE 1024
#define EXPONENT 65537

View file

@ -25,8 +25,8 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/rsa.h"
#include "xyssl/sha1.h"
#include "polarssl/rsa.h"
#include "polarssl/sha1.h"
int main( int argc, char *argv[] )
{

View file

@ -25,8 +25,8 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/rsa.h"
#include "xyssl/sha1.h"
#include "polarssl/rsa.h"
#include "polarssl/sha1.h"
int main( int argc, char *argv[] )
{

View file

@ -25,9 +25,9 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/net.h"
#include "xyssl/ssl.h"
#include "xyssl/havege.h"
#include "polarssl/net.h"
#include "polarssl/ssl.h"
#include "polarssl/havege.h"
#define SERVER_PORT 443
/*
@ -115,7 +115,7 @@ int main( void )
while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
{
if( ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " failed\n ! ssl_write returned %d\n\n", ret );
goto exit;
@ -137,10 +137,10 @@ int main( void )
memset( buf, 0, sizeof( buf ) );
ret = ssl_read( &ssl, buf, len );
if( ret == XYSSL_ERR_NET_TRY_AGAIN )
if( ret == POLARSSL_ERR_NET_TRY_AGAIN )
continue;
if( ret == XYSSL_ERR_SSL_PEER_CLOSE_NOTIFY )
if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY )
break;
if( ret <= 0 )

View file

@ -25,11 +25,11 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/net.h"
#include "xyssl/ssl.h"
#include "xyssl/havege.h"
#include "xyssl/certs.h"
#include "xyssl/x509.h"
#include "polarssl/net.h"
#include "polarssl/ssl.h"
#include "polarssl/havege.h"
#include "polarssl/certs.h"
#include "polarssl/x509.h"
#define SERVER_PORT 443
/*
@ -174,7 +174,7 @@ int main( void )
while( ( ret = ssl_handshake( &ssl ) ) != 0 )
{
if( ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " failed\n ! ssl_handshake returned %d\n\n", ret );
goto exit;
@ -223,7 +223,7 @@ int main( void )
while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
{
if( ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " failed\n ! ssl_write returned %d\n\n", ret );
goto exit;
@ -245,10 +245,10 @@ int main( void )
memset( buf, 0, sizeof( buf ) );
ret = ssl_read( &ssl, buf, len );
if( ret == XYSSL_ERR_NET_TRY_AGAIN )
if( ret == POLARSSL_ERR_NET_TRY_AGAIN )
continue;
if( ret == XYSSL_ERR_SSL_PEER_CLOSE_NOTIFY )
if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY )
break;
if( ret <= 0 )

View file

@ -30,11 +30,11 @@
#include <stdlib.h>
#include <stdio.h>
#include "xyssl/havege.h"
#include "xyssl/certs.h"
#include "xyssl/x509.h"
#include "xyssl/ssl.h"
#include "xyssl/net.h"
#include "polarssl/havege.h"
#include "polarssl/certs.h"
#include "polarssl/x509.h"
#include "polarssl/ssl.h"
#include "polarssl/net.h"
#define HTTP_RESPONSE \
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
@ -293,7 +293,7 @@ accept:
while( ( ret = ssl_handshake( &ssl ) ) != 0 )
{
if( ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " failed\n ! ssl_handshake returned %d\n\n", ret );
goto accept;
@ -314,18 +314,18 @@ accept:
memset( buf, 0, sizeof( buf ) );
ret = ssl_read( &ssl, buf, len );
if( ret == XYSSL_ERR_NET_TRY_AGAIN )
if( ret == POLARSSL_ERR_NET_TRY_AGAIN )
continue;
if( ret <= 0 )
{
switch( ret )
{
case XYSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
printf( " connection was closed gracefully\n" );
break;
case XYSSL_ERR_NET_CONN_RESET:
case POLARSSL_ERR_NET_CONN_RESET:
printf( " connection was reset by peer\n" );
break;
@ -353,13 +353,13 @@ accept:
while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
{
if( ret == XYSSL_ERR_NET_CONN_RESET )
if( ret == POLARSSL_ERR_NET_CONN_RESET )
{
printf( " failed\n ! peer closed the connection\n\n" );
goto accept;
}
if( ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " failed\n ! ssl_write returned %d\n\n", ret );
goto exit;

View file

@ -26,17 +26,17 @@
#include <stdlib.h>
#include <stdio.h>
#include "xyssl/config.h"
#include "polarssl/config.h"
#include "xyssl/md4.h"
#include "xyssl/md5.h"
#include "xyssl/sha1.h"
#include "xyssl/sha2.h"
#include "xyssl/arc4.h"
#include "xyssl/des.h"
#include "xyssl/aes.h"
#include "xyssl/rsa.h"
#include "xyssl/timing.h"
#include "polarssl/md4.h"
#include "polarssl/md5.h"
#include "polarssl/sha1.h"
#include "polarssl/sha2.h"
#include "polarssl/arc4.h"
#include "polarssl/des.h"
#include "polarssl/aes.h"
#include "polarssl/rsa.h"
#include "polarssl/timing.h"
#define BUFSIZE 1024
@ -55,17 +55,17 @@ int main( void )
int keysize;
unsigned long i, j, tsc;
unsigned char tmp[32];
#if defined(XYSSL_ARC4_C)
#if defined(POLARSSL_ARC4_C)
arc4_context arc4;
#endif
#if defined(XYSSL_DES_C)
#if defined(POLARSSL_DES_C)
des3_context des3;
des_context des;
#endif
#if defined(XYSSL_AES_C)
#if defined(POLARSSL_AES_C)
aes_context aes;
#endif
#if defined(XYSSL_RSA_C)
#if defined(POLARSSL_RSA_C)
rsa_context rsa;
#endif
@ -73,7 +73,7 @@ int main( void )
printf( "\n" );
#if defined(XYSSL_MD4_C)
#if defined(POLARSSL_MD4_C)
printf( " MD4 : " );
fflush( stdout );
@ -89,7 +89,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_MD5_C)
#if defined(POLARSSL_MD5_C)
printf( " MD5 : " );
fflush( stdout );
@ -105,7 +105,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_SHA1_C)
#if defined(POLARSSL_SHA1_C)
printf( " SHA-1 : " );
fflush( stdout );
@ -121,7 +121,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_SHA2_C)
#if defined(POLARSSL_SHA2_C)
printf( " SHA-256 : " );
fflush( stdout );
@ -137,7 +137,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_ARC4_C)
#if defined(POLARSSL_ARC4_C)
printf( " ARC4 : " );
fflush( stdout );
@ -155,7 +155,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_DES_C)
#if defined(POLARSSL_DES_C)
printf( " 3DES : " );
fflush( stdout );
@ -189,7 +189,7 @@ int main( void )
( hardclock() - tsc ) / ( j * BUFSIZE ) );
#endif
#if defined(XYSSL_AES_C)
#if defined(POLARSSL_AES_C)
for( keysize = 128; keysize <= 256; keysize += 64 )
{
printf( " AES-%d : ", keysize );
@ -213,7 +213,7 @@ int main( void )
}
#endif
#if defined(XYSSL_RSA_C)
#if defined(POLARSSL_RSA_C)
rsa_init( &rsa, RSA_PKCS_V15, 0, myrand, NULL );
rsa_gen_key( &rsa, 1024, 65537 );

View file

@ -25,21 +25,21 @@
#include <string.h>
#include <stdio.h>
#include "xyssl/config.h"
#include "polarssl/config.h"
#include "xyssl/md2.h"
#include "xyssl/md4.h"
#include "xyssl/md5.h"
#include "xyssl/sha1.h"
#include "xyssl/sha2.h"
#include "xyssl/sha4.h"
#include "xyssl/arc4.h"
#include "xyssl/des.h"
#include "xyssl/aes.h"
#include "xyssl/base64.h"
#include "xyssl/bignum.h"
#include "xyssl/rsa.h"
#include "xyssl/x509.h"
#include "polarssl/md2.h"
#include "polarssl/md4.h"
#include "polarssl/md5.h"
#include "polarssl/sha1.h"
#include "polarssl/sha2.h"
#include "polarssl/sha4.h"
#include "polarssl/arc4.h"
#include "polarssl/des.h"
#include "polarssl/aes.h"
#include "polarssl/base64.h"
#include "polarssl/bignum.h"
#include "polarssl/rsa.h"
#include "polarssl/x509.h"
int main( int argc, char *argv[] )
{
@ -53,67 +53,67 @@ int main( int argc, char *argv[] )
printf( "\n" );
}
#if defined(XYSSL_MD2_C)
#if defined(POLARSSL_MD2_C)
if( ( ret = md2_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_MD4_C)
#if defined(POLARSSL_MD4_C)
if( ( ret = md4_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_MD5_C)
#if defined(POLARSSL_MD5_C)
if( ( ret = md5_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_SHA1_C)
#if defined(POLARSSL_SHA1_C)
if( ( ret = sha1_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_SHA2_C)
#if defined(POLARSSL_SHA2_C)
if( ( ret = sha2_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_SHA4_C)
#if defined(POLARSSL_SHA4_C)
if( ( ret = sha4_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_ARC4_C)
#if defined(POLARSSL_ARC4_C)
if( ( ret = arc4_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_DES_C)
#if defined(POLARSSL_DES_C)
if( ( ret = des_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_AES_C)
#if defined(POLARSSL_AES_C)
if( ( ret = aes_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_BASE64_C)
#if defined(POLARSSL_BASE64_C)
if( ( ret = base64_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_BIGNUM_C)
#if defined(POLARSSL_BIGNUM_C)
if( ( ret = mpi_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_RSA_C)
#if defined(POLARSSL_RSA_C)
if( ( ret = rsa_self_test( v ) ) != 0 )
return( ret );
#endif
#if defined(XYSSL_X509_C)
#if defined(POLARSSL_X509_C)
if( ( ret = x509_self_test( v ) ) != 0 )
return( ret );
#endif

View file

@ -26,11 +26,11 @@
#include <stdlib.h>
#include <stdio.h>
#include "xyssl/net.h"
#include "xyssl/ssl.h"
#include "xyssl/havege.h"
#include "xyssl/timing.h"
#include "xyssl/certs.h"
#include "polarssl/net.h"
#include "polarssl/ssl.h"
#include "polarssl/havege.h"
#include "polarssl/timing.h"
#include "polarssl/certs.h"
#define OPMODE_NONE 0
#define OPMODE_CLIENT 1
@ -281,14 +281,14 @@ static int ssl_test( struct options *opt )
offset_to_write += ret;
}
if( ret == XYSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
ret == XYSSL_ERR_NET_CONN_RESET )
if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
ret == POLARSSL_ERR_NET_CONN_RESET )
{
ret = 0;
goto exit;
}
if( ret < 0 && ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret < 0 && ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " ! ssl_write returned %d\n\n", ret );
break;
@ -324,14 +324,14 @@ static int ssl_test( struct options *opt )
offset_to_read += ret;
}
if( ret == XYSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
ret == XYSSL_ERR_NET_CONN_RESET )
if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
ret == POLARSSL_ERR_NET_CONN_RESET )
{
ret = 0;
goto exit;
}
if( ret < 0 && ret != XYSSL_ERR_NET_TRY_AGAIN )
if( ret < 0 && ret != POLARSSL_ERR_NET_TRY_AGAIN )
{
printf( " ! ssl_read returned %d\n\n", ret );
break;