xref: /freebsd/sys/opencrypto/xform_auth.h (revision 36712a94975f5bd0d26c85377283b49a2369c82f)
1 /*	$FreeBSD$	*/
2 /*	$OpenBSD: xform.h,v 1.8 2001/08/28 12:20:43 ben Exp $	*/
3 
4 /*-
5  * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
6  *
7  * This code was written by Angelos D. Keromytis in Athens, Greece, in
8  * February 2000. Network Security Technologies Inc. (NSTI) kindly
9  * supported the development of this code.
10  *
11  * Copyright (c) 2000 Angelos D. Keromytis
12  * Copyright (c) 2014 The FreeBSD Foundation
13  * All rights reserved.
14  *
15  * Portions of this software were developed by John-Mark Gurney
16  * under sponsorship of the FreeBSD Foundation and
17  * Rubicon Communications, LLC (Netgate).
18  *
19  * Permission to use, copy, and modify this software without fee
20  * is hereby granted, provided that this entire notice is included in
21  * all source code copies of any software which is or includes a copy or
22  * modification of this software.
23  *
24  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
25  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
26  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
27  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
28  * PURPOSE.
29  */
30 
31 #ifndef _CRYPTO_XFORM_AUTH_H_
32 #define _CRYPTO_XFORM_AUTH_H_
33 
34 #include <sys/malloc.h>
35 #include <sys/errno.h>
36 
37 #include <sys/md5.h>
38 #include <crypto/sha1.h>
39 #include <crypto/sha2/sha224.h>
40 #include <crypto/sha2/sha256.h>
41 #include <crypto/sha2/sha384.h>
42 #include <crypto/sha2/sha512.h>
43 #include <opencrypto/rmd160.h>
44 #include <opencrypto/gmac.h>
45 #include <opencrypto/cbc_mac.h>
46 
47 #include <opencrypto/cryptodev.h>
48 #include <opencrypto/xform_userland.h>
49 
50 /* XXX use a define common with other hash stuff ! */
51 #define	AH_ALEN_MAX	64	/* max authenticator hash length */
52 
53 /* Declarations */
54 struct auth_hash {
55 	int type;
56 	char *name;
57 	u_int16_t keysize;
58 	u_int16_t hashsize;
59 	u_int16_t ctxsize;
60 	u_int16_t blocksize;
61 	void (*Init) (void *);
62 	void (*Setkey) (void *, const u_int8_t *, u_int16_t);
63 	void (*Reinit) (void *, const u_int8_t *, u_int16_t);
64 	int  (*Update) (void *, const u_int8_t *, u_int16_t);
65 	void (*Final) (u_int8_t *, void *);
66 };
67 
68 extern struct auth_hash auth_hash_null;
69 extern struct auth_hash auth_hash_key_md5;
70 extern struct auth_hash auth_hash_key_sha1;
71 extern struct auth_hash auth_hash_hmac_md5;
72 extern struct auth_hash auth_hash_hmac_sha1;
73 extern struct auth_hash auth_hash_hmac_ripemd_160;
74 extern struct auth_hash auth_hash_hmac_sha2_224;
75 extern struct auth_hash auth_hash_hmac_sha2_256;
76 extern struct auth_hash auth_hash_hmac_sha2_384;
77 extern struct auth_hash auth_hash_hmac_sha2_512;
78 extern struct auth_hash auth_hash_sha1;
79 extern struct auth_hash auth_hash_sha2_224;
80 extern struct auth_hash auth_hash_sha2_256;
81 extern struct auth_hash auth_hash_sha2_384;
82 extern struct auth_hash auth_hash_sha2_512;
83 extern struct auth_hash auth_hash_nist_gmac_aes_128;
84 extern struct auth_hash auth_hash_nist_gmac_aes_192;
85 extern struct auth_hash auth_hash_nist_gmac_aes_256;
86 extern struct auth_hash auth_hash_blake2b;
87 extern struct auth_hash auth_hash_blake2s;
88 extern struct auth_hash auth_hash_poly1305;
89 extern struct auth_hash auth_hash_ccm_cbc_mac_128;
90 extern struct auth_hash auth_hash_ccm_cbc_mac_192;
91 extern struct auth_hash auth_hash_ccm_cbc_mac_256;
92 
93 union authctx {
94 	MD5_CTX md5ctx;
95 	SHA1_CTX sha1ctx;
96 	RMD160_CTX rmd160ctx;
97 	SHA224_CTX sha224ctx;
98 	SHA256_CTX sha256ctx;
99 	SHA384_CTX sha384ctx;
100 	SHA512_CTX sha512ctx;
101 	struct aes_gmac_ctx aes_gmac_ctx;
102 	struct aes_cbc_mac_ctx aes_cbc_mac_ctx;
103 };
104 
105 #endif /* _CRYPTO_XFORM_AUTH_H_ */
106