Alternative to mem_cred_t.add_cert added, which returns the certificate.
[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 certificate to the credential set, returning a reference to it or
51 * to a cached duplicate.
52 *
53 * @param trusted TRUE to serve certificate as trusted
54 * @param cert certificate, reference gets owned by set
55 * @return reference to cert or a previously cached duplicate
56 */
57 certificate_t *(*add_cert_ref)(mem_cred_t *this, bool trusted,
58 certificate_t *cert);
59
60 /**
61 * Add a private key to the credential set.
62 *
63 * @param key key, reference gets owned by set
64 */
65 void (*add_key)(mem_cred_t *this, private_key_t *key);
66
67 /**
68 * Add a shared key to the credential set.
69 *
70 * @param shared shared key to add, gets owned by set
71 * @param ... NULL terminated list of owners (identification_t*)
72 */
73 void (*add_shared)(mem_cred_t *this, shared_key_t *shared, ...);
74
75 /**
76 * Add a shared key to the credential set.
77 *
78 * @param shared shared key to add, gets owned by set
79 * @param owners list of owners (identification_t*), gets owned
80 */
81 void (*add_shared_list)(mem_cred_t *this, shared_key_t *shared,
82 linked_list_t *owners);
83
84 /**
85 * Clear all credentials from the credential set.
86 */
87 void (*clear)(mem_cred_t *this);
88
89 /**
90 * Destroy a mem_cred_t.
91 */
92 void (*destroy)(mem_cred_t *this);
93 };
94
95 /**
96 * Create a mem_cred instance.
97 */
98 mem_cred_t *mem_cred_create();
99
100 #endif /** MEM_CRED_H_ @}*/