aboutsummaryrefslogtreecommitdiff
path: root/src/credential/credential_serialization.h
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 07:52:23 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-14 07:52:23 +0100
commit80bdda1c79efb648cb56bdfb63da0c2c0db3ff45 (patch)
tree6b6b99779062dbe1325974acb5c4ea19b78e63e8 /src/credential/credential_serialization.h
parent12a3d957faa3932db31ffea0497dd083fd381b86 (diff)
downloadgnunet-80bdda1c79efb648cb56bdfb63da0c2c0db3ff45.tar.gz
gnunet-80bdda1c79efb648cb56bdfb63da0c2c0db3ff45.zip
-add serializer
Diffstat (limited to 'src/credential/credential_serialization.h')
-rw-r--r--src/credential/credential_serialization.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/credential/credential_serialization.h b/src/credential/credential_serialization.h
new file mode 100644
index 000000000..7e984ce0a
--- /dev/null
+++ b/src/credential/credential_serialization.h
@@ -0,0 +1,81 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21
22/**
23 * @file credential/credential_serialization.h
24 * @brief API to serialize and deserialize delegation chains
25 * and credentials
26 * @author Martin Schanzenbach
27 */
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_constants.h"
31#include "gnunet_credential_service.h"
32
33/**
34 * Calculate how many bytes we will need to serialize
35 * the given delegation chain and credential
36 *
37 * @param d_count number of delegation chain entries
38 * @param dd array of #GNUNET_CREDENTIAL_Delegation
39 * @param cd a #GNUNET_CREDENTIAL_Credential
40 * @return the required size to serialize
41 */
42size_t
43GNUNET_CREDENTIAL_delegation_chain_get_size (unsigned int d_count,
44 const struct GNUNET_CREDENTIAL_Delegation *dd,
45 const struct GNUNET_CREDENTIAL_Credential *cd);
46
47/**
48 * Serizalize the given delegation chain entries and credential
49 *
50 * @param d_count number of delegation chain entries
51 * @param dd array of #GNUNET_CREDENTIAL_Delegation
52 * @param cd a #GNUNET_CREDENTIAL_Credential
53 * @param dest_size size of the destination
54 * @param dest where to store the result
55 * @return the size of the data, -1 on failure
56 */
57ssize_t
58GNUNET_CREDENTIAL_delegation_chain_serialize (unsigned int d_count,
59 const struct GNUNET_CREDENTIAL_Delegation *dd,
60 const struct GNUNET_CREDENTIAL_Credential *cd,
61 size_t dest_size,
62 char *dest);
63
64
65/**
66 * Deserialize the given destination
67 *
68 * @param len size of the serialized delegation chain and cred
69 * @param src the serialized data
70 * @param d_count the number of delegation chain entries
71 * @param dd where to put the delegation chain entries
72 * @param cd where to put the credential data
73 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
74 */
75int
76GNUNET_CREDENTIAL_delegation_chain_deserialize (size_t len,
77 const char *src,
78 unsigned int d_count,
79 struct GNUNET_CREDENTIAL_Delegation *dd,
80 struct GNUNET_CREDENTIAL_Credential *cd);
81/* end of credential_serialization.h */