GNUnet 0.22.1
gnunet_crypto_lib.h
Go to the documentation of this file.
1/*
2 This 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 <stdbool.h>
63#include <sodium.h>
64
69
70#include <gcrypt.h>
71
72
77#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
78
79
85{
92
98
105
106
110#define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
111
115#define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
116
121#define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
122
127{
128 unsigned char encoding[104];
129};
130
131
133
134
141{
148
156};
157
158
164{
168 unsigned char r[256 / 8];
169
173 unsigned char s[256 / 8];
174};
175
176
181{
185 unsigned char r[256 / 8];
186
190 unsigned char s[256 / 8];
191};
192
193
201{
207 unsigned char q_y[256 / 8];
208};
209
210
216{
221 unsigned char q_y[256 / 8];
222};
223
224
229{
231};
232
233
240{
245 unsigned char q_y[256 / 8];
246};
247
248
254{
258 unsigned char d[256 / 8];
259};
260
266{
270 unsigned char d[256 / 8];
271};
272
278{
282 unsigned char d[256 / 8];
283};
284
285
291{
295 unsigned char s[512 / 8];
296};
297
304{
309 unsigned char a[256 / 8];
310
315 unsigned char b[256 / 8];
316};
317
318
326{
332 unsigned char q_y[256 / 8];
333};
334
339{
343 unsigned char r[256 / 8];
344
348 unsigned char s[256 / 8];
349};
350
357{
361 unsigned char d[256 / 8];
362};
363
368{
373 uint8_t r[256 / 8];
374};
375
380{
386
393
400{
406 uint32_t type;
407
408 union
409 {
414
419 };
420};
421
422
427{
433 uint32_t type;
434
435 union
436 {
441
446 };
447};
448
449
454{
460 uint32_t type;
461
462 union
463 {
468
473 };
474};
475
480{
485
490};
491
496{
501};
502
504
512{
514
516};
517
518
523{
525};
526
527
532#define GNUNET_CRYPTO_PAILLIER_BITS 2048
533
534
539{
543 unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
544};
545
546
551{
559 unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
560};
561
562
567{
573
577 unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
578};
579
580
585{
589 unsigned char d[crypto_core_ed25519_SCALARBYTES];
590};
591
592
597{
602 unsigned char y[crypto_core_ed25519_BYTES];
603};
604
605
610{
612};
613
614
619{
621};
622
623
628{
631};
632
633
638{
640};
641
642
647{
649};
650
651
656{
658};
659
660
665{
667};
668
669
674{
676};
677
678
683{
688
693};
694
695
701{
702 /*a nonce*/
703 unsigned char snonce[256 / 8];
704};
705
706
712{
713 /*a nonce*/
714 unsigned char bnonce[256 / 8];
715};
716
717
718/* **************** Functions and Macros ************* */
719
727void
729
730
739uint8_t
740GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
741
742
751uint32_t
752GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
753
754
761uint16_t
763
764
773uint16_t
774GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
775
776
786int32_t
787GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
788
797void
798GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
799
800
809void
811 void *buffer,
812 size_t length);
813
814
825void
827 struct GNUNET_Uuid *uuid);
828
829
838uint32_t
840
841
850uint64_t
852
853
863unsigned int *
865
866
873void
876
877
889ssize_t
891 const void *block,
892 size_t size,
893 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
895 void *result);
896
897
909ssize_t
911 const void *block,
912 size_t size,
913 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
915 void *result);
916
917
927void
930 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
931 const void *salt,
932 size_t salt_len,
933 ...);
934
935
944void
947 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
948 const void *salt,
949 size_t salt_len,
950 va_list argp);
951
952
960void
961GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
963
964
976 size_t enclen,
977 struct GNUNET_HashCode *result);
978
979
988#define GNUNET_CRYPTO_hash_from_string(enc, result) \
989 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
990
991
1004uint32_t
1006 const struct GNUNET_HashCode *b);
1007
1008
1017void
1018GNUNET_CRYPTO_hash (const void *block,
1019 size_t size,
1020 struct GNUNET_HashCode *ret);
1021
1022
1027{
1028 char salt[crypto_pwhash_argon2id_SALTBYTES];
1029};
1030
1031
1040void
1042 const void *buf,
1043 size_t buf_len,
1044 struct GNUNET_HashCode *result);
1045
1046
1050struct GNUNET_HashContext;
1051
1052
1058struct GNUNET_HashContext *
1060
1061
1068struct GNUNET_HashContext *
1070
1071
1079void
1081 const void *buf,
1082 size_t size);
1083
1084
1091void
1093 struct GNUNET_HashCode *r_hash);
1094
1095
1101void
1103
1104
1116void
1117GNUNET_CRYPTO_hmac_raw (const void *key,
1118 size_t key_len,
1119 const void *plaintext,
1120 size_t plaintext_len,
1121 struct GNUNET_HashCode *hmac);
1122
1123
1133void
1135 const void *plaintext,
1136 size_t plaintext_len,
1137 struct GNUNET_HashCode *hmac);
1138
1139
1147typedef void
1149 void *cls,
1150 const struct GNUNET_HashCode *res);
1151
1152
1157
1158
1172 const char *filename,
1173 size_t blocksize,
1175 void *callback_cls);
1176
1177
1183void
1185
1186
1194void
1196 struct GNUNET_HashCode *result);
1197
1198
1207void
1209 const struct GNUNET_HashCode *b,
1210 struct GNUNET_HashCode *result);
1211
1212
1221void
1223 const struct GNUNET_HashCode *delta,
1224 struct GNUNET_HashCode *result);
1225
1226
1235void
1237 const struct GNUNET_HashCode *b,
1238 struct GNUNET_HashCode *result);
1239
1240
1247unsigned int
1249
1250
1257unsigned int
1259
1260
1269void
1271 const struct GNUNET_HashCode *hc,
1274
1275
1285int
1286GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1287 const struct GNUNET_HashCode *h2);
1288
1289
1300int
1302 const struct GNUNET_HashCode *h2,
1303 const struct GNUNET_HashCode *target);
1304
1305
1315void
1317 struct GNUNET_CRYPTO_AuthKey *key,
1318 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1319 const void *salt,
1320 size_t salt_len,
1321 va_list argp);
1322
1323
1333void
1335 struct GNUNET_CRYPTO_AuthKey *key,
1336 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1337 const void *salt,
1338 size_t salt_len,
1339 ...);
1340
1341
1354 const void *salt,
1355 size_t salt_len,
1356 const void *ikm,
1357 size_t ikm_len);
1358
1369 size_t out_len,
1370 const struct GNUNET_ShortHashCode *prk,
1371 ...);
1372
1383 size_t out_len,
1384 const struct GNUNET_ShortHashCode *prk,
1385 va_list argp);
1386
1387
1410 size_t out_len,
1411 const void *xts,
1412 size_t xts_len,
1413 const void *skm,
1414 size_t skm_len,
1415 ...);
1416
1417
1432 size_t out_len,
1433 const void *xts,
1434 size_t xts_len,
1435 const void *skm,
1436 size_t skm_len,
1437 va_list argp);
1438
1439
1453 size_t out_len,
1454 const void *xts,
1455 size_t xts_len,
1456 const void *skm,
1457 size_t skm_len,
1458 va_list argp);
1459
1460
1473void
1474GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1475 gcry_mpi_t n,
1476 const void *xts,
1477 size_t xts_len,
1478 const void *skm,
1479 size_t skm_len,
1480 const char *ctx);
1481
1482
1497 size_t out_len,
1498 const void *xts,
1499 size_t xts_len,
1500 const void *skm,
1501 size_t skm_len,
1502 ...);
1503
1504
1512void
1514 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1516
1524void
1526 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1528
1536void
1538 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1540
1548void
1550 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1552
1553
1560char *
1562 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1563
1570char *
1572 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1573
1574
1581char *
1583 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1584
1585
1592char *
1594 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1595
1596
1607 const char *enc,
1608 size_t enclen,
1610
1611
1622 const char *enc,
1623 size_t enclen,
1624 struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1625
1626
1637 const char *enc,
1638 size_t enclen,
1640
1641
1659 int do_create,
1661
1662
1680 int do_create,
1682
1683
1688
1689
1701 const struct GNUNET_CONFIGURATION_Handle *cfg);
1702
1703
1710void
1712
1713
1720void
1722
1723
1730void
1732
1742void
1744 const void *seed,
1745 size_t seedsize,
1747
1757void
1759
1760
1767void
1769
1770
1777void
1779
1786void
1788
1795void
1797
1804void
1806
1807
1814const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1816
1817
1827void
1829
1830
1842 struct GNUNET_PeerIdentity *dst);
1843
1844
1858 const struct
1860 struct GNUNET_CRYPTO_EddsaSignature *sig);
1861
1862
1874GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose,
1875 const struct
1877 const struct
1879 const struct GNUNET_PeerIdentity *identity);
1880
1881
1886
1887
1893{
1898 unsigned char v[256 / 8];
1899};
1900
1905{
1906 unsigned char v[256 / 8];
1907};
1908
1918 unsigned int mem);
1919
1920
1929int
1931 const struct GNUNET_CRYPTO_EccPoint *input);
1932
1933
1945void
1946GNUNET_CRYPTO_ecc_dexp (int val,
1947 struct GNUNET_CRYPTO_EccPoint*r);
1948
1949
1960 struct GNUNET_CRYPTO_EccPoint *r);
1961
1962
1973 const struct GNUNET_CRYPTO_EccScalar *val,
1974 struct GNUNET_CRYPTO_EccPoint *r);
1975
1976
1987 const struct GNUNET_CRYPTO_EccPoint *b,
1988 struct GNUNET_CRYPTO_EccPoint *r);
1989
1990
2001 struct GNUNET_CRYPTO_EccPoint *r_inv);
2002
2003
2011void
2013 struct GNUNET_CRYPTO_EccScalar *r_neg);
2014
2015
2021void
2023
2024
2030void
2032
2033
2040void
2042 struct GNUNET_CRYPTO_EccScalar *r);
2043
2044
2059 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2060 struct GNUNET_HashCode *key_material);
2061
2062
2079 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2080 struct GNUNET_HashCode *key_material);
2081
2082
2100 const struct GNUNET_CRYPTO_EcdhePublicKey *pk,
2101 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2102
2103
2113{
2119
2120// Nt
2121#define GNUNET_CRYPTO_HPKE_AEAD_ID 0x0003
2122
2123// Nn
2124#define GNUNET_CRYPTO_HPKE_NONCE_LEN 12
2125
2126// Nk
2127#define GNUNET_CRYPTO_HPKE_KEY_LEN 32
2128
2129// Nt
2130#define GNUNET_CRYPTO_HPKE_TAG_LEN 16
2131
2132// Overhead required for ciphertext
2133#define GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES GNUNET_CRYPTO_HPKE_TAG_LEN
2134
2135// Overhead required for ciphertext
2136#define GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES \
2137 GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES \
2138 + sizeof (struct GNUNET_CRYPTO_HpkeEncapsulation)
2139
2141{
2145
2147{
2151 uint64_t seq;
2153};
2154
2156{
2159};
2160
2161
2167{
2172 unsigned char q_y[256 / 8];
2173};
2174
2175
2185 struct GNUNET_CRYPTO_EcdhePrivateKey *x25519);
2186
2187
2197 struct GNUNET_CRYPTO_EcdhePublicKey *x25519);
2198
2214 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2215 struct GNUNET_ShortHashCode *prk);
2216
2232 struct GNUNET_ShortHashCode *prk);
2233
2250 const struct
2252 struct GNUNET_ShortHashCode *prk);
2253
2270 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2271 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
2273 const struct GNUNET_CRYPTO_EcdhePrivateKey *skE,
2274 struct GNUNET_ShortHashCode *shared_secret);
2275
2291 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2292 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
2294 struct GNUNET_ShortHashCode *shared_secret);
2295
2296
2312 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2313 const struct GNUNET_CRYPTO_EcdhePublicKey *pkS,
2314 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2315 struct GNUNET_ShortHashCode *shared_secret);
2316
2317
2334 uint8_t random_tweak,
2335 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2338 struct GNUNET_ShortHashCode *shared_secret);
2339
2354 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2356 struct GNUNET_ShortHashCode *shared_secret);
2357
2372 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2373 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2374 struct GNUNET_ShortHashCode *shared_secret);
2375
2393 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2394 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
2397 struct GNUNET_ShortHashCode *shared_secret);
2398
2415 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2416 const struct GNUNET_CRYPTO_EcdhePrivateKey *skS,
2418 struct GNUNET_ShortHashCode *shared_secret);
2419
2420
2437 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2438 const struct GNUNET_CRYPTO_EcdhePublicKey *pkS,
2439 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2440 struct GNUNET_ShortHashCode *shared_secret);
2441
2457 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2458 struct GNUNET_ShortHashCode *prk);
2459
2475 struct GNUNET_ShortHashCode *prk);
2476
2477
2496 const uint8_t *info, size_t info_len,
2499
2525 enum GNUNET_CRYPTO_HpkeKem kem,
2529 const struct GNUNET_CRYPTO_EcdhePublicKey *pkR,
2530 const uint8_t *info, size_t info_len,
2531 const uint8_t *psk, size_t psk_len,
2532 const uint8_t *psk_id, size_t psk_id_len,
2535
2561 enum GNUNET_CRYPTO_HpkeKem kem,
2564 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2565 const struct GNUNET_CRYPTO_EcdhePublicKey *pkS,
2566 const uint8_t *info, size_t info_len,
2567 const uint8_t *psk, size_t psk_len,
2568 const uint8_t *psk_id, size_t psk_id_len,
2570
2571
2591 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2592 const uint8_t *info,
2593 size_t info_len,
2595
2615 const uint8_t *aad,
2616 size_t aad_len,
2617 const uint8_t *pt,
2618 size_t pt_len,
2619 uint8_t *ct,
2620 unsigned long long *ct_len);
2621
2622
2644 const uint8_t *info, size_t info_len,
2645 const uint8_t*aad, size_t aad_len,
2646 const uint8_t *pt, size_t pt_len,
2647 uint8_t *ct, unsigned long long *ct_len);
2648
2649
2669 const uint8_t*aad, size_t aad_len,
2670 const uint8_t *ct, size_t ct_len,
2671 uint8_t *pt, unsigned long long *pt_len_p);
2672
2673
2695 const struct GNUNET_CRYPTO_EcdhePrivateKey *skR,
2696 const uint8_t *info, size_t info_len,
2697 const uint8_t*aad, size_t aad_len,
2698 const uint8_t *ct, size_t ct_len,
2699 uint8_t *pt, unsigned long long *pt_len);
2700
2701
2716 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2717 struct GNUNET_HashCode *key_material);
2718
2719
2738 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2739 struct GNUNET_HashCode *key_material);
2740
2741
2756 priv,
2757 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2758 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2759
2772 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2773 struct GNUNET_HashCode *key_material);
2774
2775
2793 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2794 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2795 struct GNUNET_CRYPTO_EddsaSignature *sig);
2796
2797
2810#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2811 /* check size is set correctly */ \
2812 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2813 /* check 'ps' begins with the purpose */ \
2814 GNUNET_static_assert (((void*) (ps)) == \
2815 ((void*) &(ps)->purpose)); \
2816 GNUNET_assert (GNUNET_OK == \
2817 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2818 &(ps)->purpose, \
2819 sig)); \
2820} while (0)
2821
2822
2840 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2841 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2842 struct GNUNET_CRYPTO_EcdsaSignature *sig);
2843
2855 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2856 void *data,
2857 size_t size,
2858 struct GNUNET_CRYPTO_EddsaSignature *sig);
2859
2872#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2873 /* check size is set correctly */ \
2874 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2875 /* check 'ps' begins with the purpose */ \
2876 GNUNET_static_assert (((void*) (ps)) == \
2877 ((void*) &(ps)->purpose)); \
2878 GNUNET_assert (GNUNET_OK == \
2879 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2880 &(ps)->purpose, \
2881 sig)); \
2882} while (0)
2883
2901 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2902 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2904
2905
2919#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2920 /* check size is set correctly */ \
2921 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2922 /* check 'ps' begins with the purpose */ \
2923 GNUNET_static_assert (((void*) (ps)) == \
2924 ((void*) &(ps)->purpose)); \
2925 GNUNET_assert (GNUNET_OK == \
2926 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2927 &(ps)->purpose, \
2928 sig)); \
2929} while (0)
2930
2931
2952 uint32_t purpose,
2953 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2954 const struct GNUNET_CRYPTO_EddsaSignature *sig,
2955 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2956
2957
2972#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2973 /* check size is set correctly */ \
2974 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2975 /* check 'ps' begins with the purpose */ \
2976 GNUNET_static_assert (((void*) (ps)) == \
2977 ((void*) &(ps)->purpose)); \
2978 GNUNET_CRYPTO_eddsa_verify_ (purp, \
2979 &(ps)->purpose, \
2980 sig, \
2981 pub); \
2982 })
2983
3004 uint32_t purpose,
3005 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
3006 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
3007 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
3008
3009
3024#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
3025 /* check size is set correctly */ \
3026 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3027 /* check 'ps' begins with the purpose */ \
3028 GNUNET_static_assert (((void*) (ps)) == \
3029 ((void*) &(ps)->purpose)); \
3030 GNUNET_CRYPTO_ecdsa_verify_ (purp, \
3031 &(ps)->purpose, \
3032 sig, \
3033 pub); \
3034 })
3035
3056 uint32_t purpose,
3057 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
3058 const struct GNUNET_CRYPTO_Edx25519Signature *sig,
3059 const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
3060
3061
3076#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
3077 /* check size is set correctly */ \
3078 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3079 /* check 'ps' begins with the purpose */ \
3080 GNUNET_static_assert (((void*) (ps)) == \
3081 ((void*) &(ps)->purpose)); \
3082 GNUNET_CRYPTO_edx25519_verify_ (purp, \
3083 &(ps)->purpose, \
3084 sig, \
3085 pub); \
3086 })
3087
3103 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
3104 const char *label,
3105 const char *context);
3106
3107
3119void
3121 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
3122 const char *label,
3123 const char *context,
3125
3140 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
3141 const char *label,
3142 const char *context,
3143 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
3144 struct GNUNET_CRYPTO_EcdsaSignature *sig);
3145
3146
3163void
3165 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
3166 const char *label,
3167 const char *context,
3169
3170
3182void
3184 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
3185 const char *label,
3186 const char *context,
3188
3189
3205 const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
3206 const char *label,
3207 const char *context,
3208 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
3209 struct GNUNET_CRYPTO_EddsaSignature *sig);
3210
3211
3218void
3220 const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
3222
3235void
3237 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
3238 const void *seed,
3239 size_t seedsize,
3241
3242
3253void
3256 const void *seed,
3257 size_t seedsize,
3259
3260
3269void
3271 struct GNUNET_CRYPTO_EcdhePublicKey *point,
3272 bool *high_y,
3273 const struct GNUNET_CRYPTO_ElligatorRepresentative *representative);
3274
3275
3286bool
3288 uint8_t random_tweak,
3290 const struct GNUNET_CRYPTO_EcdhePublicKey *pub);
3291
3292
3306 uint8_t random_tweak,
3310
3326
3327
3334void
3337
3338
3347void
3349 size_t size,
3350 gcry_mpi_t val);
3351
3352
3362void
3364 const void *data,
3365 size_t size);
3366
3367
3374void
3376 struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3377 struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
3378
3379
3391int
3393 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3394 const gcry_mpi_t m,
3395 int desired_ops,
3396 struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext);
3397
3398
3407void
3409 const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
3410 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3411 const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext,
3412 gcry_mpi_t m);
3413
3414
3429int
3431 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3432 const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
3433 const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
3435
3436
3443int
3445 const struct GNUNET_CRYPTO_PaillierCiphertext *c);
3446
3447
3448/* ********* Chaum-style RSA-based blind signatures ******************* */
3449
3450
3455
3460
3465{
3471};
3472
3477
3478
3486GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
3487
3488
3494void
3496
3497
3506size_t
3508 const struct GNUNET_CRYPTO_RsaPrivateKey *key,
3509 void **buffer);
3510
3511
3522 size_t buf_size);
3523
3524
3533 const struct GNUNET_CRYPTO_RsaPrivateKey *key);
3534
3535
3544 const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
3545
3546
3553void
3555 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3556 struct GNUNET_HashCode *hc);
3557
3558
3564bool
3566 const struct GNUNET_CRYPTO_RsaPublicKey *key);
3567
3574unsigned int
3576
3577
3583void
3585
3586
3595size_t
3597 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3598 void **buffer);
3599
3600
3611 size_t len);
3612
3613
3622
3623
3631int
3633 const struct GNUNET_CRYPTO_RsaSignature *s2);
3634
3642int
3644 const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
3645 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
3646
3647
3655int
3657 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
3658
3659
3664{
3670
3675};
3676
3677
3689GNUNET_CRYPTO_rsa_blind (const void *message,
3690 size_t message_size,
3691 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3694
3695
3705 const struct
3707
3708
3719 const void *message,
3720 size_t message_size);
3721
3722
3729void
3732
3733
3739void
3741
3742
3750size_t
3752 const struct GNUNET_CRYPTO_RsaSignature *sig,
3753 void **buffer);
3754
3755
3766 const void *buf,
3767 size_t buf_size);
3768
3769
3778 const struct GNUNET_CRYPTO_RsaSignature *sig);
3779
3780
3793 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3795
3796
3808GNUNET_CRYPTO_rsa_verify (const void *message,
3809 size_t message_size,
3810 const struct GNUNET_CRYPTO_RsaSignature *sig,
3811 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
3812
3813
3819void
3821
3822
3829void
3831 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3833
3834
3848void
3850 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3851 const char *seed,
3852 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3853 struct GNUNET_CRYPTO_CsRSecret r[2]);
3854
3855
3862void
3864 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3865 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3866
3867
3878void
3880 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3881 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3882
3883
3889{
3894
3899
3900};
3901
3902
3907{
3909};
3910
3911
3924void
3926 const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
3927 const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
3928 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3929 const void *msg,
3930 size_t msg_len,
3931 struct GNUNET_CRYPTO_CsC blinded_c[2],
3932 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3933
3934
3941{
3946 unsigned int b;
3947
3952};
3953
3954
3969void
3971 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3972 const struct GNUNET_CRYPTO_CsRSecret r[2],
3973 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3974 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3975
3976
3984void
3986 const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
3987 const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
3988 struct GNUNET_CRYPTO_CsS *signature_scalar);
3989
3990
4003 const struct GNUNET_CRYPTO_CsSignature *sig,
4004 const struct GNUNET_CRYPTO_CsPublicKey *pub,
4005 const void *msg,
4006 size_t msg_len);
4007
4008
4013{
4014
4019
4024
4030
4031
4036{
4037
4042
4046 unsigned int rc;
4047
4051 union
4052 {
4057
4062
4064
4065};
4066
4067
4073{
4074
4079
4083 unsigned int rc;
4084
4088 union
4089 {
4096
4101
4103
4104};
4105
4106
4111{
4112
4117
4121 unsigned int rc;
4122
4127
4131 union
4132 {
4137
4142
4144};
4145
4146
4151{
4152
4157
4161 unsigned int rc;
4162
4166 union
4167 {
4172
4177
4179};
4180
4181
4186{
4191
4195 unsigned int rc;
4196
4200 union
4201 {
4206
4211
4213};
4214
4215
4220{
4222};
4223
4224
4229{
4230
4235
4239 unsigned int rc;
4240
4244 union
4245 {
4250
4252
4253};
4254
4255
4261{
4266};
4267
4268
4280 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4281 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4282 const char *salt);
4283
4284
4290void
4292 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4293
4294
4300void
4302 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4303
4304
4310void
4312 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
4313
4314
4320void
4322 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4323
4324
4330void
4332 struct GNUNET_CRYPTO_BlindedMessage *bm);
4333
4334
4343 struct GNUNET_CRYPTO_BlindedMessage *bm);
4344
4345
4355
4356
4363void
4366
4367
4376 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4377
4378
4387 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4388
4389
4398
4399
4408 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4409
4410
4418int
4420 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
4421 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
4422
4423
4431int
4433 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
4434
4435
4443int
4445 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
4446 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
4447
4448
4456int
4458 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
4459 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
4460
4461
4477 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4478 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4480 ...);
4481
4482
4498 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4499 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4501 va_list ap);
4502
4503
4508{
4513
4518};
4519
4520
4535 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4536 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4537 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4538 const void *message,
4539 size_t message_size,
4540 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
4541
4542
4554 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4555 const char *salt,
4556 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
4557
4558
4572 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
4573 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4574 const void *message,
4575 size_t message_size,
4576 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
4577 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4578
4579
4591 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4592 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
4593 const void *message,
4594 size_t message_size);
4595
4596
4607ssize_t
4610
4626 const void *buffer,
4627 size_t len,
4629 size_t *read);
4630
4641ssize_t
4643 const struct GNUNET_CRYPTO_PrivateKey *key);
4644
4645
4658ssize_t
4661 void*buffer,
4662 size_t len);
4663
4664
4679 const void*buffer,
4680 size_t len,
4682 size_t *read);
4683
4684
4697ssize_t
4699 const struct GNUNET_CRYPTO_PrivateKey *key,
4700 void*buffer,
4701 size_t len);
4702
4703
4714ssize_t
4716 const struct GNUNET_CRYPTO_Signature *sig);
4717
4718
4729ssize_t
4731
4732
4745ssize_t
4747 struct GNUNET_CRYPTO_Signature *sig,
4748 const void*buffer,
4749 size_t len);
4750
4751
4764ssize_t
4766 const struct GNUNET_CRYPTO_Signature *sig,
4767 void*buffer,
4768 size_t len);
4769
4770
4786 const struct GNUNET_CRYPTO_PrivateKey *priv,
4787 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
4788 struct GNUNET_CRYPTO_Signature *sig);
4789
4805 const struct GNUNET_CRYPTO_PrivateKey *priv,
4806 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
4807 unsigned char *sig);
4808
4809
4821#define GNUNET_CRYPTO_sign(priv,ps,sig) do { \
4822 /* check size is set correctly */ \
4823 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4824 /* check 'ps' begins with the purpose */ \
4825 GNUNET_static_assert (((void*) (ps)) == \
4826 ((void*) &(ps)->purpose)); \
4827 GNUNET_assert (GNUNET_OK == \
4828 GNUNET_CRYPTO_sign_ (priv, \
4829 &(ps)->purpose, \
4830 sig)); \
4831} while (0)
4832
4833
4853 uint32_t purpose,
4854 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
4855 const struct GNUNET_CRYPTO_Signature *sig,
4856 const struct GNUNET_CRYPTO_PublicKey *pub);
4857
4875 uint32_t purpose,
4876 const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
4877 const unsigned char *sig,
4878 const struct GNUNET_CRYPTO_PublicKey *pub);
4879
4880
4894#define GNUNET_CRYPTO_signature_verify(purp,ps,sig,pub) ({ \
4895 /* check size is set correctly */ \
4896 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4897 /* check 'ps' begins with the purpose */ \
4898 GNUNET_static_assert (((void*) (ps)) == \
4899 ((void*) &(ps)->purpose)); \
4900 GNUNET_CRYPTO_signature_verify_ (purp, \
4901 &(ps)->purpose, \
4902 sig, \
4903 pub); \
4904 })
4905
4906
4915char *
4917 const struct GNUNET_CRYPTO_PublicKey *key);
4918
4919
4928char *
4930 const struct GNUNET_CRYPTO_PrivateKey *key);
4931
4932
4944
4945
4957
4958
4967GNUNET_CRYPTO_key_get_public (const struct
4968 GNUNET_CRYPTO_PrivateKey *privkey,
4970
4971#if 0 /* keep Emacsens' auto-indent happy */
4972{
4973#endif
4974#ifdef __cplusplus
4975}
4976#endif
4977
4978
4979/* ifndef GNUNET_CRYPTO_LIB_H */
4980#endif
4981 /* end of group addition */
4983
4984/* 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_PrivateKey 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
Definition: gnunet-scrypt.c:47
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
Definition: gnunet-scrypt.c:34
#define info
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *prk)
Deterministic variant of GNUNET_CRYPTO_hpke_kem_encaps.
Definition: crypto_hpke.c:282
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_by_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
Sign a given block with a specific purpose using the host's peer identity.
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_authkem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:212
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.
Definition: crypto_hpke.c:407
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_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.
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_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *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...
Definition: crypto_hpke.c:470
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_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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a X25519 public key.
Definition: crypto_hpke.c:299
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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition: crypto_ecc.c:554
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
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_hpke_authkem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_EcdhePublicKey *pkS, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private X25519 key.
Definition: crypto_hpke.c:327
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:841
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:480
void GNUNET_CRYPTO_symmetric_derive_iv(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len,...)
Derive an IV.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private X25519 key.
Definition: crypto_hpke.c:370
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.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:91
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:465
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:625
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_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:649
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_elligator_kem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *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...
Definition: crypto_hpke.c:449
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_authkem_decaps(const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_EcdhePublicKey *pkS, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Decapsulate a key for a private X25519 key.
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
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_EcdhePublicKey *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...
Definition: crypto_hpke.c:423
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)
Extract the public key for the given private key.
Definition: crypto_ecc.c:190
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *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_edx25519_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_Edx25519Signature *sig, const struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Verify Edx25519 signature.
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.
Definition: crypto_hpke.c:312
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_authkem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:230
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_sign_(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_Edx25519Signature *sig)
Edx25519 sign a given block.
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_PrivateKey *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.
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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_verify_peer_identity(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *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_authkem_encaps_norand(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:506
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_hpke_elligator_authkem_encaps(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const struct GNUNET_CRYPTO_EcdhePrivateKey *skS, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Encapsulate authenticated key material for a X25519 public key.
Definition: crypto_hpke.c:531
@ 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.
Definition: crypto_hkdf.c:224
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
Definition: crypto_hash.c:108
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.
Definition: crypto_hash.c:100
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)
Definition: crypto_hash.c:327
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
Definition: crypto_hash.c:120
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:132
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).
Definition: crypto_hash.c:240
void GNUNET_CRYPTO_hmac_derive_key_v(struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len, va_list argp)
Derive an authentication key.
Definition: crypto_hash.c:283
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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_gnunet(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
A peculiar HKDF instantiation that tried to mimic Truncated NMAC.
Definition: crypto_hkdf.c:199
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_gnunet_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_hkdf.c:172
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.
Definition: crypto_hash.c:218
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
Definition: crypto_hkdf.c:156
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:89
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition: crypto_kdf.c:62
void GNUNET_CRYPTO_hmac_derive_key(struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len,...)
Derive an authentication key.
Definition: crypto_hash.c:264
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand_v(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk, va_list argp)
HKDF-Expand using SHA256.
Definition: crypto_hkdf.c:144
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.
Definition: crypto_hash.c:149
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.
Definition: crypto_hash.c:174
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open_oneshot(const struct GNUNET_CRYPTO_EcdhePrivateKey *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.
Definition: crypto_hpke.c:958
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, struct GNUNET_CRYPTO_EcdhePrivateKey *skE, struct GNUNET_CRYPTO_EcdhePrivateKey *skS, const struct GNUNET_CRYPTO_EcdhePublicKey *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.
Definition: crypto_hpke.c:670
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_raw_(const struct GNUNET_CRYPTO_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, unsigned char *sig)
Sign a given block.
Definition: crypto_pkey.c:266
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
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_signature_verify_raw_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_CRYPTO_PublicKey *pub)
Verify a given signature.
Definition: crypto_pkey.c:348
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
#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.
ssize_t GNUNET_CRYPTO_read_signature_from_buffer(struct GNUNET_CRYPTO_Signature *sig, const void *buffer, size_t len)
Reads a GNUNET_CRYPTO_Signature from a compact buffer.
Definition: crypto_pkey.c:227
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition: crypto_pkey.c:85
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.
#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.
Definition: crypto_rsa.c:1015
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 generic public key union.
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_hpke_seal_oneshot(const struct GNUNET_CRYPTO_EcdhePublicKey *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.
Definition: crypto_hpke.c:929
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_Signature *sig, const struct GNUNET_CRYPTO_PublicKey *pub)
Verify a given signature.
Definition: crypto_pkey.c:319
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:98
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.
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:87
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.
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:379
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
Definition: crypto_rsa.c:1268
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.
Definition: crypto_hpke.c:863
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_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
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.
Definition: crypto_rsa.c:1063
GNUNET_CRYPTO_BlindSignatureAlgorithm
Types of public keys used for blind signatures.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_ub_sig_incref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Increment reference counter of the given ub_sig.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_private_key_from_string(const char *str, struct GNUNET_CRYPTO_PrivateKey *key)
Parses a (Base32) string representation of the private key.
Definition: crypto_pkey.c:415
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:363
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived(const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *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_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
Definition: crypto_hash.c:374
#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
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.
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
Definition: crypto_pkey.c:128
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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: crypto_pkey.c:430
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_sign_(const struct GNUNET_CRYPTO_PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_Signature *sig)
Sign a given block.
Definition: crypto_pkey.c:293
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
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:318
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 (256 BIT sessionkey)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_kdf.c:38
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
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
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.
Definition: crypto_hpke.c:894
char * GNUNET_CRYPTO_private_key_to_string(const struct GNUNET_CRYPTO_PrivateKey *key)
Creates a (Base32) string representation of the private key.
Definition: crypto_pkey.c:389
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_dup(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Duplicate the given public key.
Definition: crypto_rsa.c:1099
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
ssize_t GNUNET_CRYPTO_signature_get_raw_length_by_type(uint32_t type)
Get the compacted length of a signature by type.
Definition: crypto_pkey.c:209
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
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.
Definition: crypto_hash.c:405
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *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...
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
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.
ssize_t GNUNET_CRYPTO_write_signature_to_buffer(const struct GNUNET_CRYPTO_Signature *sig, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_Signature to a compact buffer.
Definition: crypto_pkey.c:248
#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:240
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.
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:64
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
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.
Definition: crypto_hash.c:387
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.
Definition: crypto_rsa.c:1023
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.
void GNUNET_CRYPTO_symmetric_derive_iv_v(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len, va_list argp)
Derive an IV.
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
Definition: crypto_pkey.c:172
#define GNUNET_CRYPTO_HPKE_NONCE_LEN
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.
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_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_PrivateKey *sk, struct GNUNET_CRYPTO_EcdhePrivateKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
Definition: crypto_hpke.c:1013
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.
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.
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
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_blinded_message_incref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Increment reference counter of the given bm.
ssize_t GNUNET_CRYPTO_signature_get_length(const struct GNUNET_CRYPTO_Signature *sig)
Get the compacted length of a GNUNET_CRYPTO_Signature.
Definition: crypto_pkey.c:190
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.
Definition: crypto_hash.c:196
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:330
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_PublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
Definition: crypto_hpke.c:989
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
Definition: crypto_pkey.c:102
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.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_dup(const struct GNUNET_CRYPTO_RsaPrivateKey *key)
Duplicate the given private key.
Definition: crypto_rsa.c:1248
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.
Definition: crypto_rsa.c:1118
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup(const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_EcdhePrivateKey *skR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:817
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
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:284
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:146
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:347
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...
Definition: crypto_hash.c:297
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...
Definition: crypto_rsa.c:1199
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_EcdhePrivateKey *skR, const struct GNUNET_CRYPTO_EcdhePublicKey *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.
Definition: crypto_hpke.c:760
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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup(const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
Definition: crypto_hpke.c:738
GNUNET_CRYPTO_HpkeRole
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_public_key_from_string(const char *str, struct GNUNET_CRYPTO_PublicKey *key)
Parses a (Base32) string representation of the public key.
Definition: crypto_pkey.c:399
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.
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:108
@ 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_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::@17 details
Details, depending on cipher.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@16 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.
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::@18 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.
union GNUNET_CRYPTO_BlindedSignature::@15 details
Details, depending on 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.
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::@19 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.
unsigned char v[256/8]
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
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...
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]
A private key for an identity as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity 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.
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
an RSA signature
Definition: crypto_rsa.c:65
An identity signature as per LSD0001.
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
uint32_t type
Type of signature.
unsigned char twofish_key[(256/8)]
Actual key for TwoFish.
unsigned char aes_key[(256/8)]
Actual key for AES.
Type of (unblinded) signatures.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
union GNUNET_CRYPTO_UnblindedSignature::@14 details
Details, depending on cipher.
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.
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.