GNUnet 0.26.2-32-gd298f7855
 
Loading...
Searching...
No Matches
gnunet_crypto_lib.h
Go to the documentation of this file.
1/*
2 file is part of GNUnet.
3 Copyright (C) 2001-2023 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
47#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
48#error "Only <gnunet_util_lib.h> can be included directly."
49#endif
50
51#ifndef GNUNET_CRYPTO_LIB_H
52#define GNUNET_CRYPTO_LIB_H
53
54#ifdef __cplusplus
55extern "C" {
56#if 0 /* keep Emacsens' auto-indent happy */
57}
58#endif
59#endif
60
61
62#include "gnunet_common.h"
63#include <stdbool.h>
64#include <sodium.h>
65
70
71#include <gcrypt.h>
72
73
78#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
79
80
106
107
111#define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
112
116#define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
117
122#define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
123
128{
129 unsigned char encoding[104];
130};
131
132
134
135
158
159
165{
169 unsigned char r[256 / 8];
170
174 unsigned char s[256 / 8];
175};
176
177
182{
186 unsigned char r[256 / 8];
187
191 unsigned char s[256 / 8];
192};
193
194
202{
208 unsigned char q_y[256 / 8];
209};
210
211
217{
222 unsigned char q_y[256 / 8];
223};
224
225
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
393
404
432
433
459
465{
470 uint32_t type;
471
472 union
473 {
478
479 };
480};
481
482
488{
493 uint32_t type;
494
495 union
496 {
501
502 };
503};
504
530
546
557
559
572
573
581
582
587#define GNUNET_CRYPTO_PAILLIER_BITS 2048
588
589
600
601
616
617
634
635
640{
644 unsigned char d[crypto_core_ed25519_SCALARBYTES];
645};
646
647
652{
657 unsigned char y[crypto_core_ed25519_BYTES];
658};
659
660
668
669
677
678
687
688
696
697
705
706
714
715
723
724
732
733
749
750
756{
757 /*a nonce*/
758 unsigned char snonce[256 / 8];
759};
760
761
767{
768 /*a nonce*/
769 unsigned char bnonce[256 / 8];
770};
771
772
773/* **************** Functions and Macros ************* */
774
782void
784
785
794uint8_t
795GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
796
797
806uint32_t
807GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
808
809
816uint16_t
817GNUNET_CRYPTO_crc16_finish (uint32_t sum);
818
819
828uint16_t
829GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
830
831
841int32_t
842GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
843
852void
853GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
854
855
864void
866 void *buffer,
867 size_t length);
868
869
880void
882 struct GNUNET_Uuid *uuid);
883
884
893uint32_t
895
896
905uint64_t
907
908
918unsigned int *
920
921
928void
931
932
944[[ deprecated ( "Use HPKE or other AEAD schemes for encryption" ) ]]
945ssize_t
947 const void *block,
948 size_t size,
949 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
951 void *result);
952
953
965[[ deprecated ( "Use HPKE or other AEAD schemes for encryption" ) ]]
966ssize_t
968 const void *block,
969 size_t size,
970 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
972 void *result);
973
974
982void
983GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
985
986
998 size_t enclen,
999 struct GNUNET_HashCode *result);
1000
1001
1010#define GNUNET_CRYPTO_hash_from_string(enc, result) \
1011 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
1012
1013
1026uint32_t
1028 const struct GNUNET_HashCode *b);
1029
1030
1039void
1040GNUNET_CRYPTO_hash (const void *block,
1041 size_t size,
1042 struct GNUNET_HashCode *ret);
1043
1044
1049{
1050 char salt[crypto_pwhash_argon2id_SALTBYTES];
1051};
1052
1053
1062void
1064 const void *buf,
1065 size_t buf_len,
1066 struct GNUNET_HashCode *result);
1067
1068
1072struct GNUNET_HashContext;
1073
1074
1080struct GNUNET_HashContext *
1082
1083
1090struct GNUNET_HashContext *
1092
1093
1101void
1103 const void *buf,
1104 size_t size);
1105
1106
1113void
1115 struct GNUNET_HashCode *r_hash);
1116
1117
1123void
1125
1126
1138void
1139GNUNET_CRYPTO_hmac_raw (const void *key,
1140 size_t key_len,
1141 const void *plaintext,
1142 size_t plaintext_len,
1143 struct GNUNET_HashCode *hmac);
1144
1145
1155void
1157 const void *plaintext,
1158 size_t plaintext_len,
1159 struct GNUNET_HashCode *hmac);
1160
1161
1169typedef void
1171 void *cls,
1172 const struct GNUNET_HashCode *res);
1173
1174
1179
1180
1194 const char *filename,
1195 size_t blocksize,
1197 void *callback_cls);
1198
1199
1205void
1207
1208
1216void
1218 struct GNUNET_HashCode *result);
1219
1220
1229void
1231 const struct GNUNET_HashCode *b,
1232 struct GNUNET_HashCode *result);
1233
1234
1243void
1245 const struct GNUNET_HashCode *delta,
1246 struct GNUNET_HashCode *result);
1247
1248
1257void
1259 const struct GNUNET_HashCode *b,
1260 struct GNUNET_HashCode *result);
1261
1262
1269unsigned int
1271
1272
1279unsigned int
1281
1282
1291void
1293 const struct GNUNET_HashCode *hc,
1296
1297
1307int
1308GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1309 const struct GNUNET_HashCode *h2);
1310
1311
1322int
1324 const struct GNUNET_HashCode *h2,
1325 const struct GNUNET_HashCode *target);
1326
1327
1340 const void *salt,
1341 size_t salt_len,
1342 const void *ikm,
1343 size_t ikm_len);
1344
1350{
1351
1352 // The data that is input into HKDF-Expand
1353 void*data;
1354
1355 // The length of data in bytes
1357
1358};
1359
1360#define GNUNET_CRYPTO_kdf_arg_string(d) \
1361 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1362 { \
1363 (void*) d, \
1364 strlen (d) \
1365 })
1366
1367
1368#define GNUNET_CRYPTO_kdf_arg_auto(d) \
1369 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1370 { \
1371 (void*) d, \
1372 sizeof (*d) \
1373 })
1374
1375
1376#define GNUNET_CRYPTO_kdf_arg(d,s) \
1377 ((struct GNUNET_CRYPTO_KdfInputArgument) \
1378 { \
1379 (void*) d, \
1380 s \
1381 })
1382
1383
1384#define _HKDF_ARGS_VEC_HELPER(...) \
1385 (struct \
1386 GNUNET_CRYPTO_KdfInputArgument[]) { __VA_ARGS__ }
1387
1388#define _HKDF_ARGS_VECLEN_HELPER(...) \
1389 sizeof(_HKDF_ARGS_VEC_HELPER (__VA_ARGS__)) / sizeof ( \
1390 struct GNUNET_CRYPTO_KdfInputArgument)
1391
1392
1408 size_t out_len,
1409 const void *xts,
1410 size_t xts_len,
1411 const void *skm,
1412 size_t skm_len,
1413 size_t hkdf_args_count,
1414 const struct
1416 hkdf_args_count]);
1417
1418
1449#define GNUNET_CRYPTO_hkdf_gnunet(result, \
1450 out_len, \
1451 xts, \
1452 xts_len, \
1453 skm, \
1454 skm_len, ...) \
1455 GNUNET_CRYPTO_hkdf_gnunet_v (result, out_len, xts, xts_len, skm, \
1456 skm_len, \
1457 _HKDF_ARGS_VECLEN_HELPER (__VA_ARGS__ \
1458 ), \
1459 _HKDF_ARGS_VEC_HELPER (__VA_ARGS__))
1460
1473 size_t out_len,
1474 const struct GNUNET_ShortHashCode *prk,
1475 size_t hkdf_args_count,
1476 const struct
1478 hkdf_args_count]);
1479
1490#define GNUNET_CRYPTO_hkdf_expand(result, \
1491 out_len, \
1492 prk, \
1493 ...) \
1494 GNUNET_CRYPTO_hkdf_expand_v (result, out_len, \
1495 prk, \
1496 _HKDF_ARGS_VECLEN_HELPER (__VA_ARGS__ \
1497 ), \
1498 _HKDF_ARGS_VEC_HELPER (__VA_ARGS__))
1499
1500
1513void
1514GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1515 gcry_mpi_t n,
1516 const void *xts,
1517 size_t xts_len,
1518 const void *skm,
1519 size_t skm_len,
1520 const char *ctx);
1521
1522
1535// #define GNUNET_CRYPTO_kdf GNUNET_CRYPTO_hkdf_gnunet
1536
1537
1545void
1547 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1549
1557void
1559 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1561
1569void
1571 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1573
1581void
1583 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1585
1586
1593char *
1595 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1596
1603char *
1605 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1606
1607
1614char *
1616 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1617
1618
1625char *
1627 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1628
1629
1640 const char *enc,
1641 size_t enclen,
1643
1644
1655 const char *enc,
1656 size_t enclen,
1657 struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1658
1659
1670 const char *enc,
1671 size_t enclen,
1673
1674
1692 int do_create,
1694
1695
1713 int do_create,
1715
1716
1721
1722
1734 const struct GNUNET_CONFIGURATION_Handle *cfg);
1735
1736
1743void
1745
1746
1753void
1755
1756
1763void
1765
1775void
1777 const void *seed,
1778 size_t seedsize,
1780
1790void
1792
1793
1800void
1802
1803
1810void
1812
1819void
1821
1828void
1830
1837void
1839
1840
1847const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1849
1850
1860void
1862
1863
1875 struct GNUNET_PeerIdentity *dst);
1876
1877
1891 cfg,
1892 const struct
1894 *purpose,
1895 struct
1897 sig);
1898
1899
1911GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose,
1912 const struct
1914 const struct
1916 const struct GNUNET_PeerIdentity *identity);
1917
1918
1923
1924
1930{
1935 unsigned char v[256 / 8];
1936};
1937
1942{
1943 unsigned char v[256 / 8];
1944};
1945
1955 unsigned int mem);
1956
1957
1966int
1968 const struct GNUNET_CRYPTO_EccPoint *input);
1969
1970
1982void
1983GNUNET_CRYPTO_ecc_dexp (int val,
1984 struct GNUNET_CRYPTO_EccPoint*r);
1985
1986
1997 struct GNUNET_CRYPTO_EccPoint *r);
1998
1999
2010 const struct GNUNET_CRYPTO_EccScalar *val,
2011 struct GNUNET_CRYPTO_EccPoint *r);
2012
2013
2024 const struct GNUNET_CRYPTO_EccPoint *b,
2025 struct GNUNET_CRYPTO_EccPoint *r);
2026
2027
2038 struct GNUNET_CRYPTO_EccPoint *r_inv);
2039
2040
2048void
2050 struct GNUNET_CRYPTO_EccScalar *r_neg);
2051
2052
2058void
2060
2061
2067void
2069
2070
2077void
2079 struct GNUNET_CRYPTO_EccScalar *r);
2080
2081
2096 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2097 struct GNUNET_HashCode *key_material);
2098
2099
2116 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2117 struct GNUNET_HashCode *key_material);
2118
2119
2137 const struct GNUNET_CRYPTO_EcdhePublicKey *pk,
2138 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2139
2140
2156
2157// Nt
2158#define GNUNET_CRYPTO_HPKE_AEAD_ID 0x0003
2159
2160// Nn
2161#define GNUNET_CRYPTO_HPKE_NONCE_LEN 12
2162
2163// Nk
2164#define GNUNET_CRYPTO_HPKE_KEY_LEN 32
2165
2166// Nt
2167#define GNUNET_CRYPTO_HPKE_TAG_LEN 16
2168
2169// Overhead required for ciphertext
2170#define GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES GNUNET_CRYPTO_HPKE_TAG_LEN
2171
2172// Overhead required for ciphertext
2173#define GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES \
2174 GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES \
2175 + sizeof (struct GNUNET_CRYPTO_HpkeEncapsulation)
2176
2181{
2182 // Receiver
2184 // Sender
2187
2188
2193{
2194 // Participant role
2196
2197 // Encapsulated/Decapsulated key
2199
2200 // Base nonce
2202
2203 // Sequence number
2204 uint64_t seq;
2205
2206 // Exporter secret
2208};
2209
2215{
2216 // Non-elligator X25519 KEM using HKDF256
2218 // Elligator X25519 KEM using HKDF256
2220};
2221
2222
2228{
2233 unsigned char q_y[256 / 8];
2234};
2235
2236
2247 struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc);
2248
2249
2259 pk,
2260 struct GNUNET_CRYPTO_HpkePublicKey *pk_enc);
2261
2277 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2278 struct GNUNET_ShortHashCode *prk);
2279
2295 struct GNUNET_ShortHashCode *prk);
2296
2313 const struct
2315 struct GNUNET_ShortHashCode *prk);
2316
2333 uint8_t random_tweak,
2334 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2337 struct GNUNET_ShortHashCode *shared_secret);
2338
2353 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2355 struct GNUNET_ShortHashCode *shared_secret);
2356
2371 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2372 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2373 struct GNUNET_ShortHashCode *shared_secret);
2374
2390 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2391 struct GNUNET_ShortHashCode *prk);
2392
2408 struct GNUNET_ShortHashCode *prk);
2409
2410
2429 const uint8_t *info, size_t info_len,
2432
2458 enum GNUNET_CRYPTO_HpkeKem kem,
2460 struct GNUNET_CRYPTO_HpkePrivateKey *skE,
2461 struct GNUNET_CRYPTO_HpkePrivateKey *skS,
2462 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2463 const uint8_t *info, size_t info_len,
2464 const uint8_t *psk, size_t psk_len,
2465 const uint8_t *psk_id, size_t psk_id_len,
2468
2494 enum GNUNET_CRYPTO_HpkeKem kem,
2497 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2498 const struct GNUNET_CRYPTO_HpkePublicKey *pkS,
2499 const uint8_t *info, size_t info_len,
2500 const uint8_t *psk, size_t psk_len,
2501 const uint8_t *psk_id, size_t psk_id_len,
2503
2504
2524 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2525 const uint8_t *info,
2526 size_t info_len,
2528
2548 const uint8_t *aad,
2549 size_t aad_len,
2550 const uint8_t *pt,
2551 size_t pt_len,
2552 uint8_t *ct,
2553 unsigned long long *ct_len);
2554
2555
2577 const uint8_t *info, size_t info_len,
2578 const uint8_t*aad, size_t aad_len,
2579 const uint8_t *pt, size_t pt_len,
2580 uint8_t *ct, unsigned long long *ct_len);
2581
2582
2602 const uint8_t*aad, size_t aad_len,
2603 const uint8_t *ct, size_t ct_len,
2604 uint8_t *pt, unsigned long long *pt_len_p);
2605
2606
2628 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2629 const uint8_t *info, size_t info_len,
2630 const uint8_t*aad, size_t aad_len,
2631 const uint8_t *ct, size_t ct_len,
2632 uint8_t *pt, unsigned long long *pt_len);
2633
2634
2649 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2650 struct GNUNET_HashCode *key_material);
2651
2652
2671 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2672 struct GNUNET_HashCode *key_material);
2673
2674
2689 priv,
2690 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2691 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2692
2705 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2706 struct GNUNET_HashCode *key_material);
2707
2708
2726 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2727 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2728 struct GNUNET_CRYPTO_EddsaSignature *sig);
2729
2730
2743#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2744 /* check size is set correctly */ \
2745 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2746 /* check 'ps' begins with the purpose */ \
2747 GNUNET_static_assert (((void*) (ps)) == \
2748 ((void*) &(ps)->purpose)); \
2749 GNUNET_assert (GNUNET_OK == \
2750 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2751 &(ps)->purpose, \
2752 sig)); \
2753} while (0)
2754
2755
2773 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2774 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2775 struct GNUNET_CRYPTO_EcdsaSignature *sig);
2776
2788 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2789 void *data,
2790 size_t size,
2791 struct GNUNET_CRYPTO_EddsaSignature *sig);
2792
2805#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2806 /* check size is set correctly */ \
2807 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2808 /* check 'ps' begins with the purpose */ \
2809 GNUNET_static_assert (((void*) (ps)) == \
2810 ((void*) &(ps)->purpose)); \
2811 GNUNET_assert (GNUNET_OK == \
2812 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2813 &(ps)->purpose, \
2814 sig)); \
2815} while (0)
2816
2834 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2835 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2837
2838
2852#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2853 /* check size is set correctly */ \
2854 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2855 /* check 'ps' begins with the purpose */ \
2856 GNUNET_static_assert (((void*) (ps)) == \
2857 ((void*) &(ps)->purpose)); \
2858 GNUNET_assert (GNUNET_OK == \
2859 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2860 &(ps)->purpose, \
2861 sig)); \
2862} while (0)
2863
2864
2885 uint32_t purpose,
2886 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2887 const struct GNUNET_CRYPTO_EddsaSignature *sig,
2888 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2889
2890
2905#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2906 /* check size is set correctly */ \
2907 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2908 /* check 'ps' begins with the purpose */ \
2909 GNUNET_static_assert (((void*) (ps)) == \
2910 ((void*) &(ps)->purpose)); \
2911 GNUNET_CRYPTO_eddsa_verify_ (purp, \
2912 &(ps)->purpose, \
2913 sig, \
2914 pub); \
2915 })
2916
2937 uint32_t purpose,
2938 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2939 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2940 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2941
2942
2957#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2958 /* check size is set correctly */ \
2959 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2960 /* check 'ps' begins with the purpose */ \
2961 GNUNET_static_assert (((void*) (ps)) == \
2962 ((void*) &(ps)->purpose)); \
2963 GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2964 &(ps)->purpose, \
2965 sig, \
2966 pub); \
2967 })
2968
2989 uint32_t purpose,
2990 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2991 const struct GNUNET_CRYPTO_Edx25519Signature *sig,
2992 const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
2993
2994
3009#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
3010 /* check size is set correctly */ \
3011 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3012 /* check 'ps' begins with the purpose */ \
3013 GNUNET_static_assert (((void*) (ps)) == \
3014 ((void*) &(ps)->purpose)); \
3015 GNUNET_CRYPTO_edx25519_verify_ (purp, \
3016 &(ps)->purpose, \
3017 sig, \
3018 pub); \
3019 })
3020
3036 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
3037 const char *label,
3038 const char *context);
3039
3040
3052void
3054 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
3055 const char *label,
3056 const char *context,
3058
3073 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
3074 const char *label,
3075 const char *context,
3076 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3077 struct GNUNET_CRYPTO_EcdsaSignature *sig);
3078
3079
3096void
3098 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
3099 const char *label,
3100 const char *context,
3102
3103
3115void
3117 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
3118 const char *label,
3119 const char *context,
3121
3122
3138 const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
3139 const char *label,
3140 const char *context,
3141 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3142 struct GNUNET_CRYPTO_EddsaSignature *sig);
3143
3144
3151void
3153 const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
3155
3168void
3170 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
3171 const void *seed,
3172 size_t seedsize,
3174
3175
3186void
3189 const void *seed,
3190 size_t seedsize,
3192
3193
3202void
3204 struct GNUNET_CRYPTO_EcdhePublicKey *point,
3205 bool *high_y,
3206 const struct GNUNET_CRYPTO_ElligatorRepresentative *representative);
3207
3208
3219bool
3221 uint8_t random_tweak,
3223 const struct GNUNET_CRYPTO_EcdhePublicKey *pub);
3224
3225
3239 uint8_t random_tweak,
3243
3259
3260
3267void
3270
3271
3280void
3282 size_t size,
3283 gcry_mpi_t val);
3284
3285
3295void
3297 const void *data,
3298 size_t size);
3299
3300
3307void
3309 struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3310 struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
3311
3312
3324int
3326 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3327 const gcry_mpi_t m,
3328 int desired_ops,
3329 struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext);
3330
3331
3340void
3342 const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
3343 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3344 const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext,
3345 gcry_mpi_t m);
3346
3347
3362int
3364 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3365 const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
3366 const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
3368
3369
3376int
3378 const struct GNUNET_CRYPTO_PaillierCiphertext *c);
3379
3380
3381/* ********* Chaum-style RSA-based blind signatures ******************* */
3382
3383
3388
3393
3405
3410
3411
3419GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
3420
3421
3427void
3429
3430
3439size_t
3441 const struct GNUNET_CRYPTO_RsaPrivateKey *key,
3442 void **buffer);
3443
3444
3455 size_t buf_size);
3456
3457
3466 const struct GNUNET_CRYPTO_RsaPrivateKey *key);
3467
3468
3477 const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
3478
3479
3486void
3488 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3489 struct GNUNET_HashCode *hc);
3490
3491
3497bool
3499 const struct GNUNET_CRYPTO_RsaPublicKey *key);
3500
3507unsigned int
3509
3510
3516void
3518
3519
3528size_t
3530 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3531 void **buffer);
3532
3533
3544 size_t len);
3545
3546
3555
3556
3564int
3566 const struct GNUNET_CRYPTO_RsaSignature *s2);
3567
3575int
3577 const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
3578 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
3579
3580
3588int
3590 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
3591
3592
3609
3610
3622GNUNET_CRYPTO_rsa_blind (const void *message,
3623 size_t message_size,
3624 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3627
3628
3638 const struct
3640
3641
3652 const void *message,
3653 size_t message_size);
3654
3655
3662void
3665
3666
3672void
3674
3675
3683size_t
3685 const struct GNUNET_CRYPTO_RsaSignature *sig,
3686 void **buffer);
3687
3688
3699 const void *buf,
3700 size_t buf_size);
3701
3702
3711 const struct GNUNET_CRYPTO_RsaSignature *sig);
3712
3713
3726 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3728
3729
3741GNUNET_CRYPTO_rsa_verify (const void *message,
3742 size_t message_size,
3743 const struct GNUNET_CRYPTO_RsaSignature *sig,
3744 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
3745
3746
3752void
3754
3755
3762void
3764 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3766
3767
3781void
3783 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3784 const char *seed,
3785 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3786 struct GNUNET_CRYPTO_CsRSecret r[2]);
3787
3788
3795void
3797 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3798 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3799
3800
3811void
3813 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3814 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3815
3816
3834
3835
3843
3844
3857void
3859 const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
3860 const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
3861 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3862 const void *msg,
3863 size_t msg_len,
3864 struct GNUNET_CRYPTO_CsC blinded_c[2],
3865 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3866
3867
3874{
3879 unsigned int b;
3880
3885};
3886
3887
3902void
3904 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3905 const struct GNUNET_CRYPTO_CsRSecret r[2],
3906 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3907 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3908
3909
3917void
3919 const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
3920 const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
3921 struct GNUNET_CRYPTO_CsS *signature_scalar);
3922
3923
3936 const struct GNUNET_CRYPTO_CsSignature *sig,
3937 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3938 const void *msg,
3939 size_t msg_len);
3940
3941
3963
3964
3999
4000
4038
4039
4078
4079
4113
4114
4147
4148
4156
4157
4162{
4163
4168
4172 unsigned int rc;
4173
4177 union
4178 {
4183
4185
4186};
4187
4188
4200
4201
4213 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4214 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4215 const char *salt);
4216
4217
4223void
4225 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4226
4227
4233void
4235 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4236
4237
4243void
4245 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
4246
4247
4253void
4255 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4256
4257
4263void
4265 struct GNUNET_CRYPTO_BlindedMessage *bm);
4266
4267
4276 struct GNUNET_CRYPTO_BlindedMessage *bm);
4277
4278
4288
4289
4296void
4299
4300
4309 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4310
4311
4320 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4321
4322
4331
4332
4341 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4342
4343
4351int
4353 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
4354 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
4355
4356
4364int
4366 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
4367
4368
4376int
4378 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
4379 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
4380
4381
4389int
4391 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
4392 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
4393
4394
4410 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4411 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4413 ...);
4414
4415
4431 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4432 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4434 va_list ap);
4435
4436
4452
4453
4468 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4469 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4470 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4471 const void *message,
4472 size_t message_size,
4473 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
4474
4475
4487 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4488 const char *salt,
4489 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
4490
4491
4505 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
4506 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4507 const void *message,
4508 size_t message_size,
4509 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
4510 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4511
4512
4524 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4525 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
4526 const void *message,
4527 size_t message_size);
4528
4529
4540ssize_t
4543
4559 const void *buffer,
4560 size_t len,
4562 size_t *read);
4563
4574ssize_t
4577
4578
4591ssize_t
4594 void*buffer,
4595 size_t len);
4596
4597
4612 const void*buffer,
4613 size_t len,
4615 size_t *read);
4616
4617
4630ssize_t
4633 void*buffer,
4634 size_t len);
4635
4636
4647ssize_t
4649 const struct GNUNET_CRYPTO_BlindableKeySignature *sig);
4650
4651
4662ssize_t
4664
4665
4678ssize_t
4681 const void*buffer,
4682 size_t len);
4683
4684
4697ssize_t
4699 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4700 void*buffer,
4701 size_t len);
4702
4703
4719 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4720 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4722
4738 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4739 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4740 unsigned char *sig);
4741
4742
4754#define GNUNET_CRYPTO_blinded_key_sign(priv,ps,sig) do { \
4755 /* check size is set correctly */ \
4756 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4757 /* check 'ps' begins with the purpose */ \
4758 GNUNET_static_assert (((void*) (ps)) == \
4759 ((void*) &(ps)->purpose)); \
4760 GNUNET_assert (GNUNET_OK == \
4761 GNUNET_CRYPTO_blinded_key_sign_ (priv, \
4762 &(ps)->purpose, \
4763 sig)); \
4764} while (0)
4765
4766
4786 uint32_t purpose,
4787 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4788 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4790
4808 uint32_t purpose,
4809 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4810 const unsigned char *sig,
4812
4813
4827#define GNUNET_CRYPTO_blinded_key_signature_verify(purp,ps,sig,pub) ({ \
4828 /* check size is set correctly */ \
4829 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4830 /* check 'ps' begins with the purpose */ \
4831 GNUNET_static_assert (((void*) (ps)) == \
4832 ((void*) &(ps)->purpose)); \
4833 GNUNET_CRYPTO_blinded_key_signature_verify_ (purp, \
4834 &(ps)->purpose, \
4835 sig, \
4836 pub); \
4837 })
4838
4839
4848char *
4851
4852
4861char *
4864
4865
4876 struct
4878 *key);
4879
4880
4891 struct
4893 *key);
4894
4895
4906 privkey,
4908 *key);
4909
4920ssize_t
4922 const struct GNUNET_CRYPTO_HpkePublicKey *key);
4923
4939 const void *buffer,
4940 size_t len,
4942 size_t *read);
4943
4956ssize_t
4958 const struct GNUNET_CRYPTO_HpkePublicKey *key,
4959 void*buffer,
4960 size_t len);
4961
4967void
4969
4983 const char *ikm,
4984 size_t ikm_len,
4985 struct GNUNET_CRYPTO_HpkePrivateKey *sk);
4986
4987
4999
5010ssize_t
5013
5027GNUNET_CRYPTO_read_hpke_sk_from_buffer (const void *buffer,
5028 size_t len,
5029 struct
5031 key,
5032 size_t *read);
5033
5046ssize_t
5049 key,
5050 void *buffer,
5051 size_t len);
5052
5064 privkey,
5066 *key);
5067
5068#if 0 /* keep Emacsens' auto-indent happy */
5069{
5070#endif
5071#ifdef __cplusplus
5072}
5073#endif
5074
5075
5076/* ifndef GNUNET_CRYPTO_LIB_H */
5077#endif
5078
/* end of group addition */
5080
5081/* end of gnunet_crypto_lib.h */
struct GNUNET_MessageHeader * msg
Definition 005.c:2
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition gnunet-arm.c:103
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition gnunet-arm.c:98
static int ret
Final status code.
Definition gnunet-arm.c:93
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static char * filename
static uint8_t seed
static pa_context * context
Pulseaudio context.
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_CRYPTO_BlindablePrivateKey pk
Private key from command line option, or NULL.
static char * pkey
Public key of the zone to look in, in ASCII.
static char * res
Currently read line or NULL on EOF.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
#define info
static unsigned char ikm[256/8]
The initial key material for the peer.
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
static struct GNUNET_Process * p
Helper process we started.
Definition gnunet-uri.c:38
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
static enum @52 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a public and a private ECC key.
Definition crypto_ecc.c:732
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:454
void GNUNET_CRYPTO_edx25519_key_get_public(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Extract the public key for the given private key.
bool GNUNET_CRYPTO_ecdhe_elligator_encoding(uint8_t random_tweak, struct GNUNET_CRYPTO_ElligatorRepresentative *r, const struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Encodes a point on Curve25519 to a an element of the underlying finite field.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_private_key_derive(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const char *label, const char *context)
Derive a private key from a given private key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_decaps(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private EdDSA key.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Generate a random unsigned 64-bit value.
void GNUNET_CRYPTO_eddsa_private_key_derive(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPrivateScalar *result)
Derive a private scalar from a given private key and a label.
void GNUNET_CRYPTO_symmetric_create_session_key(struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Create a new random session key.
void GNUNET_CRYPTO_edx25519_key_clear(struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Clear memory that was used to store a private key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public(const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition crypto_ecc.c:708
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_x25519_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *sk, const struct GNUNET_CRYPTO_EcdhePublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a ECDH public key and a private X25519 key.
Definition crypto_ecc.c:767
void GNUNET_CRYPTO_ecdhe_elligator_key_create(struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk)
Generates a private key for Curve25519.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
void GNUNET_CRYPTO_edx25519_private_key_derive(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PrivateKey *result)
Derive a private scalar from a given private key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_Edx25519Signature *sig, const struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Verify Edx25519 signature.
void GNUNET_CRYPTO_edx25519_key_create_from_seed(const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Create a new private key for Edx25519 from a given seed.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *priv, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Decapsulate a key for a private X25519 key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey)
Create a new private key by reading it from a file.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
void GNUNET_CRYPTO_edx25519_public_key_derive(const struct GNUNET_CRYPTO_Edx25519PublicKey *pub, const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PublicKey *result)
Derive a public key from a given public key and a label.
void GNUNET_CRYPTO_random_timeflake(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_Uuid *uuid)
Fill UUID with a timeflake pseudo-random value.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:201
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
HPKE END.
Definition crypto_ecc.c:805
void GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:447
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps_norand(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_ShortHashCode *prk)
Deterministic variant of GNUNET_CRYPTO_hpke_kem_encaps.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition crypto_ecc.c:625
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition crypto_ecc.c:745
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition crypto_ecc.c:840
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:480
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_decaps(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh decapsulation with own private key and the representative of the received public key...
void GNUNET_CRYPTO_ecdhe_elligator_decoding(struct GNUNET_CRYPTO_EcdhePublicKey *point, bool *high_y, const struct GNUNET_CRYPTO_ElligatorRepresentative *representative)
Clears the most significant bit and second most significant bit of the serialized representaive befor...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition crypto_ecc.c:823
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition crypto_ecc.c:554
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_by_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
Sign a given block with a specific purpose using the host's peer identity.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition crypto_ecc.c:465
void GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:440
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_kem_encaps(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a X25519 public key.
void GNUNET_CRYPTO_eddsa_public_key_derive(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPublicKey *result)
Derive a public key from a given public key and a label.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition crypto_ecc.c:500
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
void GNUNET_CRYPTO_edx25519_key_create(struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Create a new private key.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Derive key.
Definition crypto_ecc.c:190
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_x25519(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_EcdhePublicKey *dh)
Derive key material from a EdDSA public key and a private ECDH key.
Definition crypto_ecc.c:783
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_kem_encaps(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_CRYPTO_HpkeEncapsulation *c, struct GNUNET_ShortHashCode *prk)
Encapsulate key material for a EdDSA public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_verify_peer_identity(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_PeerIdentity *identity)
Verify a given signature with a peer's identity.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
unsigned int * GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n)
Get an array with a random permutation of the numbers 0...n-1.
void GNUNET_CRYPTO_private_key_clear(struct GNUNET_CRYPTO_BlindablePrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_pkey.c:47
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_sign_(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_Edx25519Signature *sig)
Edx25519 sign a given block.
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_ecc.c:433
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition crypto_ecc.c:217
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition crypto_ecc.c:649
@ GNUNET_CRYPTO_QUALITY_STRONG
High-quality operations are desired.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_extract(struct GNUNET_ShortHashCode *prk, const void *salt, size_t salt_len, const void *ikm, size_t ikm_len)
HKDF-Extract using SHA256.
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition crypto_hash.c:55
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition crypto_crc.c:99
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
uint8_t GNUNET_CRYPTO_crc8_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition crypto_crc.c:151
int GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2, const struct GNUNET_HashCode *target)
Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hash_from_string2(const char *enc, size_t enclen, struct GNUNET_HashCode *result)
Convert ASCII encoding back to a 'struct GNUNET_HashCode'.
Definition crypto_hash.c:72
uint16_t GNUNET_CRYPTO_crc16_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition crypto_crc.c:133
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand_v(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk, size_t hkdf_args_count, const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[hkdf_args_count])
HKDF-Expand using SHA256.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
uint32_t GNUNET_CRYPTO_hash_distance_u32(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b)
Compute the distance between 2 hashcodes.
Definition crypto_hash.c:92
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_gnunet_v(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len, size_t hkdf_args_count, const struct GNUNET_CRYPTO_KdfInputArgument hkdf_args[hkdf_args_count])
Derive key.
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
char * GNUNET_CRYPTO_eddsa_private_key_to_string(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a private key to a string.
Definition crypto_ecc.c:282
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros(const struct GNUNET_HashCode *h)
Count the number of leading 0 bits in h.
struct GNUNET_CRYPTO_BlindSignPrivateKey * GNUNET_CRYPTO_bsign_priv_incref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Increment reference counter of the given bsign_priv.
#define GNUNET_CRYPTO_HASH_LENGTH
Length of a hash value.
GNUNET_CRYPTO_HpkeKem
HPKE KEM identifier TODO: Elligator KEM was requested at IANA; Number is currently a placeholder.
void(* GNUNET_CRYPTO_HashCompletedCallback)(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over the specified file has completed.
void GNUNET_CRYPTO_blinded_message_decref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Decrement reference counter of a bm, and free it if it reaches zero.
void GNUNET_CRYPTO_mpi_scan_unsigned(gcry_mpi_t *result, const void *data, size_t size)
Convert data buffer into MPI value.
Definition crypto_mpi.c:132
ssize_t GNUNET_CRYPTO_write_hpke_pk_to_buffer(const struct GNUNET_CRYPTO_HpkePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePublicKey to a compact buffer.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_raw(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *data, size_t size, struct GNUNET_CRYPTO_EddsaSignature *sig)
Definition crypto_ecc.c:604
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,...)
Initialize public-private key pair for blind signatures.
void GNUNET_CRYPTO_ecc_rnd_mpi(struct GNUNET_CRYPTO_EccScalar *r, struct GNUNET_CRYPTO_EccScalar *r_neg)
Obtain a random scalar for point multiplication on the curve and its additive inverse.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
#define GNUNET_CRYPTO_PAILLIER_BITS
Size of paillier plain texts and public keys.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_blind(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Blinds the given message with the given blinding key.
Definition crypto_rsa.c:807
GNUNET_CRYPTO_KeyType
Key type for the blindable public key union.
ssize_t GNUNET_CRYPTO_hpke_sk_get_length(const struct GNUNET_CRYPTO_HpkePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePrivateKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_(const struct GNUNET_CRYPTO_BlindablePrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_BlindableKeySignature *sig)
Sign a given block.
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sig_incref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Increment reference counter of the given blind_sig.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePublicKey from a compact buffer.
void GNUNET_CRYPTO_cs_r_get_public(const struct GNUNET_CRYPTO_CsRSecret *r_priv, struct GNUNET_CRYPTO_CsRPublic *r_pub)
Extract the public R of the given secret r.
Definition crypto_cs.c:97
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_dexp_mpi(const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition crypto_rsa.c:144
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition crypto_rsa.c:173
int GNUNET_CRYPTO_bsign_pub_cmp(const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1, const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2)
Compare two denomination public keys.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_pmul_mpi(const struct GNUNET_CRYPTO_EccPoint *p, const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the point p on the elliptic curve by val.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_blind_sig_unblind(const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig, const union GNUNET_CRYPTO_BlindingSecretP *bks, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values, const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Unblind blind signature.
char * GNUNET_CRYPTO_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
ssize_t GNUNET_CRYPTO_blinded_key_signature_get_length_by_type(uint32_t type)
Get the compacted length of a signature by type.
void GNUNET_CRYPTO_kdf_mod_mpi(gcry_mpi_t *r, gcry_mpi_t n, const void *xts, size_t xts_len, const void *skm, size_t skm_len, const char *ctx)
Deterministically generate a pseudo-random number uniformly from the integers modulo a libgcrypt mpi.
Definition crypto_kdf.c:38
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sign(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const char *salt, const struct GNUNET_CRYPTO_BlindedMessage *blinded_message)
Create blind signature.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_cs_r_derive(const struct GNUNET_CRYPTO_CsSessionNonce *nonce, const char *seed, const struct GNUNET_CRYPTO_CsPrivateKey *lts, struct GNUNET_CRYPTO_CsRSecret r[2])
Derive a new secret r pair r0 and r1.
Definition crypto_cs.c:79
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_public_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Parses a (Base32) string representation of the public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition crypto_ecc.c:336
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_blindable_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
int GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, const struct GNUNET_CRYPTO_EccPoint *input)
Calculate ECC discrete logarithm for small factors.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
GNUNET_CRYPTO_BlindSignatureAlgorithm
Types of public keys used for blind signatures.
ssize_t GNUNET_CRYPTO_write_blindable_sk_to_buffer(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePrivateKey to a compact buffer.
ssize_t GNUNET_CRYPTO_write_blinded_key_signature_to_buffer(const struct GNUNET_CRYPTO_BlindableKeySignature *sig, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindableKeySignature to a compact buffer.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_ub_sig_incref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Increment reference counter of the given ub_sig.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
#define GNUNET_CRYPTO_HPKE_KEY_LEN
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
Definition crypto_crc.c:123
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
This is a signature function for ECDSA which takes a private key, derives/blinds it and signs the mes...
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format.
Definition crypto_rsa.c:423
int GNUNET_CRYPTO_ub_sig_cmp(const struct GNUNET_CRYPTO_UnblindedSignature *sig1, const struct GNUNET_CRYPTO_UnblindedSignature *sig2)
Compare two denomination signatures.
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_message_blind_to_sign(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const union GNUNET_CRYPTO_BlindingSecretP *bks, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values)
Blind message for blind signing with dk using blinding secret coin_bks.
int GNUNET_CRYPTO_blinded_message_cmp(const struct GNUNET_CRYPTO_BlindedMessage *bp1, const struct GNUNET_CRYPTO_BlindedMessage *bp2)
Compare two blinded messages.
int GNUNET_CRYPTO_rsa_signature_cmp(const struct GNUNET_CRYPTO_RsaSignature *s1, const struct GNUNET_CRYPTO_RsaSignature *s2)
Compare the values of two signatures.
Definition crypto_rsa.c:602
int GNUNET_CRYPTO_blind_sig_cmp(const struct GNUNET_CRYPTO_BlindedSignature *sig1, const struct GNUNET_CRYPTO_BlindedSignature *sig2)
Compare two blinded denomination signatures.
void GNUNET_CRYPTO_cs_private_key_get_public(const struct GNUNET_CRYPTO_CsPrivateKey *priv, struct GNUNET_CRYPTO_CsPublicKey *pub)
Extract the public key of the given private key.
Definition crypto_cs.c:52
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_signature_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const struct GNUNET_CRYPTO_BlindableKeySignature *sig, const struct GNUNET_CRYPTO_BlindablePublicKey *pub)
Verify a given signature.
ssize_t GNUNET_CRYPTO_hpke_pk_get_length(const struct GNUNET_CRYPTO_HpkePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_HpkePublicKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_seal_oneshot(const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, unsigned long long *ct_len)
RFC9180 HPKE encryption.
uint32_t GNUNET_CRYPTO_crc16_step(uint32_t sum, const void *buf, size_t len)
Perform an incremental step in a CRC16 (for TCP/IP) calculation.
Definition crypto_crc.c:110
void GNUNET_CRYPTO_cs_unblind(const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar, const struct GNUNET_CRYPTO_CsBlindingSecret *bs, struct GNUNET_CRYPTO_CsS *signature_scalar)
Unblind a blind-signed signature using a c that was blinded.
Definition crypto_cs.c:313
int GNUNET_CRYPTO_paillier_encrypt(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const gcry_mpi_t m, int desired_ops, struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext)
Encrypt a plaintext with a paillier public key.
bool GNUNET_CRYPTO_rsa_public_key_check(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Check if key is well-formed.
Definition crypto_rsa.c:301
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
Definition crypto_ecc.c:255
char * GNUNET_CRYPTO_blindable_private_key_to_string(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Creates a (Base32) string representation of the private key.
ssize_t GNUNET_CRYPTO_write_hpke_sk_to_buffer(const struct GNUNET_CRYPTO_HpkePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_HpkePrivateKey to a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create(enum GNUNET_CRYPTO_HpkeKeyType type, struct GNUNET_CRYPTO_HpkePrivateKey *pk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_to_x25519(const struct GNUNET_CRYPTO_BlindablePrivateKey *sk, struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create_va(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, va_list ap)
Initialize public-private key pair for blind signatures.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition crypto_ecc.c:361
unsigned int GNUNET_CRYPTO_rsa_public_key_len(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Obtain the length of the RSA key in bits.
Definition crypto_rsa.c:680
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open_oneshot(const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_rsa_blinded_message_free(struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Free memory occupied by blinded message.
Definition crypto_rsa.c:799
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_open(struct GNUNET_CRYPTO_HpkeContext *ctx, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, uint8_t *pt, unsigned long long *pt_len_p)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_dup(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Duplicate the given public key.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived(const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes a private key and derives it using the label and c...
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_fdh(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const void *message, size_t message_size)
Create and sign a full domain hash of a message.
Definition crypto_rsa.c:992
void GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc)
Compute hash over the public key.
Definition crypto_rsa.c:407
ssize_t GNUNET_CRYPTO_blinded_key_signature_get_length(const struct GNUNET_CRYPTO_BlindableKeySignature *sig)
Get the compacted length of a #GNUNET_CRYPTO_Signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sender_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, struct GNUNET_CRYPTO_HpkePrivateKey *skE, struct GNUNET_CRYPTO_HpkePrivateKey *skS, const struct GNUNET_CRYPTO_HpkePublicKey *pkR, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeEncapsulation *enc, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_decode(const void *buf, size_t buf_size)
Decode the private key from the data-format back to the "normal", internal format.
Definition crypto_rsa.c:204
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the 'proof-of-work' hash (an expensive hash).
Definition crypto_pow.c:42
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup2(enum GNUNET_CRYPTO_HpkeKem kem, enum GNUNET_CRYPTO_HpkeMode mode, const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const struct GNUNET_CRYPTO_HpkePublicKey *pkS, const uint8_t *info, size_t info_len, const uint8_t *psk, size_t psk_len, const uint8_t *psk_id, size_t psk_id_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition crypto_rsa.c:268
void GNUNET_CRYPTO_mpi_print_unsigned(void *buf, size_t size, gcry_mpi_t val)
Output the given MPI value to the given buffer in network byte order.
Definition crypto_mpi.c:79
GNUNET_SCHEDULER_Priority
Valid task priorities.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_get_public(const struct GNUNET_CRYPTO_HpkePrivateKey *privkey, struct GNUNET_CRYPTO_HpkePublicKey *key)
Retrieves the GNUNET_CRYPTO_HpkePublicKey representation of a GNUNET_CRYPTO_HpkePrivateKey.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
void GNUNET_CRYPTO_cs_calc_blinded_c(const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], const struct GNUNET_CRYPTO_CsRPublic r_pub[2], const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len, struct GNUNET_CRYPTO_CsC blinded_c[2], struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind)
Calculate two blinded c's.
Definition crypto_cs.c:237
size_t GNUNET_CRYPTO_rsa_public_key_encode(const struct GNUNET_CRYPTO_RsaPublicKey *key, void **buffer)
Encode the public key in a format suitable for storing it into a file.
Definition crypto_rsa.c:325
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
Extract the public key of the given private scalar.
int GNUNET_CRYPTO_rsa_private_key_cmp(const struct GNUNET_CRYPTO_RsaPrivateKey *p1, const struct GNUNET_CRYPTO_RsaPrivateKey *p2)
Compare the values of two private keys.
Definition crypto_rsa.c:654
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_signature_verify_raw_(uint32_t purpose, const struct GNUNET_CRYPTO_SignaturePurpose *validate, const unsigned char *sig, const struct GNUNET_CRYPTO_BlindablePublicKey *pub)
Verify a given signature.
void GNUNET_CRYPTO_blinding_input_values_decref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Decrement reference counter of the given bi, and free it if it reaches zero.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
void GNUNET_CRYPTO_ecc_dexp(int val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sig_verify(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig, const void *message, size_t message_size)
Verify signature made blindly.
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_blinding_input_values_incref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Increment reference counter of the given bi.
#define GNUNET_CRYPTO_HPKE_NONCE_LEN
void GNUNET_CRYPTO_hpke_sk_clear(struct GNUNET_CRYPTO_HpkePrivateKey *key)
Clear memory that was used to store a GNUNET_CRYPTO_HpkePrivateKey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePrivateKey from a compact buffer.
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
struct GNUNET_CRYPTO_EccDlogContext * GNUNET_CRYPTO_ecc_dlog_prepare(unsigned int max, unsigned int mem)
Do pre-calculation for ECC discrete logarithm for small factors.
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition crypto_ecc.c:228
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_private_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Parses a (Base32) string representation of the private key.
void GNUNET_CRYPTO_unblinded_sig_decref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Decrement reference counter of a ub_sig, and free it if it reaches zero.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blinded_key_sign_raw_(const struct GNUNET_CRYPTO_BlindablePrivateKey *priv, const struct GNUNET_CRYPTO_SignaturePurpose *purpose, unsigned char *sig)
Sign a given block.
int GNUNET_CRYPTO_paillier_hom_add(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *c1, const struct GNUNET_CRYPTO_PaillierCiphertext *c2, struct GNUNET_CRYPTO_PaillierCiphertext *result)
Compute a ciphertext that represents the sum of the plaintext in c1 and c2.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_receiver_setup(const struct GNUNET_CRYPTO_HpkeEncapsulation *enc, const struct GNUNET_CRYPTO_HpkePrivateKey *skR, const uint8_t *info, size_t info_len, struct GNUNET_CRYPTO_HpkeContext *ctx)
RFC9180 HPKE encryption.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_blinded(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Sign a blinded value, which must be a full domain hash of a message.
Definition crypto_rsa.c:970
ssize_t GNUNET_CRYPTO_write_blindable_pk_to_buffer(const struct GNUNET_CRYPTO_BlindablePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePublicKey to a compact buffer.
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_blinded_message_incref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Increment reference counter of the given bm.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_private_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a string representing a private key to a private key.
Definition crypto_ecc.c:386
void GNUNET_CRYPTO_blinded_sig_decref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Decrement reference counter of a blind_sig, and free it if it reaches zero.
GNUNET_CRYPTO_HpkeMode
HPKE RFC 9180.
unsigned int GNUNET_CRYPTO_hash_count_tailing_zeros(const struct GNUNET_HashCode *h)
Count the number of tailing 0 bits in h.
ssize_t GNUNET_CRYPTO_blindable_sk_get_length(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePrivateKey.
Definition crypto_pkey.c:64
char * GNUNET_CRYPTO_ecdsa_private_key_to_string(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv)
Convert a private key to a string.
Definition crypto_ecc.c:309
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_rnd(struct GNUNET_CRYPTO_EccPoint *r, struct GNUNET_CRYPTO_EccPoint *r_inv)
Obtain a random point on the curve and its additive inverse.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_cs_verify(const struct GNUNET_CRYPTO_CsSignature *sig, const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len)
Verify whether the given message corresponds to the given signature and the signature is valid with r...
Definition crypto_cs.c:325
int GNUNET_CRYPTO_rsa_public_key_cmp(const struct GNUNET_CRYPTO_RsaPublicKey *p1, const struct GNUNET_CRYPTO_RsaPublicKey *p2)
Compare the values of two public keys.
Definition crypto_rsa.c:628
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create2(enum GNUNET_CRYPTO_HpkeKeyType type, const char *ikm, size_t ikm_len, struct GNUNET_CRYPTO_HpkePrivateKey *sk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_dup(const struct GNUNET_CRYPTO_RsaPrivateKey *key)
Duplicate the given private key.
void GNUNET_CRYPTO_paillier_decrypt(const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, gcry_mpi_t m)
Decrypt a paillier ciphertext with a private key.
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_CRYPTO_BlindSignPublicKey * GNUNET_CRYPTO_bsign_pub_incref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Increment reference counter of the given bsign_pub.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_unblind(const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey)
Unblind a blind-signed signature.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_BlindablePublicKey *pk, struct GNUNET_CRYPTO_HpkePublicKey *pk_enc)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_private_key_get_public(const struct GNUNET_CRYPTO_RsaPrivateKey *priv)
Extract the public key of the given private key.
Definition crypto_rsa.c:233
ssize_t GNUNET_CRYPTO_blindable_pk_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:85
void GNUNET_CRYPTO_blind_sign_pub_decref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Decrement reference counter of a bsign_pub, and free it if it reaches zero.
void GNUNET_CRYPTO_cs_sign_derive(const struct GNUNET_CRYPTO_CsPrivateKey *priv, const struct GNUNET_CRYPTO_CsRSecret r[2], const struct GNUNET_CRYPTO_CsBlindedMessage *bm, struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig)
Sign a blinded c.
Definition crypto_cs.c:281
void GNUNET_CRYPTO_cs_private_key_generate(struct GNUNET_CRYPTO_CsPrivateKey *priv)
Create a new random private key.
Definition crypto_cs.c:45
void GNUNET_CRYPTO_blind_sign_priv_decref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Decrement reference counter of a bsign_priv, and free it if it reaches zero.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
void GNUNET_CRYPTO_hmac_raw(const void *key, size_t key_len, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104) TODO: Shouldn't this be the standard hmac function and the abo...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_verify(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaPublicKey *public_key)
Verify whether the given hash corresponds to the given signature and the signature is valid with resp...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_hpke_sk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_HpkePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_HpkePrivateKey from a compact buffer.
GNUNET_CRYPTO_HpkeKeyType
Key type for the hpke public key union.
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition crypto_rsa.c:181
GNUNET_CRYPTO_HpkeRole
Role of the HPKE participant.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_add(const struct GNUNET_CRYPTO_EccPoint *a, const struct GNUNET_CRYPTO_EccPoint *b, struct GNUNET_CRYPTO_EccPoint *r)
Add two points on the elliptic curve.
#define GNUNET_PACKED
gcc-ism to get packed structs.
ssize_t GNUNET_CRYPTO_read_blinded_key_signature_from_buffer(struct GNUNET_CRYPTO_BlindableKeySignature *sig, const void *buffer, size_t len)
Reads a GNUNET_CRYPTO_BlindableKeySignature from a compact buffer.
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_get_blinding_input_values(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const char *salt)
Compute blinding input values for a given nonce and salt.
void GNUNET_CRYPTO_cs_blinding_secrets_derive(const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed, struct GNUNET_CRYPTO_CsBlindingSecret bs[2])
Derives new random blinding factors.
Definition crypto_cs.c:107
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519_HKDF256
@ GNUNET_CRYPTO_HPKE_KEM_DH_X25519ELLIGATOR_HKDF256
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_PUBLIC_KEY_TYPE_ECDSA
The identity type.
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
@ GNUNET_CRYPTO_HPKE_MODE_PSK
@ GNUNET_CRYPTO_HPKE_MODE_AUTH_PSK
@ GNUNET_CRYPTO_HPKE_MODE_BASE
@ GNUNET_CRYPTO_HPKE_MODE_AUTH
@ GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519
Type for X25519 hybrid public key encryption.
@ GNUNET_CRYPTO_HPKE_ROLE_R
@ GNUNET_CRYPTO_HPKE_ROLE_S
#define max(x, y)
static unsigned int size
Size of the "table".
Definition peer.c:68
static struct GNUNET_TIME_Relative delta
Definition speedup.c:36
type for (message) authentication keys
unsigned char key[(512/8)]
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@21 details
Details, depending on cipher.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@20 details
Details, depending on cipher.
unsigned int rc
Reference counter.
struct GNUNET_HashCode pub_key_hash
Hash of the public key.
struct GNUNET_CRYPTO_CsPublicKey cs_public_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
struct GNUNET_CRYPTO_RsaPublicKey * rsa_public_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
An identity signature as per LSD0001.
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_EcdsaSignature ecdsa_signature
An ECDSA signature.
A private key for an identity as per LSD0001.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_key
AN EdDSA identtiy key.
An identity key as per LSD0001.
uint32_t type
Type of public key.
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
struct GNUNET_CRYPTO_EddsaPublicKey eddsa_key
AN EdDSA identtiy key.
Blinded message ready for blind signing.
unsigned int rc
Reference counter.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the sign blinded message.
struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedMessage::@22 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Type for blinded signatures.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
union GNUNET_CRYPTO_BlindedSignature::@19 details
Details, depending on cipher.
Input needed for blinding a message.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CSPublicRPairP cs_values
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindingInputValues::@23 details
Details, depending on cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Secret r for Cs denominations.
struct GNUNET_CRYPTO_CsRSecret r[2]
Pair of Public R values for Cs denominations.
struct GNUNET_CRYPTO_CsRPublic r_pub[2]
Type of a nonce used for challenges.
struct GNUNET_ShortHashCode value
The value of the nonce.
unsigned char y[crypto_core_ed25519_BYTES]
This is a point on the Curve25519.
unsigned char d[crypto_core_ed25519_SCALARBYTES]
32 byte scalar
blinded s in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The Sign Answer for Clause Blind Schnorr signature.
struct GNUNET_CRYPTO_CsBlindS s_scalar
The blinded s scalar calculated from c_b.
unsigned int b
To make ROS problem harder, the signer chooses an unpredictable b and only calculates signature of c_...
CS Parameters derived from the message during blinding to create blinded signature.
struct GNUNET_CRYPTO_CsC c[2]
The Clause Schnorr c_0 and c_1 containing the blinded message.
struct GNUNET_CRYPTO_CsSessionNonce nonce
Nonce used in initial request.
Nonce for computing blinding factors.
Secret used for blinding (alpha and beta).
struct GNUNET_CRYPTO_Cs25519Scalar alpha
struct GNUNET_CRYPTO_Cs25519Scalar beta
Schnorr c to be signed.
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The private information of an Schnorr key pair.
struct GNUNET_CRYPTO_Cs25519Scalar scalar
The public information of an Schnorr key pair.
struct GNUNET_CRYPTO_Cs25519Point point
the public R (derived from r) used in c
struct GNUNET_CRYPTO_Cs25519Point point
the private r used in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
s in the signature
struct GNUNET_CRYPTO_Cs25519Scalar scalar
Nonce for the session, picked by client, shared with the signer.
CS Signtature containing scalar s and point R.
struct GNUNET_CRYPTO_CsS s_scalar
Schnorr signatures are composed of a scalar s and a curve point.
struct GNUNET_CRYPTO_CsRPublic r_point
Curve point of the Schnorr signature.
Internal structure used to cache pre-calculated values for DLOG calculation.
unsigned int mem
How much memory should we use (relates to the number of entries in the map).
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
unsigned char v[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A ECC scalar for use in point multiplications.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
an ECC signature using ECDSA
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC scalar encoded for transmission.
unsigned char s[512/8]
s is the expandedprivate 512-bit scalar of a private key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using EdDSA.
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key material encoded for transmission.
unsigned char b[256/8]
b consists of 32 bytes which where originally the lower 32bytes of the key expansion.
unsigned char a[256/8]
a is a value mod n, where n has at most 256 bits.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using Edx25519 (same as in EdDSA).
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Special private ECC key generated by GNUNET_CRYPTO_ecdhe_elligator_key_create.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Elligator representative (always for Curve25519)
uint8_t r[256/8]
Represents an element of Curve25519 finite field.
Context used when hashing a file.
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
void * callback_cls
Closure for callback.
enum GNUNET_SCHEDULER_Priority priority
Priority we use.
0-terminated ASCII encoding of a struct GNUNET_HashCode.
struct GNUNET_ShortHashCode exporter_secret
enum GNUNET_CRYPTO_HpkeRole role
HPKE DHKEM encapsulation (X25519) See RFC 9180.
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A public key used for decryption.
struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_key
An ECDHE/X25519 key.
A public key used for encryption.
struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_key
An ECDHE/X25519 key.
As input for variadic HKDF API.
int32_t remaining_ops
Guaranteed minimum number of homomorphic operations with this ciphertext, in network byte order (NBO)...
unsigned char bits[2048 *2/8]
The bits of the ciphertext.
unsigned char mu[2048/8]
Mu-component of the private key.
unsigned char lambda[2048/8]
Lambda-component of the private key.
unsigned char n[2048/8]
N value.
Value for a salt for GNUNET_CRYPTO_pow_hash().
char salt[crypto_pwhash_argon2id_SALTBYTES]
RSA Parameters to create blinded signature.
size_t blinded_msg_size
Size of the blinded_msg to be signed.
void * blinded_msg
Blinded message to be signed Note: is malloc()'ed!
Constant-size pre-secret for blinding key generation.
uint32_t pre_secret[8]
Bits used to generate the blinding key.
The private information of an RSA key pair.
Definition crypto_rsa.c:41
The public information of an RSA key pair.
Definition crypto_rsa.c:53
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
unsigned char twofish_key[(256/8)]
Actual key for TwoFish.
unsigned char aes_key[(256/8)]
Actual key for AES.
Type of (unblinded) signatures.
union GNUNET_CRYPTO_UnblindedSignature::@18 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
A 256-bit hashcode.
A UUID, a 128 bit "random" value.
const char * str
Definition time.c:1252
Nonce used to deterministiacally derive input values used in multi-round blind signature protocols.
struct GNUNET_CRYPTO_CsSessionNonce cs_nonce
Nonce used when signing with CS.
Type of blinding secrets.
struct GNUNET_CRYPTO_CsBlindingNonce nonce
Clause Schnorr nonce.
struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks
Variant for RSA for blind signatures.