Function added to mem_cred_t to add shared secret with a linked list of owners.
[strongswan.git] / src / libstrongswan / credentials / sets / mem_cred.h
1 /*
2 * Copyright (C) 2010 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 * Copyright (C) 2010 Martin Willi
5 * Copyright (C) 2010 revosec AG
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
18 /**
19 * @defgroup mem_cred mem_cred
20 * @{ @ingroup sets
21 */
22
23 #ifndef MEM_CRED_H_
24 #define MEM_CRED_H_
25
26 typedef struct mem_cred_t mem_cred_t;
27
28 #include <credentials/credential_set.h>
29 #include <utils/linked_list.h>
30
31 /**
32 * Generic in-memory credential set.
33 */
34 struct mem_cred_t {
35
36 /**
37 * Implements credential_set_t.
38 */
39 credential_set_t set;
40
41 /**
42 * Add a certificate to the credential set.
43 *
44 * @param trusted TRUE to serve certificate as trusted
45 * @param cert certificate, reference gets owned by set
46 */
47 void (*add_cert)(mem_cred_t *this, bool trusted, certificate_t *cert);
48
49 /**
50 * Add a private key to the credential set.
51 *
52 * @param key key, reference gets owned by set
53 */
54 void (*add_key)(mem_cred_t *this, private_key_t *key);
55
56 /**
57 * Add a shared key to the credential set.
58 *
59 * @param shared shared key to add, gets owned by set
60 * @param ... NULL terminated list of owners (identification_t*)
61 */
62 void (*add_shared)(mem_cred_t *this, shared_key_t *shared, ...);
63
64 /**
65 * Add a shared key to the credential set.
66 *
67 * @param shared shared key to add, gets owned by set
68 * @param owners list of owners (identification_t*), gets owned
69 */
70 void (*add_shared_list)(mem_cred_t *this, shared_key_t *shared,
71 linked_list_t *owners);
72
73 /**
74 * Clear all credentials from the credential set.
75 */
76 void (*clear)(mem_cred_t *this);
77
78 /**
79 * Destroy a mem_cred_t.
80 */
81 void (*destroy)(mem_cred_t *this);
82 };
83
84 /**
85 * Create a mem_cred instance.
86 */
87 mem_cred_t *mem_cred_create();
88
89 #endif /** MEM_CRED_H_ @}*/