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