Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/netipsec/xform.h
39475 views
1
/* $OpenBSD: ip_ipsp.h,v 1.119 2002/03/14 01:27:11 millert Exp $ */
2
/*-
3
* The authors of this code are John Ioannidis ([email protected]),
4
* Angelos D. Keromytis ([email protected]),
5
* Niels Provos ([email protected]) and
6
* Niklas Hallqvist ([email protected]).
7
*
8
* The original version of this code was written by John Ioannidis
9
* for BSD/OS in Athens, Greece, in November 1995.
10
*
11
* Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
12
* by Angelos D. Keromytis.
13
*
14
* Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
15
* and Niels Provos.
16
*
17
* Additional features in 1999 by Angelos D. Keromytis and Niklas Hallqvist.
18
*
19
* Copyright (c) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
20
* Angelos D. Keromytis and Niels Provos.
21
* Copyright (c) 1999 Niklas Hallqvist.
22
* Copyright (c) 2001, Angelos D. Keromytis.
23
*
24
* Permission to use, copy, and modify this software with or without fee
25
* is hereby granted, provided that this entire notice is included in
26
* all copies of any software which is or includes a copy or
27
* modification of this software.
28
* You may use this code under the GNU public license if you so wish. Please
29
* contribute changes back to the authors under this freer than GPL license
30
* so that we may further the use of strong encryption without limitations to
31
* all.
32
*
33
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
34
* IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
35
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
36
* MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
37
* PURPOSE.
38
*/
39
40
#ifndef _NETIPSEC_XFORM_H_
41
#define _NETIPSEC_XFORM_H_
42
43
#include <sys/types.h>
44
#include <sys/queue.h>
45
#include <netinet/in.h>
46
#include <opencrypto/xform.h>
47
48
#define AH_HMAC_HASHLEN 12 /* 96 bits of authenticator */
49
#define AH_HMAC_MAXHASHLEN (SHA2_512_HASH_LEN/2) /* Keep this updated */
50
#define AH_HMAC_INITIAL_RPL 1 /* replay counter initial value */
51
52
#ifdef _KERNEL
53
struct secpolicy;
54
struct secasvar;
55
56
/*
57
* Packet tag assigned on completion of IPsec processing; used
58
* to speedup security policy checking for INBOUND packets.
59
*/
60
struct xform_history {
61
union sockaddr_union dst; /* destination address */
62
uint32_t spi; /* Security Parameters Index */
63
uint8_t proto; /* IPPROTO_ESP or IPPROTO_AH */
64
uint8_t mode; /* transport or tunnel */
65
};
66
67
/*
68
* Opaque data structure hung off a crypto operation descriptor.
69
*/
70
struct xform_data {
71
struct secpolicy *sp; /* security policy */
72
struct secasvar *sav; /* related SA */
73
crypto_session_t cryptoid; /* used crypto session */
74
u_int idx; /* IPsec request index */
75
int protoff; /* current protocol offset */
76
int skip; /* data offset */
77
uint8_t nxt; /* next protocol, e.g. IPV4 */
78
struct vnet *vnet;
79
};
80
81
#define XF_IP4 1 /* unused */
82
#define XF_AH 2 /* AH */
83
#define XF_ESP 3 /* ESP */
84
#define XF_TCPSIGNATURE 5 /* TCP MD5 Signature option, RFC 2358 */
85
#define XF_IPCOMP 6 /* IPCOMP */
86
87
struct xformsw {
88
u_short xf_type; /* xform ID */
89
const char *xf_name; /* human-readable name */
90
int (*xf_init)(struct secasvar*, struct xformsw*); /* setup */
91
void (*xf_cleanup)(struct secasvar*); /* cleanup */
92
int (*xf_input)(struct mbuf*, struct secasvar*, /* input */
93
int, int);
94
int (*xf_output)(struct mbuf*, /* output */
95
struct secpolicy *, struct secasvar *, u_int, int, int);
96
97
volatile u_int xf_cntr;
98
LIST_ENTRY(xformsw) chain;
99
};
100
101
const struct enc_xform * enc_algorithm_lookup(int);
102
const struct auth_hash * auth_algorithm_lookup(int);
103
const struct comp_algo * comp_algorithm_lookup(int);
104
105
void xform_attach(void *);
106
void xform_detach(void *);
107
int xform_init(struct secasvar *, u_short);
108
109
struct crypto_session_params;
110
/* XF_AH */
111
int xform_ah_authsize(const struct auth_hash *);
112
int ah_init0(struct secasvar *, struct xformsw *,
113
struct crypto_session_params *);
114
extern size_t ah_hdrsiz(struct secasvar *);
115
116
/* XF_ESP */
117
extern size_t esp_hdrsiz(struct secasvar *sav);
118
119
#endif /* _KERNEL */
120
#endif /* _NETIPSEC_XFORM_H_ */
121
122