GNUnet 0.27.0-17-g14611e095
 
Loading...
Searching...
No Matches
gnunet_crypto_lib.h
Go to the documentation of this file.
1/*
2 file is part of GNUnet.
3 Copyright (C) 2001-2023 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
47#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
48#error "Only <gnunet_util_lib.h> can be included directly."
49#endif
50
51#ifndef GNUNET_CRYPTO_LIB_H
52#define GNUNET_CRYPTO_LIB_H
53
54#ifdef __cplusplus
55extern "C" {
56#if 0 /* keep Emacsens' auto-indent happy */
57}
58#endif
59#endif
60
61
62#include "gnunet_common.h"
63#include <stdbool.h>
64#include <sodium.h>
65
70
71#include <gcrypt.h>
72
73
78#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
79
80
106
107
111#define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
112
116#define GNUNET_CRYPTO_AES_IV_LENGTH (128 / 8)
117
121#define GNUNET_CRYPTO_XSALSA20_KEY_LENGTH \
122 crypto_secretbox_xsalsa20poly1305_KEYBYTES
123
127#define GNUNET_CRYPTO_XSALSA20_IV_LENGTH \
128 crypto_secretbox_xsalsa20poly1305_NONCEBYTES
129
133#define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
134
139#define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
140
145{
146 unsigned char encoding[104];
147};
148
149
151
152
175
176
182{
186 unsigned char r[256 / 8];
187
191 unsigned char s[256 / 8];
192};
193
194
199{
203 unsigned char r[256 / 8];
204
208 unsigned char s[256 / 8];
209};
210
211
219{
225 unsigned char q_y[256 / 8];
226};
227
228
234{
239 unsigned char q_y[256 / 8];
240};
241
242
250
257{
262 unsigned char q_y[256 / 8];
263};
264
265
271{
275 unsigned char d[256 / 8];
276};
277
283{
287 unsigned char d[256 / 8];
288};
289
295{
299 unsigned char d[256 / 8];
300};
301
302
308{
312 unsigned char s[512 / 8];
313};
314
321{
326 unsigned char a[256 / 8];
327
332 unsigned char b[256 / 8];
333};
334
335
343{
349 unsigned char q_y[256 / 8];
350};
351
356{
360 unsigned char r[256 / 8];
361
365 unsigned char s[256 / 8];
366};
367
374{
378 unsigned char d[256 / 8];
379};
380
385{
390 uint8_t r[256 / 8];
391};
392
410
421
449
450
476
482{
487 uint32_t type;
488
489 union
490 {
495
496 };
497};
498
499
505{
510 uint32_t type;
511
512 union
513 {
518
519 };
520};
521
547
563
574
576
589
590
598
599
604#define GNUNET_CRYPTO_PAILLIER_BITS 2048
605
606
617
618
633
634
651
652
657{
661 unsigned char d[crypto_core_ed25519_SCALARBYTES];
662};
663
664
669{
674 unsigned char y[crypto_core_ed25519_BYTES];
675};
676
677
685
686
694
695
704
705
713
714
722
723
731
732
740
741
749
750
766
767
773{
774 /*a nonce*/
775 unsigned char snonce[256 / 8];
776};
777
778
784{
785 /*a nonce*/
786 unsigned char bnonce[256 / 8];
787};
788
789
790/* **************** Functions and Macros ************* */
791
799void
801
802
811uint8_t
812GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
813
814
823uint32_t
824GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
825
826
833uint16_t
834GNUNET_CRYPTO_crc16_finish (uint32_t sum);
835
836
845uint16_t
846GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
847
848
858int32_t
859GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
860
869void
870GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
871
872
881void
883 void *buffer,
884 size_t length);
885
886
897void
899 struct GNUNET_Uuid *uuid);
900
901
910uint32_t
912
913
922uint64_t
924
925
935unsigned int *
937
938
945void
948
949
961[[ deprecated ("Use HPKE or other AEAD schemes for encryption") ]]
962ssize_t
964 const void *block,
965 size_t size,
966 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
968 void *result);
969
970
982[[ deprecated ("Use HPKE or other AEAD schemes for encryption") ]]
983ssize_t
985 const void *block,
986 size_t size,
987 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
989 void *result);
990
991
1003void
1005 const void *in_buf,
1006 size_t in_buf_len,
1007 const unsigned char key[GNUNET_CRYPTO_AES_KEY_LENGTH],
1008 const unsigned char iv[GNUNET_CRYPTO_AES_IV_LENGTH],
1009 void *out_buf);
1010
1011
1025 size_t in_buf_len,
1026 const unsigned char in_buf[in_buf_len],
1027 const unsigned char key[GNUNET_CRYPTO_XSALSA20_KEY_LENGTH],
1028 const unsigned char nonce[GNUNET_CRYPTO_XSALSA20_IV_LENGTH],
1029 void *out_buf);
1030
1031
1045 size_t in_buf_len,
1046 const unsigned char in_buf[in_buf_len],
1047 const unsigned char key[GNUNET_CRYPTO_XSALSA20_KEY_LENGTH],
1048 const unsigned char nonce[GNUNET_CRYPTO_XSALSA20_IV_LENGTH],
1049 void *out_buf);
1050
1058void
1059GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
1061
1062
1074 size_t enclen,
1075 struct GNUNET_HashCode *result);
1076
1077
1086#define GNUNET_CRYPTO_hash_from_string(enc, result) \
1087 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
1088
1089
1102uint32_t
1104 const struct GNUNET_HashCode *b);
1105
1106
1115void
1116GNUNET_CRYPTO_hash (const void *block,
1117 size_t size,
1118 struct GNUNET_HashCode *ret);
1119
1120
1125{
1126 char salt[crypto_pwhash_argon2id_SALTBYTES];
1127};
1128
1129
1138void
1140 const void *buf,
1141 size_t buf_len,
1142 struct GNUNET_HashCode *result);
1143
1144
1148struct GNUNET_HashContext;
1149
1150
1156struct GNUNET_HashContext *
1158
1159
1166struct GNUNET_HashContext *
1168
1169
1177void
1179 const void *buf,
1180 size_t size);
1181
1182
1189void
1191 struct GNUNET_HashCode *r_hash);
1192
1193
1199void
1201
1202
1214void
1215GNUNET_CRYPTO_hmac_raw (const void *key,
1216 size_t key_len,
1217 const void *plaintext,
1218 size_t plaintext_len,
1219 struct GNUNET_HashCode *hmac);
1220
1221
1231void
1233 const void *plaintext,
1234 size_t plaintext_len,
1235 struct GNUNET_HashCode *hmac);
1236
1237
1245typedef void
1247 void *cls,
1248 const struct GNUNET_HashCode *res);
1249
1250
1255
1256
1270 const char *filename,
1271 size_t blocksize,
1273 void *callback_cls);
1274
1275
1281void
1283
1284
1292void
1294 struct GNUNET_HashCode *result);
1295
1296
1305void
1307 const struct GNUNET_HashCode *b,
1308 struct GNUNET_HashCode *result);
1309
1310
1319void
1321 const struct GNUNET_HashCode *delta,
1322 struct GNUNET_HashCode *result);
1323
1324
1333void
1335 const struct GNUNET_HashCode *b,
1336 struct GNUNET_HashCode *result);
1337
1338
1345unsigned int
1347
1348
1355unsigned int
1357
1358
1367void
1369 const struct GNUNET_HashCode *hc,
1372
1373
1383int
1384GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1385 const struct GNUNET_HashCode *h2);
1386
1387
1398int
1400 const struct GNUNET_HashCode *h2,
1401 const struct GNUNET_HashCode *target);
1402
1403
1416 const void *salt,
1417 size_t salt_len,
1418 const void *ikm,
1419 size_t ikm_len);
1420
1426{
1427
1428 // The data that is input into HKDF-Expand
1429 const void *data;
1430
1431 // The length of data in bytes
1433
1434};
1435
1436#define GNUNET_CRYPTO_kdf_arg_string(d) \
1437 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1438 { \
1439 (const void*) d, \
1440 strlen (d) \
1441 })
1442
1443
1444#define GNUNET_CRYPTO_kdf_arg_auto(d) \
1445 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1446 { \
1447 (const void*) d, \
1448 sizeof (*d) \
1449 })
1450
1451
1452#define GNUNET_CRYPTO_kdf_arg(d,s) \
1453 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1454 { \
1455 (const void*) d, \
1456 s \
1457 })
1458
1459
1460#define _HKDF_ARGS_VEC_HELPER(...) \
1461 (struct \
1462 GNUNET_CRYPTO_KdfInputArgument[]) { __VA_ARGS__ }
1463
1464#define _HKDF_ARGS_VECLEN_HELPER(...) \
1465 sizeof(_HKDF_ARGS_VEC_HELPER (__VA_ARGS__)) / sizeof ( \
1466 struct GNUNET_CRYPTO_KdfInputArgument)
1467
1468
1484 void *result,
1485 size_t out_len,
1486 const void *xts,
1487 size_t xts_len,
1488 const void *skm,
1489 size_t skm_len,
1490 size_t hkdf_args_count,
1491 const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[
1492 hkdf_args_count]);
1493
1494
1525#define GNUNET_CRYPTO_hkdf_gnunet(result, \
1526 out_len, \
1527 xts, \
1528 xts_len, \
1529 skm, \
1530 skm_len, ...) \
1531 GNUNET_CRYPTO_hkdf_gnunet_v (result, out_len, xts, xts_len, skm, \
1532 skm_len, \
1533 _HKDF_ARGS_VECLEN_HELPER (__VA_ARGS__ \
1534 ), \
1535 _HKDF_ARGS_VEC_HELPER (__VA_ARGS__))
1536
1549 void *result,
1550 size_t out_len,
1551 const struct GNUNET_ShortHashCode *prk,
1552 size_t hkdf_args_count,
1553 const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[
1554 hkdf_args_count]);
1555
1566#define GNUNET_CRYPTO_hkdf_expand(result, \
1567 out_len, \
1568 prk, \
1569 ...) \
1570 GNUNET_CRYPTO_hkdf_expand_v (result, out_len, \
1571 prk, \
1572 _HKDF_ARGS_VECLEN_HELPER (__VA_ARGS__ \
1573 ), \
1574 _HKDF_ARGS_VEC_HELPER (__VA_ARGS__))
1575
1576
1589void
1590GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1591 gcry_mpi_t n,
1592 const void *xts,
1593 size_t xts_len,
1594 const void *skm,
1595 size_t skm_len,
1596 const char *ctx);
1597
1598
1611// #define GNUNET_CRYPTO_kdf GNUNET_CRYPTO_hkdf_gnunet
1612
1613
1621void
1623 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1625
1633void
1635 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1637
1645void
1647 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1649
1657void
1659 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1661
1662
1669char *
1671 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1672
1679char *
1681 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1682
1683
1690char *
1692 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1693
1694
1701char *
1703 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1704
1705
1716 const char *enc,
1717 size_t enclen,
1719
1720
1731 const char *enc,
1732 size_t enclen,
1733 struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1734
1735
1746 const char *enc,
1747 size_t enclen,
1749
1750
1768 int do_create,
1770
1771
1789 int do_create,
1791
1792
1797
1798
1810 const struct GNUNET_CONFIGURATION_Handle *cfg);
1811
1812
1819void
1821
1822
1829void
1831
1832
1839void
1841
1851void
1853 const void *seed,
1854 size_t seedsize,
1856
1866void
1868
1869
1876void
1878
1879
1886void
1888
1895void
1897
1904void
1906
1913void
1915
1916
1923const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1925
1926
1936void
1938
1939
1951 struct GNUNET_PeerIdentity *dst);
1952
1953
1967 cfg,
1968 const struct
1970 *purpose,
1971 struct
1973 sig);
1974
1975
1987GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose,
1988 const struct
1990 const struct
1992 const struct GNUNET_PeerIdentity *identity);
1993
1994
1999
2000
2006{
2011 unsigned char v[256 / 8];
2012};
2013
2018{
2019 unsigned char v[256 / 8];
2020};
2021
2031 unsigned int mem);
2032
2033
2042int
2044 const struct GNUNET_CRYPTO_EccPoint *input);
2045
2046
2058void
2059GNUNET_CRYPTO_ecc_dexp (int val,
2060 struct GNUNET_CRYPTO_EccPoint*r);
2061
2062
2073 struct GNUNET_CRYPTO_EccPoint *r);
2074
2075
2086 const struct GNUNET_CRYPTO_EccScalar *val,
2087 struct GNUNET_CRYPTO_EccPoint *r);
2088
2089
2100 const struct GNUNET_CRYPTO_EccPoint *b,
2101 struct GNUNET_CRYPTO_EccPoint *r);
2102
2103
2114 struct GNUNET_CRYPTO_EccPoint *r_inv);
2115
2116
2124void
2126 struct GNUNET_CRYPTO_EccScalar *r_neg);
2127
2128
2134void
2136
2137
2143void
2145
2146
2153void
2155 struct GNUNET_CRYPTO_EccScalar *r);
2156
2157
2172 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2173 struct GNUNET_HashCode *key_material);
2174
2175
2192 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2193 struct GNUNET_HashCode *key_material);
2194
2195
2213 const struct GNUNET_CRYPTO_EcdhePublicKey *pk,
2214 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2215
2216
2232
2233// Nt
2234#define GNUNET_CRYPTO_HPKE_AEAD_ID 0x0003
2235
2236// Nn
2237#define GNUNET_CRYPTO_HPKE_NONCE_LEN 12
2238
2239// Nk
2240#define GNUNET_CRYPTO_HPKE_KEY_LEN 32
2241
2242// Nt
2243#define GNUNET_CRYPTO_HPKE_TAG_LEN 16
2244
2245// Overhead required for ciphertext
2246#define GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES GNUNET_CRYPTO_HPKE_TAG_LEN
2247
2248// Overhead required for ciphertext
2249#define GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES \
2250 GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES \
2251 + sizeof (struct GNUNET_CRYPTO_HpkeEncapsulation)
2252
2257{
2258 // Receiver
2260 // Sender
2263
2264
2269{
2270 // Participant role
2272
2273 // Encapsulated/Decapsulated key
2275
2276 // Base nonce
2278
2279 // Sequence number
2280 uint64_t seq;
2281
2282 // Exporter secret
2284};
2285
2291{
2292 // Non-elligator X25519 KEM using HKDF256
2294 // Elligator X25519 KEM using HKDF256
2296};
2297
2298
2304{
2309 unsigned char q_y[256 / 8];
2310};
2311
2312
2323 struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc);
2324
2325
2335 pk,
2336 struct GNUNET_CRYPTO_HpkePublicKey *pk_enc);
2337
2353 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2354 struct GNUNET_ShortHashCode *prk);
2355
2371 struct GNUNET_ShortHashCode *prk);
2372
2389 const struct
2391 struct GNUNET_ShortHashCode *prk);
2392
2409 uint8_t random_tweak,
2410 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2413 struct GNUNET_ShortHashCode *shared_secret);
2414
2429 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2431 struct GNUNET_ShortHashCode *shared_secret);
2432
2447 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2448 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2449 struct GNUNET_ShortHashCode *shared_secret);
2450
2466 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2467 struct GNUNET_ShortHashCode *prk);
2468
2484 struct GNUNET_ShortHashCode *prk);
2485
2486
2505 const uint8_t *info, size_t info_len,
2508
2534 enum GNUNET_CRYPTO_HpkeKem kem,
2536 struct GNUNET_CRYPTO_HpkePrivateKey *skE,
2537 struct GNUNET_CRYPTO_HpkePrivateKey *skS,
2538 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2539 const uint8_t *info, size_t info_len,
2540 const uint8_t *psk, size_t psk_len,
2541 const uint8_t *psk_id, size_t psk_id_len,
2544
2570 enum GNUNET_CRYPTO_HpkeKem kem,
2573 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2574 const struct GNUNET_CRYPTO_HpkePublicKey *pkS,
2575 const uint8_t *info, size_t info_len,
2576 const uint8_t *psk, size_t psk_len,
2577 const uint8_t *psk_id, size_t psk_id_len,
2579
2580
2600 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2601 const uint8_t *info,
2602 size_t info_len,
2604
2624 const uint8_t *aad,
2625 size_t aad_len,
2626 const uint8_t *pt,
2627 size_t pt_len,
2628 uint8_t *ct,
2629 unsigned long long *ct_len);
2630
2631
2653 const uint8_t *info, size_t info_len,
2654 const uint8_t*aad, size_t aad_len,
2655 const uint8_t *pt, size_t pt_len,
2656 uint8_t *ct, unsigned long long *ct_len);
2657
2658
2678 const uint8_t*aad, size_t aad_len,
2679 const uint8_t *ct, size_t ct_len,
2680 uint8_t *pt, unsigned long long *pt_len_p);
2681
2682
2704 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2705 const uint8_t *info, size_t info_len,
2706 const uint8_t*aad, size_t aad_len,
2707 const uint8_t *ct, size_t ct_len,
2708 uint8_t *pt, unsigned long long *pt_len);
2709
2710
2725 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2726 struct GNUNET_HashCode *key_material);
2727
2728
2747 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2748 struct GNUNET_HashCode *key_material);
2749
2750
2765 priv,
2766 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2767 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2768
2781 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2782 struct GNUNET_HashCode *key_material);
2783
2784
2802 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2803 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2804 struct GNUNET_CRYPTO_EddsaSignature *sig);
2805
2806
2819#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2820 /* check size is set correctly */ \
2821 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2822 /* check 'ps' begins with the purpose */ \
2823 GNUNET_static_assert (((void*) (ps)) == \
2824 ((void*) &(ps)->purpose)); \
2825 GNUNET_assert (GNUNET_OK == \
2826 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2827 &(ps)->purpose, \
2828 sig)); \
2829} while (0)
2830
2831
2849 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2850 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2851 struct GNUNET_CRYPTO_EcdsaSignature *sig);
2852
2864 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2865 void *data,
2866 size_t size,
2867 struct GNUNET_CRYPTO_EddsaSignature *sig);
2868
2881#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2882 /* check size is set correctly */ \
2883 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2884 /* check 'ps' begins with the purpose */ \
2885 GNUNET_static_assert (((void*) (ps)) == \
2886 ((void*) &(ps)->purpose)); \
2887 GNUNET_assert (GNUNET_OK == \
2888 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2889 &(ps)->purpose, \
2890 sig)); \
2891} while (0)
2892
2910 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2911 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2913
2914
2928#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2929 /* check size is set correctly */ \
2930 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2931 /* check 'ps' begins with the purpose */ \
2932 GNUNET_static_assert (((void*) (ps)) == \
2933 ((void*) &(ps)->purpose)); \
2934 GNUNET_assert (GNUNET_OK == \
2935 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2936 &(ps)->purpose, \
2937 sig)); \
2938} while (0)
2939
2940
2961 uint32_t purpose,
2962 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2963 const struct GNUNET_CRYPTO_EddsaSignature *sig,
2964 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2965
2966
2981#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2982 /* check size is set correctly */ \
2983 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2984 /* check 'ps' begins with the purpose */ \
2985 GNUNET_static_assert (((void*) (ps)) == \
2986 ((void*) &(ps)->purpose)); \
2987 GNUNET_CRYPTO_eddsa_verify_ (purp, \
2988 &(ps)->purpose, \
2989 sig, \
2990 pub); \
2991 })
2992
3013 uint32_t purpose,
3014 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
3015 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
3016 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
3017
3018
3033#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
3034 /* check size is set correctly */ \
3035 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3036 /* check 'ps' begins with the purpose */ \
3037 GNUNET_static_assert (((void*) (ps)) == \
3038 ((void*) &(ps)->purpose)); \
3039 GNUNET_CRYPTO_ecdsa_verify_ (purp, \
3040 &(ps)->purpose, \
3041 sig, \
3042 pub); \
3043 })
3044
3065 uint32_t purpose,
3066 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
3067 const struct GNUNET_CRYPTO_Edx25519Signature *sig,
3068 const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
3069
3070
3085#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
3086 /* check size is set correctly */ \
3087 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3088 /* check 'ps' begins with the purpose */ \
3089 GNUNET_static_assert (((void*) (ps)) == \
3090 ((void*) &(ps)->purpose)); \
3091 GNUNET_CRYPTO_edx25519_verify_ (purp, \
3092 &(ps)->purpose, \
3093 sig, \
3094 pub); \
3095 })
3096
3112 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
3113 const char *label,
3114 const char *context);
3115
3116
3128void
3130 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
3131 const char *label,
3132 const char *context,
3134
3149 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
3150 const char *label,
3151 const char *context,
3152 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3153 struct GNUNET_CRYPTO_EcdsaSignature *sig);
3154
3155
3172void
3174 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
3175 const char *label,
3176 const char *context,
3178
3179
3191void
3193 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
3194 const char *label,
3195 const char *context,
3197
3198
3214 const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
3215 const char *label,
3216 const char *context,
3217 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3218 struct GNUNET_CRYPTO_EddsaSignature *sig);
3219
3220
3227void
3229 const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
3231
3244void
3246 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
3247 const void *seed,
3248 size_t seedsize,
3250
3251
3262void
3265 const void *seed,
3266 size_t seedsize,
3268
3269
3278void
3280 struct GNUNET_CRYPTO_EcdhePublicKey *point,
3281 bool *high_y,
3282 const struct GNUNET_CRYPTO_ElligatorRepresentative *representative);
3283
3284
3295bool
3297 uint8_t random_tweak,
3299 const struct GNUNET_CRYPTO_EcdhePublicKey *pub);
3300
3301
3315 uint8_t random_tweak,
3319
3335
3336
3343void
3346
3347
3356void
3358 size_t size,
3359 gcry_mpi_t val);
3360
3361
3371void
3373 const void *data,
3374 size_t size);
3375
3376
3383void
3385 struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3386 struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
3387
3388
3400int
3402 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3403 const gcry_mpi_t m,
3404 int desired_ops,
3405 struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext);
3406
3407
3416void
3418 const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
3419 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3420 const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext,
3421 gcry_mpi_t m);
3422
3423
3438int
3440 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3441 const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
3442 const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
3444
3445
3452int
3454 const struct GNUNET_CRYPTO_PaillierCiphertext *c);
3455
3456
3457/* ********* Chaum-style RSA-based blind signatures ******************* */
3458
3459
3464
3469
3481
3486
3487
3495GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
3496
3497
3503void
3505
3506
3515size_t
3517 const struct GNUNET_CRYPTO_RsaPrivateKey *key,
3518 void **buffer);
3519
3520
3531 size_t buf_size);
3532
3533
3542 const struct GNUNET_CRYPTO_RsaPrivateKey *key);
3543
3544
3553 const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
3554
3555
3562void
3564 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3565 struct GNUNET_HashCode *hc);
3566
3567
3573bool
3575 const struct GNUNET_CRYPTO_RsaPublicKey *key);
3576
3583unsigned int
3585
3586
3592void
3594
3595
3604size_t
3606 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3607 void **buffer);
3608
3609
3620 size_t len);
3621
3622
3631
3632
3640int
3642 const struct GNUNET_CRYPTO_RsaSignature *s2);
3643
3651int
3653 const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
3654 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
3655
3656
3664int
3666 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
3667
3668
3685
3686
3698GNUNET_CRYPTO_rsa_blind (const void *message,
3699 size_t message_size,
3700 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3703
3704
3714 const struct
3716
3717
3728 const void *message,
3729 size_t message_size);
3730
3731
3738void
3741
3742
3748void
3750
3751
3759size_t
3761 const struct GNUNET_CRYPTO_RsaSignature *sig,
3762 void **buffer);
3763
3764
3775 const void *buf,
3776 size_t buf_size);
3777
3778
3787 const struct GNUNET_CRYPTO_RsaSignature *sig);
3788
3789
3802 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3804
3805
3817GNUNET_CRYPTO_rsa_verify (const void *message,
3818 size_t message_size,
3819 const struct GNUNET_CRYPTO_RsaSignature *sig,
3820 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
3821
3822
3828void
3830
3831
3838void
3840 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3842
3843
3857void
3859 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3860 const char *seed,
3861 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3862 struct GNUNET_CRYPTO_CsRSecret r[2]);
3863
3864
3871void
3873 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3874 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3875
3876
3887void
3889 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3890 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3891
3892
3910
3911
3919
3920
3933void
3935 const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
3936 const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
3937 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3938 const void *msg,
3939 size_t msg_len,
3940 struct GNUNET_CRYPTO_CsC blinded_c[2],
3941 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3942
3943
3950{
3955 unsigned int b;
3956
3961};
3962
3963
3978void
3980 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3981 const struct GNUNET_CRYPTO_CsRSecret r[2],
3982 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3983 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3984
3985
3993void
3995 const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
3996 const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
3997 struct GNUNET_CRYPTO_CsS *signature_scalar);
3998
3999
4012 const struct GNUNET_CRYPTO_CsSignature *sig,
4013 const struct GNUNET_CRYPTO_CsPublicKey *pub,
4014 const void *msg,
4015 size_t msg_len);
4016
4017
4039
4040
4075
4076
4114
4115
4154
4155
4189
4190
4223
4224
4232
4233
4238{
4239
4244
4248 unsigned int rc;
4249
4253 union
4254 {
4259
4261
4262};
4263
4264
4276
4277
4289 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4290 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4291 const char *salt);
4292
4293
4299void
4301 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4302
4303
4309void
4311 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4312
4313
4319void
4321 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
4322
4323
4329void
4331 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4332
4333
4339void
4341 struct GNUNET_CRYPTO_BlindedMessage *bm);
4342
4343
4352 struct GNUNET_CRYPTO_BlindedMessage *bm);
4353
4354
4364
4365
4372void
4375
4376
4385 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4386
4387
4396 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4397
4398
4407
4408
4417 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4418
4419
4427int
4429 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
4430 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
4431
4432
4440int
4442 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
4443
4444
4452int
4454 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
4455 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
4456
4457
4465int
4467 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
4468 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
4469
4470
4486 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4487 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4489 ...);
4490
4491
4507 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4508 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4510 va_list ap);
4511
4512
4528
4529
4544 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4545 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4546 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4547 const void *message,
4548 size_t message_size,
4549 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
4550
4551
4563 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4564 const char *salt,
4565 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
4566
4567
4581 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
4582 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4583 const void *message,
4584 size_t message_size,
4585 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
4586 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4587
4588
4600 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4601 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
4602 const void *message,
4603 size_t message_size);
4604
4605
4616ssize_t
4619
4635 const void *buffer,
4636 size_t len,
4638 size_t *read);
4639
4650ssize_t
4653
4654
4667ssize_t
4670 void*buffer,
4671 size_t len);
4672
4673
4688 const void*buffer,
4689 size_t len,
4691 size_t *read);
4692
4693
4706ssize_t
4709 void*buffer,
4710 size_t len);
4711
4712
4723ssize_t
4725 const struct GNUNET_CRYPTO_BlindableKeySignature *sig);
4726
4727
4738ssize_t
4740
4741
4754ssize_t
4757 const void*buffer,
4758 size_t len);
4759
4760
4773ssize_t
4775 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4776 void*buffer,
4777 size_t len);
4778
4779
4795 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4796 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4798
4814 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4815 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4816 unsigned char *sig);
4817
4818
4830#define GNUNET_CRYPTO_blinded_key_sign(priv,ps,sig) do { \
4831 /* check size is set correctly */ \
4832 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4833 /* check 'ps' begins with the purpose */ \
4834 GNUNET_static_assert (((void*) (ps)) == \
4835 ((void*) &(ps)->purpose)); \
4836 GNUNET_assert (GNUNET_OK == \
4837 GNUNET_CRYPTO_blinded_key_sign_ (priv, \
4838 &(ps)->purpose, \
4839 sig)); \
4840} while (0)
4841
4842
4862 uint32_t purpose,
4863 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4864 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4866
4884 uint32_t purpose,
4885 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4886 const unsigned char *sig,
4888
4889
4903#define GNUNET_CRYPTO_blinded_key_signature_verify(purp,ps,sig,pub) ({ \
4904 /* check size is set correctly */ \
4905 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4906 /* check 'ps' begins with the purpose */ \
4907 GNUNET_static_assert (((void*) (ps)) == \
4908 ((void*) &(ps)->purpose)); \
4909 GNUNET_CRYPTO_blinded_key_signature_verify_ (purp, \
4910 &(ps)->purpose, \
4911 sig, \
4912 pub); \
4913 })
4914
4915
4924char *
4927
4928
4937char *
4940
4941
4952 struct
4954 *key);
4955
4956
4967 struct
4969 *key);
4970
4971
4982 privkey,
4984 *key);
4985
4996ssize_t
4998 const struct GNUNET_CRYPTO_HpkePublicKey *key);
4999
5015 const void *buffer,
5016 size_t len,
5018 size_t *read);
5019
5032ssize_t
5034 const struct GNUNET_CRYPTO_HpkePublicKey *key,
5035 void*buffer,
5036 size_t len);
5037
5043void
5045
5059 const char *ikm,
5060 size_t ikm_len,
5061 struct GNUNET_CRYPTO_HpkePrivateKey *sk);
5062
5063
5075
5086ssize_t
5089
5103GNUNET_CRYPTO_read_hpke_sk_from_buffer (const void *buffer,
5104 size_t len,
5105 struct
5107 key,
5108 size_t *read);
5109
5122ssize_t
5125 key,
5126 void *buffer,
5127 size_t len);
5128
5140 privkey,
5142 *key);
5143
5144#if 0 /* keep Emacsens' auto-indent happy */
5145{
5146#endif
5147#ifdef __cplusplus
5148}
5149#endif
5150
5151
5152/* ifndef GNUNET_CRYPTO_LIB_H */
5153#endif
5154
/* end of group addition */
5156
5157/* end of gnunet_crypto_lib.h */
struct GNUNET_MessageHeader * msg
Definition 005.c:2
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition gnunet-arm.c:103
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static int ret
Final status code.
Definition gnunet-arm.c:93
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static char * filename
static uint8_t seed
static pa_context * context
Pulseaudio context.
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_CRYPTO_BlindablePrivateKey pk
Private key from command line option, or NULL.
static char * pkey
Public key of the zone to look in, in ASCII.
static char * res
Currently read line or NULL on EOF.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
#define info
static unsigned char ikm[256/8]
The initial key material for the peer.
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
static struct GNUNET_Process * p
Helper process we started.
Definition gnunet-uri.c:38
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static enum @52 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a public and a private ECC key.
Definition crypto_ecc.c:732
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:454
void GNUNET_CRYPTO_edx25519_key_get_public(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Extract the public key for the given private key.
bool GNUNET_CRYPTO_ecdhe_elligator_encoding(uint8_t random_tweak, struct GNUNET_CRYPTO_ElligatorRepresentative *r, const struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Encodes a point on Curve25519 to a an element of the underlying finite field.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_private_key_derive(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *label, const char *context)
Derive a private key from a given private key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private EdDSA key.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
void GNUNET_CRYPTO_eddsa_private_key_derive(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPrivateScalar *result)
Derive a private scalar from a given private key and a label.
void GNUNET_CRYPTO_symmetric_create_session_key(struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Create a new random session key.
void GNUNET_CRYPTO_edx25519_key_clear(struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Clear memory that was used to store a private key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public(const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition crypto_ecc.c:708
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_x25519_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *sk, const struct GNUNET_CRYPTO_EcdhePublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a ECDH public key and a private X25519 key.
Definition crypto_ecc.c:767
void GNUNET_CRYPTO_ecdhe_elligator_key_create(struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk)
Generates a private key for Curve25519.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
void GNUNET_CRYPTO_edx25519_private_key_derive(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PrivateKey *result)
Derive a private scalar from a given private key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_Edx25519Signature *sig, const struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Verify Edx25519 signature.
void GNUNET_CRYPTO_edx25519_key_create_from_seed(const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Create a new private key for Edx25519 from a given seed.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private X25519 key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey)
Create a new private key by reading it from a file.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_edx25519_public_key_derive(const struct GNUNET_CRYPTO_Edx25519PublicKey *pub, const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PublicKey *result)
Derive a public key from a given public key and a label.
void GNUNET_CRYPTO_random_timeflake(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_Uuid *uuid)
Fill UUID with a timeflake pseudo-random value.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:201
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
HPKE END.
Definition crypto_ecc.c:805
void GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:447
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps_norand(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_ShortHashCode *prk)
Deterministic variant of GNUNET_CRYPTO_hpke_kem_encaps.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition crypto_ecc.c:625
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition crypto_ecc.c:745
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition crypto_ecc.c:840
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:480
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh decapsulation with own private key and the representative of the received public key...
void GNUNET_CRYPTO_ecdhe_elligator_decoding(struct GNUNET_CRYPTO_EcdhePublicKey *point, bool *high_y, const struct GNUNET_CRYPTO_ElligatorRepresentative *representative)
Clears the most significant bit and second most significant bit of the serialized representaive befor...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition crypto_ecc.c:823
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition crypto_ecc.c:554
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_by_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
Sign a given block with a specific purpose using the host's peer identity.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_encrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const unsigned char key[crypto_secretbox_xsalsa20poly1305_KEYBYTES], const unsigned char nonce[crypto_secretbox_xsalsa20poly1305_NONCEBYTES], void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:465
void GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:440
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a X25519 public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_xsalsa20poly1305_decrypt(size_t in_buf_len, const unsigned char in_buf[in_buf_len], const unsigned char key[crypto_secretbox_xsalsa20poly1305_KEYBYTES], const unsigned char nonce[crypto_secretbox_xsalsa20poly1305_NONCEBYTES], void *out_buf)
Encrypt the given data using XSalsa20-Poly1305.
void GNUNET_CRYPTO_eddsa_public_key_derive(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPublicKey *result)
Derive a public key from a given public key and a label.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition crypto_ecc.c:500
void GNUNET_CRYPTO_aes_ctr(const void *in_buf, size_t in_buf_len, const unsigned char key[(256/8)], const unsigned char iv[(128/8)], void *out_buf)
Decrypt or encrypt a given block using a symmetric key using AES in counter mode.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
void GNUNET_CRYPTO_edx25519_key_create(struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Create a new private key.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Derive key.
Definition crypto_ecc.c:190
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_x25519(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a EdDSA public key and a private ECDH key.
Definition crypto_ecc.c:783
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a EdDSA public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_verify_peer_identity(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_PeerIdentity *identity)
Verify a given signature with a peer's identity.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
unsigned int * GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n)
Get an array with a random permutation of the numbers 0...n-1.
void GNUNET_CRYPTO_private_key_clear(struct GNUNET_CRYPTO_BlindablePrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_pkey.c:47
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_sign_(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_Edx25519Signature *sig)
Edx25519 sign a given block.
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:433
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:217
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition crypto_ecc.c:649
@ GNUNET_CRYPTO_QUALITY_STRONG
High-quality operations are desired.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_extract(struct GNUNET_ShortHashCode *prk, const void *salt, size_t salt_len, const void *ikm, size_t ikm_len)
HKDF-Extract using SHA256.
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition crypto_hash.c:55
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition crypto_crc.c:99
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
uint8_t GNUNET_CRYPTO_crc8_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition crypto_crc.c:151
int GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2, const struct GNUNET_HashCode *target)
Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hash_from_string2(const char *enc, size_t enclen, struct GNUNET_HashCode *result)
Convert ASCII encoding back to a 'struct GNUNET_HashCode'.
Definition crypto_hash.c:72
uint16_t GNUNET_CRYPTO_crc16_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition crypto_crc.c:133
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand_v(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk, size_t hkdf_args_count, const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[hkdf_args_count])
HKDF-Expand using SHA256.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
uint32_t GNUNET_CRYPTO_hash_distance_u32(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b)
Compute the distance between 2 hashcodes.
Definition crypto_hash.c:92
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_gnunet_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, size_t hkdf_args_count, const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[hkdf_args_count])
Derive key.
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
char * GNUNET_CRYPTO_eddsa_private_key_to_string(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a private key to a string.
Definition crypto_ecc.c:282
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros(const struct GNUNET_HashCode *h)
Count the number of leading 0 bits in h.
struct GNUNET_CRYPTO_BlindSignPrivateKey * GNUNET_CRYPTO_bsign_priv_incref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Increment reference counter of the given bsign_priv.
#define GNUNET_CRYPTO_HASH_LENGTH
Length of a hash value.
GNUNET_CRYPTO_HpkeKem
HPKE KEM identifier TODO: Elligator KEM was requested at IANA; Number is currently a placeholder.
void(* GNUNET_CRYPTO_HashCompletedCallback)(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over the specified file has completed.
void GNUNET_CRYPTO_blinded_message_decref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Decrement reference counter of a bm, and free it if it reaches zero.
void GNUNET_CRYPTO_mpi_scan_unsigned(gcry_mpi_t *result, const void *data, size_t size)
Convert data buffer into MPI value.
Definition crypto_mpi.c:132
ssize_t GNUNET_CRYPTO_write_hpke_pk_to_buffer(const struct GNUNET_CRYPTO_HpkePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePublicKey to a compact buffer.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_raw(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *data, size_t size, struct GNUNET_CRYPTO_EddsaSignature *sig)
Definition crypto_ecc.c:604
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,...)
Initialize public-private key pair for blind signatures.
void GNUNET_CRYPTO_ecc_rnd_mpi(struct GNUNET_CRYPTO_EccScalar *r, struct GNUNET_CRYPTO_EccScalar *r_neg)
Obtain a random scalar for point multiplication on the curve and its additive inverse.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
#define GNUNET_CRYPTO_PAILLIER_BITS
Size of paillier plain texts and public keys.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_blind(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Blinds the given message with the given blinding key.
Definition crypto_rsa.c:807
GNUNET_CRYPTO_KeyType
Key type for the blindable public key union.
ssize_t GNUNET_CRYPTO_hpke_sk_get_length(const struct GNUNET_CRYPTO_HpkePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePrivateKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_(const struct GNUNET_CRYPTO_BlindablePrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_BlindableKeySignature *sig)
Sign a given block.
#define GNUNET_CRYPTO_AES_IV_LENGTH
length of an AES key in bytes
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sig_incref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Increment reference counter of the given blind_sig.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePublicKey from a compact buffer.
void GNUNET_CRYPTO_cs_r_get_public(const struct GNUNET_CRYPTO_CsRSecret *r_priv, struct GNUNET_CRYPTO_CsRPublic *r_pub)
Extract the public R of the given secret r.
Definition crypto_cs.c:97
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_dexp_mpi(const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition crypto_rsa.c:144
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition crypto_rsa.c:173
int GNUNET_CRYPTO_bsign_pub_cmp(const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1, const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2)
Compare two denomination public keys.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_pmul_mpi(const struct GNUNET_CRYPTO_EccPoint *p, const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the point p on the elliptic curve by val.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_blind_sig_unblind(const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig, const union GNUNET_CRYPTO_BlindingSecretP *bks, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values, const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Unblind blind signature.
char * GNUNET_CRYPTO_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
ssize_t GNUNET_CRYPTO_blinded_key_signature_get_length_by_type(uint32_t type)
Get the compacted length of a signature by type.
void GNUNET_CRYPTO_kdf_mod_mpi(gcry_mpi_t *r, gcry_mpi_t n, const void *xts, size_t xts_len, const void *skm, size_t skm_len, const char *ctx)
Deterministically generate a pseudo-random number uniformly from the integers modulo a libgcrypt mpi.
Definition crypto_kdf.c:38
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sign(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const char *salt, const struct GNUNET_CRYPTO_BlindedMessage *blinded_message)
Create blind signature.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_cs_r_derive(const struct GNUNET_CRYPTO_CsSessionNonce *nonce, const char *seed, const struct GNUNET_CRYPTO_CsPrivateKey *lts, struct GNUNET_CRYPTO_CsRSecret r[2])
Derive a new secret r pair r0 and r1.
Definition crypto_cs.c:79
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_public_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Parses a (Base32) string representation of the public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition crypto_ecc.c:336
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_blindable_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
int GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, const struct GNUNET_CRYPTO_EccPoint *input)
Calculate ECC discrete logarithm for small factors.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
GNUNET_CRYPTO_BlindSignatureAlgorithm
Types of public keys used for blind signatures.
ssize_t GNUNET_CRYPTO_write_blindable_sk_to_buffer(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePrivateKey to a compact buffer.
ssize_t GNUNET_CRYPTO_write_blinded_key_signature_to_buffer(const struct GNUNET_CRYPTO_BlindableKeySignature *sig, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindableKeySignature to a compact buffer.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_ub_sig_incref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Increment reference counter of the given ub_sig.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
#define GNUNET_CRYPTO_HPKE_KEY_LEN
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
Definition crypto_crc.c:123
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
This is a signature function for ECDSA which takes a private key, derives/blinds it and signs the mes...
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format.
Definition crypto_rsa.c:423
int GNUNET_CRYPTO_ub_sig_cmp(const struct GNUNET_CRYPTO_UnblindedSignature *sig1, const struct GNUNET_CRYPTO_UnblindedSignature *sig2)
Compare two denomination signatures.
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_message_blind_to_sign(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const union GNUNET_CRYPTO_BlindingSecretP *bks, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values)
Blind message for blind signing with dk using blinding secret coin_bks.
int GNUNET_CRYPTO_blinded_message_cmp(const struct GNUNET_CRYPTO_BlindedMessage *bp1, const struct GNUNET_CRYPTO_BlindedMessage *bp2)
Compare two blinded messages.
int GNUNET_CRYPTO_rsa_signature_cmp(const struct GNUNET_CRYPTO_RsaSignature *s1, const struct GNUNET_CRYPTO_RsaSignature *s2)
Compare the values of two signatures.
Definition crypto_rsa.c:602
int GNUNET_CRYPTO_blind_sig_cmp(const struct GNUNET_CRYPTO_BlindedSignature *sig1, const struct GNUNET_CRYPTO_BlindedSignature *sig2)
Compare two blinded denomination signatures.
void GNUNET_CRYPTO_cs_private_key_get_public(const struct GNUNET_CRYPTO_CsPrivateKey *priv, struct GNUNET_CRYPTO_CsPublicKey *pub)
Extract the public key of the given private key.
Definition crypto_cs.c:52
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_BlindableKeySignature *sig, const struct GNUNET_CRYPTO_BlindablePublicKey *pub)
Verify a given signature.
ssize_t GNUNET_CRYPTO_hpke_pk_get_length(const struct GNUNET_CRYPTO_HpkePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePublicKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal_oneshot(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len)
RFC9180 HPKE encryption.
uint32_t GNUNET_CRYPTO_crc16_step(uint32_t sum, const void *buf, size_t len)
Perform an incremental step in a CRC16 (for TCP/IP) calculation.
Definition crypto_crc.c:110
void GNUNET_CRYPTO_cs_unblind(const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar, const struct GNUNET_CRYPTO_CsBlindingSecret *bs, struct GNUNET_CRYPTO_CsS *signature_scalar)
Unblind a blind-signed signature using a c that was blinded.
Definition crypto_cs.c:313
int GNUNET_CRYPTO_paillier_encrypt(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const gcry_mpi_t m, int desired_ops, struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext)
Encrypt a plaintext with a paillier public key.
bool GNUNET_CRYPTO_rsa_public_key_check(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Check if key is well-formed.
Definition crypto_rsa.c:301
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
Definition crypto_ecc.c:255
char * GNUNET_CRYPTO_blindable_private_key_to_string(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Creates a (Base32) string representation of the private key.
ssize_t GNUNET_CRYPTO_write_hpke_sk_to_buffer(const struct GNUNET_CRYPTO_HpkePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePrivateKey to a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create(enum GNUNET_CRYPTO_HpkeKeyType type, struct GNUNET_CRYPTO_HpkePrivateKey *pk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_BlindablePrivateKey *sk, struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create_va(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, va_list ap)
Initialize public-private key pair for blind signatures.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition crypto_ecc.c:361
unsigned int GNUNET_CRYPTO_rsa_public_key_len(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Obtain the length of the RSA key in bits.
Definition crypto_rsa.c:680
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open_oneshot(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_rsa_blinded_message_free(struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Free memory occupied by blinded message.
Definition crypto_rsa.c:799
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len_p)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_dup(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Duplicate the given public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived(const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes a private key and derives it using the label and c...
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_fdh(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const void *message, size_t message_size)
Create and sign a full domain hash of a message.
Definition crypto_rsa.c:992
void GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc)
Compute hash over the public key.
Definition crypto_rsa.c:407
ssize_t GNUNET_CRYPTO_blinded_key_signature_get_length(const struct GNUNET_CRYPTO_BlindableKeySignature *sig)
Get the compacted length of a #GNUNET_CRYPTO_Signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_CRYPTO_HpkePrivateKey *skS, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_decode(const void *buf, size_t buf_size)
Decode the private key from the data-format back to the "normal", internal format.
Definition crypto_rsa.c:204
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the 'proof-of-work' hash (an expensive hash).
Definition crypto_pow.c:42
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkePublicKey *pkS, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition crypto_rsa.c:268
void GNUNET_CRYPTO_mpi_print_unsigned(void *buf, size_t size, gcry_mpi_t val)
Output the given MPI value to the given buffer in network byte order.
Definition crypto_mpi.c:79
GNUNET_SCHEDULER_Priority
Valid task priorities.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_get_public(const struct GNUNET_CRYPTO_HpkePrivateKey *privkey, struct GNUNET_CRYPTO_HpkePublicKey *key)
Retrieves the GNUNET_CRYPTO_HpkePublicKey representation of a GNUNET_CRYPTO_HpkePrivateKey.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
void GNUNET_CRYPTO_cs_calc_blinded_c(const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], const struct GNUNET_CRYPTO_CsRPublic r_pub[2], const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len, struct GNUNET_CRYPTO_CsC blinded_c[2], struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind)
Calculate two blinded c's.
Definition crypto_cs.c:237
size_t GNUNET_CRYPTO_rsa_public_key_encode(const struct GNUNET_CRYPTO_RsaPublicKey *key, void **buffer)
Encode the public key in a format suitable for storing it into a file.
Definition crypto_rsa.c:325
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
Extract the public key of the given private scalar.
int GNUNET_CRYPTO_rsa_private_key_cmp(const struct GNUNET_CRYPTO_RsaPrivateKey *p1, const struct GNUNET_CRYPTO_RsaPrivateKey *p2)
Compare the values of two private keys.
Definition crypto_rsa.c:654
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_signature_verify_raw_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_CRYPTO_BlindablePublicKey *pub)
Verify a given signature.
void GNUNET_CRYPTO_blinding_input_values_decref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Decrement reference counter of the given bi, and free it if it reaches zero.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
void GNUNET_CRYPTO_ecc_dexp(int val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sig_verify(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig, const void *message, size_t message_size)
Verify signature made blindly.
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_blinding_input_values_incref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Increment reference counter of the given bi.
#define GNUNET_CRYPTO_HPKE_NONCE_LEN
void GNUNET_CRYPTO_hpke_sk_clear(struct GNUNET_CRYPTO_HpkePrivateKey *key)
Clear memory that was used to store a GNUNET_CRYPTO_HpkePrivateKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePrivateKey from a compact buffer.
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
struct GNUNET_CRYPTO_EccDlogContext * GNUNET_CRYPTO_ecc_dlog_prepare(unsigned int max, unsigned int mem)
Do pre-calculation for ECC discrete logarithm for small factors.
#define GNUNET_CRYPTO_XSALSA20_KEY_LENGTH
length of an XSalsa20 key in bytes
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition crypto_ecc.c:228
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_private_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Parses a (Base32) string representation of the private key.
void GNUNET_CRYPTO_unblinded_sig_decref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Decrement reference counter of a ub_sig, and free it if it reaches zero.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_raw_(const struct GNUNET_CRYPTO_BlindablePrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, unsigned char *sig)
Sign a given block.
int GNUNET_CRYPTO_paillier_hom_add(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *c1, const struct GNUNET_CRYPTO_PaillierCiphertext *c2, struct GNUNET_CRYPTO_PaillierCiphertext *result)
Compute a ciphertext that represents the sum of the plaintext in c1 and c2.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup(const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_blinded(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Sign a blinded value, which must be a full domain hash of a message.
Definition crypto_rsa.c:970
ssize_t GNUNET_CRYPTO_write_blindable_pk_to_buffer(const struct GNUNET_CRYPTO_BlindablePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePublicKey to a compact buffer.
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_blinded_message_incref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Increment reference counter of the given bm.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_private_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a string representing a private key to a private key.
Definition crypto_ecc.c:386
void GNUNET_CRYPTO_blinded_sig_decref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Decrement reference counter of a blind_sig, and free it if it reaches zero.
GNUNET_CRYPTO_HpkeMode
HPKE RFC 9180.
unsigned int GNUNET_CRYPTO_hash_count_tailing_zeros(const struct GNUNET_HashCode *h)
Count the number of tailing 0 bits in h.
ssize_t GNUNET_CRYPTO_blindable_sk_get_length(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePrivateKey.
Definition crypto_pkey.c:64
char * GNUNET_CRYPTO_ecdsa_private_key_to_string(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv)
Convert a private key to a string.
Definition crypto_ecc.c:309
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_rnd(struct GNUNET_CRYPTO_EccPoint *r, struct GNUNET_CRYPTO_EccPoint *r_inv)
Obtain a random point on the curve and its additive inverse.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_cs_verify(const struct GNUNET_CRYPTO_CsSignature *sig, const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len)
Verify whether the given message corresponds to the given signature and the signature is valid with r...
Definition crypto_cs.c:325
int GNUNET_CRYPTO_rsa_public_key_cmp(const struct GNUNET_CRYPTO_RsaPublicKey *p1, const struct GNUNET_CRYPTO_RsaPublicKey *p2)
Compare the values of two public keys.
Definition crypto_rsa.c:628
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create2(enum GNUNET_CRYPTO_HpkeKeyType type, const char *ikm, size_t ikm_len, struct GNUNET_CRYPTO_HpkePrivateKey *sk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_dup(const struct GNUNET_CRYPTO_RsaPrivateKey *key)
Duplicate the given private key.
void GNUNET_CRYPTO_paillier_decrypt(const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, gcry_mpi_t m)
Decrypt a paillier ciphertext with a private key.
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_CRYPTO_BlindSignPublicKey * GNUNET_CRYPTO_bsign_pub_incref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Increment reference counter of the given bsign_pub.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_unblind(const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey)
Unblind a blind-signed signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_BlindablePublicKey *pk, struct GNUNET_CRYPTO_HpkePublicKey *pk_enc)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_private_key_get_public(const struct GNUNET_CRYPTO_RsaPrivateKey *priv)
Extract the public key of the given private key.
Definition crypto_rsa.c:233
ssize_t GNUNET_CRYPTO_blindable_pk_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:85
void GNUNET_CRYPTO_blind_sign_pub_decref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Decrement reference counter of a bsign_pub, and free it if it reaches zero.
void GNUNET_CRYPTO_cs_sign_derive(const struct GNUNET_CRYPTO_CsPrivateKey *priv, const struct GNUNET_CRYPTO_CsRSecret r[2], const struct GNUNET_CRYPTO_CsBlindedMessage *bm, struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig)
Sign a blinded c.
Definition crypto_cs.c:281
void GNUNET_CRYPTO_cs_private_key_generate(struct GNUNET_CRYPTO_CsPrivateKey *priv)
Create a new random private key.
Definition crypto_cs.c:45
void GNUNET_CRYPTO_blind_sign_priv_decref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Decrement reference counter of a bsign_priv, and free it if it reaches zero.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
void GNUNET_CRYPTO_hmac_raw(const void *key, size_t key_len, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104) TODO: Shouldn't this be the standard hmac function and the abo...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_verify(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaPublicKey *public_key)
Verify whether the given hash corresponds to the given signature and the signature is valid with resp...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_sk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePrivateKey from a compact buffer.
GNUNET_CRYPTO_HpkeKeyType
Key type for the hpke public key union.
#define GNUNET_CRYPTO_XSALSA20_IV_LENGTH
length of an XSALSA20 IV in bytes
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition crypto_rsa.c:181
GNUNET_CRYPTO_HpkeRole
Role of the HPKE participant.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_add(const struct GNUNET_CRYPTO_EccPoint *a, const struct GNUNET_CRYPTO_EccPoint *b, struct GNUNET_CRYPTO_EccPoint *r)
Add two points on the elliptic curve.
#define GNUNET_PACKED
gcc-ism to get packed structs.
ssize_t GNUNET_CRYPTO_read_blinded_key_signature_from_buffer(struct GNUNET_CRYPTO_BlindableKeySignature *sig, const void *buffer, size_t len)
Reads a GNUNET_CRYPTO_BlindableKeySignature from a compact buffer.
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_get_blinding_input_values(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const char *salt)
Compute blinding input values for a given nonce and salt.
void GNUNET_CRYPTO_cs_blinding_secrets_derive(const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed, struct GNUNET_CRYPTO_CsBlindingSecret bs[2])
Derives new random blinding factors.
Definition crypto_cs.c:107
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519_HKDF256
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519ELLIGATOR_HKDF256
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
@ GNUNET_CRYPTO_HPKE_MODE_PSK
@ GNUNET_CRYPTO_HPKE_MODE_AUTH_PSK
@ GNUNET_CRYPTO_HPKE_MODE_BASE
@ GNUNET_CRYPTO_HPKE_MODE_AUTH
@ GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519
Type for X25519 hybrid public key encryption.
@ GNUNET_CRYPTO_HPKE_ROLE_R
@ GNUNET_CRYPTO_HPKE_ROLE_S
#define max(x, y)
static unsigned int size
Size of the "table".
Definition peer.c:68
static struct GNUNET_TIME_Relative delta
Definition speedup.c:36
type for (message) authentication keys
unsigned char key[(512/8)]
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@21 details
Details, depending on cipher.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@20 details
Details, depending on cipher.
unsigned int rc
Reference counter.
struct GNUNET_HashCode pub_key_hash
Hash of the public key.
struct GNUNET_CRYPTO_CsPublicKey cs_public_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
struct GNUNET_CRYPTO_RsaPublicKey * rsa_public_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
An identity signature as per LSD0001.
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
A private key for an identity as per LSD0001.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
An identity key as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
Blinded message ready for blind signing.
unsigned int rc
Reference counter.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the sign blinded message.
struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedMessage::@22 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Type for blinded signatures.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
union GNUNET_CRYPTO_BlindedSignature::@19 details
Details, depending on cipher.
Input needed for blinding a message.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CSPublicRPairP cs_values
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindingInputValues::@23 details
Details, depending on cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Secret r for Cs denominations.
struct GNUNET_CRYPTO_CsRSecret r[2]
Pair of Public R values for Cs denominations.
struct GNUNET_CRYPTO_CsRPublic r_pub[2]
Type of a nonce used for challenges.
struct GNUNET_ShortHashCode value
The value of the nonce.
unsigned char y[crypto_core_ed25519_BYTES]
This is a point on the Curve25519.
unsigned char d[crypto_core_ed25519_SCALARBYTES]
32 byte scalar
blinded s in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The Sign Answer for Clause Blind Schnorr signature.
struct GNUNET_CRYPTO_CsBlindS s_scalar
The blinded s scalar calculated from c_b.
unsigned int b
To make ROS problem harder, the signer chooses an unpredictable b and only calculates signature of c_...
CS Parameters derived from the message during blinding to create blinded signature.
struct GNUNET_CRYPTO_CsC c[2]
The Clause Schnorr c_0 and c_1 containing the blinded message.
struct GNUNET_CRYPTO_CsSessionNonce nonce
Nonce used in initial request.
Nonce for computing blinding factors.
Secret used for blinding (alpha and beta).
struct GNUNET_CRYPTO_Cs25519Scalar alpha
struct GNUNET_CRYPTO_Cs25519Scalar beta
Schnorr c to be signed.
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The private information of an Schnorr key pair.
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The public information of an Schnorr key pair.
struct GNUNET_CRYPTO_Cs25519Point point
the public R (derived from r) used in c
struct GNUNET_CRYPTO_Cs25519Point point
the private r used in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
s in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
Nonce for the session, picked by client, shared with the signer.
CS Signtature containing scalar s and point R.
struct GNUNET_CRYPTO_CsS s_scalar
Schnorr signatures are composed of a scalar s and a curve point.
struct GNUNET_CRYPTO_CsRPublic r_point
Curve point of the Schnorr signature.
Internal structure used to cache pre-calculated values for DLOG calculation.
unsigned int mem
How much memory should we use (relates to the number of entries in the map).
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
unsigned char v[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A ECC scalar for use in point multiplications.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
an ECC signature using ECDSA
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC scalar encoded for transmission.
unsigned char s[512/8]
s is the expandedprivate 512-bit scalar of a private key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using EdDSA.
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key material encoded for transmission.
unsigned char b[256/8]
b consists of 32 bytes which where originally the lower 32bytes of the key expansion.
unsigned char a[256/8]
a is a value mod n, where n has at most 256 bits.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using Edx25519 (same as in EdDSA).
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Special private ECC key generated by GNUNET_CRYPTO_ecdhe_elligator_key_create.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Elligator representative (always for Curve25519)
uint8_t r[256/8]
Represents an element of Curve25519 finite field.
Context used when hashing a file.
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
void * callback_cls
Closure for callback.
enum GNUNET_SCHEDULER_Priority priority
Priority we use.
0-terminated ASCII encoding of a struct GNUNET_HashCode.
struct GNUNET_ShortHashCode exporter_secret
enum GNUNET_CRYPTO_HpkeRole role
HPKE DHKEM encapsulation (X25519) See RFC 9180.
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A public key used for decryption.
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_key
An ECDHE/X25519 key.
A public key used for encryption.
struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_key
An ECDHE/X25519 key.
As input for variadic HKDF API.
int32_t remaining_ops
Guaranteed minimum number of homomorphic operations with this ciphertext, in network byte order (NBO)...
unsigned char bits[2048 *2/8]
The bits of the ciphertext.
unsigned char mu[2048/8]
Mu-component of the private key.
unsigned char lambda[2048/8]
Lambda-component of the private key.
unsigned char n[2048/8]
N value.
Value for a salt for GNUNET_CRYPTO_pow_hash().
char salt[crypto_pwhash_argon2id_SALTBYTES]
RSA Parameters to create blinded signature.
size_t blinded_msg_size
Size of the blinded_msg to be signed.
void * blinded_msg
Blinded message to be signed Note: is malloc()'ed!
Constant-size pre-secret for blinding key generation.
uint32_t pre_secret[8]
Bits used to generate the blinding key.
The private information of an RSA key pair.
Definition crypto_rsa.c:41
The public information of an RSA key pair.
Definition crypto_rsa.c:53
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
unsigned char twofish_key[(256/8)]
Actual key for TwoFish.
unsigned char aes_key[(256/8)]
Actual key for AES.
Type of (unblinded) signatures.
union GNUNET_CRYPTO_UnblindedSignature::@18 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
A 256-bit hashcode.
A UUID, a 128 bit "random" value.
const char * str
Definition time.c:1252
Nonce used to deterministiacally derive input values used in multi-round blind signature protocols.
struct GNUNET_CRYPTO_CsSessionNonce cs_nonce
Nonce used when signing with CS.
Type of blinding secrets.
struct GNUNET_CRYPTO_CsBlindingNonce nonce
Clause Schnorr nonce.
struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks
Variant for RSA for blind signatures.