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