diff options
Diffstat (limited to 'src/credential/credential_serialization.h')
-rw-r--r-- | src/credential/credential_serialization.h | 150 |
1 files changed, 68 insertions, 82 deletions
diff --git a/src/credential/credential_serialization.h b/src/credential/credential_serialization.h index ebeae0d89..072beb44e 100644 --- a/src/credential/credential_serialization.h +++ b/src/credential/credential_serialization.h | |||
@@ -11,17 +11,17 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | 21 | ||
22 | /** | 22 | /** |
23 | * @file credential/credential_serialization.h | 23 | * @file credential/credential_serialization.h |
24 | * @brief API to serialize and deserialize delegation chains | 24 | * @brief API to serialize and deserialize delegation chains |
25 | * and credentials | 25 | * and credentials |
26 | * @author Martin Schanzenbach | 26 | * @author Martin Schanzenbach |
27 | */ | 27 | */ |
@@ -43,8 +43,7 @@ | |||
43 | */ | 43 | */ |
44 | size_t | 44 | size_t |
45 | GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count, | 45 | GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count, |
46 | const struct | 46 | const struct GNUNET_CREDENTIAL_DelegationSet *dsr); |
47 | GNUNET_CREDENTIAL_DelegationSet *dsr); | ||
48 | 47 | ||
49 | /** | 48 | /** |
50 | * Serizalize the given delegation record entries | 49 | * Serizalize the given delegation record entries |
@@ -57,8 +56,7 @@ GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count, | |||
57 | */ | 56 | */ |
58 | ssize_t | 57 | ssize_t |
59 | GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count, | 58 | GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count, |
60 | const struct | 59 | const struct GNUNET_CREDENTIAL_DelegationSet *dsr, |
61 | GNUNET_CREDENTIAL_DelegationSet *dsr, | ||
62 | size_t dest_size, | 60 | size_t dest_size, |
63 | char *dest); | 61 | char *dest); |
64 | 62 | ||
@@ -76,79 +74,69 @@ int | |||
76 | GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, | 74 | GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len, |
77 | const char *src, | 75 | const char *src, |
78 | unsigned int d_count, | 76 | unsigned int d_count, |
79 | struct | 77 | struct GNUNET_CREDENTIAL_DelegationSet *dsr); |
80 | GNUNET_CREDENTIAL_DelegationSet * | 78 | |
81 | dsr); | 79 | /** |
82 | 80 | * Calculate how many bytes we will need to serialize | |
83 | /** | 81 | * the given delegation chain and credential |
84 | * Calculate how many bytes we will need to serialize | 82 | * |
85 | * the given delegation chain and credential | 83 | * @param d_count number of delegation chain entries |
86 | * | 84 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
87 | * @param d_count number of delegation chain entries | 85 | * @param c_count number of credential entries |
88 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 86 | * @param cd a #GNUNET_CREDENTIAL_Credential |
89 | * @param c_count number of credential entries | 87 | * @return the required size to serialize |
90 | * @param cd a #GNUNET_CREDENTIAL_Credential | 88 | */ |
91 | * @return the required size to serialize | 89 | size_t |
92 | */ | 90 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, |
93 | size_t | 91 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
94 | GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count, | 92 | unsigned int c_count, |
95 | const struct | 93 | const struct GNUNET_CREDENTIAL_Delegate *cd); |
96 | GNUNET_CREDENTIAL_Delegation *dd, | 94 | |
97 | unsigned int c_count, | 95 | /** |
98 | const struct | 96 | * Serizalize the given delegation chain entries and credential |
99 | GNUNET_CREDENTIAL_Credential *cd); | 97 | * |
100 | 98 | * @param d_count number of delegation chain entries | |
101 | /** | 99 | * @param dd array of #GNUNET_CREDENTIAL_Delegation |
102 | * Serizalize the given delegation chain entries and credential | 100 | * @param c_count number of credential entries |
103 | * | 101 | * @param cd a #GNUNET_CREDENTIAL_Credential |
104 | * @param d_count number of delegation chain entries | 102 | * @param dest_size size of the destination |
105 | * @param dd array of #GNUNET_CREDENTIAL_Delegation | 103 | * @param dest where to store the result |
106 | * @param c_count number of credential entries | 104 | * @return the size of the data, -1 on failure |
107 | * @param cd a #GNUNET_CREDENTIAL_Credential | 105 | */ |
108 | * @param dest_size size of the destination | 106 | ssize_t |
109 | * @param dest where to store the result | 107 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, |
110 | * @return the size of the data, -1 on failure | 108 | const struct GNUNET_CREDENTIAL_Delegation *dd, |
111 | */ | 109 | unsigned int c_count, |
112 | ssize_t | 110 | const struct GNUNET_CREDENTIAL_Delegate *cd, |
113 | GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count, | 111 | size_t dest_size, |
114 | const struct | 112 | char *dest); |
115 | GNUNET_CREDENTIAL_Delegation *dd, | 113 | |
116 | unsigned int c_count, | 114 | |
117 | const struct | 115 | /** |
118 | GNUNET_CREDENTIAL_Credential *cd, | 116 | * Deserialize the given destination |
119 | size_t dest_size, | 117 | * |
120 | char *dest); | 118 | * @param len size of the serialized delegation chain and cred |
121 | 119 | * @param src the serialized data | |
122 | 120 | * @param d_count the number of delegation chain entries | |
123 | /** | 121 | * @param dd where to put the delegation chain entries |
124 | * Deserialize the given destination | 122 | * @param c_count number of credential entries |
125 | * | 123 | * @param cd where to put the credential data |
126 | * @param len size of the serialized delegation chain and cred | 124 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
127 | * @param src the serialized data | 125 | */ |
128 | * @param d_count the number of delegation chain entries | 126 | int |
129 | * @param dd where to put the delegation chain entries | 127 | GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len, |
130 | * @param c_count number of credential entries | 128 | const char *src, |
131 | * @param cd where to put the credential data | 129 | unsigned int d_count, |
132 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 130 | struct GNUNET_CREDENTIAL_Delegation *dd, |
133 | */ | 131 | unsigned int c_count, |
134 | int | 132 | struct GNUNET_CREDENTIAL_Delegate *cd); |
135 | GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len, | 133 | size_t |
136 | const char *src, | 134 | GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count, |
137 | unsigned int d_count, | 135 | const struct GNUNET_CREDENTIAL_Delegate *cd); |
138 | struct | ||
139 | GNUNET_CREDENTIAL_Delegation *dd, | ||
140 | unsigned int c_count, | ||
141 | struct | ||
142 | GNUNET_CREDENTIAL_Credential *cd); | ||
143 | size_t | ||
144 | GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count, | ||
145 | const struct | ||
146 | GNUNET_CREDENTIAL_Credential *cd); | ||
147 | 136 | ||
148 | ssize_t | 137 | ssize_t |
149 | GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count, | 138 | GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count, |
150 | const struct | 139 | const struct GNUNET_CREDENTIAL_Delegate *cd, |
151 | GNUNET_CREDENTIAL_Credential *cd, | ||
152 | size_t dest_size, | 140 | size_t dest_size, |
153 | char *dest); | 141 | char *dest); |
154 | 142 | ||
@@ -157,17 +145,15 @@ int | |||
157 | GNUNET_CREDENTIAL_credentials_deserialize (size_t len, | 145 | GNUNET_CREDENTIAL_credentials_deserialize (size_t len, |
158 | const char *src, | 146 | const char *src, |
159 | unsigned int c_count, | 147 | unsigned int c_count, |
160 | struct GNUNET_CREDENTIAL_Credential * | 148 | struct GNUNET_CREDENTIAL_Delegate *cd); |
161 | cd); | ||
162 | 149 | ||
163 | 150 | ||
164 | int | 151 | int |
165 | GNUNET_CREDENTIAL_credential_serialize (struct | 152 | GNUNET_CREDENTIAL_credential_serialize (struct GNUNET_CREDENTIAL_Credential *cred, |
166 | GNUNET_CREDENTIAL_Credential *cred, | ||
167 | char **data); | 153 | char **data); |
168 | 154 | ||
169 | struct GNUNET_CREDENTIAL_Credential* | 155 | struct GNUNET_CREDENTIAL_Credential* |
170 | GNUNET_CREDENTIAL_credential_deserialize (const char*data, | 156 | GNUNET_CREDENTIAL_credential_deserialize (const char* data, |
171 | size_t data_size); | 157 | size_t data_size); |
172 | 158 | ||
173 | int | 159 | int |