2 This file is part of GNUnet
3 Copyright (C) 2012-2014 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Martin Schanzenbach
25 * API to the Credential service
27 * @defgroup credential Credential service
32 #ifndef GNUNET_CREDENTIAL_SERVICE_H
33 #define GNUNET_CREDENTIAL_SERVICE_H
35 #include "gnunet_util_lib.h"
36 #include "gnunet_gns_service.h"
37 #include "gnunet_identity_service.h"
42 #if 0 /* keep Emacsens' auto-indent happy */
49 * Connection to the Credential service.
51 struct GNUNET_CREDENTIAL_Handle;
54 * Handle to control a lookup operation.
56 struct GNUNET_CREDENTIAL_LookupRequest;
59 * Enum used for checking whether the issuer has the authority to issue credentials or is just a subject
61 enum GNUNET_CREDENTIAL_CredentialFlags {
63 //Subject had credentials before, but have been revoked now
64 GNUNET_CREDENTIAL_FLAG_REVOKED=0,
66 //Subject flag indicates that the subject is a holder of this credential and may present it as such
67 GNUNET_CREDENTIAL_FLAG_SUBJECT=1,
69 //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
70 GNUNET_CREDENTIAL_FLAG_ISSUER=2
74 GNUNET_NETWORK_STRUCT_BEGIN
76 * Data stored in the credential record
78 struct GNUNET_CREDENTIAL_RecordData {
83 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
85 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
88 uint32_t credential_flags GNUNET_PACKED;
92 GNUNET_NETWORK_STRUCT_END
97 * Initialize the connection with the Credential service.
99 * @param cfg configuration to use
100 * @return handle to the Credential service, or NULL on error
102 struct GNUNET_CREDENTIAL_Handle *
103 GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
107 * Shutdown connection with the Credentail service.
109 * @param handle connection to shut down
112 GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle);
116 * Iterator called on obtained result for a Credential lookup.
119 * @param issuer the issuer chain
120 * @param issuer_len length of issuer chain
121 * @param rd the records in reply
123 typedef void (*GNUNET_CREDENTIAL_VerifyResultProcessor) (void *cls,
124 struct GNUNET_IDENTITY_Ego *issuer,
126 const struct GNUNET_CREDENTIAL_RecordData *data);
130 * Perform an asynchronous lookup operation for a credential.
132 * @param handle handle to the Credential service
133 * @param credential the credential to look up
134 * @param subject Ego to check the credential for
135 * @param proc function to call on result
136 * @param proc_cls closure for processor
137 * @return handle to the queued request
139 struct GNUNET_CREDENTIAL_VerifyRequest*
140 GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
141 const char *issuer_attribute,
142 const char *subject_attribute,
143 const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
144 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
145 uint32_t credential_flags,
146 GNUNET_CREDENTIAL_VerifyResultProcessor proc,
150 * Issue a credential to an identity
152 * @param handle handle to the Credential service
153 * @param issuer the identity that issues the credential
154 * @param subject the subject of the credential
155 * @param credential the name of the credential
156 * @param data the data of the credential
157 * @return handle to the queued request
159 /**struct GNUNET_CREDENTIAL_IssueRequest *
160 GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle,
161 struct GNUNET_IDENTITY_Ego *issuer,
162 struct GNUNET_IDENTITY_Ego *subject,
163 const char *credential,
164 struct GNUNET_CREDENTIAL_Data *data,
165 GNUNET_CREDENTIAL_IssueResultProcessor proc,
169 * Remove a credential
171 * @param handle handle to the Credential service
172 * @param issuer the identity that issued the credential
173 * @param subject the subject of the credential
174 * @param credential the name of the credential
175 * @return handle to the queued request
178 struct GNUNET_CREDENTIAL_IssueRequest *
179 GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle,
180 struct GNUNET_IDENTITY_Ego *issuer,
181 struct GNUNET_IDENTITY_Ego *subject,
182 const char *credential,
183 GNUNET_CREDENTIAL_IssueResultProcessor proc,
189 * Cancel pending lookup request
191 * @param lr the lookup request to cancel
194 GNUNET_CREDENTIAL_verify_cancel (struct GNUNET_CREDENTIAL_VerifyRequest *vr);
197 #if 0 /* keep Emacsens' auto-indent happy */
206 /** @} */ /* end of group */