-Merge branch 'master' of ssh://gnunet.org/gnunet into gsoc2018/rest_api
[oweals/gnunet.git] / src / credential / credential.h
1 /*
2       This file is part of GNUnet
3       Copyright (C) 2012-2013 GNUnet e.V.
4
5       GNUnet is free software: you can redistribute it and/or modify it
6       under the terms of the GNU Affero General Public License as published
7       by the Free Software Foundation, either version 3 of the License,
8       or (at your option) any later version.
9
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       Affero General Public License for more details.
14      
15       You should have received a copy of the GNU Affero General Public License
16       along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 /**
19  * @file credential/credential.h
20  * @brief IPC messages between CREDENTIAL API and CREDENTIAL service
21  * @author Martin Schanzenbach
22  */
23 #ifndef CREDENTIAL_H
24 #define CREDENTIAL_H
25
26 #include "gnunet_credential_service.h"
27
28 GNUNET_NETWORK_STRUCT_BEGIN
29
30 /**
31  * Message from client to Credential service to collect credentials.
32  */
33 struct CollectMessage
34 {
35   /**
36    * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY
37    */
38   struct GNUNET_MessageHeader header;
39
40   /**
41    * Subject public key
42    */
43   struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key;
44
45   /**
46    * Trust anchor
47    */
48   struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
49
50   /**
51    * Length of the issuer attribute
52    */
53   uint16_t issuer_attribute_len;
54
55   /**
56    * Unique identifier for this request (for key collisions).
57    */
58   uint32_t id GNUNET_PACKED;
59
60   /* Followed by the zero-terminated attribute */
61
62 };
63
64
65 /**
66  * Message from client to Credential service to verify attributes.
67  */
68 struct VerifyMessage
69 {
70   /**
71    * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY
72    */
73   struct GNUNET_MessageHeader header;
74
75   /**
76    * Subject public key
77    */
78   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
79
80   /**
81    * Trust anchor
82    */
83   struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
84
85   /**
86    * Number of credentials
87    */
88   uint32_t c_count;
89
90   /**
91    * Length of the issuer attribute
92    */
93   uint16_t issuer_attribute_len;
94
95   /**
96    * Unique identifier for this request (for key collisions).
97    */
98   uint32_t id GNUNET_PACKED;
99
100   /* Followed by the zero-terminated attribute and credentials to look up */
101
102 };
103
104
105 /**
106  * Message from CREDENTIAL service to client: new results.
107  */
108 struct DelegationChainResultMessage
109 {
110   /**
111     * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT
112    */
113   struct GNUNET_MessageHeader header;
114
115   /**
116    * Unique identifier for this request (for key collisions).
117    */
118   uint32_t id GNUNET_PACKED;
119   
120   /**
121    * Indicates if credential has been found at all
122    */
123   uint32_t cred_found GNUNET_PACKED;
124
125   /**
126    * The number of delegations in the response
127    */
128   uint32_t d_count GNUNET_PACKED;
129
130   /**
131    * The number of credentials in the response
132    */
133   uint32_t c_count GNUNET_PACKED;
134
135   /* followed by ad_count GNUNET_CREDENTIAL_RecordData structs*/
136
137 };
138
139 struct DelegationRecordData
140 {
141   /**
142    * Subject key
143    */
144   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
145   
146   /**
147    * Subject attributes
148    */
149   uint32_t subject_attribute_len GNUNET_PACKED;
150 };
151
152
153 struct ChainEntry
154 {
155   /**
156    * Issuer key
157    */
158   struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
159   
160   /**
161    * Subject key
162    */
163   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
164   
165   /**
166    * Issuer attributes
167    */
168   uint32_t issuer_attribute_len GNUNET_PACKED;
169   
170   /**
171    * Subject attributes
172    */
173   uint32_t subject_attribute_len GNUNET_PACKED;
174 };
175
176
177 struct CredentialEntry
178 {
179
180   /**
181    * The signature for this credential by the issuer
182    */
183   struct GNUNET_CRYPTO_EcdsaSignature signature;
184
185   /**
186    * Signature meta
187    */
188   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
189
190   /**
191    * Public key of the issuer
192    */
193   struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
194
195   /**
196    * Public key of the subject this credential was issued to
197    */
198   struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
199
200   /**
201    * Expiration time of this credential
202    */
203   uint64_t expiration GNUNET_PACKED;
204    
205   /**
206    * Issuer attribute length
207    */
208   uint32_t issuer_attribute_len;
209
210   /**
211    * Followed by the attribute string
212    */
213 };
214
215
216 GNUNET_NETWORK_STRUCT_END
217
218 #endif
219