cleaned up pluto's crypto framework
[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 "connections.h"
19
20 struct ike_alg {
21 u_int16_t algo_type;
22 u_int16_t algo_id;
23 struct ike_alg *algo_next;
24 };
25
26 typedef struct enc_testvector enc_testvector_t;
27
28 struct enc_testvector {
29 const size_t key_size;
30 const u_char *key;
31 const u_char *iv;
32 const size_t data_size;
33 const u_char *plain;
34 const u_char *cipher;
35 };
36
37 struct encrypt_desc {
38 u_int16_t algo_type;
39 u_int16_t algo_id;
40 struct ike_alg *algo_next;
41
42 size_t enc_blocksize;
43 u_int keydeflen;
44 u_int keymaxlen;
45 u_int keyminlen;
46 const enc_testvector_t *enc_testvectors;
47 };
48
49 typedef struct hash_testvector hash_testvector_t;
50
51 struct hash_testvector {
52 const size_t msg_size;
53 const u_char *msg;
54 const u_char *msg_digest;
55 };
56
57 typedef struct hmac_testvector hmac_testvector_t;
58
59 struct hmac_testvector {
60 const size_t key_size;
61 const u_char *key;
62 const size_t msg_size;
63 const u_char *msg;
64 const u_char *hmac;
65 };
66 struct hash_desc {
67 u_int16_t algo_type;
68 u_int16_t algo_id;
69 struct ike_alg *algo_next;
70
71 size_t hash_digest_size;
72 const hash_testvector_t *hash_testvectors;
73 const hmac_testvector_t *hmac_testvectors;
74 };
75
76 #define IKE_ALG_ENCRYPT 0
77 #define IKE_ALG_HASH 1
78 #define IKE_ALG_MAX IKE_ALG_HASH
79
80 extern int ike_alg_add(struct ike_alg *a);
81 extern struct hash_desc *ike_alg_get_hasher(u_int alg);
82 extern struct encrypt_desc *ike_alg_get_encrypter(u_int alg);
83 extern bool ike_alg_enc_present(u_int ealg);
84 extern bool ike_alg_hash_present(u_int halg);
85 extern int ike_alg_register_hash(struct hash_desc *a);
86 extern int ike_alg_register_enc(struct encrypt_desc *e);
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 */