1104476Ssam/*	$FreeBSD: stable/10/sys/opencrypto/xform.h 314327 2017-02-27 08:27:38Z avg $	*/
2104476Ssam/*	$OpenBSD: xform.h,v 1.8 2001/08/28 12:20:43 ben Exp $	*/
3104476Ssam
4139825Simp/*-
5104476Ssam * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
6104476Ssam *
7104476Ssam * This code was written by Angelos D. Keromytis in Athens, Greece, in
8104476Ssam * February 2000. Network Security Technologies Inc. (NSTI) kindly
9104476Ssam * supported the development of this code.
10104476Ssam *
11104476Ssam * Copyright (c) 2000 Angelos D. Keromytis
12104476Ssam *
13104476Ssam * Permission to use, copy, and modify this software without fee
14104476Ssam * is hereby granted, provided that this entire notice is included in
15104476Ssam * all source code copies of any software which is or includes a copy or
16104476Ssam * modification of this software.
17104476Ssam *
18104476Ssam * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
19104476Ssam * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
20104476Ssam * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
21104476Ssam * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
22104476Ssam * PURPOSE.
23104476Ssam */
24104476Ssam
25104476Ssam#ifndef _CRYPTO_XFORM_H_
26104476Ssam#define _CRYPTO_XFORM_H_
27104476Ssam
28104476Ssam#include <sys/md5.h>
29104476Ssam#include <crypto/sha1.h>
30314327Savg#include <crypto/sha2/sha256.h>
31314327Savg#include <crypto/sha2/sha384.h>
32314327Savg#include <crypto/sha2/sha512.h>
33104476Ssam#include <opencrypto/rmd160.h>
34104476Ssam
35104476Ssam/* Declarations */
36104476Ssamstruct auth_hash {
37104476Ssam	int type;
38104476Ssam	char *name;
39104476Ssam	u_int16_t keysize;
40104476Ssam	u_int16_t hashsize;
41158703Spjd	u_int16_t blocksize;
42104476Ssam	u_int16_t ctxsize;
43104476Ssam	void (*Init) (void *);
44104476Ssam	int  (*Update) (void *, u_int8_t *, u_int16_t);
45104476Ssam	void (*Final) (u_int8_t *, void *);
46104476Ssam};
47104476Ssam
48219026Svanhu/* XXX use a define common with other hash stuff ! */
49219026Svanhu#define	AH_ALEN_MAX	64	/* max authenticator hash length */
50104476Ssam
51104476Ssamstruct enc_xform {
52104476Ssam	int type;
53104476Ssam	char *name;
54104476Ssam	u_int16_t blocksize;
55104476Ssam	u_int16_t minkey, maxkey;
56104476Ssam	void (*encrypt) (caddr_t, u_int8_t *);
57104476Ssam	void (*decrypt) (caddr_t, u_int8_t *);
58104476Ssam	int (*setkey) (u_int8_t **, u_int8_t *, int len);
59104476Ssam	void (*zerokey) (u_int8_t **);
60213068Spjd	void (*reinit) (caddr_t, u_int8_t *);
61104476Ssam};
62104476Ssam
63104476Ssamstruct comp_algo {
64104476Ssam	int type;
65104476Ssam	char *name;
66104476Ssam	size_t minlen;
67104476Ssam	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
68104476Ssam	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
69104476Ssam};
70104476Ssam
71104476Ssamunion authctx {
72104476Ssam	MD5_CTX md5ctx;
73104476Ssam	SHA1_CTX sha1ctx;
74104476Ssam	RMD160_CTX rmd160ctx;
75104476Ssam	SHA256_CTX sha256ctx;
76104476Ssam	SHA384_CTX sha384ctx;
77104476Ssam	SHA512_CTX sha512ctx;
78104476Ssam};
79104476Ssam
80104476Ssamextern struct enc_xform enc_xform_null;
81104476Ssamextern struct enc_xform enc_xform_des;
82104476Ssamextern struct enc_xform enc_xform_3des;
83104476Ssamextern struct enc_xform enc_xform_blf;
84104476Ssamextern struct enc_xform enc_xform_cast5;
85104476Ssamextern struct enc_xform enc_xform_skipjack;
86104476Ssamextern struct enc_xform enc_xform_rijndael128;
87213068Spjdextern struct enc_xform enc_xform_aes_xts;
88104476Ssamextern struct enc_xform enc_xform_arc4;
89169425Sgnnextern struct enc_xform enc_xform_camellia;
90104476Ssam
91104476Ssamextern struct auth_hash auth_hash_null;
92104476Ssamextern struct auth_hash auth_hash_key_md5;
93104476Ssamextern struct auth_hash auth_hash_key_sha1;
94158703Spjdextern struct auth_hash auth_hash_hmac_md5;
95158703Spjdextern struct auth_hash auth_hash_hmac_sha1;
96158703Spjdextern struct auth_hash auth_hash_hmac_ripemd_160;
97104476Ssamextern struct auth_hash auth_hash_hmac_sha2_256;
98104476Ssamextern struct auth_hash auth_hash_hmac_sha2_384;
99104476Ssamextern struct auth_hash auth_hash_hmac_sha2_512;
100104476Ssam
101104476Ssamextern struct comp_algo comp_algo_deflate;
102104476Ssam
103104476Ssam#ifdef _KERNEL
104104476Ssam#include <sys/malloc.h>
105104476SsamMALLOC_DECLARE(M_XDATA);
106104476Ssam#endif
107104476Ssam#endif /* _CRYPTO_XFORM_H_ */
108