GNUnet 0.26.2-15-g4c7b9ce93
 
Loading...
Searching...
No Matches
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 "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
944ssize_t
946 const void *block,
947 size_t size,
948 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
950 void *result);
951
952
964ssize_t
966 const void *block,
967 size_t size,
968 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
970 void *result);
971
972
982void
985 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
986 const void *salt,
987 size_t salt_len,
988 ...);
989
990
999void
1002 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
1003 const void *salt,
1004 size_t salt_len,
1005 va_list argp);
1006
1007
1015void
1016GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
1018
1019
1031 size_t enclen,
1032 struct GNUNET_HashCode *result);
1033
1034
1043#define GNUNET_CRYPTO_hash_from_string(enc, result) \
1044 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
1045
1046
1059uint32_t
1061 const struct GNUNET_HashCode *b);
1062
1063
1072void
1073GNUNET_CRYPTO_hash (const void *block,
1074 size_t size,
1075 struct GNUNET_HashCode *ret);
1076
1077
1082{
1083 char salt[crypto_pwhash_argon2id_SALTBYTES];
1084};
1085
1086
1095void
1097 const void *buf,
1098 size_t buf_len,
1099 struct GNUNET_HashCode *result);
1100
1101
1105struct GNUNET_HashContext;
1106
1107
1113struct GNUNET_HashContext *
1115
1116
1123struct GNUNET_HashContext *
1125
1126
1134void
1136 const void *buf,
1137 size_t size);
1138
1139
1146void
1148 struct GNUNET_HashCode *r_hash);
1149
1150
1156void
1158
1159
1171void
1172GNUNET_CRYPTO_hmac_raw (const void *key,
1173 size_t key_len,
1174 const void *plaintext,
1175 size_t plaintext_len,
1176 struct GNUNET_HashCode *hmac);
1177
1178
1188void
1190 const void *plaintext,
1191 size_t plaintext_len,
1192 struct GNUNET_HashCode *hmac);
1193
1194
1202typedef void
1204 void *cls,
1205 const struct GNUNET_HashCode *res);
1206
1207
1212
1213
1227 const char *filename,
1228 size_t blocksize,
1230 void *callback_cls);
1231
1232
1238void
1240
1241
1249void
1251 struct GNUNET_HashCode *result);
1252
1253
1262void
1264 const struct GNUNET_HashCode *b,
1265 struct GNUNET_HashCode *result);
1266
1267
1276void
1278 const struct GNUNET_HashCode *delta,
1279 struct GNUNET_HashCode *result);
1280
1281
1290void
1292 const struct GNUNET_HashCode *b,
1293 struct GNUNET_HashCode *result);
1294
1295
1302unsigned int
1304
1305
1312unsigned int
1314
1315
1324void
1326 const struct GNUNET_HashCode *hc,
1329
1330
1340int
1341GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1342 const struct GNUNET_HashCode *h2);
1343
1344
1355int
1357 const struct GNUNET_HashCode *h2,
1358 const struct GNUNET_HashCode *target);
1359
1360
1370void
1372 struct GNUNET_CRYPTO_AuthKey *key,
1373 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1374 const void *salt,
1375 size_t salt_len,
1376 va_list argp);
1377
1378
1388void
1390 struct GNUNET_CRYPTO_AuthKey *key,
1391 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1392 const void *salt,
1393 size_t salt_len,
1394 ...);
1395
1396
1409 const void *salt,
1410 size_t salt_len,
1411 const void *ikm,
1412 size_t ikm_len);
1413
1425 size_t out_len,
1426 const struct GNUNET_ShortHashCode *prk,
1427 ...);
1428
1439 size_t out_len,
1440 const struct GNUNET_ShortHashCode *prk,
1441 va_list argp);
1442
1443
1466 size_t out_len,
1467 const void *xts,
1468 size_t xts_len,
1469 const void *skm,
1470 size_t skm_len,
1471 ...);
1472
1473
1488 size_t out_len,
1489 const void *xts,
1490 size_t xts_len,
1491 const void *skm,
1492 size_t skm_len,
1493 va_list argp);
1494
1495
1509 size_t out_len,
1510 const void *xts,
1511 size_t xts_len,
1512 const void *skm,
1513 size_t skm_len,
1514 va_list argp);
1515
1516
1529void
1530GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1531 gcry_mpi_t n,
1532 const void *xts,
1533 size_t xts_len,
1534 const void *skm,
1535 size_t skm_len,
1536 const char *ctx);
1537
1538
1553 size_t out_len,
1554 const void *xts,
1555 size_t xts_len,
1556 const void *skm,
1557 size_t skm_len,
1558 ...);
1559
1560
1568void
1570 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1572
1580void
1582 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1584
1592void
1594 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1596
1604void
1606 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1608
1609
1616char *
1618 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1619
1626char *
1628 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1629
1630
1637char *
1639 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1640
1641
1648char *
1650 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1651
1652
1663 const char *enc,
1664 size_t enclen,
1666
1667
1678 const char *enc,
1679 size_t enclen,
1680 struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1681
1682
1693 const char *enc,
1694 size_t enclen,
1696
1697
1715 int do_create,
1717
1718
1736 int do_create,
1738
1739
1744
1745
1757 const struct GNUNET_CONFIGURATION_Handle *cfg);
1758
1759
1766void
1768
1769
1776void
1778
1779
1786void
1788
1798void
1800 const void *seed,
1801 size_t seedsize,
1803
1813void
1815
1816
1823void
1825
1826
1833void
1835
1842void
1844
1851void
1853
1860void
1862
1863
1870const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1872
1873
1883void
1885
1886
1898 struct GNUNET_PeerIdentity *dst);
1899
1900
1914 cfg,
1915 const struct
1917 *purpose,
1918 struct
1920 sig);
1921
1922
1934GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose,
1935 const struct
1937 const struct
1939 const struct GNUNET_PeerIdentity *identity);
1940
1941
1946
1947
1953{
1958 unsigned char v[256 / 8];
1959};
1960
1965{
1966 unsigned char v[256 / 8];
1967};
1968
1978 unsigned int mem);
1979
1980
1989int
1991 const struct GNUNET_CRYPTO_EccPoint *input);
1992
1993
2005void
2006GNUNET_CRYPTO_ecc_dexp (int val,
2007 struct GNUNET_CRYPTO_EccPoint*r);
2008
2009
2020 struct GNUNET_CRYPTO_EccPoint *r);
2021
2022
2033 const struct GNUNET_CRYPTO_EccScalar *val,
2034 struct GNUNET_CRYPTO_EccPoint *r);
2035
2036
2047 const struct GNUNET_CRYPTO_EccPoint *b,
2048 struct GNUNET_CRYPTO_EccPoint *r);
2049
2050
2061 struct GNUNET_CRYPTO_EccPoint *r_inv);
2062
2063
2071void
2073 struct GNUNET_CRYPTO_EccScalar *r_neg);
2074
2075
2081void
2083
2084
2090void
2092
2093
2100void
2102 struct GNUNET_CRYPTO_EccScalar *r);
2103
2104
2119 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2120 struct GNUNET_HashCode *key_material);
2121
2122
2139 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2140 struct GNUNET_HashCode *key_material);
2141
2142
2160 const struct GNUNET_CRYPTO_EcdhePublicKey *pk,
2161 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2162
2163
2179
2180// Nt
2181#define GNUNET_CRYPTO_HPKE_AEAD_ID 0x0003
2182
2183// Nn
2184#define GNUNET_CRYPTO_HPKE_NONCE_LEN 12
2185
2186// Nk
2187#define GNUNET_CRYPTO_HPKE_KEY_LEN 32
2188
2189// Nt
2190#define GNUNET_CRYPTO_HPKE_TAG_LEN 16
2191
2192// Overhead required for ciphertext
2193#define GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES GNUNET_CRYPTO_HPKE_TAG_LEN
2194
2195// Overhead required for ciphertext
2196#define GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES \
2197 GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES \
2198 + sizeof (struct GNUNET_CRYPTO_HpkeEncapsulation)
2199
2204{
2205 // Receiver
2207 // Sender
2210
2211
2216{
2217 // Participant role
2219
2220 // Encapsulated/Decapsulated key
2222
2223 // Base nonce
2225
2226 // Sequence number
2227 uint64_t seq;
2228
2229 // Exporter secret
2231};
2232
2238{
2239 // Non-elligator X25519 KEM using HKDF256
2241 // Elligator X25519 KEM using HKDF256
2243};
2244
2245
2251{
2256 unsigned char q_y[256 / 8];
2257};
2258
2259
2270 struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc);
2271
2272
2282 pk,
2283 struct GNUNET_CRYPTO_HpkePublicKey *pk_enc);
2284
2300 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2301 struct GNUNET_ShortHashCode *prk);
2302
2318 struct GNUNET_ShortHashCode *prk);
2319
2336 const struct
2338 struct GNUNET_ShortHashCode *prk);
2339
2356 uint8_t random_tweak,
2357 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2360 struct GNUNET_ShortHashCode *shared_secret);
2361
2376 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2378 struct GNUNET_ShortHashCode *shared_secret);
2379
2394 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2395 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2396 struct GNUNET_ShortHashCode *shared_secret);
2397
2413 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2414 struct GNUNET_ShortHashCode *prk);
2415
2431 struct GNUNET_ShortHashCode *prk);
2432
2433
2452 const uint8_t *info, size_t info_len,
2455
2481 enum GNUNET_CRYPTO_HpkeKem kem,
2483 struct GNUNET_CRYPTO_HpkePrivateKey *skE,
2484 struct GNUNET_CRYPTO_HpkePrivateKey *skS,
2485 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2486 const uint8_t *info, size_t info_len,
2487 const uint8_t *psk, size_t psk_len,
2488 const uint8_t *psk_id, size_t psk_id_len,
2491
2517 enum GNUNET_CRYPTO_HpkeKem kem,
2520 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2521 const struct GNUNET_CRYPTO_HpkePublicKey *pkS,
2522 const uint8_t *info, size_t info_len,
2523 const uint8_t *psk, size_t psk_len,
2524 const uint8_t *psk_id, size_t psk_id_len,
2526
2527
2547 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2548 const uint8_t *info,
2549 size_t info_len,
2551
2571 const uint8_t *aad,
2572 size_t aad_len,
2573 const uint8_t *pt,
2574 size_t pt_len,
2575 uint8_t *ct,
2576 unsigned long long *ct_len);
2577
2578
2600 const uint8_t *info, size_t info_len,
2601 const uint8_t*aad, size_t aad_len,
2602 const uint8_t *pt, size_t pt_len,
2603 uint8_t *ct, unsigned long long *ct_len);
2604
2605
2625 const uint8_t*aad, size_t aad_len,
2626 const uint8_t *ct, size_t ct_len,
2627 uint8_t *pt, unsigned long long *pt_len_p);
2628
2629
2651 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2652 const uint8_t *info, size_t info_len,
2653 const uint8_t*aad, size_t aad_len,
2654 const uint8_t *ct, size_t ct_len,
2655 uint8_t *pt, unsigned long long *pt_len);
2656
2657
2672 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2673 struct GNUNET_HashCode *key_material);
2674
2675
2694 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2695 struct GNUNET_HashCode *key_material);
2696
2697
2712 priv,
2713 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2714 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2715
2728 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2729 struct GNUNET_HashCode *key_material);
2730
2731
2749 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2750 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2751 struct GNUNET_CRYPTO_EddsaSignature *sig);
2752
2753
2766#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2767 /* check size is set correctly */ \
2768 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2769 /* check 'ps' begins with the purpose */ \
2770 GNUNET_static_assert (((void*) (ps)) == \
2771 ((void*) &(ps)->purpose)); \
2772 GNUNET_assert (GNUNET_OK == \
2773 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2774 &(ps)->purpose, \
2775 sig)); \
2776} while (0)
2777
2778
2796 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2797 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2798 struct GNUNET_CRYPTO_EcdsaSignature *sig);
2799
2811 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2812 void *data,
2813 size_t size,
2814 struct GNUNET_CRYPTO_EddsaSignature *sig);
2815
2828#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2829 /* check size is set correctly */ \
2830 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2831 /* check 'ps' begins with the purpose */ \
2832 GNUNET_static_assert (((void*) (ps)) == \
2833 ((void*) &(ps)->purpose)); \
2834 GNUNET_assert (GNUNET_OK == \
2835 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2836 &(ps)->purpose, \
2837 sig)); \
2838} while (0)
2839
2857 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2858 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2860
2861
2875#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2876 /* check size is set correctly */ \
2877 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2878 /* check 'ps' begins with the purpose */ \
2879 GNUNET_static_assert (((void*) (ps)) == \
2880 ((void*) &(ps)->purpose)); \
2881 GNUNET_assert (GNUNET_OK == \
2882 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2883 &(ps)->purpose, \
2884 sig)); \
2885} while (0)
2886
2887
2908 uint32_t purpose,
2909 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2910 const struct GNUNET_CRYPTO_EddsaSignature *sig,
2911 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2912
2913
2928#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2929 /* check size is set correctly */ \
2930 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2931 /* check 'ps' begins with the purpose */ \
2932 GNUNET_static_assert (((void*) (ps)) == \
2933 ((void*) &(ps)->purpose)); \
2934 GNUNET_CRYPTO_eddsa_verify_ (purp, \
2935 &(ps)->purpose, \
2936 sig, \
2937 pub); \
2938 })
2939
2960 uint32_t purpose,
2961 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2962 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2963 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2964
2965
2980#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2981 /* check size is set correctly */ \
2982 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2983 /* check 'ps' begins with the purpose */ \
2984 GNUNET_static_assert (((void*) (ps)) == \
2985 ((void*) &(ps)->purpose)); \
2986 GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2987 &(ps)->purpose, \
2988 sig, \
2989 pub); \
2990 })
2991
3012 uint32_t purpose,
3013 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
3014 const struct GNUNET_CRYPTO_Edx25519Signature *sig,
3015 const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
3016
3017
3032#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
3033 /* check size is set correctly */ \
3034 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3035 /* check 'ps' begins with the purpose */ \
3036 GNUNET_static_assert (((void*) (ps)) == \
3037 ((void*) &(ps)->purpose)); \
3038 GNUNET_CRYPTO_edx25519_verify_ (purp, \
3039 &(ps)->purpose, \
3040 sig, \
3041 pub); \
3042 })
3043
3059 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
3060 const char *label,
3061 const char *context);
3062
3063
3075void
3077 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
3078 const char *label,
3079 const char *context,
3081
3096 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
3097 const char *label,
3098 const char *context,
3099 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3100 struct GNUNET_CRYPTO_EcdsaSignature *sig);
3101
3102
3119void
3121 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
3122 const char *label,
3123 const char *context,
3125
3126
3138void
3140 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
3141 const char *label,
3142 const char *context,
3144
3145
3161 const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
3162 const char *label,
3163 const char *context,
3164 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3165 struct GNUNET_CRYPTO_EddsaSignature *sig);
3166
3167
3174void
3176 const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
3178
3191void
3193 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
3194 const void *seed,
3195 size_t seedsize,
3197
3198
3209void
3212 const void *seed,
3213 size_t seedsize,
3215
3216
3225void
3227 struct GNUNET_CRYPTO_EcdhePublicKey *point,
3228 bool *high_y,
3229 const struct GNUNET_CRYPTO_ElligatorRepresentative *representative);
3230
3231
3242bool
3244 uint8_t random_tweak,
3246 const struct GNUNET_CRYPTO_EcdhePublicKey *pub);
3247
3248
3262 uint8_t random_tweak,
3266
3282
3283
3290void
3293
3294
3303void
3305 size_t size,
3306 gcry_mpi_t val);
3307
3308
3318void
3320 const void *data,
3321 size_t size);
3322
3323
3330void
3332 struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3333 struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
3334
3335
3347int
3349 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3350 const gcry_mpi_t m,
3351 int desired_ops,
3352 struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext);
3353
3354
3363void
3365 const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
3366 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3367 const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext,
3368 gcry_mpi_t m);
3369
3370
3385int
3387 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3388 const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
3389 const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
3391
3392
3399int
3401 const struct GNUNET_CRYPTO_PaillierCiphertext *c);
3402
3403
3404/* ********* Chaum-style RSA-based blind signatures ******************* */
3405
3406
3411
3416
3428
3433
3434
3442GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
3443
3444
3450void
3452
3453
3462size_t
3464 const struct GNUNET_CRYPTO_RsaPrivateKey *key,
3465 void **buffer);
3466
3467
3478 size_t buf_size);
3479
3480
3489 const struct GNUNET_CRYPTO_RsaPrivateKey *key);
3490
3491
3500 const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
3501
3502
3509void
3511 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3512 struct GNUNET_HashCode *hc);
3513
3514
3520bool
3522 const struct GNUNET_CRYPTO_RsaPublicKey *key);
3523
3530unsigned int
3532
3533
3539void
3541
3542
3551size_t
3553 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3554 void **buffer);
3555
3556
3567 size_t len);
3568
3569
3578
3579
3587int
3589 const struct GNUNET_CRYPTO_RsaSignature *s2);
3590
3598int
3600 const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
3601 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
3602
3603
3611int
3613 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
3614
3615
3632
3633
3645GNUNET_CRYPTO_rsa_blind (const void *message,
3646 size_t message_size,
3647 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3650
3651
3661 const struct
3663
3664
3675 const void *message,
3676 size_t message_size);
3677
3678
3685void
3688
3689
3695void
3697
3698
3706size_t
3708 const struct GNUNET_CRYPTO_RsaSignature *sig,
3709 void **buffer);
3710
3711
3722 const void *buf,
3723 size_t buf_size);
3724
3725
3734 const struct GNUNET_CRYPTO_RsaSignature *sig);
3735
3736
3749 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3751
3752
3764GNUNET_CRYPTO_rsa_verify (const void *message,
3765 size_t message_size,
3766 const struct GNUNET_CRYPTO_RsaSignature *sig,
3767 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
3768
3769
3775void
3777
3778
3785void
3787 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3789
3790
3804void
3806 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3807 const char *seed,
3808 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3809 struct GNUNET_CRYPTO_CsRSecret r[2]);
3810
3811
3818void
3820 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3821 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3822
3823
3834void
3836 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3837 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3838
3839
3857
3858
3866
3867
3880void
3882 const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
3883 const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
3884 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3885 const void *msg,
3886 size_t msg_len,
3887 struct GNUNET_CRYPTO_CsC blinded_c[2],
3888 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3889
3890
3897{
3902 unsigned int b;
3903
3908};
3909
3910
3925void
3927 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3928 const struct GNUNET_CRYPTO_CsRSecret r[2],
3929 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3930 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3931
3932
3940void
3942 const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
3943 const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
3944 struct GNUNET_CRYPTO_CsS *signature_scalar);
3945
3946
3959 const struct GNUNET_CRYPTO_CsSignature *sig,
3960 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3961 const void *msg,
3962 size_t msg_len);
3963
3964
3986
3987
4022
4023
4061
4062
4101
4102
4136
4137
4170
4171
4179
4180
4185{
4186
4191
4195 unsigned int rc;
4196
4200 union
4201 {
4206
4208
4209};
4210
4211
4223
4224
4236 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4237 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4238 const char *salt);
4239
4240
4246void
4248 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4249
4250
4256void
4258 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4259
4260
4266void
4268 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
4269
4270
4276void
4278 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4279
4280
4286void
4288 struct GNUNET_CRYPTO_BlindedMessage *bm);
4289
4290
4299 struct GNUNET_CRYPTO_BlindedMessage *bm);
4300
4301
4311
4312
4319void
4322
4323
4332 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4333
4334
4343 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4344
4345
4354
4355
4364 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4365
4366
4374int
4376 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
4377 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
4378
4379
4387int
4389 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
4390
4391
4399int
4401 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
4402 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
4403
4404
4412int
4414 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
4415 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
4416
4417
4433 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4434 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4436 ...);
4437
4438
4454 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4455 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4457 va_list ap);
4458
4459
4475
4476
4491 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4492 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4493 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4494 const void *message,
4495 size_t message_size,
4496 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
4497
4498
4510 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4511 const char *salt,
4512 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
4513
4514
4528 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
4529 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4530 const void *message,
4531 size_t message_size,
4532 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
4533 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4534
4535
4547 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4548 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
4549 const void *message,
4550 size_t message_size);
4551
4552
4563ssize_t
4566
4582 const void *buffer,
4583 size_t len,
4585 size_t *read);
4586
4597ssize_t
4600
4601
4614ssize_t
4617 void*buffer,
4618 size_t len);
4619
4620
4635 const void*buffer,
4636 size_t len,
4638 size_t *read);
4639
4640
4653ssize_t
4656 void*buffer,
4657 size_t len);
4658
4659
4670ssize_t
4672 const struct GNUNET_CRYPTO_BlindableKeySignature *sig);
4673
4674
4685ssize_t
4687
4688
4701ssize_t
4704 const void*buffer,
4705 size_t len);
4706
4707
4720ssize_t
4722 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4723 void*buffer,
4724 size_t len);
4725
4726
4742 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4743 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4745
4761 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4762 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4763 unsigned char *sig);
4764
4765
4777#define GNUNET_CRYPTO_blinded_key_sign(priv,ps,sig) do { \
4778 /* check size is set correctly */ \
4779 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4780 /* check 'ps' begins with the purpose */ \
4781 GNUNET_static_assert (((void*) (ps)) == \
4782 ((void*) &(ps)->purpose)); \
4783 GNUNET_assert (GNUNET_OK == \
4784 GNUNET_CRYPTO_blinded_key_sign_ (priv, \
4785 &(ps)->purpose, \
4786 sig)); \
4787} while (0)
4788
4789
4809 uint32_t purpose,
4810 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4811 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4813
4831 uint32_t purpose,
4832 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4833 const unsigned char *sig,
4835
4836
4850#define GNUNET_CRYPTO_blinded_key_signature_verify(purp,ps,sig,pub) ({ \
4851 /* check size is set correctly */ \
4852 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4853 /* check 'ps' begins with the purpose */ \
4854 GNUNET_static_assert (((void*) (ps)) == \
4855 ((void*) &(ps)->purpose)); \
4856 GNUNET_CRYPTO_blinded_key_signature_verify_ (purp, \
4857 &(ps)->purpose, \
4858 sig, \
4859 pub); \
4860 })
4861
4862
4871char *
4874
4875
4884char *
4887
4888
4899 struct
4901 *key);
4902
4903
4914 struct
4916 *key);
4917
4918
4929 privkey,
4931 *key);
4932
4943ssize_t
4945 const struct GNUNET_CRYPTO_HpkePublicKey *key);
4946
4962 const void *buffer,
4963 size_t len,
4965 size_t *read);
4966
4979ssize_t
4981 const struct GNUNET_CRYPTO_HpkePublicKey *key,
4982 void*buffer,
4983 size_t len);
4984
4990void
4992
5004
5015ssize_t
5018
5032GNUNET_CRYPTO_read_hpke_sk_from_buffer (const void *buffer,
5033 size_t len,
5034 struct
5036 key,
5037 size_t *read);
5038
5051ssize_t
5054 key,
5055 void *buffer,
5056 size_t len);
5057
5069 privkey,
5071 *key);
5072
5073#if 0 /* keep Emacsens' auto-indent happy */
5074{
5075#endif
5076#ifdef __cplusplus
5077}
5078#endif
5079
5080
5081/* ifndef GNUNET_CRYPTO_LIB_H */
5082#endif
5083
/* end of group addition */
5085
5086/* 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_OS_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 @49 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
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_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)
Extract the public key for the given private 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).
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.
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.
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.
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_expand(void *result, size_t out_len, const struct GNUNET_ShortHashCode *prk,...)
HKDF-Expand using SHA256.
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_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.
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.
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: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.
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: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.
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: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
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: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.
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.
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.
#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:330
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.
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: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.
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: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_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.
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.