hmacsha.c revision ec5347e2c775f027573ce5648b910361aa926c01
/*
* Copyright (C) 2005, 2006 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.6 2007/06/18 23:47:44 tbox 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>
#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++)
}
/*
* Verify signature - finalize SHA1 operation and reapply SHA1, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
}
/*
* 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++)
}
/*
* Verify signature - finalize SHA224 operation and reapply SHA224, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
}
/*
* 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++)
}
/*
* Verify signature - finalize SHA256 operation and reapply SHA256, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
}
/*
* 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++)
}
/*
* Verify signature - finalize SHA384 operation and reapply SHA384, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
}
/*
* 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++)
}
/*
* Verify signature - finalize SHA512 operation and reapply SHA512, then
* compare to the supplied digest.
*/
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
}