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