xref: /netbsd/crypto/external/bsd/openssh/dist/umac.h (revision 6550d01e)
1 /*	$NetBSD: umac.h,v 1.2 2009/06/07 22:38:48 christos Exp $	*/
2 /* $OpenBSD: umac.h,v 1.1 2007/06/07 19:37:34 pvalchev Exp $ */
3 /* -----------------------------------------------------------------------
4  *
5  * umac.h -- C Implementation UMAC Message Authentication
6  *
7  * Version 0.93a of rfc4418.txt -- 2006 July 14
8  *
9  * For a full description of UMAC message authentication see the UMAC
10  * world-wide-web page at http://www.cs.ucdavis.edu/~rogaway/umac
11  * Please report bugs and suggestions to the UMAC webpage.
12  *
13  * Copyright (c) 1999-2004 Ted Krovetz
14  *
15  * Permission to use, copy, modify, and distribute this software and
16  * its documentation for any purpose and with or without fee, is hereby
17  * granted provided that the above copyright notice appears in all copies
18  * and in supporting documentation, and that the name of the copyright
19  * holder not be used in advertising or publicity pertaining to
20  * distribution of the software without specific, written prior permission.
21  *
22  * Comments should be directed to Ted Krovetz (tdk@acm.org)
23  *
24  * ---------------------------------------------------------------------- */
25 
26  /* ////////////////////// IMPORTANT NOTES /////////////////////////////////
27   *
28   * 1) This version does not work properly on messages larger than 16MB
29   *
30   * 2) If you set the switch to use SSE2, then all data must be 16-byte
31   *    aligned
32   *
33   * 3) When calling the function umac(), it is assumed that msg is in
34   * a writable buffer of length divisible by 32 bytes. The message itself
35   * does not have to fill the entire buffer, but bytes beyond msg may be
36   * zeroed.
37   *
38   * 4) Two free AES implementations are supported by this implementation of
39   * UMAC. Paulo Barreto's version is in the public domain and can be found
40   * at http://www.esat.kuleuven.ac.be/~rijmen/rijndael/ (search for
41   * "Barreto"). The only two files needed are rijndael-alg-fst.c and
42   * rijndael-alg-fst.h.
43   * Brian Gladman's version is distributed with GNU Public lisence
44   * and can be found at http://fp.gladman.plus.com/AES/index.htm. It
45   * includes a fast IA-32 assembly version.
46   *
47   /////////////////////////////////////////////////////////////////////// */
48 #ifndef HEADER_UMAC_H
49 #define HEADER_UMAC_H
50 
51 
52 #ifdef __cplusplus
53     extern "C" {
54 #endif
55 
56 struct umac_ctx *umac_new(u_char key[]);
57 /* Dynamically allocate a umac_ctx struct, initialize variables,
58  * generate subkeys from key.
59  */
60 
61 #if 0
62 int umac_reset(struct umac_ctx *ctx);
63 /* Reset a umac_ctx to begin authenicating a new message */
64 #endif
65 
66 int umac_update(struct umac_ctx *ctx, u_char *input, long len);
67 /* Incorporate len bytes pointed to by input into context ctx */
68 
69 int umac_final(struct umac_ctx *ctx, u_char tag[], u_char nonce[8]);
70 /* Incorporate any pending data and the ctr value, and return tag.
71  * This function returns error code if ctr < 0.
72  */
73 
74 int umac_delete(struct umac_ctx *ctx);
75 /* Deallocate the context structure */
76 
77 #if 0
78 int umac(struct umac_ctx *ctx, u_char *input,
79          long len, u_char tag[],
80          u_char nonce[8]);
81 /* All-in-one implementation of the functions Reset, Update and Final */
82 #endif
83 
84 /* uhash.h */
85 
86 
87 #if 0
88 typedef struct uhash_ctx *uhash_ctx_t;
89   /* The uhash_ctx structure is defined by the implementation of the    */
90   /* UHASH functions.                                                   */
91 
92 uhash_ctx_t uhash_alloc(u_char key[16]);
93   /* Dynamically allocate a uhash_ctx struct and generate subkeys using */
94   /* the kdf and kdf_key passed in. If kdf_key_len is 0 then RC6 is     */
95   /* used to generate key with a fixed key. If kdf_key_len > 0 but kdf  */
96   /* is NULL then the first 16 bytes pointed at by kdf_key is used as a */
97   /* key for an RC6 based KDF.                                          */
98 
99 int uhash_free(uhash_ctx_t ctx);
100 
101 int uhash_set_params(uhash_ctx_t ctx,
102                    void       *params);
103 
104 int uhash_reset(uhash_ctx_t ctx);
105 
106 int uhash_update(uhash_ctx_t ctx,
107                u_char       *input,
108                long        len);
109 
110 int uhash_final(uhash_ctx_t ctx,
111               u_char        ouput[]);
112 
113 int uhash(uhash_ctx_t ctx,
114         u_char       *input,
115         long        len,
116         u_char        output[]);
117 
118 #endif
119 
120 #ifdef __cplusplus
121     }
122 #endif
123 
124 #endif /* HEADER_UMAC_H */
125