GNUnet  0.11.x
gnunet_crypto_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001-2013 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 
43 #ifndef GNUNET_CRYPTO_LIB_H
44 #define GNUNET_CRYPTO_LIB_H
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #if 0 /* keep Emacsens' auto-indent happy */
49 }
50 #endif
51 #endif
52 
53 #include <stdbool.h>
54 #include <sodium.h>
55 
59 struct GNUNET_PeerIdentity;
60 
61 #include "gnunet_common.h"
62 #include <gcrypt.h>
63 
64 
69 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
70 
71 
77 {
84 
90 
96 };
97 
98 
102 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
103 
107 #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
108 
113 #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
114 
119 {
120  unsigned char encoding[104];
121 };
122 
123 
125 
126 
133 {
139  uint32_t size GNUNET_PACKED;
140 
148 };
149 
150 
156 {
160  unsigned char r[256 / 8];
161 
165  unsigned char s[256 / 8];
166 };
167 
168 
173 {
177  unsigned char r[256 / 8];
178 
182  unsigned char s[256 / 8];
183 };
184 
185 
193 {
199  unsigned char q_y[256 / 8];
200 };
201 
202 
208 {
213  unsigned char q_y[256 / 8];
214 };
215 
216 
221 {
223 };
224 
225 
232 {
237  unsigned char q_y[256 / 8];
238 };
239 
240 
246 {
250  unsigned char d[256 / 8];
251 };
252 
258 {
262  unsigned char d[256 / 8];
263 };
264 
270 {
274  unsigned char d[256 / 8];
275 };
276 
277 
283 {
287  unsigned char s[512 / 8];
288 };
289 
296 {
301  unsigned char a[256 / 8];
302 
307  unsigned char b[256 / 8];
308 };
309 
310 
318 {
324  unsigned char q_y[256 / 8];
325 };
326 
331 {
335  unsigned char r[256 / 8];
336 
340  unsigned char s[256 / 8];
341 };
342 
343 
348 {
353 
358 };
359 
364 {
369 };
370 
372 
380 {
382 
384 };
385 
386 
391 {
393 };
394 
395 
400 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
401 
402 
407 {
411  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
412 };
413 
414 
419 {
427  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
428 };
429 
430 
435 {
441 
445  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
446 };
447 
448 
453 {
457  unsigned char d[crypto_core_ed25519_SCALARBYTES];
458 };
459 
460 
465 {
470  unsigned char y[crypto_core_ed25519_BYTES];
471 };
472 
473 
478 {
480 };
481 
482 
487 {
489 };
490 
491 
496 {
499 };
500 
501 
506 {
508 };
509 
510 
515 {
517 };
518 
519 
524 {
526 };
527 
528 
533 {
535 };
536 
537 
542 {
544 };
545 
546 
551 {
557 };
558 
559 
564 {
565  /*a nonce*/
566  unsigned char nonce[256 / 8];
567 };
568 
569 
570 /* **************** Functions and Macros ************* */
571 
579 void
580 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
581 
582 
591 uint8_t
592 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
593 
594 
603 uint32_t
604 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
605 
606 
613 uint16_t
615 
616 
625 uint16_t
626 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
627 
628 
638 int32_t
639 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
640 
649 void
650 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
651 
652 
661 void
663  void *buffer,
664  size_t length);
665 
666 
677 void
679  struct GNUNET_Uuid *uuid);
680 
681 
690 uint32_t
692 
693 
702 uint64_t
704 
705 
715 unsigned int *
717 
718 
725 void
728 
729 
741 ssize_t
743  const void *block,
744  size_t size,
745  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
747  void *result);
748 
749 
761 ssize_t
763  const void *block,
764  size_t size,
765  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
767  void *result);
768 
769 
779 void
782  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
783  const void *salt,
784  size_t salt_len,
785  ...);
786 
787 
796 void
799  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
800  const void *salt,
801  size_t salt_len,
802  va_list argp);
803 
804 
812 void
813 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
815 
816 
828  size_t enclen,
829  struct GNUNET_HashCode *result);
830 
831 
840 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
841  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
842 
843 
856 uint32_t
858  const struct GNUNET_HashCode *b);
859 
860 
869 void
870 GNUNET_CRYPTO_hash (const void *block,
871  size_t size,
872  struct GNUNET_HashCode *ret);
873 
874 
879 {
880  char salt[crypto_pwhash_argon2id_SALTBYTES];
881 };
882 
883 
892 void
894  const void *buf,
895  size_t buf_len,
896  struct GNUNET_HashCode *result);
897 
898 
902 struct GNUNET_HashContext;
903 
904 
910 struct GNUNET_HashContext *
912 
913 
920 struct GNUNET_HashContext *
922 
923 
931 void
933  const void *buf,
934  size_t size);
935 
936 
943 void
945  struct GNUNET_HashCode *r_hash);
946 
947 
953 void
955 
956 
968 void
969 GNUNET_CRYPTO_hmac_raw (const void *key,
970  size_t key_len,
971  const void *plaintext,
972  size_t plaintext_len,
973  struct GNUNET_HashCode *hmac);
974 
975 
985 void
987  const void *plaintext,
988  size_t plaintext_len,
989  struct GNUNET_HashCode *hmac);
990 
991 
999 typedef void
1001  void *cls,
1002  const struct GNUNET_HashCode *res);
1003 
1004 
1009 
1010 
1024  const char *filename,
1025  size_t blocksize,
1027  void *callback_cls);
1028 
1029 
1035 void
1037 
1038 
1046 void
1048  struct GNUNET_HashCode *result);
1049 
1050 
1059 void
1061  const struct GNUNET_HashCode *b,
1062  struct GNUNET_HashCode *result);
1063 
1064 
1073 void
1074 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
1075  const struct GNUNET_HashCode *delta,
1076  struct GNUNET_HashCode *result);
1077 
1078 
1087 void
1088 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
1089  const struct GNUNET_HashCode *b,
1090  struct GNUNET_HashCode *result);
1091 
1092 
1099 unsigned int
1101 
1102 
1109 unsigned int
1111 
1112 
1121 void
1123  const struct GNUNET_HashCode *hc,
1124  struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
1126 
1127 
1137 int
1138 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1139  const struct GNUNET_HashCode *h2);
1140 
1141 
1152 int
1153 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
1154  const struct GNUNET_HashCode *h2,
1155  const struct GNUNET_HashCode *target);
1156 
1157 
1167 void
1169  struct GNUNET_CRYPTO_AuthKey *key,
1170  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1171  const void *salt,
1172  size_t salt_len,
1173  va_list argp);
1174 
1175 
1185 void
1187  struct GNUNET_CRYPTO_AuthKey *key,
1188  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1189  const void *salt,
1190  size_t salt_len,
1191  ...);
1192 
1193 
1209 GNUNET_CRYPTO_hkdf (void *result,
1210  size_t out_len,
1211  int xtr_algo,
1212  int prf_algo,
1213  const void *xts,
1214  size_t xts_len,
1215  const void *skm,
1216  size_t skm_len,
1217  ...);
1218 
1219 
1236  size_t out_len,
1237  int xtr_algo,
1238  int prf_algo,
1239  const void *xts,
1240  size_t xts_len,
1241  const void *skm,
1242  size_t skm_len,
1243  va_list argp);
1244 
1245 
1259  size_t out_len,
1260  const void *xts,
1261  size_t xts_len,
1262  const void *skm,
1263  size_t skm_len,
1264  va_list argp);
1265 
1266 
1279 void
1280 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1281  gcry_mpi_t n,
1282  const void *xts,
1283  size_t xts_len,
1284  const void *skm,
1285  size_t skm_len,
1286  const char *ctx);
1287 
1288 
1302 GNUNET_CRYPTO_kdf (void *result,
1303  size_t out_len,
1304  const void *xts,
1305  size_t xts_len,
1306  const void *skm,
1307  size_t skm_len,
1308  ...);
1309 
1310 
1318 void
1320  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1322 
1330 void
1332  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1334 
1342 void
1344  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1346 
1354 void
1356  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1358 
1359 
1366 char *
1368  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1369 
1376 char *
1378  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1379 
1380 
1387 char *
1389  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1390 
1391 
1398 char *
1400  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1401 
1402 
1413  const char *enc,
1414  size_t enclen,
1416 
1417 
1428  const char *enc,
1429  size_t enclen,
1431 
1432 
1443  const char *enc,
1444  size_t enclen,
1446 
1447 
1465  int do_create,
1467 
1468 
1486  int do_create,
1488 
1489 
1494 
1495 
1507  const struct GNUNET_CONFIGURATION_Handle *cfg);
1508 
1509 
1516 void
1518 
1519 
1526 void
1528 
1529 
1536 void
1538 
1548 void
1550  const void *seed,
1551  size_t seedsize,
1553 
1560 void
1562 
1563 
1570 void
1572 
1573 
1580 void
1582 
1589 void
1591 
1598 void
1600 
1601 
1608 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1610 
1611 
1621 void
1622 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1623 
1624 
1634 int
1636  struct GNUNET_PeerIdentity *dst);
1637 
1638 
1643 
1644 
1650 {
1655  unsigned char v[256 / 8];
1656 };
1657 
1662 {
1663  unsigned char v[256 / 8];
1664 };
1665 
1674 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1675  unsigned int mem);
1676 
1677 
1686 int
1688  const struct GNUNET_CRYPTO_EccPoint *input);
1689 
1690 
1702 void
1703 GNUNET_CRYPTO_ecc_dexp (int val,
1704  struct GNUNET_CRYPTO_EccPoint*r);
1705 
1706 
1717  struct GNUNET_CRYPTO_EccPoint *r);
1718 
1719 
1730  const struct GNUNET_CRYPTO_EccScalar *val,
1731  struct GNUNET_CRYPTO_EccPoint *r);
1732 
1733 
1744  const struct GNUNET_CRYPTO_EccPoint *b,
1745  struct GNUNET_CRYPTO_EccPoint *r);
1746 
1747 
1758  struct GNUNET_CRYPTO_EccPoint *r_inv);
1759 
1760 
1768 void
1770  struct GNUNET_CRYPTO_EccScalar *r_neg);
1771 
1772 
1778 void
1780 
1781 
1787 void
1789 
1790 
1797 void
1799  struct GNUNET_CRYPTO_EccScalar *r);
1800 
1801 
1813  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1814  struct GNUNET_HashCode *key_material);
1815 
1816 
1829  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1830  struct GNUNET_HashCode *key_material);
1831 
1832 
1845  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1846  struct GNUNET_HashCode *key_material);
1847 
1848 
1861  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1862  struct GNUNET_HashCode *key_material);
1863 
1876  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1877  struct GNUNET_HashCode *key_material);
1878 
1879 
1897  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1898  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1899  struct GNUNET_CRYPTO_EddsaSignature *sig);
1900 
1901 
1914 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1915  /* check size is set correctly */ \
1916  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1917  /* check 'ps' begins with the purpose */ \
1918  GNUNET_static_assert (((void*) (ps)) == \
1919  ((void*) &(ps)->purpose)); \
1920  GNUNET_assert (GNUNET_OK == \
1921  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1922  &(ps)->purpose, \
1923  sig)); \
1924 } while (0)
1925 
1926 
1944  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1945  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1946  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1947 
1948 
1961 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1962  /* check size is set correctly */ \
1963  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1964  /* check 'ps' begins with the purpose */ \
1965  GNUNET_static_assert (((void*) (ps)) == \
1966  ((void*) &(ps)->purpose)); \
1967  GNUNET_assert (GNUNET_OK == \
1968  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1969  &(ps)->purpose, \
1970  sig)); \
1971 } while (0)
1972 
1990  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1991  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1992  struct GNUNET_CRYPTO_Edx25519Signature *sig);
1993 
1994 
2008 #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2009  /* check size is set correctly */ \
2010  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2011  /* check 'ps' begins with the purpose */ \
2012  GNUNET_static_assert (((void*) (ps)) == \
2013  ((void*) &(ps)->purpose)); \
2014  GNUNET_assert (GNUNET_OK == \
2015  GNUNET_CRYPTO_edx25519_sign_ (priv, \
2016  &(ps)->purpose, \
2017  sig)); \
2018 } while (0)
2019 
2020 
2041  uint32_t purpose,
2042  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2043  const struct GNUNET_CRYPTO_EddsaSignature *sig,
2044  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2045 
2046 
2061 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2062  /* check size is set correctly */ \
2063  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2064  /* check 'ps' begins with the purpose */ \
2065  GNUNET_static_assert (((void*) (ps)) == \
2066  ((void*) &(ps)->purpose)); \
2067  GNUNET_CRYPTO_eddsa_verify_ (purp, \
2068  &(ps)->purpose, \
2069  sig, \
2070  pub); \
2071  })
2072 
2093  uint32_t purpose,
2094  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2095  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2096  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2097 
2098 
2113 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2114  /* check size is set correctly */ \
2115  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2116  /* check 'ps' begins with the purpose */ \
2117  GNUNET_static_assert (((void*) (ps)) == \
2118  ((void*) &(ps)->purpose)); \
2119  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2120  &(ps)->purpose, \
2121  sig, \
2122  pub); \
2123  })
2124 
2145  uint32_t purpose,
2146  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2147  const struct GNUNET_CRYPTO_Edx25519Signature *sig,
2148  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
2149 
2150 
2165 #define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
2166  /* check size is set correctly */ \
2167  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2168  /* check 'ps' begins with the purpose */ \
2169  GNUNET_static_assert (((void*) (ps)) == \
2170  ((void*) &(ps)->purpose)); \
2171  GNUNET_CRYPTO_edx25519_verify_ (purp, \
2172  &(ps)->purpose, \
2173  sig, \
2174  pub); \
2175  })
2176 
2192  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2193  const char *label,
2194  const char *context);
2195 
2196 
2208 void
2210  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2211  const char *label,
2212  const char *context,
2214 
2229  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
2230  const char *label,
2231  const char *context,
2232  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2233  struct GNUNET_CRYPTO_EcdsaSignature *sig);
2234 
2235 
2252 void
2254  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2255  const char *label,
2256  const char *context,
2258 
2259 
2271 void
2273  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2274  const char *label,
2275  const char *context,
2277 
2278 
2294  const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
2295  const char *label,
2296  const char *context,
2297  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2298  struct GNUNET_CRYPTO_EddsaSignature *sig);
2299 
2300 
2307 void
2309  const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
2311 
2324 void
2326  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2327  const void *seed,
2328  size_t seedsize,
2330 
2331 
2342 void
2344  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub,
2345  const void *seed,
2346  size_t seedsize,
2348 
2349 
2358 void
2360  size_t size,
2361  gcry_mpi_t val);
2362 
2363 
2373 void
2375  const void *data,
2376  size_t size);
2377 
2378 
2385 void
2387  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2388  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
2389 
2390 
2402 int
2404  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2405  const gcry_mpi_t m,
2406  int desired_ops,
2408 
2409 
2418 void
2420  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
2421  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2423  gcry_mpi_t m);
2424 
2425 
2439 int
2441  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2442  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2443  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2445 
2446 
2453 int
2455  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2456 
2457 
2458 /* ********* Chaum-style RSA-based blind signatures ******************* */
2459 
2460 
2465 
2470 
2475 {
2481 };
2482 
2487 
2488 
2497 
2498 
2504 void
2506 
2507 
2516 size_t
2518  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2519  void **buffer);
2520 
2521 
2532  size_t buf_size);
2533 
2534 
2543  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2544 
2545 
2554  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2555 
2556 
2563 void
2565  struct GNUNET_HashCode *hc);
2566 
2567 
2573 bool
2575  const struct GNUNET_CRYPTO_RsaPublicKey *key);
2576 
2583 unsigned int
2585 
2586 
2592 void
2594 
2595 
2604 size_t
2606  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2607  void **buffer);
2608 
2609 
2620  size_t len);
2621 
2622 
2631 
2632 
2640 int
2642  const struct GNUNET_CRYPTO_RsaSignature *s2);
2643 
2651 int
2653  const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
2654  const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2655 
2656 
2664 int
2666  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2667 
2668 
2679 int
2680 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2681  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2683  void **buf,
2684  size_t *buf_size);
2685 
2686 
2697  const void *msg,
2698  size_t msg_len);
2699 
2700 
2710  const struct GNUNET_HashCode *hash);
2711 
2712 
2718 void
2720 
2721 
2729 size_t
2731  const struct GNUNET_CRYPTO_RsaSignature *sig,
2732  void **buffer);
2733 
2734 
2745  size_t buf_size);
2746 
2747 
2756 
2757 
2770  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2772 
2773 
2784 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2785  const struct GNUNET_CRYPTO_RsaSignature *sig,
2786  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2787 
2788 
2794 void
2796 
2797 
2804 void
2806  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2807  struct GNUNET_CRYPTO_CsPublicKey *pub);
2808 
2809 
2823 void
2825  const char *seed,
2826  const struct GNUNET_CRYPTO_CsPrivateKey *lts,
2827  struct GNUNET_CRYPTO_CsRSecret r[2]);
2828 
2829 
2836 void
2838  struct GNUNET_CRYPTO_CsRPublic *r_pub);
2839 
2850 void
2852  const struct GNUNET_CRYPTO_CsNonce *blind_seed,
2853  struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
2854 
2855 
2868 void
2870  const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
2871  const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
2872  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2873  const void *msg,
2874  size_t msg_len,
2875  struct GNUNET_CRYPTO_CsC blinded_c[2],
2876  struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]);
2877 
2878 
2895 unsigned int
2897  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2898  const struct GNUNET_CRYPTO_CsRSecret r[2],
2899  const struct GNUNET_CRYPTO_CsC c[2],
2900  const struct GNUNET_CRYPTO_CsNonce *nonce,
2901  struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar);
2902 
2903 
2911 void
2913  const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
2914  const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
2915  struct GNUNET_CRYPTO_CsS *signature_scalar);
2916 
2917 
2930  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2931  const void *msg,
2932  size_t msg_len);
2933 
2934 
2935 #if 0 /* keep Emacsens' auto-indent happy */
2936 {
2937 #endif
2938 #ifdef __cplusplus
2939 }
2940 #endif
2941 
2942 
2943 /* ifndef GNUNET_CRYPTO_LIB_H */
2944 #endif
2945 /* end of gnunet_crypto_lib.h */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int res
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static pa_context * context
Pulseaudio context.
static OpusEncoder * enc
OPUS encoder.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static char * pkey
Public key of the zone to look in, in ASCII.
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
static char buf[2048]
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
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;.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
#define GNUNET_PACKED
gcc-ism to get packed structs.
unsigned int GNUNET_CRYPTO_hash_count_leading_zeros(const struct GNUNET_HashCode *h)
Count the number of leading 0 bits in h.
Definition: crypto_hash.c:176
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_dup(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Duplicate the given public key.
Definition: crypto_rsa.c:1074
#define GNUNET_CRYPTO_HASH_LENGTH
Length of a hash value.
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_mpi_scan_unsigned(gcry_mpi_t *result, const void *data, size_t size)
Convert data buffer into MPI value.
Definition: crypto_mpi.c:131
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
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.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:1038
#define GNUNET_CRYPTO_PAILLIER_BITS
Size of paillier plain texts and public keys.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:990
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:348
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:96
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:224
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...
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition: crypto_rsa.c:172
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.
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:94
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_verify(const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaPublicKey *public_key)
Verify whether the given hash corresponds to the given signature and the signature is valid with resp...
Definition: crypto_rsa.c:1174
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:332
int GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, const struct GNUNET_CRYPTO_EccPoint *input)
Calculate ECC discrete logarithm for small factors.
void GNUNET_CRYPTO_cs_blinding_secrets_derive(const struct GNUNET_CRYPTO_CsNonce *blind_seed, struct GNUNET_CRYPTO_CsBlindingSecret bs[2])
Derives new random blinding factors.
Definition: crypto_cs.c:105
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:364
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:203
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_derived(const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes a private key and derives it using the label and c...
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_unblind(const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey)
Unblind a blind-signed signature.
Definition: crypto_rsa.c:1093
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
Definition: crypto_crc.c:144
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:601
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:51
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:125
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:299
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:300
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
void GNUNET_CRYPTO_cs_r_derive(const struct GNUNET_CRYPTO_CsNonce *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:77
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:251
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:37
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
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:357
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:679
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:406
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
Definition: crypto_hash.c:406
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_derived(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, const char *context, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
This is a signature function for ECDSA which takes a private key, derives/blinds it and signs the mes...
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the 'proof-of-work' hash (an expensive hash).
Definition: crypto_pow.c:41
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:267
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:422
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
Definition: crypto_hash.c:375
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:78
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_CsRPublic blinded_r_pub[2])
Calculate two blinded c's Comment: One would be insecure due to Wagner's algorithm solving ROS.
Definition: crypto_cs.c:230
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:324
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
unsigned int GNUNET_CRYPTO_cs_sign_derive(const struct GNUNET_CRYPTO_CsPrivateKey *priv, const struct GNUNET_CRYPTO_CsRSecret r[2], const struct GNUNET_CRYPTO_CsC c[2], const struct GNUNET_CRYPTO_CsNonce *nonce, struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar)
Sign a blinded c This function derives b from a nonce and a longterm secret In original papers b is g...
Definition: crypto_cs.c:260
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:653
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:388
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.
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
Definition: crypto_rsa.c:998
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...
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.
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
Definition: crypto_rsa.c:1240
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_private_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPrivateKey *pub)
Convert a string representing a private key to a private key.
Definition: crypto_ecc.c:382
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_fdh(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const struct GNUNET_HashCode *hash)
Create and sign a full domain hash of a message.
Definition: crypto_rsa.c:970
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 x1 and x2.
unsigned int GNUNET_CRYPTO_hash_count_tailing_zeros(const struct GNUNET_HashCode *h)
Count the number of tailing 0 bits in h.
Definition: crypto_hash.c:198
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:311
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:627
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
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:232
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.
void GNUNET_CRYPTO_cs_private_key_generate(struct GNUNET_CRYPTO_CsPrivateKey *priv)
Create a new random private key.
Definition: crypto_cs.c:44
void GNUNET_CRYPTO_hmac_raw(const void *key, size_t key_len, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104) TODO: Shouldn't this be the standard hmac function and the abo...
Definition: crypto_hash.c:299
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:305
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:278
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:180
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition: crypto_rsa.c:143
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_dup(const struct GNUNET_CRYPTO_RsaPrivateKey *key)
Duplicate the given private key.
Definition: crypto_rsa.c:1220
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.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_blinded(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const void *msg, size_t msg_len)
Sign a blinded value, which must be a full domain hash of a message.
Definition: crypto_rsa.c:946
int GNUNET_CRYPTO_rsa_blind(const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, void **buf, size_t *buf_size)
Blinds the given message with the given blinding key.
Definition: crypto_rsa.c:789
static enum @8 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:705
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:435
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.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
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.
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.
void GNUNET_CRYPTO_edx25519_key_clear(struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Clear memory that was used to store a private key.
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.
void GNUNET_CRYPTO_edx25519_key_create_from_seed(const void *seed, size_t seedsize, struct GNUNET_CRYPTO_Edx25519PrivateKey *pk)
Create a new private key for Edx25519 from a given seed.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey)
Create a new private key by reading it from a file.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
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:197
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private ECDSA key.
Definition: crypto_ecc.c:740
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:428
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition: crypto_ecc.c:549
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
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:718
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:481
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:775
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:461
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_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:758
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:97
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:446
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:599
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:421
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:623
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.
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:186
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:682
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_edx25519_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_Edx25519Signature *sig, const struct GNUNET_CRYPTO_Edx25519PublicKey *pub)
Verify Edx25519 signature.
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_edx25519_sign_(const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_Edx25519Signature *sig)
Edx25519 sign a given block.
unsigned int * GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n)
Get an array with a random permutation of the numbers 0...n-1.
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
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:414
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:213
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.
@ 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.
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
Definition: crypto_hash.c:111
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
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:55
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:100
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition: crypto_crc.c:106
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
Definition: crypto_hash.c:328
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
Definition: crypto_hash.c:123
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:135
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf_v(void *result, size_t out_len, int xtr_algo, int prf_algo, const void *xts, size_t xts_len, const void *skm, size_t skm_len, va_list argp)
Derive key.
Definition: crypto_hkdf.c:165
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:179
int GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2, const struct GNUNET_HashCode *target)
Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).
Definition: crypto_hash.c:242
void GNUNET_CRYPTO_hmac_derive_key_v(struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len, va_list argp)
Derive an authentication key.
Definition: crypto_hash.c:285
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hkdf(void *result, size_t out_len, int xtr_algo, int prf_algo, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
Definition: crypto_hkdf.c:340
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
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.
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:161
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:220
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:69
void GNUNET_CRYPTO_hmac_derive_key(struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, const void *salt, size_t salt_len,...)
Derive an authentication key.
Definition: crypto_hash.c:266
void GNUNET_CRYPTO_hash_to_aes_key(const struct GNUNET_HashCode *hc, struct GNUNET_CRYPTO_SymmetricSessionKey *skey, struct GNUNET_CRYPTO_SymmetricInitializationVector *iv)
Convert a hashcode into a key.
Definition: crypto_hash.c:151
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:67
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
type for (message) authentication keys
unsigned char key[(512/8)]
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
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
unsigned char nonce[256/8]
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
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
Internal structure used to cache pre-calculated values for DLOG calculation.
unsigned int mem
How much memory should we use (relates to the number of entries in the map).
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
unsigned char v[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A ECC scalar for use in point multiplications.
unsigned char v[256/8]
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
an ECC signature using ECDSA
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC scalar encoded for transmission.
unsigned char s[512/8]
s is the expandedprivate 512-bit scalar of a private key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using EdDSA.
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key material encoded for transmission.
unsigned char b[256/8]
b consists of 32 bytes which where originally the lower 32bytes of the key expansion.
unsigned char a[256/8]
a is a value mod n, where n has at most 256 bits.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using Edx25519 (same as in EdDSA).
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
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.
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]
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:40
The public information of an RSA key pair.
Definition: crypto_rsa.c:52
an RSA signature
Definition: crypto_rsa.c:64
unsigned char twofish_key[(256/8)]
Actual key for TwoFish.
unsigned char aes_key[(256/8)]
Actual key for AES.
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.