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.

482 lines
14 KiB

  1. From 5be7a51b0980909719670953c938ee724627ad90 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <daniel@makrotopia.org>
  3. Date: Thu, 28 Feb 2019 15:30:26 +0100
  4. Subject: [PATCH] credential: include headers in dist sources
  5. ---
  6. src/credential/Makefile.am | 3 +++
  7. src/include/Makefile.am | 4 ++--
  8. 2 files changed, 5 insertions(+), 2 deletions(-)
  9. --- a/src/credential/Makefile.am
  10. +++ b/src/credential/Makefile.am
  11. @@ -68,8 +68,11 @@ gnunet_service_credential_LDADD = \
  12. libgnunetcredential_la_SOURCES = \
  13. + credential.h \
  14. credential_api.c \
  15. + credential_serialization.h \
  16. credential_serialization.c \
  17. + credential_misc.h \
  18. credential_misc.c
  19. libgnunetcredential_la_LIBADD = \
  20. $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
  21. --- a/src/include/Makefile.am
  22. +++ b/src/include/Makefile.am
  23. @@ -47,7 +47,7 @@ gnunetinclude_HEADERS = \
  24. gnunet_container_lib.h \
  25. gnunet_conversation_service.h \
  26. gnunet_core_service.h \
  27. - gnunet_credential_service.h \
  28. + gnunet_credential_service.h \
  29. gnunet_crypto_lib.h \
  30. gnunet_curl_lib.h \
  31. gnunet_datacache_lib.h \
  32. @@ -107,7 +107,7 @@ gnunetinclude_HEADERS = \
  33. gnunet_regex_service.h \
  34. gnunet_rest_lib.h \
  35. gnunet_rest_plugin.h \
  36. - gnunet_rps_service.h \
  37. + gnunet_rps_service.h \
  38. gnunet_revocation_service.h \
  39. gnunet_scalarproduct_service.h \
  40. gnunet_scheduler_lib.h \
  41. --- /dev/null
  42. +++ b/src/credential/credential.h
  43. @@ -0,0 +1,221 @@
  44. +/*
  45. + This file is part of GNUnet
  46. + Copyright (C) 2012-2013 GNUnet e.V.
  47. +
  48. + GNUnet is free software: you can redistribute it and/or modify it
  49. + under the terms of the GNU Affero General Public License as published
  50. + by the Free Software Foundation, either version 3 of the License,
  51. + or (at your option) any later version.
  52. +
  53. + GNUnet is distributed in the hope that it will be useful, but
  54. + WITHOUT ANY WARRANTY; without even the implied warranty of
  55. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  56. + Affero General Public License for more details.
  57. +
  58. + You should have received a copy of the GNU Affero General Public License
  59. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  60. +
  61. + SPDX-License-Identifier: AGPL3.0-or-later
  62. + */
  63. +/**
  64. + * @file credential/credential.h
  65. + * @brief IPC messages between CREDENTIAL API and CREDENTIAL service
  66. + * @author Martin Schanzenbach
  67. + */
  68. +#ifndef CREDENTIAL_H
  69. +#define CREDENTIAL_H
  70. +
  71. +#include "gnunet_credential_service.h"
  72. +
  73. +GNUNET_NETWORK_STRUCT_BEGIN
  74. +
  75. +/**
  76. + * Message from client to Credential service to collect credentials.
  77. + */
  78. +struct CollectMessage
  79. +{
  80. + /**
  81. + * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY
  82. + */
  83. + struct GNUNET_MessageHeader header;
  84. +
  85. + /**
  86. + * Subject public key
  87. + */
  88. + struct GNUNET_CRYPTO_EcdsaPrivateKey subject_key;
  89. +
  90. + /**
  91. + * Trust anchor
  92. + */
  93. + struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
  94. +
  95. + /**
  96. + * Length of the issuer attribute
  97. + */
  98. + uint16_t issuer_attribute_len;
  99. +
  100. + /**
  101. + * Unique identifier for this request (for key collisions).
  102. + */
  103. + uint32_t id GNUNET_PACKED;
  104. +
  105. + /* Followed by the zero-terminated attribute */
  106. +
  107. +};
  108. +
  109. +
  110. +/**
  111. + * Message from client to Credential service to verify attributes.
  112. + */
  113. +struct VerifyMessage
  114. +{
  115. + /**
  116. + * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY
  117. + */
  118. + struct GNUNET_MessageHeader header;
  119. +
  120. + /**
  121. + * Subject public key
  122. + */
  123. + struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
  124. +
  125. + /**
  126. + * Trust anchor
  127. + */
  128. + struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
  129. +
  130. + /**
  131. + * Number of credentials
  132. + */
  133. + uint32_t c_count;
  134. +
  135. + /**
  136. + * Length of the issuer attribute
  137. + */
  138. + uint16_t issuer_attribute_len;
  139. +
  140. + /**
  141. + * Unique identifier for this request (for key collisions).
  142. + */
  143. + uint32_t id GNUNET_PACKED;
  144. +
  145. + /* Followed by the zero-terminated attribute and credentials to look up */
  146. +
  147. +};
  148. +
  149. +
  150. +/**
  151. + * Message from CREDENTIAL service to client: new results.
  152. + */
  153. +struct DelegationChainResultMessage
  154. +{
  155. + /**
  156. + * Header of type #GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT
  157. + */
  158. + struct GNUNET_MessageHeader header;
  159. +
  160. + /**
  161. + * Unique identifier for this request (for key collisions).
  162. + */
  163. + uint32_t id GNUNET_PACKED;
  164. +
  165. + /**
  166. + * Indicates if credential has been found at all
  167. + */
  168. + uint32_t cred_found GNUNET_PACKED;
  169. +
  170. + /**
  171. + * The number of delegations in the response
  172. + */
  173. + uint32_t d_count GNUNET_PACKED;
  174. +
  175. + /**
  176. + * The number of credentials in the response
  177. + */
  178. + uint32_t c_count GNUNET_PACKED;
  179. +
  180. + /* followed by ad_count GNUNET_CREDENTIAL_RecordData structs*/
  181. +
  182. +};
  183. +
  184. +struct DelegationRecordData
  185. +{
  186. + /**
  187. + * Subject key
  188. + */
  189. + struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
  190. +
  191. + /**
  192. + * Subject attributes
  193. + */
  194. + uint32_t subject_attribute_len GNUNET_PACKED;
  195. +};
  196. +
  197. +
  198. +struct ChainEntry
  199. +{
  200. + /**
  201. + * Issuer key
  202. + */
  203. + struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
  204. +
  205. + /**
  206. + * Subject key
  207. + */
  208. + struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
  209. +
  210. + /**
  211. + * Issuer attributes
  212. + */
  213. + uint32_t issuer_attribute_len GNUNET_PACKED;
  214. +
  215. + /**
  216. + * Subject attributes
  217. + */
  218. + uint32_t subject_attribute_len GNUNET_PACKED;
  219. +};
  220. +
  221. +
  222. +struct CredentialEntry
  223. +{
  224. +
  225. + /**
  226. + * The signature for this credential by the issuer
  227. + */
  228. + struct GNUNET_CRYPTO_EcdsaSignature signature;
  229. +
  230. + /**
  231. + * Signature meta
  232. + */
  233. + struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
  234. +
  235. + /**
  236. + * Public key of the issuer
  237. + */
  238. + struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
  239. +
  240. + /**
  241. + * Public key of the subject this credential was issued to
  242. + */
  243. + struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
  244. +
  245. + /**
  246. + * Expiration time of this credential
  247. + */
  248. + uint64_t expiration GNUNET_PACKED;
  249. +
  250. + /**
  251. + * Issuer attribute length
  252. + */
  253. + uint32_t issuer_attribute_len;
  254. +
  255. + /**
  256. + * Followed by the attribute string
  257. + */
  258. +};
  259. +
  260. +
  261. +GNUNET_NETWORK_STRUCT_END
  262. +
  263. +#endif
  264. +
  265. --- /dev/null
  266. +++ b/src/credential/credential_misc.h
  267. @@ -0,0 +1,35 @@
  268. +/*
  269. + This file is part of GNUnet
  270. + Copyright (C) 2012-2013 GNUnet e.V.
  271. +
  272. + GNUnet is free software: you can redistribute it and/or modify it
  273. + under the terms of the GNU Affero General Public License as published
  274. + by the Free Software Foundation, either version 3 of the License,
  275. + or (at your option) any later version.
  276. +
  277. + GNUnet is distributed in the hope that it will be useful, but
  278. + WITHOUT ANY WARRANTY; without even the implied warranty of
  279. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  280. + Affero General Public License for more details.
  281. +
  282. + You should have received a copy of the GNU Affero General Public License
  283. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  284. +
  285. + SPDX-License-Identifier: AGPL3.0-or-later
  286. + */
  287. +/**
  288. + * @file credential/credential_misc.h
  289. + * @brief Credential helper functions
  290. + */
  291. +#ifndef CREDENTIAL_MISC_H
  292. +#define CREDENTIAL_MISC_H
  293. +
  294. +
  295. +
  296. +char*
  297. +GNUNET_CREDENTIAL_credential_to_string (const struct GNUNET_CREDENTIAL_Credential *cred);
  298. +
  299. +struct GNUNET_CREDENTIAL_Credential*
  300. +GNUNET_CREDENTIAL_credential_from_string (const char* str);
  301. +
  302. +#endif
  303. --- /dev/null
  304. +++ b/src/credential/credential_serialization.h
  305. @@ -0,0 +1,159 @@
  306. +/*
  307. + This file is part of GNUnet.
  308. + Copyright (C) 2009-2013, 2016 GNUnet e.V.
  309. +
  310. + GNUnet is free software: you can redistribute it and/or modify it
  311. + under the terms of the GNU Affero General Public License as published
  312. + by the Free Software Foundation, either version 3 of the License,
  313. + or (at your option) any later version.
  314. +
  315. + GNUnet is distributed in the hope that it will be useful, but
  316. + WITHOUT ANY WARRANTY; without even the implied warranty of
  317. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  318. + Affero General Public License for more details.
  319. +
  320. + You should have received a copy of the GNU Affero General Public License
  321. + along with this program. If not, see <http://www.gnu.org/licenses/>.
  322. +
  323. + SPDX-License-Identifier: AGPL3.0-or-later
  324. +*/
  325. +
  326. +
  327. +/**
  328. + * @file credential/credential_serialization.h
  329. + * @brief API to serialize and deserialize delegation chains
  330. + * and credentials
  331. + * @author Martin Schanzenbach
  332. + */
  333. +#ifndef CREDENTIAL_SERIALIZATION_H
  334. +#define CREDENTIAL_SERIALIZATION_H
  335. +
  336. +#include "platform.h"
  337. +#include "gnunet_util_lib.h"
  338. +#include "gnunet_constants.h"
  339. +#include "gnunet_credential_service.h"
  340. +
  341. +/**
  342. + * Calculate how many bytes we will need to serialize
  343. + * the given delegation record
  344. + *
  345. + * @param ds_count number of delegation chain entries
  346. + * @param dsr array of #GNUNET_CREDENTIAL_Delegation
  347. + * @return the required size to serialize
  348. + */
  349. +size_t
  350. +GNUNET_CREDENTIAL_delegation_set_get_size (unsigned int ds_count,
  351. + const struct GNUNET_CREDENTIAL_DelegationSet *dsr);
  352. +
  353. +/**
  354. + * Serizalize the given delegation record entries
  355. + *
  356. + * @param d_count number of delegation chain entries
  357. + * @param dsr array of #GNUNET_CREDENTIAL_Delegation
  358. + * @param dest_size size of the destination
  359. + * @param dest where to store the result
  360. + * @return the size of the data, -1 on failure
  361. + */
  362. +ssize_t
  363. +GNUNET_CREDENTIAL_delegation_set_serialize (unsigned int d_count,
  364. + const struct GNUNET_CREDENTIAL_DelegationSet *dsr,
  365. + size_t dest_size,
  366. + char *dest);
  367. +
  368. +
  369. +/**
  370. + * Deserialize the given destination
  371. + *
  372. + * @param len size of the serialized delegation recird
  373. + * @param src the serialized data
  374. + * @param d_count the number of delegation chain entries
  375. + * @param dsr where to put the delegation chain entries
  376. + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  377. + */
  378. +int
  379. +GNUNET_CREDENTIAL_delegation_set_deserialize (size_t len,
  380. + const char *src,
  381. + unsigned int d_count,
  382. + struct GNUNET_CREDENTIAL_DelegationSet *dsr);
  383. +
  384. + /**
  385. + * Calculate how many bytes we will need to serialize
  386. + * the given delegation chain and credential
  387. + *
  388. + * @param d_count number of delegation chain entries
  389. + * @param dd array of #GNUNET_CREDENTIAL_Delegation
  390. + * @param c_count number of credential entries
  391. + * @param cd a #GNUNET_CREDENTIAL_Credential
  392. + * @return the required size to serialize
  393. + */
  394. + size_t
  395. + GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
  396. + const struct GNUNET_CREDENTIAL_Delegation *dd,
  397. + unsigned int c_count,
  398. + const struct GNUNET_CREDENTIAL_Credential *cd);
  399. +
  400. + /**
  401. + * Serizalize the given delegation chain entries and credential
  402. + *
  403. + * @param d_count number of delegation chain entries
  404. + * @param dd array of #GNUNET_CREDENTIAL_Delegation
  405. + * @param c_count number of credential entries
  406. + * @param cd a #GNUNET_CREDENTIAL_Credential
  407. + * @param dest_size size of the destination
  408. + * @param dest where to store the result
  409. + * @return the size of the data, -1 on failure
  410. + */
  411. + ssize_t
  412. + GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
  413. + const struct GNUNET_CREDENTIAL_Delegation *dd,
  414. + unsigned int c_count,
  415. + const struct GNUNET_CREDENTIAL_Credential *cd,
  416. + size_t dest_size,
  417. + char *dest);
  418. +
  419. +
  420. + /**
  421. + * Deserialize the given destination
  422. + *
  423. + * @param len size of the serialized delegation chain and cred
  424. + * @param src the serialized data
  425. + * @param d_count the number of delegation chain entries
  426. + * @param dd where to put the delegation chain entries
  427. + * @param c_count number of credential entries
  428. + * @param cd where to put the credential data
  429. + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
  430. + */
  431. + int
  432. + GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
  433. + const char *src,
  434. + unsigned int d_count,
  435. + struct GNUNET_CREDENTIAL_Delegation *dd,
  436. + unsigned int c_count,
  437. + struct GNUNET_CREDENTIAL_Credential *cd);
  438. + size_t
  439. + GNUNET_CREDENTIAL_credentials_get_size (unsigned int c_count,
  440. + const struct GNUNET_CREDENTIAL_Credential *cd);
  441. +
  442. +ssize_t
  443. +GNUNET_CREDENTIAL_credentials_serialize (unsigned int c_count,
  444. + const struct GNUNET_CREDENTIAL_Credential *cd,
  445. + size_t dest_size,
  446. + char *dest);
  447. +
  448. +
  449. +int
  450. +GNUNET_CREDENTIAL_credentials_deserialize (size_t len,
  451. + const char *src,
  452. + unsigned int c_count,
  453. + struct GNUNET_CREDENTIAL_Credential *cd);
  454. +
  455. +
  456. +int
  457. +GNUNET_CREDENTIAL_credential_serialize (struct GNUNET_CREDENTIAL_Credential *cred,
  458. + char **data);
  459. +
  460. +struct GNUNET_CREDENTIAL_Credential*
  461. +GNUNET_CREDENTIAL_credential_deserialize (const char* data,
  462. + size_t data_size);
  463. +#endif
  464. +/* end of credential_serialization.h */
  465. --- a/src/credential/Makefile.in
  466. +++ b/src/credential/Makefile.in
  467. @@ -714,8 +714,11 @@ gnunet_service_credential_LDADD = \
  468. $(GN_LIBINTL)
  469. libgnunetcredential_la_SOURCES = \
  470. + credential.h \
  471. credential_api.c \
  472. + credential_serialization.h \
  473. credential_serialization.c \
  474. + credential_misc.h \
  475. credential_misc.c
  476. libgnunetcredential_la_LIBADD = \