2 * Copyright (C) 2010-2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 * Copyright (C) 2010 Martin Willi
5 * Copyright (C) 2010 revosec AG
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>.
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
19 * @defgroup mem_cred mem_cred
26 typedef struct mem_cred_t mem_cred_t
;
28 #include <credentials/credential_set.h>
29 #include <credentials/certificates/crl.h>
30 #include <collections/linked_list.h>
33 * Generic in-memory credential set.
38 * Implements credential_set_t.
43 * Add a certificate to the credential set.
45 * @param trusted TRUE to serve certificate as trusted
46 * @param cert certificate, reference gets owned by set
48 void (*add_cert
)(mem_cred_t
*this, bool trusted
, certificate_t
*cert
);
51 * Add a certificate to the credential set, returning a reference to it or
52 * to a cached duplicate.
54 * @param trusted TRUE to serve certificate as trusted
55 * @param cert certificate, reference gets owned by set
56 * @return reference to cert or a previously cached duplicate
58 certificate_t
*(*add_cert_ref
)(mem_cred_t
*this, bool trusted
,
62 * Get an existing reference to the same certificate.
64 * Searches for the same certficate in the set, and returns a reference
65 * to it, destroying the passed certificate. If the passed certificate
66 * is not found, it is just returned.
68 * @param cert certificate to look up
69 * @return the same certificate, potentially different instance
71 certificate_t
* (*get_cert_ref
)(mem_cred_t
*this, certificate_t
*cert
);
74 * Add an X.509 CRL to the credential set.
76 * @param crl CRL, gets owned by set
77 * @return TRUE, if the CRL is newer than an existing one (or
80 bool (*add_crl
)(mem_cred_t
*this, crl_t
*crl
);
83 * Add a private key to the credential set.
85 * @param key key, reference gets owned by set
87 void (*add_key
)(mem_cred_t
*this, private_key_t
*key
);
90 * Add a shared key to the credential set.
92 * @param shared shared key to add, gets owned by set
93 * @param ... NULL terminated list of owners (identification_t*)
95 void (*add_shared
)(mem_cred_t
*this, shared_key_t
*shared
, ...);
98 * Add a shared key to the credential set.
100 * @param shared shared key to add, gets owned by set
101 * @param owners list of owners (identification_t*), gets owned
103 void (*add_shared_list
)(mem_cred_t
*this, shared_key_t
*shared
,
104 linked_list_t
*owners
);
106 * Add a certificate distribution point to the set.
108 * @param type type of the certificate
109 * @param id certificate ID CDP has a cert for, gets cloned
110 * @param uri CDP URI, gets strduped
112 void (*add_cdp
)(mem_cred_t
*this, certificate_type_t type
,
113 identification_t
*id
, char *uri
);
116 * Replace all secrets (private and shared keys) in this credential set
117 * with those of another.
119 * @param other credential set to get secrets from
120 * @param clone TRUE to clone secrets, FALSE to adopt them (they
121 * get removed from the other set)
123 void (*replace_secrets
)(mem_cred_t
*this, mem_cred_t
*other
, bool clone
);
126 * Clear all credentials from the credential set.
128 void (*clear
)(mem_cred_t
*this);
131 * Clear the secrets (private and shared keys, not the certificates) from
132 * the credential set.
134 void (*clear_secrets
)(mem_cred_t
*this);
137 * Destroy a mem_cred_t.
139 void (*destroy
)(mem_cred_t
*this);
143 * Create a mem_cred instance.
145 mem_cred_t
*mem_cred_create();
147 #endif /** MEM_CRED_H_ @}*/