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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
23 * @file credential/credential_serialization.h
24 * @brief API to serialize and deserialize delegation chains
26 * @author Martin Schanzenbach
28 #ifndef CREDENTIAL_SERIALIZATION_H
29 #define CREDENTIAL_SERIALIZATION_H
32 #include "gnunet_util_lib.h"
33 #include "gnunet_constants.h"
34 #include "gnunet_credential_service.h"
37 * Calculate how many bytes we will need to serialize
38 * the given delegation record
40 * @param ds_count number of delegation chain entries
41 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
42 * @return the required size to serialize
45 GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count,
47 GNUNET_CREDENTIAL_DelegationSet *dsr);
50 * Serizalize the given delegation record entries
52 * @param d_count number of delegation chain entries
53 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
54 * @param dest_size size of the destination
55 * @param dest where to store the result
56 * @return the size of the data, -1 on failure
59 GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count,
61 GNUNET_CREDENTIAL_DelegationSet *dsr,
67 * Deserialize the given destination
69 * @param len size of the serialized delegation recird
70 * @param src the serialized data
71 * @param d_count the number of delegation chain entries
72 * @param dsr where to put the delegation chain entries
73 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
76 GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
80 GNUNET_CREDENTIAL_DelegationSet *
84 * Calculate how many bytes we will need to serialize
85 * the given delegation chain and credential
87 * @param d_count number of delegation chain entries
88 * @param dd array of #GNUNET_CREDENTIAL_Delegation
89 * @param c_count number of credential entries
90 * @param cd a #GNUNET_CREDENTIAL_Credential
91 * @return the required size to serialize
94 GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
96 GNUNET_CREDENTIAL_Delegation *dd,
99 GNUNET_CREDENTIAL_Credential *cd);
102 * Serizalize the given delegation chain entries and credential
104 * @param d_count number of delegation chain entries
105 * @param dd array of #GNUNET_CREDENTIAL_Delegation
106 * @param c_count number of credential entries
107 * @param cd a #GNUNET_CREDENTIAL_Credential
108 * @param dest_size size of the destination
109 * @param dest where to store the result
110 * @return the size of the data, -1 on failure
113 GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
115 GNUNET_CREDENTIAL_Delegation *dd,
116 unsigned int c_count,
118 GNUNET_CREDENTIAL_Credential *cd,
124 * Deserialize the given destination
126 * @param len size of the serialized delegation chain and cred
127 * @param src the serialized data
128 * @param d_count the number of delegation chain entries
129 * @param dd where to put the delegation chain entries
130 * @param c_count number of credential entries
131 * @param cd where to put the credential data
132 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
135 GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
137 unsigned int d_count,
139 GNUNET_CREDENTIAL_Delegation *dd,
140 unsigned int c_count,
142 GNUNET_CREDENTIAL_Credential *cd);
144 GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
146 GNUNET_CREDENTIAL_Credential *cd);
149 GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
151 GNUNET_CREDENTIAL_Credential *cd,
157 GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
159 unsigned int c_count,
160 struct GNUNET_CREDENTIAL_Credential *
165 GNUNET_CREDENTIAL_credential_serialize (struct
166 GNUNET_CREDENTIAL_Credential *cred,
169 struct GNUNET_CREDENTIAL_Credential*
170 GNUNET_CREDENTIAL_credential_deserialize (const char*data,
173 /* end of credential_serialization.h */