OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / pluto / alg_info.h
1 /*
2  * Algorithm info parsing and creation functions
3  * Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
4  *
5  * $Id: alg_info.h,v 1.1 2002-07-15 05:55:21 danield Exp $
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  * for more details.
16  */
17 #ifndef ALG_INFO_H
18 #define ALG_INFO_H
19 struct esp_info {
20         u_int8_t transid;       /* ESP transform */
21         u_int16_t auth;         /* AUTH */
22         size_t enckeylen;       /* keylength for ESP transform */
23         size_t authkeylen;      /* keylength for AUTH */
24         u_int8_t encryptalg;    /* normally  encryptalg=transid */
25         u_int8_t authalg;       /* normally  authalg=auth+1 */
26 };
27 struct ike_info {
28         u_int16_t ike_ealg;     /* high 16 bit nums for reserved */
29         u_int8_t ike_halg;
30         size_t ike_eklen;
31         size_t ike_hklen;
32         u_int16_t ike_modp;
33 };
34 #define ALG_INFO_COMMON \
35         int alg_info_cnt;               \
36         int ref_cnt;                    \
37         unsigned alg_info_flags;        \
38         unsigned alg_info_protoid
39 struct alg_info {
40         ALG_INFO_COMMON;
41 };
42 struct alg_info_esp {
43         ALG_INFO_COMMON;
44         struct esp_info esp[64];
45         int esp_pfsgroup;
46 };
47 struct alg_info_ike {
48         ALG_INFO_COMMON;
49         struct ike_info ike[64];
50 };
51 #define esp_ealg_id transid
52 #define esp_aalg_id auth
53 #define esp_ealg_keylen enckeylen       /* bits */
54 #define esp_aalg_keylen authkeylen      /* bits */
55
56 /*      alg_info_flags bits */
57 #define ALG_INFO_F_STRICT       0x01
58
59 int alg_info_esp_aa2sadb(int auth);
60 int alg_info_esp_sadb2aa(int sadb_aalg);
61 void alg_info_free(struct alg_info *alg_info);
62 void alg_info_addref(struct alg_info *alg_info);
63 void alg_info_delref(struct alg_info **alg_info);
64 struct alg_info_esp * alg_info_esp_create_from_str (const char *alg_str, const char **err_p);
65 struct alg_info_ike * alg_info_ike_create_from_str (const char *alg_str, const char **err_p);
66 int alg_info_parse(const char *str);
67 int alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info);
68 int alg_info_snprint_esp(char *buf, int buflen, struct alg_info_esp *alg_info);
69 int alg_info_snprint_ike(char *buf, int buflen, struct alg_info_ike *alg_info);
70 #define ALG_INFO_ESP_FOREACH(ai, ai_esp, i) \
71         for (i=(ai)->alg_info_cnt,ai_esp=(ai)->esp; i--; ai_esp++) 
72 #define ALG_INFO_IKE_FOREACH(ai, ai_ike, i) \
73         for (i=(ai)->alg_info_cnt,ai_ike=(ai)->ike; i--; ai_ike++) 
74 #endif /* ALG_INFO_H */