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
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* \brief SHA-224 and SHA-256 cryptographic hash function
|
||||
*
|
||||
* 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>
|
||||
|
@ -27,6 +27,8 @@
|
|||
#ifndef POLARSSL_SHA2_H
|
||||
#define POLARSSL_SHA2_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -38,6 +40,10 @@ typedef UINT32 uint32_t;
|
|||
|
||||
#define POLARSSL_ERR_SHA2_FILE_IO_ERROR -0x0078 /**< Read/write error in file. */
|
||||
|
||||
#if !defined(POLARSSL_SHA2_ALT)
|
||||
// Regular implementation
|
||||
//
|
||||
|
||||
/**
|
||||
* \brief SHA-256 context structure
|
||||
*/
|
||||
|
@ -82,6 +88,21 @@ void sha2_update( sha2_context *ctx, const unsigned char *input, size_t ilen );
|
|||
*/
|
||||
void sha2_finish( sha2_context *ctx, unsigned char output[32] );
|
||||
|
||||
/* Internal use */
|
||||
void sha2_process( sha2_context *ctx, const unsigned char data[64] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* POLARSSL_SHA2_ALT */
|
||||
#include "sha2_alt.h"
|
||||
#endif /* POLARSSL_SHA2_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Output = SHA-256( input buffer )
|
||||
*
|
||||
|
@ -160,9 +181,6 @@ void sha2_hmac( const unsigned char *key, size_t keylen,
|
|||
*/
|
||||
int sha2_self_test( int verbose );
|
||||
|
||||
/* Internal use */
|
||||
void sha2_process( sha2_context *ctx, const unsigned char data[64] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue