You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
8.6 KiB

  1. From 53969c9d9a95234ee845fa0542a330f788ad2a2c Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <daniel@makrotopia.org>
  3. Date: Fri, 5 Apr 2019 14:41:44 +0200
  4. Subject: [PATCH] include credential_*.h in dist
  5. ---
  6. src/credential/Makefile.am | 4 +++-
  7. 1 file changed, 3 insertions(+), 1 deletion(-)
  8. diff --git a/src/credential/Makefile.am b/src/credential/Makefile.am
  9. index aaac0d2c2..f2550eca6 100644
  10. --- a/src/credential/Makefile.am
  11. +++ b/src/credential/Makefile.am
  12. @@ -70,7 +70,9 @@ gnunet_service_credential_LDADD = \
  13. libgnunetcredential_la_SOURCES = \
  14. credential_api.c credential.h \
  15. credential_serialization.c \
  16. - credential_misc.c
  17. + credential_serialization.h \
  18. + credential_misc.c \
  19. + credential_misc.h
  20. libgnunetcredential_la_LIBADD = \
  21. $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
  22. libgnunetcredential_la_LDFLAGS = \
  23. --
  24. 2.21.0
  25. --- /dev/null 2019-04-03 22:31:17.799489053 +0200
  26. +++ b/src/credential/credential_serialization.h 2019-01-28 21:42:05.304419524 +0100
  27. @@ -0,0 +1,159 @@
  28. +/*
  29. + This file is part of GNUnet.
  30. + Copyright (C) 2009-2013, 2016 GNUnet e.V.
  31. +
  32. + GNUnet is free software: you can redistribute it and/or modify it
  33. + under the terms of the GNU Affero General Public License as published
  34. + by the Free Software Foundation, either version 3 of the License,
  35. + or (at your option) any later version.
  36. +
  37. + GNUnet is distributed in the hope that it will be useful, but
  38. + WITHOUT ANY WARRANTY; without even the implied warranty of
  39. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  40. + Affero General Public License for more details.
  41. +
  42. + You should have received a copy of the GNU Affero General Public License
  43. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  44. +
  45. + SPDX-License-Identifier: AGPL3.0-or-later
  46. +*/
  47. +
  48. +
  49. +/**
  50. + * @file credential/credential_serialization.h
  51. + * @brief API to serialize and deserialize delegation chains
  52. + * and credentials
  53. + * @author Martin Schanzenbach
  54. + */
  55. +#ifndef CREDENTIAL_SERIALIZATION_H
  56. +#define CREDENTIAL_SERIALIZATION_H
  57. +
  58. +#include "platform.h"
  59. +#include "gnunet_util_lib.h"
  60. +#include "gnunet_constants.h"
  61. +#include "gnunet_credential_service.h"
  62. +
  63. +/**
  64. + * Calculate how many bytes we will need to serialize
  65. + * the given delegation record
  66. + *
  67. + * @param ds_count number of delegation chain entries
  68. + * @param dsr array of #GNUNET_CREDENTIAL_Delegation
  69. + * @return the required size to serialize
  70. + */
  71. +size_t
  72. +GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count,
  73. + const struct GNUNET_CREDENTIAL_DelegationSet *dsr);
  74. +
  75. +/**
  76. + * Serizalize the given delegation record entries
  77. + *
  78. + * @param d_count number of delegation chain entries
  79. + * @param dsr array of #GNUNET_CREDENTIAL_Delegation
  80. + * @param dest_size size of the destination
  81. + * @param dest where to store the result
  82. + * @return the size of the data, -1 on failure
  83. + */
  84. +ssize_t
  85. +GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count,
  86. + const struct GNUNET_CREDENTIAL_DelegationSet *dsr,
  87. + size_t dest_size,
  88. + char *dest);
  89. +
  90. +
  91. +/**
  92. + * Deserialize the given destination
  93. + *
  94. + * @param len size of the serialized delegation recird
  95. + * @param src the serialized data
  96. + * @param d_count the number of delegation chain entries
  97. + * @param dsr where to put the delegation chain entries
  98. + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  99. + */
  100. +int
  101. +GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
  102. + const char *src,
  103. + unsigned int d_count,
  104. + struct GNUNET_CREDENTIAL_DelegationSet *dsr);
  105. +
  106. + /**
  107. + * Calculate how many bytes we will need to serialize
  108. + * the given delegation chain and credential
  109. + *
  110. + * @param d_count number of delegation chain entries
  111. + * @param dd array of #GNUNET_CREDENTIAL_Delegation
  112. + * @param c_count number of credential entries
  113. + * @param cd a #GNUNET_CREDENTIAL_Credential
  114. + * @return the required size to serialize
  115. + */
  116. + size_t
  117. + GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
  118. + const struct GNUNET_CREDENTIAL_Delegation *dd,
  119. + unsigned int c_count,
  120. + const struct GNUNET_CREDENTIAL_Credential *cd);
  121. +
  122. + /**
  123. + * Serizalize the given delegation chain entries and credential
  124. + *
  125. + * @param d_count number of delegation chain entries
  126. + * @param dd array of #GNUNET_CREDENTIAL_Delegation
  127. + * @param c_count number of credential entries
  128. + * @param cd a #GNUNET_CREDENTIAL_Credential
  129. + * @param dest_size size of the destination
  130. + * @param dest where to store the result
  131. + * @return the size of the data, -1 on failure
  132. + */
  133. + ssize_t
  134. + GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
  135. + const struct GNUNET_CREDENTIAL_Delegation *dd,
  136. + unsigned int c_count,
  137. + const struct GNUNET_CREDENTIAL_Credential *cd,
  138. + size_t dest_size,
  139. + char *dest);
  140. +
  141. +
  142. + /**
  143. + * Deserialize the given destination
  144. + *
  145. + * @param len size of the serialized delegation chain and cred
  146. + * @param src the serialized data
  147. + * @param d_count the number of delegation chain entries
  148. + * @param dd where to put the delegation chain entries
  149. + * @param c_count number of credential entries
  150. + * @param cd where to put the credential data
  151. + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  152. + */
  153. + int
  154. + GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
  155. + const char *src,
  156. + unsigned int d_count,
  157. + struct GNUNET_CREDENTIAL_Delegation *dd,
  158. + unsigned int c_count,
  159. + struct GNUNET_CREDENTIAL_Credential *cd);
  160. + size_t
  161. + GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
  162. + const struct GNUNET_CREDENTIAL_Credential *cd);
  163. +
  164. +ssize_t
  165. +GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
  166. + const struct GNUNET_CREDENTIAL_Credential *cd,
  167. + size_t dest_size,
  168. + char *dest);
  169. +
  170. +
  171. +int
  172. +GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
  173. + const char *src,
  174. + unsigned int c_count,
  175. + struct GNUNET_CREDENTIAL_Credential *cd);
  176. +
  177. +
  178. +int
  179. +GNUNET_CREDENTIAL_credential_serialize (struct GNUNET_CREDENTIAL_Credential *cred,
  180. + char **data);
  181. +
  182. +struct GNUNET_CREDENTIAL_Credential*
  183. +GNUNET_CREDENTIAL_credential_deserialize (const char* data,
  184. + size_t data_size);
  185. +#endif
  186. +/* end of credential_serialization.h */
  187. --- /dev/null 2019-04-03 22:31:17.799489053 +0200
  188. +++ b/src/credential/credential_misc.h 2019-01-28 21:42:05.304419524 +0100
  189. @@ -0,0 +1,35 @@
  190. +/*
  191. + This file is part of GNUnet
  192. + Copyright (C) 2012-2013 GNUnet e.V.
  193. +
  194. + GNUnet is free software: you can redistribute it and/or modify it
  195. + under the terms of the GNU Affero General Public License as published
  196. + by the Free Software Foundation, either version 3 of the License,
  197. + or (at your option) any later version.
  198. +
  199. + GNUnet is distributed in the hope that it will be useful, but
  200. + WITHOUT ANY WARRANTY; without even the implied warranty of
  201. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  202. + Affero General Public License for more details.
  203. +
  204. + You should have received a copy of the GNU Affero General Public License
  205. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  206. +
  207. + SPDX-License-Identifier: AGPL3.0-or-later
  208. + */
  209. +/**
  210. + * @file credential/credential_misc.h
  211. + * @brief Credential helper functions
  212. + */
  213. +#ifndef CREDENTIAL_MISC_H
  214. +#define CREDENTIAL_MISC_H
  215. +
  216. +
  217. +
  218. +char*
  219. +GNUNET_CREDENTIAL_credential_to_string (const struct GNUNET_CREDENTIAL_Credential *cred);
  220. +
  221. +struct GNUNET_CREDENTIAL_Credential*
  222. +GNUNET_CREDENTIAL_credential_from_string (const char* str);
  223. +
  224. +#endif