a41718c04097ca881ace1e699de2205bdfdad2ec
[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 * RCSID $Id: ike_alg.h,v 1.3 2004/09/16 23:22:22 as Exp $
15 */
16
17 #ifndef _IKE_ALG_H
18 #define _IKE_ALG_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 struct encrypt_desc {
29 u_int16_t algo_type;
30 u_int16_t algo_id;
31 struct ike_alg *algo_next;
32
33 size_t enc_ctxsize;
34 size_t enc_blocksize;
35 u_int keydeflen;
36 u_int keymaxlen;
37 u_int keyminlen;
38 void (*do_crypt)(u_int8_t *dat, size_t datasize, u_int8_t *key, size_t key_size, u_int8_t *iv, bool enc);
39 };
40
41 struct hash_desc {
42 u_int16_t algo_type;
43 u_int16_t algo_id;
44 struct ike_alg *algo_next;
45
46 size_t hash_ctx_size;
47 size_t hash_digest_size;
48 void (*hash_init)(void *ctx);
49 void (*hash_update)(void *ctx, const u_int8_t *in, size_t datasize);
50 void (*hash_final)(u_int8_t *out, void *ctx);
51 };
52
53 #define IKE_ALG_ENCRYPT 0
54 #define IKE_ALG_HASH 1
55 #define IKE_ALG_MAX IKE_ALG_HASH
56
57 extern int ike_alg_add(struct ike_alg *a);
58 extern struct hash_desc *ike_alg_get_hasher(u_int alg);
59 extern struct encrypt_desc *ike_alg_get_encrypter(u_int alg);
60 extern bool ike_alg_enc_present(u_int ealg);
61 extern bool ike_alg_hash_present(u_int halg);
62 extern int ike_alg_register_hash(struct hash_desc *a);
63 extern int ike_alg_register_enc(struct encrypt_desc *e);
64 extern const struct oakley_group_desc* ike_alg_pfsgroup(struct connection *c
65 , lset_t policy);
66 extern struct db_context * ike_alg_db_new(struct alg_info_ike *ai, lset_t policy);
67 extern void ike_alg_list(void);
68 extern void ike_alg_show_connection(struct connection *c, const char *instance);
69 extern bool ike_alg_ok_final(u_int ealg, u_int key_len, u_int aalg, u_int group
70 , struct alg_info_ike *alg_info_ike);
71 extern int ike_alg_init(void);
72
73 #endif /* _IKE_ALG_H */