1/*	$FreeBSD: stable/10/sys/opencrypto/xform.h 314327 2017-02-27 08:27:38Z avg $	*/
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/sha256.h>
31#include <crypto/sha2/sha384.h>
32#include <crypto/sha2/sha512.h>
33#include <opencrypto/rmd160.h>
34
35/* Declarations */
36struct auth_hash {
37	int type;
38	char *name;
39	u_int16_t keysize;
40	u_int16_t hashsize;
41	u_int16_t blocksize;
42	u_int16_t ctxsize;
43	void (*Init) (void *);
44	int  (*Update) (void *, u_int8_t *, u_int16_t);
45	void (*Final) (u_int8_t *, void *);
46};
47
48/* XXX use a define common with other hash stuff ! */
49#define	AH_ALEN_MAX	64	/* max authenticator hash length */
50
51struct enc_xform {
52	int type;
53	char *name;
54	u_int16_t blocksize;
55	u_int16_t minkey, maxkey;
56	void (*encrypt) (caddr_t, u_int8_t *);
57	void (*decrypt) (caddr_t, u_int8_t *);
58	int (*setkey) (u_int8_t **, u_int8_t *, int len);
59	void (*zerokey) (u_int8_t **);
60	void (*reinit) (caddr_t, u_int8_t *);
61};
62
63struct 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
71union authctx {
72	MD5_CTX md5ctx;
73	SHA1_CTX sha1ctx;
74	RMD160_CTX rmd160ctx;
75	SHA256_CTX sha256ctx;
76	SHA384_CTX sha384ctx;
77	SHA512_CTX sha512ctx;
78};
79
80extern struct enc_xform enc_xform_null;
81extern struct enc_xform enc_xform_des;
82extern struct enc_xform enc_xform_3des;
83extern struct enc_xform enc_xform_blf;
84extern struct enc_xform enc_xform_cast5;
85extern struct enc_xform enc_xform_skipjack;
86extern struct enc_xform enc_xform_rijndael128;
87extern struct enc_xform enc_xform_aes_xts;
88extern struct enc_xform enc_xform_arc4;
89extern struct enc_xform enc_xform_camellia;
90
91extern struct auth_hash auth_hash_null;
92extern struct auth_hash auth_hash_key_md5;
93extern struct auth_hash auth_hash_key_sha1;
94extern struct auth_hash auth_hash_hmac_md5;
95extern struct auth_hash auth_hash_hmac_sha1;
96extern struct auth_hash auth_hash_hmac_ripemd_160;
97extern struct auth_hash auth_hash_hmac_sha2_256;
98extern struct auth_hash auth_hash_hmac_sha2_384;
99extern struct auth_hash auth_hash_hmac_sha2_512;
100
101extern struct comp_algo comp_algo_deflate;
102
103#ifdef _KERNEL
104#include <sys/malloc.h>
105MALLOC_DECLARE(M_XDATA);
106#endif
107#endif /* _CRYPTO_XFORM_H_ */
108