2 * MIPL Mobile IPv6 Message authentication algorithms
4 * $Id: s.hmac.h 1.9 03/04/10 13:09:54+03:00 anttit@jon.mipl.mediapoli.com $
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.
15 #include <linux/types.h>
16 #include <linux/in6.h>
18 #define HAVE_LITTLE_ENDIAN
20 #define NO_EXPIRY 1 /* For sec_as */
22 #define ALG_AUTH_NONE 0
23 #define ALG_AUTH_HMAC_MD5 1
24 #define ALG_AUTH_HMAC_SHA1 2
27 struct ah_processing {
31 u_int32_t key_auth_len;
47 u_int32_t A, B, C, D, E;
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*);
63 #define AH_HDR_LEN 12 /* # of bytes for Next Header, Payload Length,
64 RESERVED, Security Parameters Index and
66 Sequence Number Field */
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);
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);
82 struct in6_addr haddr;
86 #define MIPV6_MAX_AUTH_DATA 20
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 */