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