xform.h revision 1.22 1 1.22 riastrad /* $NetBSD: xform.h,v 1.22 2022/05/22 11:39:08 riastradh Exp $ */
2 1.15 maxv /* $FreeBSD: xform.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
3 1.1 jonathan /* $OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $ */
4 1.1 jonathan /*
5 1.1 jonathan * The authors of this code are John Ioannidis (ji (at) tla.org),
6 1.1 jonathan * Angelos D. Keromytis (kermit (at) csd.uch.gr),
7 1.1 jonathan * Niels Provos (provos (at) physnet.uni-hamburg.de) and
8 1.1 jonathan * Niklas Hallqvist (niklas (at) appli.se).
9 1.1 jonathan *
10 1.1 jonathan * The original version of this code was written by John Ioannidis
11 1.1 jonathan * for BSD/OS in Athens, Greece, in November 1995.
12 1.1 jonathan *
13 1.1 jonathan * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
14 1.1 jonathan * by Angelos D. Keromytis.
15 1.1 jonathan *
16 1.1 jonathan * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
17 1.1 jonathan * and Niels Provos.
18 1.1 jonathan *
19 1.1 jonathan * Additional features in 1999 by Angelos D. Keromytis and Niklas Hallqvist.
20 1.1 jonathan *
21 1.1 jonathan * Copyright (c) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
22 1.1 jonathan * Angelos D. Keromytis and Niels Provos.
23 1.1 jonathan * Copyright (c) 1999 Niklas Hallqvist.
24 1.1 jonathan * Copyright (c) 2001, Angelos D. Keromytis.
25 1.1 jonathan *
26 1.1 jonathan * Permission to use, copy, and modify this software with or without fee
27 1.1 jonathan * is hereby granted, provided that this entire notice is included in
28 1.1 jonathan * all copies of any software which is or includes a copy or
29 1.1 jonathan * modification of this software.
30 1.1 jonathan * You may use this code under the GNU public license if you so wish. Please
31 1.1 jonathan * contribute changes back to the authors under this freer than GPL license
32 1.1 jonathan * so that we may further the use of strong encryption without limitations to
33 1.1 jonathan * all.
34 1.1 jonathan *
35 1.1 jonathan * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
36 1.1 jonathan * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
37 1.1 jonathan * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
38 1.1 jonathan * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
39 1.1 jonathan * PURPOSE.
40 1.1 jonathan */
41 1.1 jonathan
42 1.1 jonathan #ifndef _NETIPSEC_XFORM_H_
43 1.1 jonathan #define _NETIPSEC_XFORM_H_
44 1.1 jonathan
45 1.1 jonathan #include <sys/types.h>
46 1.1 jonathan #include <netinet/in.h>
47 1.1 jonathan #include <opencrypto/xform.h>
48 1.1 jonathan
49 1.1 jonathan /*
50 1.1 jonathan * Opaque data structure hung off a crypto operation descriptor.
51 1.1 jonathan */
52 1.10 ozaki struct secasvar;
53 1.1 jonathan struct tdb_crypto {
54 1.12 ozaki const struct ipsecrequest *tc_isr; /* ipsec request state */
55 1.1 jonathan u_int32_t tc_spi; /* associated SPI */
56 1.1 jonathan union sockaddr_union tc_dst; /* dst addr of packet */
57 1.1 jonathan u_int8_t tc_proto; /* current protocol, e.g. AH */
58 1.1 jonathan u_int8_t tc_nxt; /* next protocol, e.g. IPV4 */
59 1.1 jonathan int tc_protoff; /* current protocol offset */
60 1.1 jonathan int tc_skip; /* data offset */
61 1.21 knakahar int tc_flags; /* outer protocol flags, e.g. IPV6_MINMTU */
62 1.10 ozaki struct secasvar *tc_sav; /* ipsec SA */
63 1.1 jonathan };
64 1.1 jonathan
65 1.1 jonathan struct ipescrequest;
66 1.1 jonathan
67 1.1 jonathan struct xformsw {
68 1.18 maxv u_short xf_type;
69 1.1 jonathan #define XF_IP4 1 /* IP inside IP */
70 1.1 jonathan #define XF_AH 2 /* AH */
71 1.1 jonathan #define XF_ESP 3 /* ESP */
72 1.1 jonathan #define XF_TCPSIGNATURE 5 /* TCP MD5 Signature option, RFC 2358 */
73 1.1 jonathan #define XF_IPCOMP 6 /* IPCOMP */
74 1.18 maxv u_short xf_flags;
75 1.1 jonathan #define XFT_AUTH 0x0001
76 1.1 jonathan #define XFT_CONF 0x0100
77 1.1 jonathan #define XFT_COMP 0x1000
78 1.18 maxv const char *xf_name;
79 1.18 maxv int (*xf_init)(struct secasvar *, const struct xformsw *);
80 1.22 riastrad void (*xf_zeroize)(struct secasvar *);
81 1.18 maxv int (*xf_input)(struct mbuf *, struct secasvar *, int, int);
82 1.18 maxv int (*xf_output)(struct mbuf *, const struct ipsecrequest *,
83 1.21 knakahar struct secasvar *, int, int, int);
84 1.18 maxv struct xformsw *xf_next; /* list of registered xforms */
85 1.1 jonathan };
86 1.1 jonathan
87 1.1 jonathan #ifdef _KERNEL
88 1.18 maxv void xform_register(struct xformsw *);
89 1.18 maxv int xform_init(struct secasvar *sav, int);
90 1.1 jonathan
91 1.1 jonathan struct cryptoini;
92 1.1 jonathan
93 1.1 jonathan /* XF_IP4 */
94 1.19 maxv int ipip_output(struct mbuf *, struct secasvar *, struct mbuf **);
95 1.1 jonathan
96 1.1 jonathan /* XF_AH */
97 1.14 maxv int ah_init0(struct secasvar *, const struct xformsw *, struct cryptoini *);
98 1.22 riastrad void ah_zeroize(struct secasvar *);
99 1.18 maxv const struct auth_hash *ah_algorithm_lookup(int);
100 1.20 maxv size_t ah_authsiz(const struct secasvar *);
101 1.14 maxv size_t ah_hdrsiz(const struct secasvar *);
102 1.1 jonathan
103 1.1 jonathan /* XF_ESP */
104 1.18 maxv const struct enc_xform *esp_algorithm_lookup(int);
105 1.18 maxv size_t esp_hdrsiz(const struct secasvar *);
106 1.1 jonathan
107 1.1 jonathan /* XF_COMP */
108 1.18 maxv const struct comp_algo *ipcomp_algorithm_lookup(int);
109 1.1 jonathan
110 1.1 jonathan #endif /* _KERNEL */
111 1.3 elad #endif /* !_NETIPSEC_XFORM_H_ */
112