Implemented a callback based credential set, currently for shared keys only
[strongswan.git] / src / libstrongswan / credentials / sets / callback_cred.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup callback_cred callback_cred
18 * @{ @ingroup sets
19 */
20
21 #ifndef CALLBACK_CRED_H_
22 #define CALLBACK_CRED_H_
23
24 typedef struct callback_cred_t callback_cred_t;
25
26 #include <credentials/credential_set.h>
27
28 /**
29 * Callback function to get shared keys.
30 *
31 * @param me own identity
32 * @param other other identity
33 * @param match_me match result of own identity
34 * @param match_other match result of other identity
35 */
36 typedef shared_key_t* (*callback_cred_shared_cb_t)(void *data,
37 identification_t *me, identification_t *other,
38 id_match_t *match_me, id_match_t *match_other);
39
40 /**
41 * Generic callbcack using user specified callback functions.
42 */
43 struct callback_cred_t {
44
45 /**
46 * Implements credential_set_t.
47 */
48 credential_set_t set;
49
50 /**
51 * Destroy a callback_cred_t.
52 */
53 void (*destroy)(callback_cred_t *this);
54 };
55
56 /**
57 * Create a callback_cred instance, for a shared key.
58 *
59 * @param cb callback function
60 * @param data data to pass to callback
61 */
62 callback_cred_t *callback_cred_create_shared(callback_cred_shared_cb_t cb,
63 void *data);
64
65 #endif /** CALLBACK_CRED_H_ @}*/