xref: /openbsd/sys/crypto/xform.h (revision 91f110e0)
1 /*	$OpenBSD: xform.h,v 1.23 2013/08/25 14:26:56 jsing Exp $	*/
2 
3 /*
4  * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
5  *
6  * This code was written by Angelos D. Keromytis in Athens, Greece, in
7  * February 2000. Network Security Technologies Inc. (NSTI) kindly
8  * supported the development of this code.
9  *
10  * Copyright (c) 2000 Angelos D. Keromytis
11  *
12  * Permission to use, copy, and modify this software with or without fee
13  * is hereby granted, provided that this entire notice is included in
14  * all source code copies of any software which is or includes a copy or
15  * modification of this software.
16  *
17  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
18  * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
19  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
20  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
21  * PURPOSE.
22  */
23 
24 #ifndef _CRYPTO_XFORM_H_
25 #define _CRYPTO_XFORM_H_
26 
27 #include <crypto/md5.h>
28 #include <crypto/sha1.h>
29 #include <crypto/rmd160.h>
30 #include <crypto/sha2.h>
31 #include <crypto/gmac.h>
32 
33 /* Declarations */
34 struct auth_hash {
35 	int type;
36 	char *name;
37 	u_int16_t keysize;
38 	u_int16_t hashsize;
39 	u_int16_t authsize;
40 	u_int16_t ctxsize;
41 	u_int16_t blocksize;
42 	void (*Init) (void *);
43 	void (*Setkey) (void *, const u_int8_t *, u_int16_t);
44 	void (*Reinit) (void *, const u_int8_t *, u_int16_t);
45 	int  (*Update) (void *, const u_int8_t *, u_int16_t);
46 	void (*Final) (u_int8_t *, void *);
47 };
48 
49 struct enc_xform {
50 	int type;
51 	char *name;
52 	u_int16_t blocksize;
53 	u_int16_t ivsize;
54 	u_int16_t minkey;
55 	u_int16_t maxkey;
56 	u_int16_t ctxsize;
57 	void (*encrypt) (caddr_t, u_int8_t *);
58 	void (*decrypt) (caddr_t, u_int8_t *);
59 	int  (*setkey) (void *, u_int8_t *, int len);
60 	void (*reinit) (caddr_t, u_int8_t *);
61 };
62 
63 struct comp_algo {
64 	int type;
65 	char *name;
66 	size_t minlen;
67 	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
68 	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
69 };
70 
71 union authctx {
72 	MD5_CTX md5ctx;
73 	SHA1_CTX sha1ctx;
74 	RMD160_CTX rmd160ctx;
75 	SHA2_CTX sha2_ctx;
76 	AES_GMAC_CTX aes_gmac_ctx;
77 };
78 
79 extern struct enc_xform enc_xform_des;
80 extern struct enc_xform enc_xform_3des;
81 extern struct enc_xform enc_xform_blf;
82 extern struct enc_xform enc_xform_cast5;
83 extern struct enc_xform enc_xform_rijndael128;
84 extern struct enc_xform enc_xform_aes_ctr;
85 extern struct enc_xform enc_xform_aes_gcm;
86 extern struct enc_xform enc_xform_aes_gmac;
87 extern struct enc_xform enc_xform_aes_xts;
88 extern struct enc_xform enc_xform_arc4;
89 extern struct enc_xform enc_xform_null;
90 
91 extern struct auth_hash auth_hash_md5;
92 extern struct auth_hash auth_hash_sha1;
93 extern struct auth_hash auth_hash_key_md5;
94 extern struct auth_hash auth_hash_key_sha1;
95 extern struct auth_hash auth_hash_hmac_md5_96;
96 extern struct auth_hash auth_hash_hmac_sha1_96;
97 extern struct auth_hash auth_hash_hmac_ripemd_160_96;
98 extern struct auth_hash auth_hash_hmac_sha2_256_128;
99 extern struct auth_hash auth_hash_hmac_sha2_384_192;
100 extern struct auth_hash auth_hash_hmac_sha2_512_256;
101 extern struct auth_hash auth_hash_gmac_aes_128;
102 extern struct auth_hash auth_hash_gmac_aes_192;
103 extern struct auth_hash auth_hash_gmac_aes_256;
104 
105 extern struct comp_algo comp_algo_deflate;
106 extern struct comp_algo comp_algo_lzs;
107 
108 #endif /* _CRYPTO_XFORM_H_ */
109