GNUnet 0.26.0
 
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
421
422
448
454{
459 uint32_t type;
460
461 union
462 {
467
468 };
469};
470
471
477{
482 uint32_t type;
483
484 union
485 {
490
491 };
492};
493
519
535
546
548
561
562
570
571
576#define GNUNET_CRYPTO_PAILLIER_BITS 2048
577
578
589
590
605
606
623
624
629{
633 unsigned char d[crypto_core_ed25519_SCALARBYTES];
634};
635
636
641{
646 unsigned char y[crypto_core_ed25519_BYTES];
647};
648
649
657
658
666
667
676
677
685
686
694
695
703
704
712
713
721
722
738
739
745{
746 /*a nonce*/
747 unsigned char snonce[256 / 8];
748};
749
750
756{
757 /*a nonce*/
758 unsigned char bnonce[256 / 8];
759};
760
761
762/* **************** Functions and Macros ************* */
763
771void
773
774
783uint8_t
784GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
785
786
795uint32_t
796GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
797
798
805uint16_t
806GNUNET_CRYPTO_crc16_finish (uint32_t sum);
807
808
817uint16_t
818GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
819
820
830int32_t
831GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
832
841void
842GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
843
844
853void
855 void *buffer,
856 size_t length);
857
858
869void
871 struct GNUNET_Uuid *uuid);
872
873
882uint32_t
884
885
894uint64_t
896
897
907unsigned int *
909
910
917void
920
921
933ssize_t
935 const void *block,
936 size_t size,
937 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
939 void *result);
940
941
953ssize_t
955 const void *block,
956 size_t size,
957 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
959 void *result);
960
961
971void
974 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
975 const void *salt,
976 size_t salt_len,
977 ...);
978
979
988void
991 const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
992 const void *salt,
993 size_t salt_len,
994 va_list argp);
995
996
1004void
1005GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
1007
1008
1020 size_t enclen,
1021 struct GNUNET_HashCode *result);
1022
1023
1032#define GNUNET_CRYPTO_hash_from_string(enc, result) \
1033 GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
1034
1035
1048uint32_t
1050 const struct GNUNET_HashCode *b);
1051
1052
1061void
1062GNUNET_CRYPTO_hash (const void *block,
1063 size_t size,
1064 struct GNUNET_HashCode *ret);
1065
1066
1071{
1072 char salt[crypto_pwhash_argon2id_SALTBYTES];
1073};
1074
1075
1084void
1086 const void *buf,
1087 size_t buf_len,
1088 struct GNUNET_HashCode *result);
1089
1090
1094struct GNUNET_HashContext;
1095
1096
1102struct GNUNET_HashContext *
1104
1105
1112struct GNUNET_HashContext *
1114
1115
1123void
1125 const void *buf,
1126 size_t size);
1127
1128
1135void
1137 struct GNUNET_HashCode *r_hash);
1138
1139
1145void
1147
1148
1160void
1161GNUNET_CRYPTO_hmac_raw (const void *key,
1162 size_t key_len,
1163 const void *plaintext,
1164 size_t plaintext_len,
1165 struct GNUNET_HashCode *hmac);
1166
1167
1177void
1179 const void *plaintext,
1180 size_t plaintext_len,
1181 struct GNUNET_HashCode *hmac);
1182
1183
1191typedef void
1193 void *cls,
1194 const struct GNUNET_HashCode *res);
1195
1196
1201
1202
1216 const char *filename,
1217 size_t blocksize,
1219 void *callback_cls);
1220
1221
1227void
1229
1230
1238void
1240 struct GNUNET_HashCode *result);
1241
1242
1251void
1253 const struct GNUNET_HashCode *b,
1254 struct GNUNET_HashCode *result);
1255
1256
1265void
1267 const struct GNUNET_HashCode *delta,
1268 struct GNUNET_HashCode *result);
1269
1270
1279void
1281 const struct GNUNET_HashCode *b,
1282 struct GNUNET_HashCode *result);
1283
1284
1291unsigned int
1293
1294
1301unsigned int
1303
1304
1313void
1315 const struct GNUNET_HashCode *hc,
1318
1319
1329int
1330GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1331 const struct GNUNET_HashCode *h2);
1332
1333
1344int
1346 const struct GNUNET_HashCode *h2,
1347 const struct GNUNET_HashCode *target);
1348
1349
1359void
1361 struct GNUNET_CRYPTO_AuthKey *key,
1362 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1363 const void *salt,
1364 size_t salt_len,
1365 va_list argp);
1366
1367
1377void
1379 struct GNUNET_CRYPTO_AuthKey *key,
1380 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1381 const void *salt,
1382 size_t salt_len,
1383 ...);
1384
1385
1398 const void *salt,
1399 size_t salt_len,
1400 const void *ikm,
1401 size_t ikm_len);
1402
1414 size_t out_len,
1415 const struct GNUNET_ShortHashCode *prk,
1416 ...);
1417
1428 size_t out_len,
1429 const struct GNUNET_ShortHashCode *prk,
1430 va_list argp);
1431
1432
1455 size_t out_len,
1456 const void *xts,
1457 size_t xts_len,
1458 const void *skm,
1459 size_t skm_len,
1460 ...);
1461
1462
1477 size_t out_len,
1478 const void *xts,
1479 size_t xts_len,
1480 const void *skm,
1481 size_t skm_len,
1482 va_list argp);
1483
1484
1498 size_t out_len,
1499 const void *xts,
1500 size_t xts_len,
1501 const void *skm,
1502 size_t skm_len,
1503 va_list argp);
1504
1505
1518void
1519GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1520 gcry_mpi_t n,
1521 const void *xts,
1522 size_t xts_len,
1523 const void *skm,
1524 size_t skm_len,
1525 const char *ctx);
1526
1527
1542 size_t out_len,
1543 const void *xts,
1544 size_t xts_len,
1545 const void *skm,
1546 size_t skm_len,
1547 ...);
1548
1549
1557void
1559 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1561
1569void
1571 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1573
1581void
1583 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1585
1593void
1595 const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1597
1598
1605char *
1607 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1608
1615char *
1617 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1618
1619
1626char *
1628 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1629
1630
1637char *
1639 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1640
1641
1652 const char *enc,
1653 size_t enclen,
1655
1656
1667 const char *enc,
1668 size_t enclen,
1669 struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1670
1671
1682 const char *enc,
1683 size_t enclen,
1685
1686
1704 int do_create,
1706
1707
1725 int do_create,
1727
1728
1733
1734
1746 const struct GNUNET_CONFIGURATION_Handle *cfg);
1747
1748
1755void
1757
1758
1765void
1767
1768
1775void
1777
1787void
1789 const void *seed,
1790 size_t seedsize,
1792
1802void
1804
1805
1812void
1814
1815
1822void
1824
1831void
1833
1840void
1842
1849void
1851
1852
1859const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1861
1862
1872void
1874
1875
1887 struct GNUNET_PeerIdentity *dst);
1888
1889
1903 cfg,
1904 const struct
1906 *purpose,
1907 struct
1909 sig);
1910
1911
1923GNUNET_CRYPTO_verify_peer_identity (uint32_t purpose,
1924 const struct
1926 const struct
1928 const struct GNUNET_PeerIdentity *identity);
1929
1930
1935
1936
1942{
1947 unsigned char v[256 / 8];
1948};
1949
1954{
1955 unsigned char v[256 / 8];
1956};
1957
1967 unsigned int mem);
1968
1969
1978int
1980 const struct GNUNET_CRYPTO_EccPoint *input);
1981
1982
1994void
1995GNUNET_CRYPTO_ecc_dexp (int val,
1996 struct GNUNET_CRYPTO_EccPoint*r);
1997
1998
2009 struct GNUNET_CRYPTO_EccPoint *r);
2010
2011
2022 const struct GNUNET_CRYPTO_EccScalar *val,
2023 struct GNUNET_CRYPTO_EccPoint *r);
2024
2025
2036 const struct GNUNET_CRYPTO_EccPoint *b,
2037 struct GNUNET_CRYPTO_EccPoint *r);
2038
2039
2050 struct GNUNET_CRYPTO_EccPoint *r_inv);
2051
2052
2060void
2062 struct GNUNET_CRYPTO_EccScalar *r_neg);
2063
2064
2070void
2072
2073
2079void
2081
2082
2089void
2091 struct GNUNET_CRYPTO_EccScalar *r);
2092
2093
2108 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2109 struct GNUNET_HashCode *key_material);
2110
2111
2128 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2129 struct GNUNET_HashCode *key_material);
2130
2131
2149 const struct GNUNET_CRYPTO_EcdhePublicKey *pk,
2150 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2151
2152
2168
2169// Nt
2170#define GNUNET_CRYPTO_HPKE_AEAD_ID 0x0003
2171
2172// Nn
2173#define GNUNET_CRYPTO_HPKE_NONCE_LEN 12
2174
2175// Nk
2176#define GNUNET_CRYPTO_HPKE_KEY_LEN 32
2177
2178// Nt
2179#define GNUNET_CRYPTO_HPKE_TAG_LEN 16
2180
2181// Overhead required for ciphertext
2182#define GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES GNUNET_CRYPTO_HPKE_TAG_LEN
2183
2184// Overhead required for ciphertext
2185#define GNUNET_CRYPTO_HPKE_SEAL_ONESHOT_OVERHEAD_BYTES \
2186 GNUNET_CRYPTO_HPKE_SEAL_OVERHEAD_BYTES \
2187 + sizeof (struct GNUNET_CRYPTO_HpkeEncapsulation)
2188
2193{
2194 // Receiver
2196 // Sender
2199
2200
2205{
2206 // Participant role
2208
2209 // Encapsulated/Decapsulated key
2211
2212 // Base nonce
2214
2215 // Sequence number
2216 uint64_t seq;
2217
2218 // Exporter secret
2220};
2221
2227{
2228 // Non-elligator X25519 KEM using HKDF256
2230 // Elligator X25519 KEM using HKDF256
2232};
2233
2234
2240{
2245 unsigned char q_y[256 / 8];
2246};
2247
2248
2259 struct GNUNET_CRYPTO_HpkePrivateKey *sk_enc);
2260
2261
2271 pk,
2272 struct GNUNET_CRYPTO_HpkePublicKey *pk_enc);
2273
2289 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2290 struct GNUNET_ShortHashCode *prk);
2291
2307 struct GNUNET_ShortHashCode *prk);
2308
2325 const struct
2327 struct GNUNET_ShortHashCode *prk);
2328
2345 uint8_t random_tweak,
2346 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2349 struct GNUNET_ShortHashCode *shared_secret);
2350
2365 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2367 struct GNUNET_ShortHashCode *shared_secret);
2368
2383 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2384 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2385 struct GNUNET_ShortHashCode *shared_secret);
2386
2402 const struct GNUNET_CRYPTO_HpkeEncapsulation *c,
2403 struct GNUNET_ShortHashCode *prk);
2404
2420 struct GNUNET_ShortHashCode *prk);
2421
2422
2441 const uint8_t *info, size_t info_len,
2444
2470 enum GNUNET_CRYPTO_HpkeKem kem,
2472 struct GNUNET_CRYPTO_HpkePrivateKey *skE,
2473 struct GNUNET_CRYPTO_HpkePrivateKey *skS,
2474 const struct GNUNET_CRYPTO_HpkePublicKey *pkR,
2475 const uint8_t *info, size_t info_len,
2476 const uint8_t *psk, size_t psk_len,
2477 const uint8_t *psk_id, size_t psk_id_len,
2480
2506 enum GNUNET_CRYPTO_HpkeKem kem,
2509 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2510 const struct GNUNET_CRYPTO_HpkePublicKey *pkS,
2511 const uint8_t *info, size_t info_len,
2512 const uint8_t *psk, size_t psk_len,
2513 const uint8_t *psk_id, size_t psk_id_len,
2515
2516
2536 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2537 const uint8_t *info,
2538 size_t info_len,
2540
2560 const uint8_t *aad,
2561 size_t aad_len,
2562 const uint8_t *pt,
2563 size_t pt_len,
2564 uint8_t *ct,
2565 unsigned long long *ct_len);
2566
2567
2589 const uint8_t *info, size_t info_len,
2590 const uint8_t*aad, size_t aad_len,
2591 const uint8_t *pt, size_t pt_len,
2592 uint8_t *ct, unsigned long long *ct_len);
2593
2594
2614 const uint8_t*aad, size_t aad_len,
2615 const uint8_t *ct, size_t ct_len,
2616 uint8_t *pt, unsigned long long *pt_len_p);
2617
2618
2640 const struct GNUNET_CRYPTO_HpkePrivateKey *skR,
2641 const uint8_t *info, size_t info_len,
2642 const uint8_t*aad, size_t aad_len,
2643 const uint8_t *ct, size_t ct_len,
2644 uint8_t *pt, unsigned long long *pt_len);
2645
2646
2661 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2662 struct GNUNET_HashCode *key_material);
2663
2664
2683 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2684 struct GNUNET_HashCode *key_material);
2685
2686
2701 priv,
2702 const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
2703 struct GNUNET_CRYPTO_EcdhePublicKey *dh);
2704
2717 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2718 struct GNUNET_HashCode *key_material);
2719
2720
2738 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2739 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2740 struct GNUNET_CRYPTO_EddsaSignature *sig);
2741
2742
2755#define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
2756 /* check size is set correctly */ \
2757 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
2758 /* check 'ps' begins with the purpose */ \
2759 GNUNET_static_assert (((void*) (ps)) == \
2760 ((void*) &(ps)->purpose)); \
2761 GNUNET_assert (GNUNET_OK == \
2762 GNUNET_CRYPTO_eddsa_sign_ (priv, \
2763 &(ps)->purpose, \
2764 sig)); \
2765} while (0)
2766
2767
2785 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2786 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2787 struct GNUNET_CRYPTO_EcdsaSignature *sig);
2788
2800 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2801 void *data,
2802 size_t size,
2803 struct GNUNET_CRYPTO_EddsaSignature *sig);
2804
2817#define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
2818 /* check size is set correctly */ \
2819 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2820 /* check 'ps' begins with the purpose */ \
2821 GNUNET_static_assert (((void*) (ps)) == \
2822 ((void*) &(ps)->purpose)); \
2823 GNUNET_assert (GNUNET_OK == \
2824 GNUNET_CRYPTO_ecdsa_sign_ (priv, \
2825 &(ps)->purpose, \
2826 sig)); \
2827} while (0)
2828
2846 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2847 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
2849
2850
2864#define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2865 /* check size is set correctly */ \
2866 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2867 /* check 'ps' begins with the purpose */ \
2868 GNUNET_static_assert (((void*) (ps)) == \
2869 ((void*) &(ps)->purpose)); \
2870 GNUNET_assert (GNUNET_OK == \
2871 GNUNET_CRYPTO_edx25519_sign_ (priv, \
2872 &(ps)->purpose, \
2873 sig)); \
2874} while (0)
2875
2876
2897 uint32_t purpose,
2898 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2899 const struct GNUNET_CRYPTO_EddsaSignature *sig,
2900 const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2901
2902
2917#define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2918 /* check size is set correctly */ \
2919 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2920 /* check 'ps' begins with the purpose */ \
2921 GNUNET_static_assert (((void*) (ps)) == \
2922 ((void*) &(ps)->purpose)); \
2923 GNUNET_CRYPTO_eddsa_verify_ (purp, \
2924 &(ps)->purpose, \
2925 sig, \
2926 pub); \
2927 })
2928
2949 uint32_t purpose,
2950 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
2951 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2952 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2953
2954
2969#define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2970 /* check size is set correctly */ \
2971 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2972 /* check 'ps' begins with the purpose */ \
2973 GNUNET_static_assert (((void*) (ps)) == \
2974 ((void*) &(ps)->purpose)); \
2975 GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2976 &(ps)->purpose, \
2977 sig, \
2978 pub); \
2979 })
2980
3001 uint32_t purpose,
3002 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
3003 const struct GNUNET_CRYPTO_Edx25519Signature *sig,
3004 const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
3005
3006
3021#define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
3022 /* check size is set correctly */ \
3023 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
3024 /* check 'ps' begins with the purpose */ \
3025 GNUNET_static_assert (((void*) (ps)) == \
3026 ((void*) &(ps)->purpose)); \
3027 GNUNET_CRYPTO_edx25519_verify_ (purp, \
3028 &(ps)->purpose, \
3029 sig, \
3030 pub); \
3031 })
3032
3048 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
3049 const char *label,
3050 const char *context);
3051
3052
3064void
3066 const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
3067 const char *label,
3068 const char *context,
3070
3085 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
3086 const char *label,
3087 const char *context,
3088 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3089 struct GNUNET_CRYPTO_EcdsaSignature *sig);
3090
3091
3108void
3110 const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
3111 const char *label,
3112 const char *context,
3114
3115
3127void
3129 const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
3130 const char *label,
3131 const char *context,
3133
3134
3150 const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
3151 const char *label,
3152 const char *context,
3153 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
3154 struct GNUNET_CRYPTO_EddsaSignature *sig);
3155
3156
3163void
3165 const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
3167
3180void
3182 const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
3183 const void *seed,
3184 size_t seedsize,
3186
3187
3198void
3201 const void *seed,
3202 size_t seedsize,
3204
3205
3214void
3216 struct GNUNET_CRYPTO_EcdhePublicKey *point,
3217 bool *high_y,
3218 const struct GNUNET_CRYPTO_ElligatorRepresentative *representative);
3219
3220
3231bool
3233 uint8_t random_tweak,
3235 const struct GNUNET_CRYPTO_EcdhePublicKey *pub);
3236
3237
3251 uint8_t random_tweak,
3255
3271
3272
3279void
3282
3283
3292void
3294 size_t size,
3295 gcry_mpi_t val);
3296
3297
3307void
3309 const void *data,
3310 size_t size);
3311
3312
3319void
3321 struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3322 struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
3323
3324
3336int
3338 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3339 const gcry_mpi_t m,
3340 int desired_ops,
3341 struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext);
3342
3343
3352void
3354 const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
3355 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3356 const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext,
3357 gcry_mpi_t m);
3358
3359
3374int
3376 const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
3377 const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
3378 const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
3380
3381
3388int
3390 const struct GNUNET_CRYPTO_PaillierCiphertext *c);
3391
3392
3393/* ********* Chaum-style RSA-based blind signatures ******************* */
3394
3395
3400
3405
3417
3422
3423
3431GNUNET_CRYPTO_rsa_private_key_create (unsigned int len);
3432
3433
3439void
3441
3442
3451size_t
3453 const struct GNUNET_CRYPTO_RsaPrivateKey *key,
3454 void **buffer);
3455
3456
3467 size_t buf_size);
3468
3469
3478 const struct GNUNET_CRYPTO_RsaPrivateKey *key);
3479
3480
3489 const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
3490
3491
3498void
3500 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3501 struct GNUNET_HashCode *hc);
3502
3503
3509bool
3511 const struct GNUNET_CRYPTO_RsaPublicKey *key);
3512
3519unsigned int
3521
3522
3528void
3530
3531
3540size_t
3542 const struct GNUNET_CRYPTO_RsaPublicKey *key,
3543 void **buffer);
3544
3545
3556 size_t len);
3557
3558
3567
3568
3576int
3578 const struct GNUNET_CRYPTO_RsaSignature *s2);
3579
3587int
3589 const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
3590 const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
3591
3592
3600int
3602 const struct GNUNET_CRYPTO_RsaPublicKey *p2);
3603
3604
3621
3622
3634GNUNET_CRYPTO_rsa_blind (const void *message,
3635 size_t message_size,
3636 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3639
3640
3650 const struct
3652
3653
3664 const void *message,
3665 size_t message_size);
3666
3667
3674void
3677
3678
3684void
3686
3687
3695size_t
3697 const struct GNUNET_CRYPTO_RsaSignature *sig,
3698 void **buffer);
3699
3700
3711 const void *buf,
3712 size_t buf_size);
3713
3714
3723 const struct GNUNET_CRYPTO_RsaSignature *sig);
3724
3725
3738 const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
3740
3741
3753GNUNET_CRYPTO_rsa_verify (const void *message,
3754 size_t message_size,
3755 const struct GNUNET_CRYPTO_RsaSignature *sig,
3756 const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
3757
3758
3764void
3766
3767
3774void
3776 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3778
3779
3793void
3795 const struct GNUNET_CRYPTO_CsSessionNonce *nonce,
3796 const char *seed,
3797 const struct GNUNET_CRYPTO_CsPrivateKey *lts,
3798 struct GNUNET_CRYPTO_CsRSecret r[2]);
3799
3800
3807void
3809 const struct GNUNET_CRYPTO_CsRSecret *r_priv,
3810 struct GNUNET_CRYPTO_CsRPublic *r_pub);
3811
3812
3823void
3825 const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed,
3826 struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
3827
3828
3846
3847
3855
3856
3869void
3871 const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
3872 const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
3873 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3874 const void *msg,
3875 size_t msg_len,
3876 struct GNUNET_CRYPTO_CsC blinded_c[2],
3877 struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind);
3878
3879
3886{
3891 unsigned int b;
3892
3897};
3898
3899
3914void
3916 const struct GNUNET_CRYPTO_CsPrivateKey *priv,
3917 const struct GNUNET_CRYPTO_CsRSecret r[2],
3918 const struct GNUNET_CRYPTO_CsBlindedMessage *bm,
3919 struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig);
3920
3921
3929void
3931 const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
3932 const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
3933 struct GNUNET_CRYPTO_CsS *signature_scalar);
3934
3935
3948 const struct GNUNET_CRYPTO_CsSignature *sig,
3949 const struct GNUNET_CRYPTO_CsPublicKey *pub,
3950 const void *msg,
3951 size_t msg_len);
3952
3953
3975
3976
4011
4012
4050
4051
4090
4091
4125
4126
4159
4160
4168
4169
4174{
4175
4180
4184 unsigned int rc;
4185
4189 union
4190 {
4195
4197
4198};
4199
4200
4212
4213
4225 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4226 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4227 const char *salt);
4228
4229
4235void
4237 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4238
4239
4245void
4247 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4248
4249
4255void
4257 struct GNUNET_CRYPTO_UnblindedSignature *ub_sig);
4258
4259
4265void
4267 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4268
4269
4275void
4277 struct GNUNET_CRYPTO_BlindedMessage *bm);
4278
4279
4288 struct GNUNET_CRYPTO_BlindedMessage *bm);
4289
4290
4300
4301
4308void
4311
4312
4321 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4322
4323
4332 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv);
4333
4334
4343
4344
4353 struct GNUNET_CRYPTO_BlindedSignature *blind_sig);
4354
4355
4363int
4365 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
4366 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2);
4367
4368
4376int
4378 const struct GNUNET_CRYPTO_UnblindedSignature *sig2);
4379
4380
4388int
4390 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
4391 const struct GNUNET_CRYPTO_BlindedSignature *sig2);
4392
4393
4401int
4403 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
4404 const struct GNUNET_CRYPTO_BlindedMessage *bp2);
4405
4406
4422 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4423 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4425 ...);
4426
4427
4443 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
4444 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
4446 va_list ap);
4447
4448
4464
4465
4480 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4481 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4482 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
4483 const void *message,
4484 size_t message_size,
4485 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values);
4486
4487
4499 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
4500 const char *salt,
4501 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message);
4502
4503
4517 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
4518 const union GNUNET_CRYPTO_BlindingSecretP *bks,
4519 const void *message,
4520 size_t message_size,
4521 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
4522 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub);
4523
4524
4536 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
4537 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
4538 const void *message,
4539 size_t message_size);
4540
4541
4552ssize_t
4555
4571 const void *buffer,
4572 size_t len,
4574 size_t *read);
4575
4586ssize_t
4589
4590
4603ssize_t
4606 key,
4607 void*buffer,
4608 size_t len);
4609
4610
4625 const void*buffer,
4626 size_t len,
4628 size_t *read);
4629
4630
4643ssize_t
4646 void*buffer,
4647 size_t len);
4648
4649
4660ssize_t
4662 const struct GNUNET_CRYPTO_BlindableKeySignature *sig);
4663
4664
4675ssize_t
4677
4678
4691ssize_t
4694 const void*buffer,
4695 size_t len);
4696
4697
4710ssize_t
4712 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4713 void*buffer,
4714 size_t len);
4715
4716
4732 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4733 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4735
4751 const struct GNUNET_CRYPTO_BlindablePrivateKey *priv,
4752 const struct GNUNET_CRYPTO_SignaturePurpose *purpose,
4753 unsigned char *sig);
4754
4755
4767#define GNUNET_CRYPTO_blinded_key_sign(priv,ps,sig) do { \
4768 /* check size is set correctly */ \
4769 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4770 /* check 'ps' begins with the purpose */ \
4771 GNUNET_static_assert (((void*) (ps)) == \
4772 ((void*) &(ps)->purpose)); \
4773 GNUNET_assert (GNUNET_OK == \
4774 GNUNET_CRYPTO_blinded_key_sign_ (priv, \
4775 &(ps)->purpose, \
4776 sig)); \
4777} while (0)
4778
4779
4799 uint32_t purpose,
4800 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4801 const struct GNUNET_CRYPTO_BlindableKeySignature *sig,
4803
4821 uint32_t purpose,
4822 const struct GNUNET_CRYPTO_SignaturePurpose *validate,
4823 const unsigned char *sig,
4825
4826
4840#define GNUNET_CRYPTO_blinded_key_signature_verify(purp,ps,sig,pub) ({ \
4841 /* check size is set correctly */ \
4842 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
4843 /* check 'ps' begins with the purpose */ \
4844 GNUNET_static_assert (((void*) (ps)) == \
4845 ((void*) &(ps)->purpose)); \
4846 GNUNET_CRYPTO_blinded_key_signature_verify_ (purp, \
4847 &(ps)->purpose, \
4848 sig, \
4849 pub); \
4850 })
4851
4852
4861char *
4864
4865
4874char *
4877
4878
4889 struct
4891 *key);
4892
4893
4904 struct
4906 *key);
4907
4908
4919 privkey,
4921 *key);
4922
4923#if 0 /* keep Emacsens' auto-indent happy */
4924{
4925#endif
4926#ifdef __cplusplus
4927}
4928#endif
4929
4930
4931/* ifndef GNUNET_CRYPTO_LIB_H */
4932#endif
4933
/* end of group addition */
4935
4936/* 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:89
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition crypto_kdf.c:62
void GNUNET_CRYPTO_hmac_derive_key(struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len,...)
Derive an authentication key.
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.
ssize_t GNUNET_CRYPTO_public_key_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_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
#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 generic public key union.
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.
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.
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.
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.
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.
#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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_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.
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
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
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...
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_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.