2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
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.
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.
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/>.
21 * @file credential/credential_serialization.h
22 * @brief API to serialize and deserialize delegation chains
24 * @author Martin Schanzenbach
26 #ifndef CREDENTIAL_SERIALIZATION_H
27 #define CREDENTIAL_SERIALIZATION_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_constants.h"
32 #include "gnunet_credential_service.h"
35 * Calculate how many bytes we will need to serialize
36 * the given delegation record
38 * @param ds_count number of delegation chain entries
39 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
40 * @return the required size to serialize
43 GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count,
44 const struct GNUNET_CREDENTIAL_DelegationSet *dsr);
47 * Serizalize the given delegation record entries
49 * @param d_count number of delegation chain entries
50 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
51 * @param dest_size size of the destination
52 * @param dest where to store the result
53 * @return the size of the data, -1 on failure
56 GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count,
57 const struct GNUNET_CREDENTIAL_DelegationSet *dsr,
63 * Deserialize the given destination
65 * @param len size of the serialized delegation recird
66 * @param src the serialized data
67 * @param d_count the number of delegation chain entries
68 * @param dsr where to put the delegation chain entries
69 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
72 GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
75 struct GNUNET_CREDENTIAL_DelegationSet *dsr);
78 * Calculate how many bytes we will need to serialize
79 * the given delegation chain and credential
81 * @param d_count number of delegation chain entries
82 * @param dd array of #GNUNET_CREDENTIAL_Delegation
83 * @param c_count number of credential entries
84 * @param cd a #GNUNET_CREDENTIAL_Credential
85 * @return the required size to serialize
88 GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
89 const struct GNUNET_CREDENTIAL_Delegation *dd,
91 const struct GNUNET_CREDENTIAL_Credential *cd);
94 * Serizalize the given delegation chain entries and credential
96 * @param d_count number of delegation chain entries
97 * @param dd array of #GNUNET_CREDENTIAL_Delegation
98 * @param c_count number of credential entries
99 * @param cd a #GNUNET_CREDENTIAL_Credential
100 * @param dest_size size of the destination
101 * @param dest where to store the result
102 * @return the size of the data, -1 on failure
105 GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
106 const struct GNUNET_CREDENTIAL_Delegation *dd,
107 unsigned int c_count,
108 const struct GNUNET_CREDENTIAL_Credential *cd,
114 * Deserialize the given destination
116 * @param len size of the serialized delegation chain and cred
117 * @param src the serialized data
118 * @param d_count the number of delegation chain entries
119 * @param dd where to put the delegation chain entries
120 * @param c_count number of credential entries
121 * @param cd where to put the credential data
122 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
125 GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
127 unsigned int d_count,
128 struct GNUNET_CREDENTIAL_Delegation *dd,
129 unsigned int c_count,
130 struct GNUNET_CREDENTIAL_Credential *cd);
132 GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
133 const struct GNUNET_CREDENTIAL_Credential *cd);
136 GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
137 const struct GNUNET_CREDENTIAL_Credential *cd,
143 GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
145 unsigned int c_count,
146 struct GNUNET_CREDENTIAL_Credential *cd);
150 GNUNET_CREDENTIAL_credential_serialize (struct GNUNET_CREDENTIAL_Credential *cred,
153 struct GNUNET_CREDENTIAL_Credential*
154 GNUNET_CREDENTIAL_credential_deserialize (const char* data,
157 /* end of credential_serialization.h */