xref: /freebsd/sys/opencrypto/xform.h (revision 39ee7a7a6bdd1557b1c3532abf60d139798ac88b)
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_H_
32 #define _CRYPTO_XFORM_H_
33 
34 #include <sys/md5.h>
35 #include <crypto/sha1.h>
36 #include <crypto/sha2/sha2.h>
37 #include <opencrypto/rmd160.h>
38 #include <opencrypto/gmac.h>
39 
40 /* Declarations */
41 struct auth_hash {
42 	int type;
43 	char *name;
44 	u_int16_t keysize;
45 	u_int16_t hashsize;
46 	u_int16_t ctxsize;
47 	u_int16_t blocksize;
48 	void (*Init) (void *);
49 	void (*Setkey) (void *, const u_int8_t *, u_int16_t);
50 	void (*Reinit) (void *, const u_int8_t *, u_int16_t);
51 	int  (*Update) (void *, const u_int8_t *, u_int16_t);
52 	void (*Final) (u_int8_t *, void *);
53 };
54 
55 /* XXX use a define common with other hash stuff ! */
56 #define	AH_ALEN_MAX	64	/* max authenticator hash length */
57 
58 struct enc_xform {
59 	int type;
60 	char *name;
61 	u_int16_t blocksize;
62 	u_int16_t ivsize;
63 	u_int16_t minkey, maxkey;
64 	void (*encrypt) (caddr_t, u_int8_t *);
65 	void (*decrypt) (caddr_t, u_int8_t *);
66 	int (*setkey) (u_int8_t **, u_int8_t *, int len);
67 	void (*zerokey) (u_int8_t **);
68 	void (*reinit) (caddr_t, u_int8_t *);
69 };
70 
71 struct comp_algo {
72 	int type;
73 	char *name;
74 	size_t minlen;
75 	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
76 	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
77 };
78 
79 union authctx {
80 	MD5_CTX md5ctx;
81 	SHA1_CTX sha1ctx;
82 	RMD160_CTX rmd160ctx;
83 	SHA256_CTX sha256ctx;
84 	SHA384_CTX sha384ctx;
85 	SHA512_CTX sha512ctx;
86 	struct aes_gmac_ctx aes_gmac_ctx;
87 };
88 
89 extern struct enc_xform enc_xform_null;
90 extern struct enc_xform enc_xform_des;
91 extern struct enc_xform enc_xform_3des;
92 extern struct enc_xform enc_xform_blf;
93 extern struct enc_xform enc_xform_cast5;
94 extern struct enc_xform enc_xform_skipjack;
95 extern struct enc_xform enc_xform_rijndael128;
96 extern struct enc_xform enc_xform_aes_icm;
97 extern struct enc_xform enc_xform_aes_nist_gcm;
98 extern struct enc_xform enc_xform_aes_nist_gmac;
99 extern struct enc_xform enc_xform_aes_xts;
100 extern struct enc_xform enc_xform_arc4;
101 extern struct enc_xform enc_xform_camellia;
102 
103 extern struct auth_hash auth_hash_null;
104 extern struct auth_hash auth_hash_key_md5;
105 extern struct auth_hash auth_hash_key_sha1;
106 extern struct auth_hash auth_hash_hmac_md5;
107 extern struct auth_hash auth_hash_hmac_sha1;
108 extern struct auth_hash auth_hash_hmac_ripemd_160;
109 extern struct auth_hash auth_hash_hmac_sha2_256;
110 extern struct auth_hash auth_hash_hmac_sha2_384;
111 extern struct auth_hash auth_hash_hmac_sha2_512;
112 extern struct auth_hash auth_hash_nist_gmac_aes_128;
113 extern struct auth_hash auth_hash_nist_gmac_aes_192;
114 extern struct auth_hash auth_hash_nist_gmac_aes_256;
115 
116 extern struct comp_algo comp_algo_deflate;
117 
118 #ifdef _KERNEL
119 #include <sys/malloc.h>
120 MALLOC_DECLARE(M_XDATA);
121 #endif
122 #endif /* _CRYPTO_XFORM_H_ */
123