2 * Authentication Header declarations
3 * Copyright (C) 1996, 1997 John Ioannidis.
4 * Copyright (C) 1998, 1999, 2000, 2001 Richard Guy Briggs.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * RCSID $Id: ipsec_ah.h,v 1.2 2004/03/22 21:53:18 as Exp $
19 #include "ipsec_md5h.h"
20 #include "ipsec_sha1.h"
24 #endif /* IPPROTO_AH */
26 #define AH_FLENGTH 12 /* size of fixed part */
27 #define AHMD5_KMAX 64 /* MD5 max 512 bits key */
28 #define AHMD5_AMAX 12 /* MD5 96 bits of authenticator */
30 #define AHMD596_KLEN 16 /* MD5 128 bits key */
31 #define AHSHA196_KLEN 20 /* SHA1 160 bits key */
33 #define AHMD596_ALEN 16 /* MD5 128 bits authentication length */
34 #define AHSHA196_ALEN 20 /* SHA1 160 bits authentication length */
36 #define AHMD596_BLKLEN 64 /* MD5 block length */
37 #define AHSHA196_BLKLEN 64 /* SHA1 block length */
38 #define AHSHA2_256_BLKLEN 64 /* SHA2-256 block length */
39 #define AHSHA2_384_BLKLEN 128 /* SHA2-384 block length (?) */
40 #define AHSHA2_512_BLKLEN 128 /* SHA2-512 block length */
42 #define AH_BLKLEN_MAX 128 /* keep up to date! */
44 #define AH_AMAX AHSHA196_ALEN /* keep up to date! */
45 #define AHHMAC_HASHLEN 12 /* authenticator length of 96bits */
46 #define AHHMAC_RPLLEN 4 /* 32 bit replay counter */
48 #define DB_AH_PKTRX 0x0001
49 #define DB_AH_PKTRX2 0x0002
50 #define DB_AH_DMP 0x0004
51 #define DB_AH_IPSA 0x0010
52 #define DB_AH_XF 0x0020
53 #define DB_AH_INAU 0x0040
54 #define DB_AH_REPLAY 0x0100
58 /* General HMAC algorithm is described in RFC 2104 */
60 #define HMAC_IPAD 0x36
61 #define HMAC_OPAD 0x5C
64 MD5_CTX ictx
; /* context after H(K XOR ipad) */
65 MD5_CTX octx
; /* context after H(K XOR opad) */
69 SHA1_CTX ictx
; /* context after H(K XOR ipad) */
70 SHA1_CTX octx
; /* context after H(K XOR opad) */
74 void (*init
)(void *ctx
);
75 void (*update
)(void *ctx
, unsigned char *bytes
, __u32 len
);
76 void (*final
)(unsigned char *hash
, void *ctx
);
80 extern struct inet_protocol ah_protocol
;
85 ah_rcv(struct sk_buff
*skb
,
92 struct inet_protocol
*protocol
);
94 struct ahhdr
/* Generic AH header */
96 __u8 ah_nh
; /* Next header (protocol) */
97 __u8 ah_hl
; /* AH length, in 32-bit words */
98 __u16 ah_rv
; /* reserved, must be 0 */
99 __u32 ah_spi
; /* Security Parameters Index */
100 __u32 ah_rpl
; /* Replay prevention */
101 __u8 ah_data
[AHHMAC_HASHLEN
];/* Authentication hash */
103 #define AH_BASIC_LEN 8 /* basic AH header is 8 bytes, nh,hl,rv,spi
104 * and the ah_hl, says how many bytes after that
108 #ifdef CONFIG_IPSEC_DEBUG
110 #endif /* CONFIG_IPSEC_DEBUG */
111 #endif /* __KERNEL__ */