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.
18 * @file credential/credential_serialization.h
19 * @brief API to serialize and deserialize delegation chains
21 * @author Martin Schanzenbach
23 #ifndef CREDENTIAL_SERIALIZATION_H
24 #define CREDENTIAL_SERIALIZATION_H
27 #include "gnunet_util_lib.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_credential_service.h"
32 * Calculate how many bytes we will need to serialize
33 * the given delegation record
35 * @param ds_count number of delegation chain entries
36 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
37 * @return the required size to serialize
40 GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count,
41 const struct GNUNET_CREDENTIAL_DelegationSet *dsr);
44 * Serizalize the given delegation record entries
46 * @param d_count number of delegation chain entries
47 * @param dsr array of #GNUNET_CREDENTIAL_Delegation
48 * @param dest_size size of the destination
49 * @param dest where to store the result
50 * @return the size of the data, -1 on failure
53 GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count,
54 const struct GNUNET_CREDENTIAL_DelegationSet *dsr,
60 * Deserialize the given destination
62 * @param len size of the serialized delegation recird
63 * @param src the serialized data
64 * @param d_count the number of delegation chain entries
65 * @param dsr where to put the delegation chain entries
66 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
69 GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
72 struct GNUNET_CREDENTIAL_DelegationSet *dsr);
75 * Calculate how many bytes we will need to serialize
76 * the given delegation chain and credential
78 * @param d_count number of delegation chain entries
79 * @param dd array of #GNUNET_CREDENTIAL_Delegation
80 * @param c_count number of credential entries
81 * @param cd a #GNUNET_CREDENTIAL_Credential
82 * @return the required size to serialize
85 GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
86 const struct GNUNET_CREDENTIAL_Delegation *dd,
88 const struct GNUNET_CREDENTIAL_Credential *cd);
91 * Serizalize the given delegation chain entries and credential
93 * @param d_count number of delegation chain entries
94 * @param dd array of #GNUNET_CREDENTIAL_Delegation
95 * @param c_count number of credential entries
96 * @param cd a #GNUNET_CREDENTIAL_Credential
97 * @param dest_size size of the destination
98 * @param dest where to store the result
99 * @return the size of the data, -1 on failure
102 GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
103 const struct GNUNET_CREDENTIAL_Delegation *dd,
104 unsigned int c_count,
105 const struct GNUNET_CREDENTIAL_Credential *cd,
111 * Deserialize the given destination
113 * @param len size of the serialized delegation chain and cred
114 * @param src the serialized data
115 * @param d_count the number of delegation chain entries
116 * @param dd where to put the delegation chain entries
117 * @param c_count number of credential entries
118 * @param cd where to put the credential data
119 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
122 GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
124 unsigned int d_count,
125 struct GNUNET_CREDENTIAL_Delegation *dd,
126 unsigned int c_count,
127 struct GNUNET_CREDENTIAL_Credential *cd);
129 GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
130 const struct GNUNET_CREDENTIAL_Credential *cd);
133 GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
134 const struct GNUNET_CREDENTIAL_Credential *cd,
140 GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
142 unsigned int c_count,
143 struct GNUNET_CREDENTIAL_Credential *cd);
147 GNUNET_CREDENTIAL_credential_serialize (struct GNUNET_CREDENTIAL_Credential *cred,
150 struct GNUNET_CREDENTIAL_Credential*
151 GNUNET_CREDENTIAL_credential_deserialize (const char* data,
154 /* end of credential_serialization.h */