xform.h revision 1.5.4.2 1 1.5.4.2 skrll /* $NetBSD: xform.h,v 1.5.4.2 2004/08/03 10:56:25 skrll Exp $ */
2 1.5.4.2 skrll /* $FreeBSD: src/sys/opencrypto/xform.h,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $ */
3 1.5.4.2 skrll /* $OpenBSD: xform.h,v 1.10 2002/04/22 23:10:09 deraadt Exp $ */
4 1.5.4.2 skrll
5 1.5.4.2 skrll /*
6 1.5.4.2 skrll * The author of this code is Angelos D. Keromytis (angelos (at) cis.upenn.edu)
7 1.5.4.2 skrll *
8 1.5.4.2 skrll * This code was written by Angelos D. Keromytis in Athens, Greece, in
9 1.5.4.2 skrll * February 2000. Network Security Technologies Inc. (NSTI) kindly
10 1.5.4.2 skrll * supported the development of this code.
11 1.5.4.2 skrll *
12 1.5.4.2 skrll * Copyright (c) 2000 Angelos D. Keromytis
13 1.5.4.2 skrll *
14 1.5.4.2 skrll * Permission to use, copy, and modify this software with or without fee
15 1.5.4.2 skrll * is hereby granted, provided that this entire notice is included in
16 1.5.4.2 skrll * all source code copies of any software which is or includes a copy or
17 1.5.4.2 skrll * modification of this software.
18 1.5.4.2 skrll *
19 1.5.4.2 skrll * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
20 1.5.4.2 skrll * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
21 1.5.4.2 skrll * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
22 1.5.4.2 skrll * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
23 1.5.4.2 skrll * PURPOSE.
24 1.5.4.2 skrll */
25 1.5.4.2 skrll
26 1.5.4.2 skrll #ifndef _CRYPTO_XFORM_H_
27 1.5.4.2 skrll #define _CRYPTO_XFORM_H_
28 1.5.4.2 skrll
29 1.5.4.2 skrll #include <sys/md5.h>
30 1.5.4.2 skrll #include <sys/sha1.h>
31 1.5.4.2 skrll #include <crypto/sha2/sha2.h>
32 1.5.4.2 skrll #include <crypto/ripemd160/rmd160.h>
33 1.5.4.2 skrll
34 1.5.4.2 skrll /* Declarations */
35 1.5.4.2 skrll struct auth_hash {
36 1.5.4.2 skrll int type;
37 1.5.4.2 skrll char *name;
38 1.5.4.2 skrll u_int16_t keysize;
39 1.5.4.2 skrll u_int16_t hashsize;
40 1.5.4.2 skrll u_int16_t authsize;
41 1.5.4.2 skrll u_int16_t ctxsize;
42 1.5.4.2 skrll void (*Init) (void *);
43 1.5.4.2 skrll int (*Update) (void *, const u_int8_t *, u_int16_t);
44 1.5.4.2 skrll void (*Final) (u_int8_t *, void *);
45 1.5.4.2 skrll };
46 1.5.4.2 skrll
47 1.5.4.2 skrll /* Provide array-limit for clients (e.g., netipsec) */
48 1.5.4.2 skrll #define AH_ALEN_MAX 20 /* max authenticator hash length */
49 1.5.4.2 skrll
50 1.5.4.2 skrll struct enc_xform {
51 1.5.4.2 skrll int type;
52 1.5.4.2 skrll char *name;
53 1.5.4.2 skrll u_int16_t blocksize;
54 1.5.4.2 skrll u_int16_t minkey, maxkey;
55 1.5.4.2 skrll void (*encrypt) (caddr_t, u_int8_t *);
56 1.5.4.2 skrll void (*decrypt) (caddr_t, u_int8_t *);
57 1.5.4.2 skrll int (*setkey) (u_int8_t **, const u_int8_t *, int len);
58 1.5.4.2 skrll void (*zerokey) (u_int8_t **);
59 1.5.4.2 skrll };
60 1.5.4.2 skrll
61 1.5.4.2 skrll struct comp_algo {
62 1.5.4.2 skrll int type;
63 1.5.4.2 skrll char *name;
64 1.5.4.2 skrll size_t minlen;
65 1.5.4.2 skrll u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
66 1.5.4.2 skrll u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
67 1.5.4.2 skrll };
68 1.5.4.2 skrll
69 1.5.4.2 skrll union authctx {
70 1.5.4.2 skrll MD5_CTX md5ctx;
71 1.5.4.2 skrll SHA1_CTX sha1ctx;
72 1.5.4.2 skrll RMD160_CTX rmd160ctx;
73 1.5.4.2 skrll SHA256_CTX sha256ctx;
74 1.5.4.2 skrll SHA384_CTX sha384ctx;
75 1.5.4.2 skrll SHA512_CTX sha512ctx;
76 1.5.4.2 skrll };
77 1.5.4.2 skrll
78 1.5.4.2 skrll extern struct enc_xform enc_xform_null;
79 1.5.4.2 skrll extern struct enc_xform enc_xform_des;
80 1.5.4.2 skrll extern struct enc_xform enc_xform_3des;
81 1.5.4.2 skrll extern struct enc_xform enc_xform_blf;
82 1.5.4.2 skrll extern struct enc_xform enc_xform_cast5;
83 1.5.4.2 skrll extern struct enc_xform enc_xform_skipjack;
84 1.5.4.2 skrll extern struct enc_xform enc_xform_rijndael128;
85 1.5.4.2 skrll extern struct enc_xform enc_xform_arc4;
86 1.5.4.2 skrll
87 1.5.4.2 skrll extern struct auth_hash auth_hash_null;
88 1.5.4.2 skrll extern struct auth_hash auth_hash_md5;
89 1.5.4.2 skrll extern struct auth_hash auth_hash_sha1;
90 1.5.4.2 skrll extern struct auth_hash auth_hash_key_md5;
91 1.5.4.2 skrll extern struct auth_hash auth_hash_key_sha1;
92 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_md5_96;
93 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_sha1_96;
94 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_ripemd_160_96;
95 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_sha2_256;
96 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_sha2_384;
97 1.5.4.2 skrll extern struct auth_hash auth_hash_hmac_sha2_512;
98 1.5.4.2 skrll
99 1.5.4.2 skrll extern struct comp_algo comp_algo_deflate;
100 1.5.4.2 skrll
101 1.5.4.2 skrll #ifdef _KERNEL
102 1.5.4.2 skrll #include <sys/malloc.h>
103 1.5.4.2 skrll MALLOC_DECLARE(M_XDATA);
104 1.5.4.2 skrll #endif
105 1.5.4.2 skrll #endif /* _CRYPTO_XFORM_H_ */
106