1*04171cfcSAugustin Cavalier /* $OpenBSD: hmac.h,v 1.3 2012/12/05 23:20:15 deraadt Exp $ */ 2*04171cfcSAugustin Cavalier 3*04171cfcSAugustin Cavalier /*- 4*04171cfcSAugustin Cavalier * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> 5*04171cfcSAugustin Cavalier * 6*04171cfcSAugustin Cavalier * Permission to use, copy, modify, and distribute this software for any 7*04171cfcSAugustin Cavalier * purpose with or without fee is hereby granted, provided that the above 8*04171cfcSAugustin Cavalier * copyright notice and this permission notice appear in all copies. 9*04171cfcSAugustin Cavalier * 10*04171cfcSAugustin Cavalier * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11*04171cfcSAugustin Cavalier * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12*04171cfcSAugustin Cavalier * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13*04171cfcSAugustin Cavalier * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14*04171cfcSAugustin Cavalier * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15*04171cfcSAugustin Cavalier * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16*04171cfcSAugustin Cavalier * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17*04171cfcSAugustin Cavalier */ 18*04171cfcSAugustin Cavalier 19*04171cfcSAugustin Cavalier #ifndef _HMAC_H_ 20*04171cfcSAugustin Cavalier #define _HMAC_H_ 21*04171cfcSAugustin Cavalier 22*04171cfcSAugustin Cavalier typedef struct _HMAC_MD5_CTX { 23*04171cfcSAugustin Cavalier MD5_CTX ctx; 24*04171cfcSAugustin Cavalier u_int8_t key[MD5_BLOCK_LENGTH]; 25*04171cfcSAugustin Cavalier u_int key_len; 26*04171cfcSAugustin Cavalier } HMAC_MD5_CTX; 27*04171cfcSAugustin Cavalier 28*04171cfcSAugustin Cavalier typedef struct _HMAC_SHA1_CTX { 29*04171cfcSAugustin Cavalier SHA1_CTX ctx; 30*04171cfcSAugustin Cavalier u_int8_t key[SHA1_BLOCK_LENGTH]; 31*04171cfcSAugustin Cavalier u_int key_len; 32*04171cfcSAugustin Cavalier } HMAC_SHA1_CTX; 33*04171cfcSAugustin Cavalier 34*04171cfcSAugustin Cavalier typedef struct _HMAC_SHA256_CTX { 35*04171cfcSAugustin Cavalier SHA2_CTX ctx; 36*04171cfcSAugustin Cavalier u_int8_t key[SHA256_BLOCK_LENGTH]; 37*04171cfcSAugustin Cavalier u_int key_len; 38*04171cfcSAugustin Cavalier } HMAC_SHA256_CTX; 39*04171cfcSAugustin Cavalier 40*04171cfcSAugustin Cavalier __BEGIN_DECLS 41*04171cfcSAugustin Cavalier 42*04171cfcSAugustin Cavalier void HMAC_MD5_Init(HMAC_MD5_CTX *, const u_int8_t *, u_int) 43*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 44*04171cfcSAugustin Cavalier void HMAC_MD5_Update(HMAC_MD5_CTX *, const u_int8_t *, u_int) 45*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 46*04171cfcSAugustin Cavalier void HMAC_MD5_Final(u_int8_t [MD5_DIGEST_LENGTH], HMAC_MD5_CTX *) 47*04171cfcSAugustin Cavalier __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH))); 48*04171cfcSAugustin Cavalier 49*04171cfcSAugustin Cavalier void HMAC_SHA1_Init(HMAC_SHA1_CTX *, const u_int8_t *, u_int) 50*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 51*04171cfcSAugustin Cavalier void HMAC_SHA1_Update(HMAC_SHA1_CTX *, const u_int8_t *, u_int) 52*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 53*04171cfcSAugustin Cavalier void HMAC_SHA1_Final(u_int8_t [SHA1_DIGEST_LENGTH], HMAC_SHA1_CTX *) 54*04171cfcSAugustin Cavalier __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH))); 55*04171cfcSAugustin Cavalier 56*04171cfcSAugustin Cavalier void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const u_int8_t *, u_int) 57*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 58*04171cfcSAugustin Cavalier void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const u_int8_t *, u_int) 59*04171cfcSAugustin Cavalier __attribute__((__bounded__(__string__,2,3))); 60*04171cfcSAugustin Cavalier void HMAC_SHA256_Final(u_int8_t [SHA256_DIGEST_LENGTH], HMAC_SHA256_CTX *) 61*04171cfcSAugustin Cavalier __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH))); 62*04171cfcSAugustin Cavalier 63*04171cfcSAugustin Cavalier __END_DECLS 64*04171cfcSAugustin Cavalier 65*04171cfcSAugustin Cavalier #endif /* _HMAC_H_ */ 66