xref: /dragonfly/sys/opencrypto/xform.h (revision 7d84b73d)
1 /*	$FreeBSD: src/sys/opencrypto/xform.h,v 1.4 2007/05/09 19:37:02 gnn Exp $	*/
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  *
13  * Permission to use, copy, and modify this software without fee
14  * is hereby granted, provided that this entire notice is included in
15  * all source code copies of any software which is or includes a copy or
16  * modification of this software.
17  *
18  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
19  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
20  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
21  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
22  * PURPOSE.
23  */
24 
25 #ifndef _CRYPTO_XFORM_H_
26 #define _CRYPTO_XFORM_H_
27 
28 #include <sys/md5.h>
29 #include <crypto/sha1.h>
30 #include <crypto/sha2/sha2.h>
31 #include <opencrypto/rmd160.h>
32 #include <opencrypto/gmac.h>
33 
34 /* Declarations */
35 struct auth_hash {
36 	int type;
37 	char *name;
38 	u_int16_t keysize;
39 	u_int16_t hashsize;
40 	u_int16_t blocksize;
41 	u_int16_t ctxsize;
42 	void (*Init) (void *);
43 	int  (*Setkey) (void *, const u_int8_t *, u_int16_t);
44 	void (*Reinit) (void *, const u_int8_t *, u_int16_t);
45 	int  (*Update) (void *, u_int8_t *, u_int16_t);
46 	void (*Final) (u_int8_t *, void *);
47 };
48 
49 #define	AH_ALEN_MAX	20	/* max authenticator hash length */
50 
51 struct enc_xform {
52 	int type;
53 	char *name;
54 	u_int16_t blocksize;
55 	u_int16_t ivsize;
56 	u_int16_t minkey;
57 	u_int16_t maxkey;
58 	u_int16_t ctxsize;
59 	void (*encrypt) (caddr_t, u_int8_t *, u_int8_t *);
60 	void (*decrypt) (caddr_t, u_int8_t *, u_int8_t *);
61 	int (*setkey) (void *, u_int8_t *, int);
62 	void (*reinit) (caddr_t, u_int8_t *);
63 };
64 
65 struct comp_algo {
66 	int type;
67 	char *name;
68 	size_t minlen;
69 	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
70 	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
71 };
72 
73 union authctx {
74 	MD5_CTX md5ctx;
75 	SHA1_CTX sha1ctx;
76 	RMD160_CTX rmd160ctx;
77 	SHA256_CTX sha256ctx;
78 	SHA384_CTX sha384ctx;
79 	SHA512_CTX sha512ctx;
80 	AES_GMAC_CTX	aes_gmac_ctx;
81 };
82 
83 extern struct enc_xform enc_xform_null;
84 extern struct enc_xform enc_xform_des;
85 extern struct enc_xform enc_xform_3des;
86 extern struct enc_xform enc_xform_blf;
87 extern struct enc_xform enc_xform_cast5;
88 extern struct enc_xform enc_xform_skipjack;
89 extern struct enc_xform enc_xform_rijndael128;
90 extern struct enc_xform enc_xform_aes_xts;
91 extern struct enc_xform enc_xform_aes_ctr;
92 extern struct enc_xform enc_xform_aes_gcm;
93 extern struct enc_xform enc_xform_aes_gmac;
94 extern struct enc_xform enc_xform_arc4;
95 extern struct enc_xform enc_xform_camellia;
96 extern struct enc_xform enc_xform_twofish;
97 extern struct enc_xform enc_xform_serpent;
98 extern struct enc_xform enc_xform_twofish_xts;
99 extern struct enc_xform enc_xform_serpent_xts;
100 
101 extern struct auth_hash auth_hash_null;
102 extern struct auth_hash auth_hash_key_md5;
103 extern struct auth_hash auth_hash_key_sha1;
104 extern struct auth_hash auth_hash_hmac_md5;
105 extern struct auth_hash auth_hash_hmac_sha1;
106 extern struct auth_hash auth_hash_hmac_ripemd_160;
107 extern struct auth_hash auth_hash_hmac_sha2_256;
108 extern struct auth_hash auth_hash_hmac_sha2_384;
109 extern struct auth_hash auth_hash_hmac_sha2_512;
110 extern struct auth_hash auth_hash_gmac_aes_128;
111 extern struct auth_hash auth_hash_gmac_aes_192;
112 extern struct auth_hash auth_hash_gmac_aes_256;
113 
114 extern struct comp_algo comp_algo_deflate;
115 
116 #ifdef MALLOC_DECLARE
117 MALLOC_DECLARE(M_XDATA);
118 #endif
119 #endif /* _CRYPTO_XFORM_H_ */
120