xform_auth.h revision 139825
1104476Ssam/*	$FreeBSD: head/sys/opencrypto/xform.h 139825 2005-01-07 02:29:27Z imp $	*/
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>
30104476Ssam#include <crypto/sha2/sha2.h>
31104476Ssam#include <opencrypto/rmd160.h>
32104476Ssam
33104476Ssam/* Declarations */
34104476Ssamstruct auth_hash {
35104476Ssam	int type;
36104476Ssam	char *name;
37104476Ssam	u_int16_t keysize;
38104476Ssam	u_int16_t hashsize;
39104476Ssam	u_int16_t authsize;
40104476Ssam	u_int16_t ctxsize;
41104476Ssam	void (*Init) (void *);
42104476Ssam	int  (*Update) (void *, u_int8_t *, u_int16_t);
43104476Ssam	void (*Final) (u_int8_t *, void *);
44104476Ssam};
45104476Ssam
46104476Ssam#define	AH_ALEN_MAX	20	/* max authenticator hash length */
47104476Ssam
48104476Ssamstruct enc_xform {
49104476Ssam	int type;
50104476Ssam	char *name;
51104476Ssam	u_int16_t blocksize;
52104476Ssam	u_int16_t minkey, maxkey;
53104476Ssam	void (*encrypt) (caddr_t, u_int8_t *);
54104476Ssam	void (*decrypt) (caddr_t, u_int8_t *);
55104476Ssam	int (*setkey) (u_int8_t **, u_int8_t *, int len);
56104476Ssam	void (*zerokey) (u_int8_t **);
57104476Ssam};
58104476Ssam
59104476Ssamstruct comp_algo {
60104476Ssam	int type;
61104476Ssam	char *name;
62104476Ssam	size_t minlen;
63104476Ssam	u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
64104476Ssam	u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
65104476Ssam};
66104476Ssam
67104476Ssamunion authctx {
68104476Ssam	MD5_CTX md5ctx;
69104476Ssam	SHA1_CTX sha1ctx;
70104476Ssam	RMD160_CTX rmd160ctx;
71104476Ssam	SHA256_CTX sha256ctx;
72104476Ssam	SHA384_CTX sha384ctx;
73104476Ssam	SHA512_CTX sha512ctx;
74104476Ssam};
75104476Ssam
76104476Ssamextern struct enc_xform enc_xform_null;
77104476Ssamextern struct enc_xform enc_xform_des;
78104476Ssamextern struct enc_xform enc_xform_3des;
79104476Ssamextern struct enc_xform enc_xform_blf;
80104476Ssamextern struct enc_xform enc_xform_cast5;
81104476Ssamextern struct enc_xform enc_xform_skipjack;
82104476Ssamextern struct enc_xform enc_xform_rijndael128;
83104476Ssamextern struct enc_xform enc_xform_arc4;
84104476Ssam
85104476Ssamextern struct auth_hash auth_hash_null;
86104476Ssamextern struct auth_hash auth_hash_key_md5;
87104476Ssamextern struct auth_hash auth_hash_key_sha1;
88104476Ssamextern struct auth_hash auth_hash_hmac_md5_96;
89104476Ssamextern struct auth_hash auth_hash_hmac_sha1_96;
90104476Ssamextern struct auth_hash auth_hash_hmac_ripemd_160_96;
91104476Ssamextern struct auth_hash auth_hash_hmac_sha2_256;
92104476Ssamextern struct auth_hash auth_hash_hmac_sha2_384;
93104476Ssamextern struct auth_hash auth_hash_hmac_sha2_512;
94104476Ssam
95104476Ssamextern struct comp_algo comp_algo_deflate;
96104476Ssam
97104476Ssam#ifdef _KERNEL
98104476Ssam#include <sys/malloc.h>
99104476SsamMALLOC_DECLARE(M_XDATA);
100104476Ssam#endif
101104476Ssam#endif /* _CRYPTO_XFORM_H_ */
102