14647e20c59368a2b9ab70c44b74de830b29c631
[strongswan.git] / src / pluto / ike_alg.h
1 /* IKE modular algorithm handling interface
2 * Author: JuanJo Ciarlante <jjo-ipsec@mendoza.gov.ar>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #ifndef _IKE_ALG_H
16 #define _IKE_ALG_H
17
18 #include <freeswan.h>
19
20 #include "connections.h"
21
22 struct ike_alg {
23 u_int16_t algo_type;
24 u_int16_t algo_id;
25 struct ike_alg *algo_next;
26 };
27
28 typedef struct enc_testvector enc_testvector_t;
29
30 struct enc_testvector {
31 const size_t key_size;
32 const u_char *key;
33 const u_char *iv;
34 const size_t data_size;
35 const u_char *plain;
36 const u_char *cipher;
37 };
38
39 struct encrypt_desc {
40 u_int16_t algo_type;
41 u_int16_t algo_id;
42 struct ike_alg *algo_next;
43
44 size_t enc_blocksize;
45 u_int keydeflen;
46 u_int keymaxlen;
47 u_int keyminlen;
48 const enc_testvector_t *enc_testvectors;
49 };
50
51 typedef struct hash_testvector hash_testvector_t;
52
53 struct hash_testvector {
54 const size_t msg_size;
55 const u_char *msg;
56 const u_char *msg_digest;
57 };
58
59 typedef struct hmac_testvector hmac_testvector_t;
60
61 struct hmac_testvector {
62 const size_t key_size;
63 const u_char *key;
64 const size_t msg_size;
65 const u_char *msg;
66 const u_char *hmac;
67 };
68 struct hash_desc {
69 u_int16_t algo_type;
70 u_int16_t algo_id;
71 struct ike_alg *algo_next;
72
73 size_t hash_digest_size;
74 const hash_testvector_t *hash_testvectors;
75 const hmac_testvector_t *hmac_testvectors;
76 };
77
78 #define IKE_ALG_ENCRYPT 0
79 #define IKE_ALG_HASH 1
80 #define IKE_ALG_MAX IKE_ALG_HASH
81
82 extern int ike_alg_add(struct ike_alg *a);
83 extern struct hash_desc *ike_alg_get_hasher(u_int alg);
84 extern struct encrypt_desc *ike_alg_get_encrypter(u_int alg);
85 extern bool ike_alg_enc_present(u_int ealg);
86 extern bool ike_alg_hash_present(u_int halg);
87 extern const struct oakley_group_desc* ike_alg_pfsgroup(struct connection *c
88 , lset_t policy);
89 extern struct db_context * ike_alg_db_new(struct alg_info_ike *ai, lset_t policy);
90 extern void ike_alg_list(void);
91 extern void ike_alg_show_connection(struct connection *c, const char *instance);
92 extern bool ike_alg_test(void);
93 extern bool ike_alg_ok_final(u_int ealg, u_int key_len, u_int aalg, u_int group
94 , struct alg_info_ike *alg_info_ike);
95 extern int ike_alg_init(void);
96
97 #endif /* _IKE_ALG_H */