xref: /xnu-11417.140.69/bsd/netinet6/ah.h (revision 43a90889846e00bfb5cf1d255cdc0a701a1e05a4)
1*43a90889SApple OSS Distributions /*	$FreeBSD: src/sys/netinet6/ah.h,v 1.3.2.2 2001/07/03 11:01:49 ume Exp $	*/
2*43a90889SApple OSS Distributions /*	$KAME: ah.h,v 1.13 2000/10/18 21:28:00 itojun Exp $	*/
3*43a90889SApple OSS Distributions 
4*43a90889SApple OSS Distributions /*
5*43a90889SApple OSS Distributions  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6*43a90889SApple OSS Distributions  * All rights reserved.
7*43a90889SApple OSS Distributions  *
8*43a90889SApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
9*43a90889SApple OSS Distributions  * modification, are permitted provided that the following conditions
10*43a90889SApple OSS Distributions  * are met:
11*43a90889SApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
12*43a90889SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
13*43a90889SApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
14*43a90889SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
15*43a90889SApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
16*43a90889SApple OSS Distributions  * 3. Neither the name of the project nor the names of its contributors
17*43a90889SApple OSS Distributions  *    may be used to endorse or promote products derived from this software
18*43a90889SApple OSS Distributions  *    without specific prior written permission.
19*43a90889SApple OSS Distributions  *
20*43a90889SApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21*43a90889SApple OSS Distributions  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*43a90889SApple OSS Distributions  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*43a90889SApple OSS Distributions  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24*43a90889SApple OSS Distributions  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*43a90889SApple OSS Distributions  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*43a90889SApple OSS Distributions  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*43a90889SApple OSS Distributions  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*43a90889SApple OSS Distributions  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*43a90889SApple OSS Distributions  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*43a90889SApple OSS Distributions  * SUCH DAMAGE.
31*43a90889SApple OSS Distributions  */
32*43a90889SApple OSS Distributions 
33*43a90889SApple OSS Distributions /*
34*43a90889SApple OSS Distributions  * RFC1826/2402 authentication header.
35*43a90889SApple OSS Distributions  */
36*43a90889SApple OSS Distributions 
37*43a90889SApple OSS Distributions #ifndef _NETINET6_AH_H_
38*43a90889SApple OSS Distributions #define _NETINET6_AH_H_
39*43a90889SApple OSS Distributions #include <sys/appleapiopts.h>
40*43a90889SApple OSS Distributions 
41*43a90889SApple OSS Distributions #include <sys/types.h>
42*43a90889SApple OSS Distributions 
43*43a90889SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
44*43a90889SApple OSS Distributions #include <corecrypto/cchmac.h>
45*43a90889SApple OSS Distributions #include <corecrypto/ccsha2.h>
46*43a90889SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */
47*43a90889SApple OSS Distributions 
48*43a90889SApple OSS Distributions struct ah {
49*43a90889SApple OSS Distributions 	u_int8_t        ah_nxt;         /* Next Header */
50*43a90889SApple OSS Distributions 	u_int8_t        ah_len;         /* Length of data, in 32bit */
51*43a90889SApple OSS Distributions 	u_int16_t       ah_reserve;     /* Reserved for future use */
52*43a90889SApple OSS Distributions 	u_int32_t       ah_spi;         /* Security parameter index */
53*43a90889SApple OSS Distributions 	/* variable size, 32bit bound*/	/* Authentication data */
54*43a90889SApple OSS Distributions };
55*43a90889SApple OSS Distributions 
56*43a90889SApple OSS Distributions struct newah {
57*43a90889SApple OSS Distributions 	u_int8_t        ah_nxt;         /* Next Header */
58*43a90889SApple OSS Distributions 	u_int8_t        ah_len;         /* Length of data + 1, in 32bit */
59*43a90889SApple OSS Distributions 	u_int16_t       ah_reserve;     /* Reserved for future use */
60*43a90889SApple OSS Distributions 	u_int32_t       ah_spi;         /* Security parameter index */
61*43a90889SApple OSS Distributions 	u_int32_t       ah_seq;         /* Sequence number field */
62*43a90889SApple OSS Distributions 	/* variable size, 32bit bound*/	/* Authentication data */
63*43a90889SApple OSS Distributions };
64*43a90889SApple OSS Distributions 
65*43a90889SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE
66*43a90889SApple OSS Distributions struct secasvar;
67*43a90889SApple OSS Distributions 
68*43a90889SApple OSS Distributions struct ah_algorithm_state {
69*43a90889SApple OSS Distributions 	const struct ccdigest_info *digest;
70*43a90889SApple OSS Distributions 	cchmac_ctx_decl(CCSHA512_STATE_SIZE, CCSHA512_BLOCK_SIZE, hmac_ctx);
71*43a90889SApple OSS Distributions };
72*43a90889SApple OSS Distributions 
73*43a90889SApple OSS Distributions struct ah_algorithm {
74*43a90889SApple OSS Distributions 	int (*sumsiz)(struct secasvar *);
75*43a90889SApple OSS Distributions 	int (*mature)(struct secasvar *);
76*43a90889SApple OSS Distributions 	u_int16_t keymin;     /* in bits */
77*43a90889SApple OSS Distributions 	u_int16_t keymax;     /* in bits */
78*43a90889SApple OSS Distributions 	const char *name;
79*43a90889SApple OSS Distributions 	int (*init)(struct ah_algorithm_state *, struct secasvar *);
80*43a90889SApple OSS Distributions 	void (*update)(struct ah_algorithm_state *, caddr_t, size_t);
81*43a90889SApple OSS Distributions 	void (*result)(struct ah_algorithm_state *, caddr_t, size_t);
82*43a90889SApple OSS Distributions 	/* not supposed to be called directly */
83*43a90889SApple OSS Distributions 	const struct ccdigest_info *(*digest)(void);
84*43a90889SApple OSS Distributions 	size_t (*schedlen)(const struct ah_algorithm *);
85*43a90889SApple OSS Distributions 	int (*schedule)(const struct ah_algorithm *, struct secasvar *);
86*43a90889SApple OSS Distributions };
87*43a90889SApple OSS Distributions 
88*43a90889SApple OSS Distributions #define AH_MAXSUMSIZE   64 // sha2-512's output size
89*43a90889SApple OSS Distributions 
90*43a90889SApple OSS Distributions extern const struct ah_algorithm *ah_algorithm_lookup(int);
91*43a90889SApple OSS Distributions 
92*43a90889SApple OSS Distributions /* cksum routines */
93*43a90889SApple OSS Distributions extern size_t ah_hdrlen(struct secasvar *);
94*43a90889SApple OSS Distributions extern size_t ah_hdrsiz(struct ipsecrequest *);
95*43a90889SApple OSS Distributions extern int ah_schedule(const struct ah_algorithm *, struct secasvar *);
96*43a90889SApple OSS Distributions 
97*43a90889SApple OSS Distributions extern void ah4_input(struct mbuf *, int);
98*43a90889SApple OSS Distributions extern int ah4_output(struct mbuf *, struct secasvar *);
99*43a90889SApple OSS Distributions extern int ah4_calccksum(struct mbuf *, caddr_t __sized_by(len), size_t len,
100*43a90889SApple OSS Distributions     const struct ah_algorithm *, struct secasvar *);
101*43a90889SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */
102*43a90889SApple OSS Distributions 
103*43a90889SApple OSS Distributions #endif /* _NETINET6_AH_H_ */
104