umac.h revision 181111
1183234Ssimon/* $OpenBSD: umac.h,v 1.1 2007/06/07 19:37:34 pvalchev Exp $ */ 2280304Sjkim/* ----------------------------------------------------------------------- 3280304Sjkim * 4183234Ssimon * umac.h -- C Implementation UMAC Message Authentication 5183234Ssimon * 6183234Ssimon * Version 0.93a of rfc4418.txt -- 2006 July 14 7183234Ssimon * 8183234Ssimon * For a full description of UMAC message authentication see the UMAC 9183234Ssimon * world-wide-web page at http://www.cs.ucdavis.edu/~rogaway/umac 10183234Ssimon * Please report bugs and suggestions to the UMAC webpage. 11183234Ssimon * 12183234Ssimon * Copyright (c) 1999-2004 Ted Krovetz 13183234Ssimon * 14280304Sjkim * Permission to use, copy, modify, and distribute this software and 15183234Ssimon * its documentation for any purpose and with or without fee, is hereby 16183234Ssimon * granted provided that the above copyright notice appears in all copies 17183234Ssimon * and in supporting documentation, and that the name of the copyright 18183234Ssimon * holder not be used in advertising or publicity pertaining to 19183234Ssimon * distribution of the software without specific, written prior permission. 20183234Ssimon * 21183234Ssimon * Comments should be directed to Ted Krovetz (tdk@acm.org) 22183234Ssimon * 23183234Ssimon * ---------------------------------------------------------------------- */ 24183234Ssimon 25183234Ssimon /* ////////////////////// IMPORTANT NOTES ///////////////////////////////// 26183234Ssimon * 27183234Ssimon * 1) This version does not work properly on messages larger than 16MB 28183234Ssimon * 29183234Ssimon * 2) If you set the switch to use SSE2, then all data must be 16-byte 30183234Ssimon * aligned 31183234Ssimon * 32183234Ssimon * 3) When calling the function umac(), it is assumed that msg is in 33183234Ssimon * a writable buffer of length divisible by 32 bytes. The message itself 34183234Ssimon * does not have to fill the entire buffer, but bytes beyond msg may be 35183234Ssimon * zeroed. 36183234Ssimon * 37183234Ssimon * 4) Two free AES implementations are supported by this implementation of 38183234Ssimon * UMAC. Paulo Barreto's version is in the public domain and can be found 39183234Ssimon * at http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ (search for 40183234Ssimon * "Barreto"). The only two files needed are rijndael-alg-fst.c and 41183234Ssimon * rijndael-alg-fst.h. 42183234Ssimon * Brian Gladman's version is distributed with GNU Public lisence 43183234Ssimon * and can be found at http://fp.gladman.plus.com/AES/index.htm. It 44183234Ssimon * includes a fast IA-32 assembly version. 45183234Ssimon * 46183234Ssimon /////////////////////////////////////////////////////////////////////// */ 47183234Ssimon#ifndef HEADER_UMAC_H 48183234Ssimon#define HEADER_UMAC_H 49183234Ssimon 50183234Ssimon 51183234Ssimon#ifdef __cplusplus 52183234Ssimon extern "C" { 53183234Ssimon#endif 54183234Ssimon 55183234Ssimonstruct umac_ctx *umac_new(u_char key[]); 56183234Ssimon/* Dynamically allocate a umac_ctx struct, initialize variables, 57183234Ssimon * generate subkeys from key. 58183234Ssimon */ 59183234Ssimon 60183234Ssimon#if 0 61183234Ssimonint umac_reset(struct umac_ctx *ctx); 62280304Sjkim/* Reset a umac_ctx to begin authenicating a new message */ 63183234Ssimon#endif 64280304Sjkim 65183234Ssimonint umac_update(struct umac_ctx *ctx, u_char *input, long len); 66280304Sjkim/* Incorporate len bytes pointed to by input into context ctx */ 67183234Ssimon 68280304Sjkimint umac_final(struct umac_ctx *ctx, u_char tag[], u_char nonce[8]); 69280304Sjkim/* Incorporate any pending data and the ctr value, and return tag. 70280304Sjkim * This function returns error code if ctr < 0. 71183234Ssimon */ 72280304Sjkim 73183234Ssimonint umac_delete(struct umac_ctx *ctx); 74238405Sjkim/* Deallocate the context structure */ 75238405Sjkim 76238405Sjkim#if 0 77238405Sjkimint umac(struct umac_ctx *ctx, u_char *input, 78238405Sjkim long len, u_char tag[], 79238405Sjkim u_char nonce[8]); 80238405Sjkim/* All-in-one implementation of the functions Reset, Update and Final */ 81238405Sjkim#endif 82238405Sjkim 83238405Sjkim/* uhash.h */ 84238405Sjkim 85238405Sjkim 86280304Sjkim#if 0 87238405Sjkimtypedef struct uhash_ctx *uhash_ctx_t; 88238405Sjkim /* The uhash_ctx structure is defined by the implementation of the */ 89280304Sjkim /* UHASH functions. */ 90280304Sjkim 91280304Sjkimuhash_ctx_t uhash_alloc(u_char key[16]); 92280304Sjkim /* Dynamically allocate a uhash_ctx struct and generate subkeys using */ 93238405Sjkim /* the kdf and kdf_key passed in. If kdf_key_len is 0 then RC6 is */ 94238405Sjkim /* used to generate key with a fixed key. If kdf_key_len > 0 but kdf */ 95238405Sjkim /* is NULL then the first 16 bytes pointed at by kdf_key is used as a */ 96280304Sjkim /* key for an RC6 based KDF. */ 97280304Sjkim 98183234Ssimonint uhash_free(uhash_ctx_t ctx); 99183234Ssimon 100280304Sjkimint uhash_set_params(uhash_ctx_t ctx, 101280304Sjkim void *params); 102280304Sjkim 103183234Ssimonint uhash_reset(uhash_ctx_t ctx); 104280304Sjkim 105280304Sjkimint uhash_update(uhash_ctx_t ctx, 106280304Sjkim u_char *input, 107183234Ssimon long len); 108280304Sjkim 109280304Sjkimint uhash_final(uhash_ctx_t ctx, 110280304Sjkim u_char ouput[]); 111206046Ssimon 112280304Sjkimint uhash(uhash_ctx_t ctx, 113280304Sjkim u_char *input, 114280304Sjkim long len, 115183234Ssimon u_char output[]); 116280304Sjkim 117280304Sjkim#endif 118183234Ssimon 119183234Ssimon#ifdef __cplusplus 120183234Ssimon } 121183234Ssimon#endif 122183234Ssimon 123183234Ssimon#endif /* HEADER_UMAC_H */ 124183234Ssimon