Two swsusp patches:
[linux-flexiantxendom0-3.2.10.git] / net / ipv6 / mobile_ip6 / hmac.h
1 /*
2  *      MIPL Mobile IPv6 Message authentication algorithms        
3  * 
4  *      $Id: s.hmac.h 1.9 03/04/10 13:09:54+03:00 anttit@jon.mipl.mediapoli.com $
5  *
6  *      This program is free software; you can redistribute it and/or
7  *      modify it under the terms of the GNU General Public License
8  *      as published by the Free Software Foundation; either version
9  *      2 of the License, or (at your option) any later version.
10  */
11
12 #ifndef _HMAC_H
13 #define _HMAC_H
14
15 #include <linux/types.h>
16 #include <linux/in6.h>
17
18 #define HAVE_LITTLE_ENDIAN
19
20 #define NO_EXPIRY 1  /* For sec_as */
21
22 #define ALG_AUTH_NONE           0
23 #define ALG_AUTH_HMAC_MD5       1
24 #define ALG_AUTH_HMAC_SHA1      2
25
26 struct sec_as;
27 struct ah_processing {
28         void *context;
29         struct sec_as *sas;
30         u_int8_t *key_auth;
31         u_int32_t key_auth_len;
32 };
33
34 struct antireplay {
35         u_int32_t count;
36         u_int32_t bitmap; 
37 };
38
39 typedef struct {
40   u_int32_t A, B, C, D;
41   u_int32_t bitlen[2];
42   u_int8_t* buf_cur;
43   u_int8_t buf[64];
44 } MD5_CTX;
45
46 typedef struct {
47   u_int32_t A, B, C, D, E;
48   u_int32_t bitlen[2];
49   u_int8_t* buf_cur;
50   u_int8_t buf[64];
51 } SHA1_CTX;
52
53
54
55 int ah_hmac_md5_init (struct ah_processing *ahp, u_int8_t *key, u_int32_t key_len);
56 void ah_hmac_md5_loop(struct ah_processing*, void*, u_int32_t);
57 void ah_hmac_md5_result(struct ah_processing*, char*);
58 int ah_hmac_sha1_init(struct ah_processing*, u_int8_t *key, u_int32_t key_len);
59 void ah_hmac_sha1_loop(struct ah_processing*, void*, u_int32_t);
60 void ah_hmac_sha1_result(struct ah_processing*, char*);
61
62
63 #define AH_HDR_LEN 12   /* # of bytes for Next Header, Payload Length,
64                            RESERVED, Security Parameters Index and
65
66                            Sequence Number Field */
67
68 void md5_init(MD5_CTX *ctx);
69 void md5_over_block(MD5_CTX *ctx, u_int8_t* data);
70 void create_M_blocks(u_int32_t* M, u_int8_t* data);
71 void md5_compute(MD5_CTX *ctx, u_int8_t* data, u_int32_t len);
72 void md5_final(MD5_CTX *ctx, u_int8_t* digest);
73
74 void sha1_init(SHA1_CTX *ctx);
75 void sha1_over_block(SHA1_CTX *ctx, u_int8_t* data);
76 void create_W_blocks(u_int32_t* W, u_int8_t* data);
77 void sha1_compute(SHA1_CTX *ctx, u_int8_t* data, u_int32_t len);
78 void sha1_final(SHA1_CTX *ctx, u_int8_t* digest);
79
80 struct mipv6_acq {
81         struct in6_addr coa;
82         struct in6_addr haddr;
83         struct in6_addr peer;
84         u_int32_t spi;
85 };
86 #define MIPV6_MAX_AUTH_DATA 20
87
88 #define HMAC_MD5_HASH_LEN   16
89 #define HMAC_SHA1_HASH_LEN  20
90 #define HMAC_SHA1_KEY_SIZE  20
91 #define HMAC_MD5_ICV_LEN   12 /* RFC 2403 */
92 #define HMAC_SHA1_ICV_LEN  12 /* RFC 2404 */
93
94 #endif /* _HMAC_H */