- First replacement of xyssl by polarssl where needed
diff --git a/library/bignum.c b/library/bignum.c
index f25fc4d..38d1610 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -25,12 +25,12 @@
* http://math.libtomcrypt.com/files/tommath.pdf
*/
-#include "xyssl/config.h"
+#include "polarssl/config.h"
-#if defined(XYSSL_BIGNUM_C)
+#if defined(POLARSSL_BIGNUM_C)
-#include "xyssl/bignum.h"
-#include "xyssl/bn_mul.h"
+#include "polarssl/bignum.h"
+#include "polarssl/bn_mul.h"
#include <string.h>
#include <stdlib.h>
@@ -232,7 +232,7 @@
if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57;
if( *d >= (t_int) radix )
- return( XYSSL_ERR_MPI_INVALID_CHARACTER );
+ return( POLARSSL_ERR_MPI_INVALID_CHARACTER );
return( 0 );
}
@@ -247,7 +247,7 @@
mpi T;
if( radix < 2 || radix > 16 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
mpi_init( &T, NULL );
@@ -304,7 +304,7 @@
t_int r;
if( radix < 2 || radix > 16 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
MPI_CHK( mpi_mod_int( &r, X, radix ) );
MPI_CHK( mpi_div_int( X, NULL, X, radix ) );
@@ -332,7 +332,7 @@
mpi T;
if( radix < 2 || radix > 16 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
n = mpi_msb( X );
if( radix >= 4 ) n >>= 1;
@@ -342,7 +342,7 @@
if( *slen < n )
{
*slen = n;
- return( XYSSL_ERR_MPI_BUFFER_TOO_SMALL );
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
}
p = s;
@@ -397,7 +397,7 @@
memset( s, 0, sizeof( s ) );
if( fgets( s, sizeof( s ) - 1, fin ) == NULL )
- return( XYSSL_ERR_MPI_FILE_IO_ERROR );
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
slen = strlen( s );
if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
@@ -438,7 +438,7 @@
{
if( fwrite( p, 1, plen, fout ) != plen ||
fwrite( s, 1, slen, fout ) != slen )
- return( XYSSL_ERR_MPI_FILE_IO_ERROR );
+ return( POLARSSL_ERR_MPI_FILE_IO_ERROR );
}
else
printf( "%s%s", p, s );
@@ -480,7 +480,7 @@
n = mpi_size( X );
if( buflen < n )
- return( XYSSL_ERR_MPI_BUFFER_TOO_SMALL );
+ return( POLARSSL_ERR_MPI_BUFFER_TOO_SMALL );
memset( buf, 0, buflen );
@@ -734,7 +734,7 @@
int ret, n;
if( mpi_cmp_abs( A, B ) < 0 )
- return( XYSSL_ERR_MPI_NEGATIVE_VALUE );
+ return( POLARSSL_ERR_MPI_NEGATIVE_VALUE );
mpi_init( &TB, NULL );
@@ -981,7 +981,7 @@
mpi X, Y, Z, T1, T2;
if( mpi_cmp_int( B, 0 ) == 0 )
- return( XYSSL_ERR_MPI_DIVISION_BY_ZERO );
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
mpi_init( &X, &Y, &Z, &T1, &T2, NULL );
@@ -1027,7 +1027,7 @@
Z.p[i - t - 1] = ~0;
else
{
-#if defined(XYSSL_HAVE_LONGLONG)
+#if defined(POLARSSL_HAVE_LONGLONG)
t_dbl r;
r = (t_dbl) X.p[i] << biL;
@@ -1138,7 +1138,7 @@
*
* Returns 0 if successful
* 1 if memory allocation failed
- * XYSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
*/
int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b )
{
@@ -1182,7 +1182,7 @@
t_int x, y, z;
if( b == 0 )
- return( XYSSL_ERR_MPI_DIVISION_BY_ZERO );
+ return( POLARSSL_ERR_MPI_DIVISION_BY_ZERO );
if( b < 0 )
b = -b;
@@ -1303,7 +1303,7 @@
mpi RR, T, W[64];
if( mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
/*
* Init temps and window size
@@ -1469,7 +1469,7 @@
return( ret );
}
-#if defined(XYSSL_GENPRIME)
+#if defined(POLARSSL_GENPRIME)
/*
* Greatest common divisor: G = gcd(A, B) (HAC 14.54)
@@ -1522,7 +1522,7 @@
mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
if( mpi_cmp_int( N, 0 ) <= 0 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
mpi_init( &TA, &TU, &U1, &U2, &G,
&TB, &TV, &V1, &V2, NULL );
@@ -1531,7 +1531,7 @@
if( mpi_cmp_int( &G, 1 ) != 0 )
{
- ret = XYSSL_ERR_MPI_NOT_ACCEPTABLE;
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
goto cleanup;
}
@@ -1651,7 +1651,7 @@
* test trivial factors first
*/
if( ( X->p[0] & 1 ) == 0 )
- return( XYSSL_ERR_MPI_NOT_ACCEPTABLE );
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
for( i = 0; small_prime[i] > 0; i++ )
{
@@ -1663,7 +1663,7 @@
MPI_CHK( mpi_mod_int( &r, X, small_prime[i] ) );
if( r == 0 )
- return( XYSSL_ERR_MPI_NOT_ACCEPTABLE );
+ return( POLARSSL_ERR_MPI_NOT_ACCEPTABLE );
}
/*
@@ -1728,7 +1728,7 @@
if( mpi_cmp_mpi( &A, &W ) != 0 ||
mpi_cmp_int( &A, 1 ) == 0 )
{
- ret = XYSSL_ERR_MPI_NOT_ACCEPTABLE;
+ ret = POLARSSL_ERR_MPI_NOT_ACCEPTABLE;
break;
}
}
@@ -1753,7 +1753,7 @@
mpi Y;
if( nbits < 3 )
- return( XYSSL_ERR_MPI_BAD_INPUT_DATA );
+ return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
mpi_init( &Y, NULL );
@@ -1776,7 +1776,7 @@
{
while( ( ret = mpi_is_prime( X, f_rng, p_rng ) ) != 0 )
{
- if( ret != XYSSL_ERR_MPI_NOT_ACCEPTABLE )
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
goto cleanup;
MPI_CHK( mpi_add_int( X, X, 2 ) );
@@ -1794,11 +1794,11 @@
if( ( ret = mpi_is_prime( &Y, f_rng, p_rng ) ) == 0 )
break;
- if( ret != XYSSL_ERR_MPI_NOT_ACCEPTABLE )
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
goto cleanup;
}
- if( ret != XYSSL_ERR_MPI_NOT_ACCEPTABLE )
+ if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
goto cleanup;
MPI_CHK( mpi_add_int( &Y, X, 1 ) );
@@ -1816,7 +1816,7 @@
#endif
-#if defined(XYSSL_SELF_TEST)
+#if defined(POLARSSL_SELF_TEST)
/*
* Checkup routine