hmacsha.c revision acbb301e648b82fcc38b876a44403cf0fe539cc9
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2005-2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
821644d49b73b49f2abc5463bc53a3132f612478Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
821644d49b73b49f2abc5463bc53a3132f612478Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt * PERFORMANCE OF THIS SOFTWARE.
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt * This code implements the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384
5a77e9620a0b2f7417469c98be374de49d0eccc6Andreas Gustafsson * and HMAC-SHA512 keyed hash algorithm described in RFC 2104 and
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyerisc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews unsigned int len)
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha1());
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Huntisc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt unsigned int len)
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Huntisc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
c5272fb3303425f794dab68f734f6a2a45dce01eMichael Sawyerisc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
c5272fb3303425f794dab68f734f6a2a45dce01eMichael Sawyer unsigned int len)
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha224());
c5272fb3303425f794dab68f734f6a2a45dce01eMichael Sawyerisc_hmacsha224_invalidate(isc_hmacsha224_t *ctx) {
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrewsisc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews unsigned int len)
7318bbc26262a66a0d740ceefed769961ef7e476Evan Huntisc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
de5890da9b87cb4b91aca033db0e25b1fdb68c77Evan Huntisc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
de5890da9b87cb4b91aca033db0e25b1fdb68c77Evan Hunt unsigned int len)
de5890da9b87cb4b91aca033db0e25b1fdb68c77Evan Hunt HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha256());
2c089bf6d24936de631a57b4958ba6b8b5e3b23dMark Andrewsisc_hmacsha256_invalidate(isc_hmacsha256_t *ctx) {
2c089bf6d24936de631a57b4958ba6b8b5e3b23dMark Andrewsisc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
2c089bf6d24936de631a57b4958ba6b8b5e3b23dMark Andrews unsigned int len)
948c80ffa8f4efbade049f49d9751675f6937cf4Tinderbox Userisc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
74717eef53ba5d6aefc80eb262bbb090ff4bb3b5Mark Andrews unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
unsigned int len)
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)
unsigned int len)
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)