1 /* $OpenBSD: umac.h,v 1.3 2013/07/22 12:20:02 djm Exp $ */
2 /* -----------------------------------------------------------------------
4 * umac.h -- C Implementation UMAC Message Authentication
6 * Version 0.93a of rfc4418.txt -- 2006 July 14
8 * For a full description of UMAC message authentication see the UMAC
9 * world-wide-web page at http://www.cs.ucdavis.edu/~rogaway/umac
10 * Please report bugs and suggestions to the UMAC webpage.
12 * Copyright (c) 1999-2004 Ted Krovetz
14 * Permission to use, copy, modify, and distribute this software and
15 * its documentation for any purpose and with or without fee, is hereby
16 * granted provided that the above copyright notice appears in all copies
17 * and in supporting documentation, and that the name of the copyright
18 * holder not be used in advertising or publicity pertaining to
19 * distribution of the software without specific, written prior permission.
21 * Comments should be directed to Ted Krovetz (tdk@acm.org)
23 * ---------------------------------------------------------------------- */
25 /* ////////////////////// IMPORTANT NOTES /////////////////////////////////
27 * 1) This version does not work properly on messages larger than 16MB
29 * 2) If you set the switch to use SSE2, then all data must be 16-byte
32 * 3) When calling the function umac(), it is assumed that msg is in
33 * a writable buffer of length divisible by 32 bytes. The message itself
34 * does not have to fill the entire buffer, but bytes beyond msg may be
37 * 4) Two free AES implementations are supported by this implementation of
38 * UMAC. Paulo Barreto's version is in the public domain and can be found
39 * at http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ (search for
40 * "Barreto"). The only two files needed are rijndael-alg-fst.c and
42 * Brian Gladman's version is distributed with GNU Public lisence
43 * and can be found at http://fp.gladman.plus.com/AES/index.htm. It
44 * includes a fast IA-32 assembly version.
46 /////////////////////////////////////////////////////////////////////// */
55 struct umac_ctx
*umac_new(const u_char key
[]);
56 /* Dynamically allocate a umac_ctx struct, initialize variables,
57 * generate subkeys from key.
61 int umac_reset(struct umac_ctx
*ctx
);
62 /* Reset a umac_ctx to begin authenicating a new message */
65 int umac_update(struct umac_ctx
*ctx
, const u_char
*input
, long len
);
66 /* Incorporate len bytes pointed to by input into context ctx */
68 int umac_final(struct umac_ctx
*ctx
, u_char tag
[], const u_char nonce
[8]);
69 /* Incorporate any pending data and the ctr value, and return tag.
70 * This function returns error code if ctr < 0.
73 int umac_delete(struct umac_ctx
*ctx
);
74 /* Deallocate the context structure */
77 int umac(struct umac_ctx
*ctx
, u_char
*input
,
78 long len
, u_char tag
[],
80 /* All-in-one implementation of the functions Reset, Update and Final */
87 typedef struct uhash_ctx
*uhash_ctx_t
;
88 /* The uhash_ctx structure is defined by the implementation of the */
89 /* UHASH functions. */
91 uhash_ctx_t
uhash_alloc(u_char key
[16]);
92 /* Dynamically allocate a uhash_ctx struct and generate subkeys using */
93 /* the kdf and kdf_key passed in. If kdf_key_len is 0 then RC6 is */
94 /* used to generate key with a fixed key. If kdf_key_len > 0 but kdf */
95 /* is NULL then the first 16 bytes pointed at by kdf_key is used as a */
96 /* key for an RC6 based KDF. */
98 int uhash_free(uhash_ctx_t ctx
);
100 int uhash_set_params(uhash_ctx_t ctx
,
103 int uhash_reset(uhash_ctx_t ctx
);
105 int uhash_update(uhash_ctx_t ctx
,
109 int uhash_final(uhash_ctx_t ctx
,
112 int uhash(uhash_ctx_t ctx
,
119 /* matching umac-128 API, we reuse umac_ctx, since it's opaque */
120 struct umac_ctx
*umac128_new(const u_char key
[]);
121 int umac128_update(struct umac_ctx
*ctx
, const u_char
*input
, long len
);
122 int umac128_final(struct umac_ctx
*ctx
, u_char tag
[], const u_char nonce
[8]);
123 int umac128_delete(struct umac_ctx
*ctx
);
129 #endif /* HEADER_UMAC_H */