Added mechanism to provide alternative cipher / hash implementations
All symmetric cipher algorithms and hash algorithms now include support for a POLARSSL_XXX_ALT flag that prevents the definition of the algorithm context structure and all 'core' functions.
This commit is contained in:
parent
9691bbe9b3
commit
4087c47043
27 changed files with 331 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FIPS-197 compliant AES implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include "polarssl/padlock.h"
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_AES_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
*/
|
||||
|
@ -914,6 +916,7 @@ int aes_crypt_ctr( aes_context *ctx,
|
|||
return( 0 );
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
#endif /* !POLARSSL_AES_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* An implementation of the ARCFOUR algorithm
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "polarssl/arc4.h"
|
||||
|
||||
#if !defined(POLARSSL_ARC4_ALT)
|
||||
|
||||
/*
|
||||
* ARC4 key schedule
|
||||
*/
|
||||
|
@ -95,6 +97,8 @@ int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input,
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_ARC4_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Blowfish implementation
|
||||
*
|
||||
* Copyright (C) 2012-2012, Brainspark B.V.
|
||||
* Copyright (C) 2012-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "polarssl/blowfish.h"
|
||||
|
||||
#if !defined(POLARSSL_BLOWFISH_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -626,4 +628,5 @@ static const uint32_t S[4][256] = {
|
|||
0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L }
|
||||
};
|
||||
|
||||
#endif /* !POLARSSL_BLOWFISH_ALT */
|
||||
#endif /* POLARSSL_BLOWFISH_C */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Camellia implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "polarssl/camellia.h"
|
||||
|
||||
#if !defined(POLARSSL_CAMELLIA_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -656,6 +658,7 @@ int camellia_crypt_ctr( camellia_context *ctx,
|
|||
return( 0 );
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
#endif /* !POLARSSL_CAMELLIA_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FIPS-46-3 compliant Triple-DES implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "polarssl/des.h"
|
||||
|
||||
#if !defined(POLARSSL_DES_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -751,6 +753,8 @@ int des3_crypt_cbc( des3_context *ctx,
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_DES_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* RFC 1115/1319 compliant MD2 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -39,6 +39,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_MD2_ALT)
|
||||
|
||||
static const unsigned char PI_SUBST[256] =
|
||||
{
|
||||
0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36,
|
||||
|
@ -163,6 +165,8 @@ void md2_finish( md2_context *ctx, unsigned char output[16] )
|
|||
memcpy( output, ctx->state, 16 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_MD2_ALT */
|
||||
|
||||
/*
|
||||
* output = MD2( input buffer )
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* RFC 1186/1320 compliant MD4 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -39,6 +39,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_MD4_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
*/
|
||||
|
@ -259,6 +261,8 @@ void md4_finish( md4_context *ctx, unsigned char output[16] )
|
|||
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_MD4_ALT */
|
||||
|
||||
/*
|
||||
* output = MD4( input buffer )
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* RFC 1321 compliant MD5 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_MD5_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
*/
|
||||
|
@ -276,6 +278,8 @@ void md5_finish( md5_context *ctx, unsigned char output[16] )
|
|||
PUT_UINT32_LE( ctx->state[3], output, 12 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_MD5_ALT */
|
||||
|
||||
/*
|
||||
* output = MD5( input buffer )
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FIPS-180-1 compliant SHA-1 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_SHA1_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -309,6 +311,8 @@ void sha1_finish( sha1_context *ctx, unsigned char output[20] )
|
|||
PUT_UINT32_BE( ctx->state[4], output, 16 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_SHA1_ALT */
|
||||
|
||||
/*
|
||||
* output = SHA-1( input buffer )
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FIPS-180-2 compliant SHA-256 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_SHA2_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -310,6 +312,8 @@ void sha2_finish( sha2_context *ctx, unsigned char output[32] )
|
|||
PUT_UINT32_BE( ctx->state[7], output, 28 );
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_SHA2_ALT */
|
||||
|
||||
/*
|
||||
* output = SHA-256( input buffer )
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* FIPS-180-2 compliant SHA-384/512 implementation
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_SHA4_ALT)
|
||||
|
||||
/*
|
||||
* 64-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -308,6 +310,8 @@ void sha4_finish( sha4_context *ctx, unsigned char output[64] )
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* !POLARSSL_SHA4_ALT */
|
||||
|
||||
/*
|
||||
* output = SHA-512( input buffer )
|
||||
*/
|
||||
|
|
|
@ -2547,11 +2547,15 @@ static void ssl_calc_finished_ssl(
|
|||
* SHA1( handshake + sender + master + pad1 ) )
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_MD5_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished md5 state", (unsigned char *)
|
||||
md5.state, sizeof( md5.state ) );
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_SHA1_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished sha1 state", (unsigned char *)
|
||||
sha1.state, sizeof( sha1.state ) );
|
||||
#endif
|
||||
|
||||
sender = ( from == SSL_IS_CLIENT ) ? "CLNT"
|
||||
: "SRVR";
|
||||
|
@ -2618,11 +2622,15 @@ static void ssl_calc_finished_tls(
|
|||
* MD5( handshake ) + SHA1( handshake ) )[0..11]
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_MD5_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished md5 state", (unsigned char *)
|
||||
md5.state, sizeof( md5.state ) );
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_SHA1_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished sha1 state", (unsigned char *)
|
||||
sha1.state, sizeof( sha1.state ) );
|
||||
#endif
|
||||
|
||||
sender = ( from == SSL_IS_CLIENT )
|
||||
? "client finished"
|
||||
|
@ -2666,8 +2674,10 @@ static void ssl_calc_finished_tls_sha256(
|
|||
* Hash( handshake ) )[0.11]
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_SHA2_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished sha2 state", (unsigned char *)
|
||||
sha2.state, sizeof( sha2.state ) );
|
||||
#endif
|
||||
|
||||
sender = ( from == SSL_IS_CLIENT )
|
||||
? "client finished"
|
||||
|
@ -2710,8 +2720,10 @@ static void ssl_calc_finished_tls_sha384(
|
|||
* Hash( handshake ) )[0.11]
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_SHA4_ALT)
|
||||
SSL_DEBUG_BUF( 4, "finished sha4 state", (unsigned char *)
|
||||
sha4.state, sizeof( sha4.state ) );
|
||||
#endif
|
||||
|
||||
sender = ( from == SSL_IS_CLIENT )
|
||||
? "client finished"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* An 32-bit implementation of the XTEA algorithm
|
||||
*
|
||||
* Copyright (C) 2006-2010, Brainspark B.V.
|
||||
* Copyright (C) 2006-2013, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "polarssl/xtea.h"
|
||||
|
||||
#if !defined(POLARSSL_XTEA_ALT)
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
|
@ -160,6 +162,7 @@ int xtea_crypt_cbc( xtea_context *ctx,
|
|||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* !POLARSSL_XTEA_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue