aboutsummaryrefslogtreecommitdiff
path: root/src/lib/gnsrecord/gnsrecord_crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/gnsrecord/gnsrecord_crypto.h')
-rw-r--r--src/lib/gnsrecord/gnsrecord_crypto.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lib/gnsrecord/gnsrecord_crypto.h b/src/lib/gnsrecord/gnsrecord_crypto.h
new file mode 100644
index 000000000..4f2e4a5ca
--- /dev/null
+++ b/src/lib/gnsrecord/gnsrecord_crypto.h
@@ -0,0 +1,85 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2018 GNUnet e.V.
4
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.
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 Affero General Public License for more details.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file gnsrecord/gnsrecord_crypto.h
23 * @brief API for GNS record-related crypto
24 * @author Martin Schanzenbach
25 * @author Matthias Wachs
26 * @author Christian Grothoff
27 */
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_constants.h"
31#include "gnunet_signatures.h"
32#include "gnunet_arm_service.h"
33#include "gnunet_gnsrecord_lib.h"
34
35/**
36 * Information we have in an encrypted block with record data (i.e. in the DHT).
37 */
38struct GNRBlockPS
39{
40 /**
41 * Number of bytes signed; also specifies the number of bytes
42 * of encrypted data that follow.
43 */
44 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
45
46 /**
47 * Expiration time of the block.
48 */
49 struct GNUNET_TIME_AbsoluteNBO expiration_time;
50
51 /* followed by encrypted data */
52};
53
54
55/**
56 * Derive session key and iv from label and public key.
57 *
58 * @param iv initialization vector to initialize
59 * @param skey session key to initialize
60 * @param label label to use for KDF
61 * @param pub public key to use for KDF
62 */
63void
64GNR_derive_block_aes_key (unsigned char *ctr,
65 unsigned char *key,
66 const char *label,
67 uint64_t exp,
68 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
69
70
71/**
72 * Derive session key and iv from label and public key.
73 *
74 * @param nonce initialization vector to initialize
75 * @param skey session key to initialize
76 * @param label label to use for KDF
77 * @param pub public key to use for KDF
78 */
79void
80GNR_derive_block_xsalsa_key (unsigned char *nonce,
81 unsigned char *key,
82 const char *label,
83 uint64_t exp,
84 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
85