From 30c8e19de7c76ce038e435e8d57071df97526b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 11 Jul 2014 13:54:22 +0000 Subject: [PATCH] Remove HMAC-MD2 and HMAC-MD4. They may or may not reappear at a later date in libcryb-mac. --- include/cryb/md2.h | 42 ---------------------------- include/cryb/md4.h | 42 ---------------------------- lib/digest/md2.c | 69 ---------------------------------------------- lib/digest/md4.c | 69 ---------------------------------------------- 4 files changed, 222 deletions(-) diff --git a/include/cryb/md2.h b/include/cryb/md2.h index ecb89f1..f9aac1c 100644 --- a/include/cryb/md2.h +++ b/include/cryb/md2.h @@ -54,9 +54,6 @@ typedef struct unsigned char cksum[16]; /*!< checksum of the data block */ unsigned char state[48]; /*!< intermediate digest state */ unsigned char buffer[16]; /*!< data block being processed */ - - unsigned char ipad[64]; /*!< HMAC: inner padding */ - unsigned char opad[64]; /*!< HMAC: outer padding */ int left; /*!< amount of data in buffer */ } md2_ctx; @@ -97,45 +94,6 @@ void md2_final( md2_ctx *ctx, unsigned char output[16] ); */ void md2_complete( const void *input, int ilen, unsigned char output[16] ); -/** - * \brief MD2 HMAC context setup - * - * \param ctx HMAC context to be initialized - * \param key HMAC secret key - * \param keylen length of the HMAC key - */ -void md2_hmac_init( md2_ctx *ctx, unsigned char *key, int keylen ); - -/** - * \brief MD2 HMAC process buffer - * - * \param ctx HMAC context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md2_hmac_update( md2_ctx *ctx, unsigned char *input, int ilen ); - -/** - * \brief MD2 HMAC final digest - * - * \param ctx HMAC context - * \param output MD2 HMAC checksum result - */ -void md2_hmac_final( md2_ctx *ctx, unsigned char output[16] ); - -/** - * \brief Output = HMAC-MD2( hmac key, input buffer ) - * - * \param key HMAC secret key - * \param keylen length of the HMAC key - * \param input buffer holding the data - * \param ilen length of the input data - * \param output HMAC-MD2 result - */ -void md2_hmac_complete( unsigned char *key, int keylen, - unsigned char *input, int ilen, - unsigned char output[16] ); - #ifdef __cplusplus } #endif diff --git a/include/cryb/md4.h b/include/cryb/md4.h index 1a5ff81..b48d7ee 100644 --- a/include/cryb/md4.h +++ b/include/cryb/md4.h @@ -54,9 +54,6 @@ typedef struct unsigned long total[2]; /*!< number of bytes processed */ unsigned long state[4]; /*!< intermediate digest state */ unsigned char buffer[64]; /*!< data block being processed */ - - unsigned char ipad[64]; /*!< HMAC: inner padding */ - unsigned char opad[64]; /*!< HMAC: outer padding */ } md4_ctx; @@ -97,45 +94,6 @@ void md4_final( md4_ctx *ctx, unsigned char output[16] ); */ void md4_complete( const void *input, int ilen, unsigned char output[16] ); -/** - * \brief MD4 HMAC context setup - * - * \param ctx HMAC context to be initialized - * \param key HMAC secret key - * \param keylen length of the HMAC key - */ -void md4_hmac_init( md4_ctx *ctx, unsigned char *key, int keylen ); - -/** - * \brief MD4 HMAC process buffer - * - * \param ctx HMAC context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md4_hmac_update( md4_ctx *ctx, unsigned char *input, int ilen ); - -/** - * \brief MD4 HMAC final digest - * - * \param ctx HMAC context - * \param output MD4 HMAC checksum result - */ -void md4_hmac_final( md4_ctx *ctx, unsigned char output[16] ); - -/** - * \brief Output = HMAC-MD4( hmac key, input buffer ) - * - * \param key HMAC secret key - * \param keylen length of the HMAC key - * \param input buffer holding the data - * \param ilen length of the input data - * \param output HMAC-MD4 result - */ -void md4_hmac_complete( unsigned char *key, int keylen, - unsigned char *input, int ilen, - unsigned char output[16] ); - #ifdef __cplusplus } #endif diff --git a/lib/digest/md2.c b/lib/digest/md2.c index 2320e5a..5a83745 100644 --- a/lib/digest/md2.c +++ b/lib/digest/md2.c @@ -176,75 +176,6 @@ void md2_complete( const void *input, int ilen, unsigned char *output ) memset( &ctx, 0, sizeof( md2_ctx ) ); } -/* - * MD2 HMAC context setup - */ -void md2_hmac_init( md2_ctx *ctx, unsigned char *key, int keylen ) -{ - int i; - unsigned char sum[MD2_DIGEST_LEN]; - - if( keylen > 64 ) - { - md2_complete( key, keylen, sum ); - keylen = sizeof sum; - key = sum; - } - - memset( ctx->ipad, 0x36, sizeof ctx->ipad ); - memset( ctx->opad, 0x5C, sizeof ctx->opad ); - - for( i = 0; i < keylen; i++ ) - { - ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); - ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); - } - - md2_init( ctx ); - md2_update( ctx, ctx->ipad, sizeof ctx->ipad ); - - memset( sum, 0, sizeof( sum ) ); -} - -/* - * MD2 HMAC process buffer - */ -void md2_hmac_update( md2_ctx *ctx, unsigned char *input, int ilen ) -{ - md2_update( ctx, input, ilen ); -} - -/* - * MD2 HMAC final digest - */ -void md2_hmac_final( md2_ctx *ctx, unsigned char *output ) -{ - unsigned char tmpbuf[MD2_DIGEST_LEN]; - - md2_final( ctx, tmpbuf ); - md2_init( ctx ); - md2_update( ctx, ctx->opad, sizeof ctx->opad ); - md2_update( ctx, tmpbuf, sizeof tmpbuf ); - md2_final( ctx, output ); - - memset( tmpbuf, 0, sizeof( tmpbuf ) ); -} - -/* - * output = HMAC-MD2( hmac key, input buffer ) - */ -void md2_hmac_complete( unsigned char *key, int keylen, unsigned char *input, int ilen, - unsigned char *output ) -{ - md2_ctx ctx; - - md2_hmac_init( &ctx, key, keylen ); - md2_hmac_update( &ctx, input, ilen ); - md2_hmac_final( &ctx, output ); - - memset( &ctx, 0, sizeof( md2_ctx ) ); -} - digest_algorithm md2_algorithm = { .name = "md2", .contextlen = sizeof(md2_ctx), diff --git a/lib/digest/md4.c b/lib/digest/md4.c index 552f54a..6f14ef8 100644 --- a/lib/digest/md4.c +++ b/lib/digest/md4.c @@ -275,75 +275,6 @@ void md4_complete( const void *input, int ilen, unsigned char *output ) memset( &ctx, 0, sizeof( md4_ctx ) ); } -/* - * MD4 HMAC context setup - */ -void md4_hmac_init( md4_ctx *ctx, unsigned char *key, int keylen ) -{ - int i; - unsigned char sum[16]; - - if( keylen > 64 ) - { - md4_complete( key, keylen, sum ); - keylen = 16; - key = sum; - } - - memset( ctx->ipad, 0x36, 64 ); - memset( ctx->opad, 0x5C, 64 ); - - for( i = 0; i < keylen; i++ ) - { - ctx->ipad[i] = (unsigned char)( ctx->ipad[i] ^ key[i] ); - ctx->opad[i] = (unsigned char)( ctx->opad[i] ^ key[i] ); - } - - md4_init( ctx ); - md4_update( ctx, ctx->ipad, 64 ); - - memset( sum, 0, sizeof( sum ) ); -} - -/* - * MD4 HMAC process buffer - */ -void md4_hmac_update( md4_ctx *ctx, unsigned char *input, int ilen ) -{ - md4_update( ctx, input, ilen ); -} - -/* - * MD4 HMAC final digest - */ -void md4_hmac_final( md4_ctx *ctx, unsigned char *output ) -{ - unsigned char tmpbuf[MD4_DIGEST_LEN]; - - md4_final( ctx, tmpbuf ); - md4_init( ctx ); - md4_update( ctx, ctx->opad, 64 ); - md4_update( ctx, tmpbuf, 16 ); - md4_final( ctx, output ); - - memset( tmpbuf, 0, sizeof( tmpbuf ) ); -} - -/* - * output = HMAC-MD4( hmac key, input buffer ) - */ -void md4_hmac_complete( unsigned char *key, int keylen, unsigned char *input, int ilen, - unsigned char output[16] ) -{ - md4_ctx ctx; - - md4_hmac_init( &ctx, key, keylen ); - md4_hmac_update( &ctx, input, ilen ); - md4_hmac_final( &ctx, output ); - - memset( &ctx, 0, sizeof( md4_ctx ) ); -} - digest_algorithm md4_algorithm = { .name = "md4", .contextlen = sizeof(md4_ctx),