hmacsha.c revision c1d7e0562f6a72ecc07ab5140cf2b88183adbd08
/*
* Copyright (C) 2005-2007 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: hmacsha.c,v 1.9 2009/02/06 12:26:23 fdupont Exp $ */
/*
* This code implements the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384
* and HMAC-SHA512 keyed hash algorithm described in RFC 2104 and
*/
#include "config.h"
#include <isc/assertions.h>
#include <isc/platform.h>
#ifdef ISC_PLATFORM_OPENSSLHASH
void
unsigned int len)
{
}
void
}
void
unsigned int len)
{
}
void
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
}
void
unsigned int len)
{
}
void
}
void
unsigned int len)
{
}
void
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
}
void
unsigned int len)
{
}
void
}
void
unsigned int len)
{
}
void
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
}
void
unsigned int len)
{
}
void
}
void
unsigned int len)
{
}
void
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
}
void
unsigned int len)
{
}
void
}
void
unsigned int len)
{
}
void
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
}
#else
#define IPAD 0x36
#define OPAD 0x5C
/*
* Start HMAC-SHA1 process. Initialize an sha1 context and digest the key.
*/
void
unsigned int len)
{
unsigned char ipad[ISC_SHA1_BLOCK_LENGTH];
unsigned int i;
} else
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
}
void
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*
* Compute signature - finalize SHA1 operation and reapply SHA1.
*/
void
unsigned char opad[ISC_SHA1_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
unsigned int i;
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
}
/*
* Start HMAC-SHA224 process. Initialize an sha224 context and digest the key.
*/
void
unsigned int len)
{
unsigned char ipad[ISC_SHA224_BLOCK_LENGTH];
unsigned int i;
} else
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
}
void
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*
* Compute signature - finalize SHA224 operation and reapply SHA224.
*/
void
unsigned char opad[ISC_SHA224_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
unsigned int i;
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
}
/*
* Start HMAC-SHA256 process. Initialize an sha256 context and digest the key.
*/
void
unsigned int len)
{
unsigned char ipad[ISC_SHA256_BLOCK_LENGTH];
unsigned int i;
} else
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
}
void
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*
* Compute signature - finalize SHA256 operation and reapply SHA256.
*/
void
unsigned char opad[ISC_SHA256_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
unsigned int i;
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
}
/*
* Start HMAC-SHA384 process. Initialize an sha384 context and digest the key.
*/
void
unsigned int len)
{
unsigned char ipad[ISC_SHA384_BLOCK_LENGTH];
unsigned int i;
} else
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
}
void
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*
* Compute signature - finalize SHA384 operation and reapply SHA384.
*/
void
unsigned char opad[ISC_SHA384_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
unsigned int i;
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
}
/*
* Start HMAC-SHA512 process. Initialize an sha512 context and digest the key.
*/
void
unsigned int len)
{
unsigned char ipad[ISC_SHA512_BLOCK_LENGTH];
unsigned int i;
} else
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)
}
void
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*
* Compute signature - finalize SHA512 operation and reapply SHA512.
*/
void
unsigned char opad[ISC_SHA512_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
unsigned int i;
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)
}
#endif /* !ISC_PLATFORM_OPENSSLHASH */
/*
* Verify signature - finalize SHA1 operation and reapply SHA1, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
}
/*
* Verify signature - finalize SHA224 operation and reapply SHA224, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
}
/*
* Verify signature - finalize SHA256 operation and reapply SHA256, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
}
/*
* Verify signature - finalize SHA384 operation and reapply SHA384, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
}
/*
* Verify signature - finalize SHA512 operation and reapply SHA512, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
}