Commit 40e46940 authored by Paul Bakker's avatar Paul Bakker
Browse files

- First replacement of xyssl by polarssl where needed

parent 8e831edc
/**
* \file aes.h
*/
#ifndef XYSSL_AES_H
#define XYSSL_AES_H
#ifndef POLARSSL_AES_H
#define POLARSSL_AES_H
#define AES_ENCRYPT 1
#define AES_DECRYPT 0
......
/**
* \file arc4.h
*/
#ifndef XYSSL_ARC4_H
#define XYSSL_ARC4_H
#ifndef POLARSSL_ARC4_H
#define POLARSSL_ARC4_H
/**
* \brief ARC4 context structure
......
/**
* \file base64.h
*/
#ifndef XYSSL_BASE64_H
#define XYSSL_BASE64_H
#ifndef POLARSSL_BASE64_H
#define POLARSSL_BASE64_H
#define XYSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
#define XYSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
#ifdef __cplusplus
extern "C" {
......@@ -19,7 +19,7 @@ extern "C" {
* \param src source buffer
* \param slen amount of data to be encoded
*
* \return 0 if successful, or XYSSL_ERR_BASE64_BUFFER_TOO_SMALL.
* \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
* *dlen is always updated to reflect the amount
* of data that has (or would have) been written.
*
......@@ -37,8 +37,8 @@ int base64_encode( unsigned char *dst, int *dlen,
* \param src source buffer
* \param slen amount of data to be decoded
*
* \return 0 if successful, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
* XYSSL_ERR_BASE64_INVALID_DATA if the input data is not
* \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
* POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
* correct. *dlen is always updated to reflect the amount
* of data that has (or would have) been written.
*
......
/**
* \file bignum.h
*/
#ifndef XYSSL_BIGNUM_H
#define XYSSL_BIGNUM_H
#ifndef POLARSSL_BIGNUM_H
#define POLARSSL_BIGNUM_H
#include <stdio.h>
#define XYSSL_ERR_MPI_FILE_IO_ERROR -0x0002
#define XYSSL_ERR_MPI_BAD_INPUT_DATA -0x0004
#define XYSSL_ERR_MPI_INVALID_CHARACTER -0x0006
#define XYSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008
#define XYSSL_ERR_MPI_NEGATIVE_VALUE -0x000A
#define XYSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C
#define XYSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E
#define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002
#define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004
#define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006
#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008
#define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A
#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C
#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E
#define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup
/*
* Define the base integer type, architecture-wise
*/
#if defined(XYSSL_HAVE_INT8)
#if defined(POLARSSL_HAVE_INT8)
typedef unsigned char t_int;
typedef unsigned short t_dbl;
#else
#if defined(XYSSL_HAVE_INT16)
#if defined(POLARSSL_HAVE_INT16)
typedef unsigned short t_int;
typedef unsigned long t_dbl;
#else
......@@ -118,7 +118,7 @@ int mpi_size( mpi *X );
* \param radix input numeric base
* \param s null-terminated string buffer
*
* \return 0 if successful, or an XYSSL_ERR_MPI_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*/
int mpi_read_string( mpi *X, int radix, char *s );
......@@ -130,7 +130,7 @@ int mpi_read_string( mpi *X, int radix, char *s );
* \param s string buffer
* \param slen string buffer size
*
* \return 0 if successful, or an XYSSL_ERR_MPI_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*
* \note Call this function with *slen = 0 to obtain the
* minimum required buffer size in *slen.
......@@ -144,7 +144,7 @@ int mpi_write_string( mpi *X, int radix, char *s, int *slen );
* \param radix input numeric base
* \param fin input file handle
*
* \return 0 if successful, or an XYSSL_ERR_MPI_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*/
int mpi_read_file( mpi *X, int radix, FILE *fin );
......@@ -156,7 +156,7 @@ int mpi_read_file( mpi *X, int radix, FILE *fin );
* \param radix output numeric base
* \param fout output file handle
*
* \return 0 if successful, or an XYSSL_ERR_MPI_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_MPI_XXX error code
*
* \note Set fout == NULL to print X on the console.
*/
......@@ -182,7 +182,7 @@ int mpi_read_binary( mpi *X, unsigned char *buf, int buflen );
* \param buflen output buffer size
*
* \return 0 if successful,
* XYSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
* POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
*
* \note Call this function with *buflen = 0 to obtain the
* minimum required buffer size in *buflen.
......@@ -244,7 +244,7 @@ int mpi_add_abs( mpi *X, mpi *A, mpi *B );
* \brief Unsigned substraction: X = |A| - |B|
*
* \return 0 if successful,
* XYSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
* POLARSSL_ERR_MPI_NEGATIVE_VALUE if B is greater than A
*/
int mpi_sub_abs( mpi *X, mpi *A, mpi *B );
......@@ -301,7 +301,7 @@ int mpi_mul_int( mpi *X, mpi *A, t_int b );
*
* \return 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
*
* \note Either Q or R can be NULL.
*/
......@@ -312,7 +312,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, mpi *A, mpi *B );
*
* \return 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
*
* \note Either Q or R can be NULL.
*/
......@@ -323,7 +323,7 @@ int mpi_div_int( mpi *Q, mpi *R, mpi *A, int b );
*
* \return 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_mod_mpi( mpi *R, mpi *A, mpi *B );
......@@ -332,7 +332,7 @@ int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
*
* \return 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_mod_int( t_int *r, mpi *A, int b );
......@@ -341,7 +341,7 @@ int mpi_mod_int( t_int *r, mpi *A, int b );
*
* \return 0 if successful,
* 1 if memory allocation failed,
* XYSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even
*
* \note _RR is used to avoid re-computing R*R mod N across
* multiple calls, which speeds up things a bit. It can
......@@ -362,8 +362,8 @@ int mpi_gcd( mpi *G, mpi *A, mpi *B );
*
* \return 0 if successful,
* 1 if memory allocation failed,
* XYSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
* XYSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
* POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
*/
int mpi_inv_mod( mpi *X, mpi *A, mpi *N );
......@@ -372,7 +372,7 @@ int mpi_inv_mod( mpi *X, mpi *A, mpi *N );
*
* \return 0 if successful (probably prime),
* 1 if memory allocation failed,
* XYSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime
* POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime
*/
int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
......@@ -387,7 +387,7 @@ int mpi_is_prime( mpi *X, int (*f_rng)(void *), void *p_rng );
*
* \return 0 if successful (probably prime),
* 1 if memory allocation failed,
* XYSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
* POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
*/
int mpi_gen_prime( mpi *X, int nbits, int dh_flag,
int (*f_rng)(void *), void *p_rng );
......
......@@ -15,12 +15,12 @@
* . Alpha . MIPS32
* . C, longlong . C, generic
*/
#ifndef XYSSL_BN_MUL_H
#define XYSSL_BN_MUL_H
#ifndef POLARSSL_BN_MUL_H
#define POLARSSL_BN_MUL_H
#include "polarssl/config.h"
#if defined(XYSSL_HAVE_ASM)
#if defined(POLARSSL_HAVE_ASM)
#if defined(__GNUC__)
#if defined(__i386__)
......@@ -42,7 +42,7 @@
asm( "movl %edx, %ecx " ); \
asm( "stosl " );
#if defined(XYSSL_HAVE_SSE2)
#if defined(POLARSSL_HAVE_SSE2)
#define MULADDC_HUIT \
asm( "movd %ecx, %mm1 " ); \
......@@ -565,7 +565,7 @@
__asm mov ecx, edx \
__asm stosd
#if defined(XYSSL_HAVE_SSE2)
#if defined(POLARSSL_HAVE_SSE2)
#define EMIT __asm _emit
......@@ -648,10 +648,10 @@
#endif /* SSE2 */
#endif /* MSVC */
#endif /* XYSSL_HAVE_ASM */
#endif /* POLARSSL_HAVE_ASM */
#if !defined(MULADDC_CORE)
#if defined(XYSSL_HAVE_LONGLONG)
#if defined(POLARSSL_HAVE_LONGLONG)
#define MULADDC_INIT \
{ \
......
/**
* \file certs.h
*/
#ifndef XYSSL_CERTS_H
#define XYSSL_CERTS_H
#ifndef POLARSSL_CERTS_H
#define POLARSSL_CERTS_H
#ifdef __cplusplus
extern "C" {
......
......@@ -5,8 +5,8 @@
* or disable features selectively, and reduce the global
* memory footprint.
*/
#ifndef XYSSL_CONFIG_H
#define XYSSL_CONFIG_H
#ifndef POLARSSL_CONFIG_H
#define POLARSSL_CONFIG_H
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE 1
......@@ -15,51 +15,51 @@
/*
* Uncomment if native integers are 8-bit wide.
*
#define XYSSL_HAVE_INT8
#define POLARSSL_HAVE_INT8
*/
/*
* Uncomment if native integers are 16-bit wide.
*
#define XYSSL_HAVE_INT16
#define POLARSSL_HAVE_INT16
*/
/*
* Uncomment if the compiler supports long long.
*
#define XYSSL_HAVE_LONGLONG
#define POLARSSL_HAVE_LONGLONG
*/
/*
* Uncomment to enable the use of assembly code.
*/
#define XYSSL_HAVE_ASM
#define POLARSSL_HAVE_ASM
/*
* Uncomment if the CPU supports SSE2 (IA-32 specific).
*
#define XYSSL_HAVE_SSE2
#define POLARSSL_HAVE_SSE2
*/
/*
* Enable all SSL/TLS debugging messages.
*/
#define XYSSL_DEBUG_MSG
#define POLARSSL_DEBUG_MSG
/*
* Enable the checkup functions (*_self_test).
*/
#define XYSSL_SELF_TEST
#define POLARSSL_SELF_TEST
/*
* Enable the prime-number generation code.
*/
#define XYSSL_GENPRIME
#define POLARSSL_GENPRIME
/*
* Uncomment this macro to store the AES tables in ROM.
*
#define XYSSL_AES_ROM_TABLES
#define POLARSSL_AES_ROM_TABLES
*/
/*
......@@ -71,7 +71,7 @@
* SSL_RSA_AES_256_SHA
* SSL_EDH_RSA_AES_256_SHA
*/
#define XYSSL_AES_C
#define POLARSSL_AES_C
/*
* Module: library/arc4.c
......@@ -81,7 +81,7 @@
* SSL_RSA_RC4_128_MD5
* SSL_RSA_RC4_128_SHA
*/
#define XYSSL_ARC4_C
#define POLARSSL_ARC4_C
/*
* Module: library/base64.c
......@@ -89,7 +89,7 @@
*
* This module is required for X.509 support.
*/
#define XYSSL_BASE64_C
#define POLARSSL_BASE64_C
/*
* Module: library/bignum.c
......@@ -100,7 +100,7 @@
*
* This module is required for RSA and DHM support.
*/
#define XYSSL_BIGNUM_C
#define POLARSSL_BIGNUM_C
/*
* Module: library/certs.c
......@@ -108,7 +108,7 @@
*
* This module is used for testing (ssl_client/server).
*/
#define XYSSL_CERTS_C
#define POLARSSL_CERTS_C
/*
* Module: library/debug.c
......@@ -118,7 +118,7 @@
*
* This module provides debugging functions.
*/
#define XYSSL_DEBUG_C
#define POLARSSL_DEBUG_C
/*
* Module: library/des.c
......@@ -128,7 +128,7 @@
* SSL_RSA_DES_168_SHA
* SSL_EDH_RSA_DES_168_SHA
*/
#define XYSSL_DES_C
#define POLARSSL_DES_C
/*
* Module: library/dhm.c
......@@ -139,7 +139,7 @@
* SSL_EDH_RSA_DES_168_SHA
* SSL_EDH_RSA_AES_256_SHA
*/
#define XYSSL_DHM_C
#define POLARSSL_DHM_C
/*
* Module: library/havege.c
......@@ -147,7 +147,7 @@
*
* This module enables the HAVEGE random number generator.
*/
#define XYSSL_HAVEGE_C
#define POLARSSL_HAVEGE_C
/*
* Module: library/md2.c
......@@ -155,7 +155,7 @@
*
* Uncomment to enable support for (rare) MD2-signed X.509 certs.
*
#define XYSSL_MD2_C
#define POLARSSL_MD2_C
*/
/*
......@@ -164,7 +164,7 @@
*
* Uncomment to enable support for (rare) MD4-signed X.509 certs.
*
#define XYSSL_MD4_C
#define POLARSSL_MD4_C
*/
/*
......@@ -174,7 +174,7 @@
*
* This module is required for SSL/TLS and X.509.
*/
#define XYSSL_MD5_C
#define POLARSSL_MD5_C
/*
* Module: library/net.c
......@@ -182,7 +182,7 @@
*
* This module provides TCP/IP networking routines.
*/
#define XYSSL_NET_C
#define POLARSSL_NET_C
/*
* Module: library/padlock.c
......@@ -190,7 +190,7 @@
*
* This modules adds support for the VIA PadLock on x86.
*/
#define XYSSL_PADLOCK_C
#define POLARSSL_PADLOCK_C
/*
* Module: library/rsa.c
......@@ -201,7 +201,7 @@
*
* This module is required for SSL/TLS and MD5-signed certificates.
*/
#define XYSSL_RSA_C
#define POLARSSL_RSA_C
/*
* Module: library/sha1.c
......@@ -212,7 +212,7 @@
*
* This module is required for SSL/TLS and SHA1-signed certificates.
*/
#define XYSSL_SHA1_C
#define POLARSSL_SHA1_C
/*
* Module: library/sha2.c
......@@ -220,7 +220,7 @@
*
* This module adds support for SHA-224 and SHA-256.
*/
#define XYSSL_SHA2_C
#define POLARSSL_SHA2_C
/*
* Module: library/sha4.c
......@@ -228,7 +228,7 @@
*
* This module adds support for SHA-384 and SHA-512.
*/
#define XYSSL_SHA4_C
#define POLARSSL_SHA4_C
/*
* Module: library/ssl_cli.c
......@@ -236,7 +236,7 @@
*
* This module is required for SSL/TLS client support.
*/
#define XYSSL_SSL_CLI_C
#define POLARSSL_SSL_CLI_C
/*
* Module: library/ssl_srv.c
......@@ -244,7 +244,7 @@
*
* This module is required for SSL/TLS server support.
*/
#define XYSSL_SSL_SRV_C
#define POLARSSL_SSL_SRV_C
/*
* Module: library/ssl_tls.c
......@@ -253,7 +253,7 @@
*
* This module is required for SSL/TLS.
*/
#define XYSSL_SSL_TLS_C
#define POLARSSL_SSL_TLS_C
/*
* Module: library/timing.c
......@@ -261,7 +261,7 @@
*
* This module is used by the HAVEGE random number generator.
*/
#define XYSSL_TIMING_C
#define POLARSSL_TIMING_C
/*
* Module: library/x509parse.c
......@@ -271,7 +271,7 @@
*
* This module is required for X.509 certificate parsing.
*/
#define XYSSL_X509_PARSE_C
#define POLARSSL_X509_PARSE_C
/*
* Module: library/x509_write.c
......@@ -279,6 +279,6 @@
*
* This module is required for X.509 certificate writing.
*/
#define XYSSL_X509_WRITE_C
#define POLARSSL_X509_WRITE_C
#endif /* config.h */
......@@ -7,7 +7,7 @@
#include "polarssl/config.h"
#include "polarssl/ssl.h"
#if defined(XYSSL_DEBUG_MSG)
#if defined(POLARSSL_DEBUG_MSG)
#define SSL_DEBUG_MSG( level, args ) \
debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
......
/**
* \file des.h
*/
#ifndef XYSSL_DES_H
#define XYSSL_DES_H
#ifndef POLARSSL_DES_H
#define POLARSSL_DES_H
#define DES_ENCRYPT 1
#define DES_DECRYPT 0
......
/**
* \file dhm.h
*/
#ifndef XYSSL_DHM_H
#define XYSSL_DHM_H
#ifndef POLARSSL_DHM_H
#define POLARSSL_DHM_H
#include "polarssl/bignum.h"
#define XYSSL_ERR_DHM_BAD_INPUT_DATA -0x0480
#define XYSSL_ERR_DHM_READ_PARAMS_FAILED -0x0490
#define XYSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x04A0
#define XYSSL_ERR_DHM_READ_PUBLIC_FAILED -0x04B0
#define XYSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x04C0
#define XYSSL_ERR_DHM_CALC_SECRET_FAILED -0x04D0
#define POLARSSL_ERR_DHM_BAD_INPUT_DATA -0x0480
#define POLARSSL_ERR_DHM_READ_PARAMS_FAILED -0x0490
#define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x04A0
#define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED -0x04B0
#define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x04C0
#define POLARSSL_ERR_DHM_CALC_SECRET_FAILED -0x04D0
typedef struct
{
......@@ -37,7 +37,7 @@ extern "C" {
* \param p &(start of input buffer)
* \param end end of buffer
*
* \return 0 if successful, or an XYSSL_ERR_DHM_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_read_params( dhm_context *ctx,
unsigned char **p,
......@@ -57,7 +57,7 @@ int dhm_read_params( dhm_context *ctx,
* have already been properly set (for example
* using mpi_read_string or mpi_read_binary).
*
* \return 0 if successful, or an XYSSL_ERR_DHM_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_make_params( dhm_context *ctx, int s_size,
unsigned char *output, int *olen,
......@@ -70,7 +70,7 @@ int dhm_make_params( dhm_context *ctx, int s_size,
* \param input input buffer
* \param ilen size of buffer
*
* \return 0 if successful, or an XYSSL_ERR_DHM_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_read_public( dhm_context *ctx,
unsigned char *input, int ilen );
......@@ -85,7 +85,7 @@ int dhm_read_public( dhm_context *ctx,
* \param f_rng RNG function
* \param p_rng RNG parameter
*
* \return 0 if successful, or an XYSSL_ERR_DHM_XXX error code
* \return 0 if successful, or an POLARSSL_ERR_DHM_XXX error code
*/
int dhm_make_public( dhm_context *ctx, int s_size,