GNUnet  0.17.6
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 
47 #ifndef GNUNET_CRYPTO_LIB_H
48 #define GNUNET_CRYPTO_LIB_H
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #if 0 /* keep Emacsens' auto-indent happy */
53 }
54 #endif
55 #endif
56 
57 #include <stdbool.h>
58 #include <sodium.h>
59 
63 struct GNUNET_PeerIdentity;
64 
65 #include "gnunet_common.h"
66 #include <gcrypt.h>
67 
68 
73 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
74 
75 
81 {
88 
94 
100 };
101 
102 
106 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
107 
111 #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
112 
117 #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
118 
123 {
124  unsigned char encoding[104];
125 };
126 
127 
129 
130 
137 {
143  uint32_t size GNUNET_PACKED;
144 
152 };
153 
154 
160 {
164  unsigned char r[256 / 8];
165 
169  unsigned char s[256 / 8];
170 };
171 
172 
177 {
181  unsigned char r[256 / 8];
182 
186  unsigned char s[256 / 8];
187 };
188 
189 
197 {
203  unsigned char q_y[256 / 8];
204 };
205 
206 
212 {
217  unsigned char q_y[256 / 8];
218 };
219 
220 
225 {
227 };
228 
229 
236 {
241  unsigned char q_y[256 / 8];
242 };
243 
244 
250 {
254  unsigned char d[256 / 8];
255 };
256 
262 {
266  unsigned char d[256 / 8];
267 };
268 
274 {
278  unsigned char d[256 / 8];
279 };
280 
281 
287 {
291  unsigned char s[512 / 8];
292 };
293 
300 {
305  unsigned char a[256 / 8];
306 
311  unsigned char b[256 / 8];
312 };
313 
314 
322 {
328  unsigned char q_y[256 / 8];
329 };
330 
335 {
339  unsigned char r[256 / 8];
340 
344  unsigned char s[256 / 8];
345 };
346 
347 
352 {
357 
362 };
363 
368 {
373 };
374 
376 
384 {
386 
388 };
389 
390 
395 {
397 };
398 
399 
404 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
405 
406 
411 {
415  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
416 };
417 
418 
423 {
431  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
432 };
433 
434 
439 {
445 
449  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
450 };
451 
452 
457 {
461  unsigned char d[crypto_core_ed25519_SCALARBYTES];
462 };
463 
464 
469 {
474  unsigned char y[crypto_core_ed25519_BYTES];
475 };
476 
477 
482 {
484 };
485 
486 
491 {
493 };
494 
495 
500 {
503 };
504 
505 
510 {
512 };
513 
514 
519 {
521 };
522 
523 
528 {
530 };
531 
532 
537 {
539 };
540 
541 
546 {
548 };
549 
550 
555 {
561 };
562 
563 
568 {
569  /*a nonce*/
570  unsigned char nonce[256 / 8];
571 };
572 
573 
574 /* **************** Functions and Macros ************* */
575 
583 void
584 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
585 
586 
595 uint8_t
596 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
597 
598 
607 uint32_t
608 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
609 
610 
617 uint16_t
619 
620 
629 uint16_t
630 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
631 
632 
642 int32_t
643 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
644 
653 void
654 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
655 
656 
665 void
667  void *buffer,
668  size_t length);
669 
670 
681 void
683  struct GNUNET_Uuid *uuid);
684 
685 
694 uint32_t
696 
697 
706 uint64_t
708 
709 
719 unsigned int *
721 
722 
729 void
732 
733 
745 ssize_t
747  const void *block,
748  size_t size,
749  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
751  void *result);
752 
753 
765 ssize_t
767  const void *block,
768  size_t size,
769  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
771  void *result);
772 
773 
783 void
786  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
787  const void *salt,
788  size_t salt_len,
789  ...);
790 
791 
800 void
803  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
804  const void *salt,
805  size_t salt_len,
806  va_list argp);
807 
808 
816 void
817 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
819 
820 
832  size_t enclen,
833  struct GNUNET_HashCode *result);
834 
835 
844 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
845  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
846 
847 
860 uint32_t
862  const struct GNUNET_HashCode *b);
863 
864 
873 void
874 GNUNET_CRYPTO_hash (const void *block,
875  size_t size,
876  struct GNUNET_HashCode *ret);
877 
878 
883 {
884  char salt[crypto_pwhash_argon2id_SALTBYTES];
885 };
886 
887 
896 void
898  const void *buf,
899  size_t buf_len,
900  struct GNUNET_HashCode *result);
901 
902 
906 struct GNUNET_HashContext;
907 
908 
914 struct GNUNET_HashContext *
916 
917 
924 struct GNUNET_HashContext *
926 
927 
935 void
937  const void *buf,
938  size_t size);
939 
940 
947 void
949  struct GNUNET_HashCode *r_hash);
950 
951 
957 void
959 
960 
972 void
973 GNUNET_CRYPTO_hmac_raw (const void *key,
974  size_t key_len,
975  const void *plaintext,
976  size_t plaintext_len,
977  struct GNUNET_HashCode *hmac);
978 
979 
989 void
991  const void *plaintext,
992  size_t plaintext_len,
993  struct GNUNET_HashCode *hmac);
994 
995 
1003 typedef void
1005  void *cls,
1006  const struct GNUNET_HashCode *res);
1007 
1008 
1013 
1014 
1028  const char *filename,
1029  size_t blocksize,
1031  void *callback_cls);
1032 
1033 
1039 void
1041 
1042 
1050 void
1052  struct GNUNET_HashCode *result);
1053 
1054 
1063 void
1065  const struct GNUNET_HashCode *b,
1066  struct GNUNET_HashCode *result);
1067 
1068 
1077 void
1078 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
1079  const struct GNUNET_HashCode *delta,
1080  struct GNUNET_HashCode *result);
1081 
1082 
1091 void
1092 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
1093  const struct GNUNET_HashCode *b,
1094  struct GNUNET_HashCode *result);
1095 
1096 
1103 unsigned int
1105 
1106 
1113 unsigned int
1115 
1116 
1125 void
1127  const struct GNUNET_HashCode *hc,
1128  struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
1130 
1131 
1141 int
1142 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1143  const struct GNUNET_HashCode *h2);
1144 
1145 
1156 int
1157 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
1158  const struct GNUNET_HashCode *h2,
1159  const struct GNUNET_HashCode *target);
1160 
1161 
1171 void
1173  struct GNUNET_CRYPTO_AuthKey *key,
1174  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1175  const void *salt,
1176  size_t salt_len,
1177  va_list argp);
1178 
1179 
1189 void
1191  struct GNUNET_CRYPTO_AuthKey *key,
1192  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1193  const void *salt,
1194  size_t salt_len,
1195  ...);
1196 
1197 
1213 GNUNET_CRYPTO_hkdf (void *result,
1214  size_t out_len,
1215  int xtr_algo,
1216  int prf_algo,
1217  const void *xts,
1218  size_t xts_len,
1219  const void *skm,
1220  size_t skm_len,
1221  ...);
1222 
1223 
1240  size_t out_len,
1241  int xtr_algo,
1242  int prf_algo,
1243  const void *xts,
1244  size_t xts_len,
1245  const void *skm,
1246  size_t skm_len,
1247  va_list argp);
1248 
1249 
1263  size_t out_len,
1264  const void *xts,
1265  size_t xts_len,
1266  const void *skm,
1267  size_t skm_len,
1268  va_list argp);
1269 
1270 
1283 void
1284 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1285  gcry_mpi_t n,
1286  const void *xts,
1287  size_t xts_len,
1288  const void *skm,
1289  size_t skm_len,
1290  const char *ctx);
1291 
1292 
1306 GNUNET_CRYPTO_kdf (void *result,
1307  size_t out_len,
1308  const void *xts,
1309  size_t xts_len,
1310  const void *skm,
1311  size_t skm_len,
1312  ...);
1313 
1314 
1322 void
1324  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1326 
1334 void
1336  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1338 
1346 void
1348  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1350 
1358 void
1360  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1362 
1363 
1370 char *
1372  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1373 
1380 char *
1382  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1383 
1384 
1391 char *
1393  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1394 
1395 
1402 char *
1404  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1405 
1406 
1417  const char *enc,
1418  size_t enclen,
1420 
1421 
1432  const char *enc,
1433  size_t enclen,
1435 
1436 
1447  const char *enc,
1448  size_t enclen,
1450 
1451 
1469  int do_create,
1471 
1472 
1490  int do_create,
1492 
1493 
1498 
1499 
1511  const struct GNUNET_CONFIGURATION_Handle *cfg);
1512 
1513 
1520 void
1522 
1523 
1530 void
1532 
1533 
1540 void
1542 
1552 void
1554  const void *seed,
1555  size_t seedsize,
1557 
1564 void
1566 
1567 
1574 void
1576 
1577 
1584 void
1586 
1593 void
1595 
1602 void
1604 
1605 
1612 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1614 
1615 
1625 void
1626 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1627 
1628 
1640  struct GNUNET_PeerIdentity *dst);
1641 
1642 
1647 
1648 
1654 {
1659  unsigned char v[256 / 8];
1660 };
1661 
1666 {
1667  unsigned char v[256 / 8];
1668 };
1669 
1678 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1679  unsigned int mem);
1680 
1681 
1690 int
1692  const struct GNUNET_CRYPTO_EccPoint *input);
1693 
1694 
1706 void
1707 GNUNET_CRYPTO_ecc_dexp (int val,
1708  struct GNUNET_CRYPTO_EccPoint*r);
1709 
1710 
1721  struct GNUNET_CRYPTO_EccPoint *r);
1722 
1723 
1734  const struct GNUNET_CRYPTO_EccScalar *val,
1735  struct GNUNET_CRYPTO_EccPoint *r);
1736 
1737 
1748  const struct GNUNET_CRYPTO_EccPoint *b,
1749  struct GNUNET_CRYPTO_EccPoint *r);
1750 
1751 
1762  struct GNUNET_CRYPTO_EccPoint *r_inv);
1763 
1764 
1772 void
1774  struct GNUNET_CRYPTO_EccScalar *r_neg);
1775 
1776 
1782 void
1784 
1785 
1791 void
1793 
1794 
1801 void
1803  struct GNUNET_CRYPTO_EccScalar *r);
1804 
1805 
1817  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1818  struct GNUNET_HashCode *key_material);
1819 
1820 
1833  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1834  struct GNUNET_HashCode *key_material);
1835 
1836 
1849  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1850  struct GNUNET_HashCode *key_material);
1851 
1852 
1865  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1866  struct GNUNET_HashCode *key_material);
1867 
1880  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1881  struct GNUNET_HashCode *key_material);
1882 
1883 
1901  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1902  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1903  struct GNUNET_CRYPTO_EddsaSignature *sig);
1904 
1905 
1918 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1919  /* check size is set correctly */ \
1920  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1921  /* check 'ps' begins with the purpose */ \
1922  GNUNET_static_assert (((void*) (ps)) == \
1923  ((void*) &(ps)->purpose)); \
1924  GNUNET_assert (GNUNET_OK == \
1925  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1926  &(ps)->purpose, \
1927  sig)); \
1928 } while (0)
1929 
1930 
1948  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1949  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1950  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1951 
1963  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1964  void *data,
1965  size_t size,
1966  struct GNUNET_CRYPTO_EddsaSignature *sig);
1967 
1980 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1981  /* check size is set correctly */ \
1982  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1983  /* check 'ps' begins with the purpose */ \
1984  GNUNET_static_assert (((void*) (ps)) == \
1985  ((void*) &(ps)->purpose)); \
1986  GNUNET_assert (GNUNET_OK == \
1987  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1988  &(ps)->purpose, \
1989  sig)); \
1990 } while (0)
1991 
2009  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2010  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2011  struct GNUNET_CRYPTO_Edx25519Signature *sig);
2012 
2013 
2027 #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2028  /* check size is set correctly */ \
2029  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2030  /* check 'ps' begins with the purpose */ \
2031  GNUNET_static_assert (((void*) (ps)) == \
2032  ((void*) &(ps)->purpose)); \
2033  GNUNET_assert (GNUNET_OK == \
2034  GNUNET_CRYPTO_edx25519_sign_ (priv, \
2035  &(ps)->purpose, \
2036  sig)); \
2037 } while (0)
2038 
2039 
2060  uint32_t purpose,
2061  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2062  const struct GNUNET_CRYPTO_EddsaSignature *sig,
2063  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2064 
2065 
2080 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2081  /* check size is set correctly */ \
2082  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2083  /* check 'ps' begins with the purpose */ \
2084  GNUNET_static_assert (((void*) (ps)) == \
2085  ((void*) &(ps)->purpose)); \
2086  GNUNET_CRYPTO_eddsa_verify_ (purp, \
2087  &(ps)->purpose, \
2088  sig, \
2089  pub); \
2090  })
2091 
2112  uint32_t purpose,
2113  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2114  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2115  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2116 
2117 
2132 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2133  /* check size is set correctly */ \
2134  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2135  /* check 'ps' begins with the purpose */ \
2136  GNUNET_static_assert (((void*) (ps)) == \
2137  ((void*) &(ps)->purpose)); \
2138  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2139  &(ps)->purpose, \
2140  sig, \
2141  pub); \
2142  })
2143 
2164  uint32_t purpose,
2165  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2166  const struct GNUNET_CRYPTO_Edx25519Signature *sig,
2167  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
2168 
2169 
2184 #define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
2185  /* check size is set correctly */ \
2186  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2187  /* check 'ps' begins with the purpose */ \
2188  GNUNET_static_assert (((void*) (ps)) == \
2189  ((void*) &(ps)->purpose)); \
2190  GNUNET_CRYPTO_edx25519_verify_ (purp, \
2191  &(ps)->purpose, \
2192  sig, \
2193  pub); \
2194  })
2195 
2211  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2212  const char *label,
2213  const char *context);
2214 
2215 
2227 void
2229  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2230  const char *label,
2231  const char *context,
2233 
2248  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
2249  const char *label,
2250  const char *context,
2251  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2252  struct GNUNET_CRYPTO_EcdsaSignature *sig);
2253 
2254 
2271 void
2273  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2274  const char *label,
2275  const char *context,
2277 
2278 
2290 void
2292  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2293  const char *label,
2294  const char *context,
2296 
2297 
2313  const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
2314  const char *label,
2315  const char *context,
2316  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2317  struct GNUNET_CRYPTO_EddsaSignature *sig);
2318 
2319 
2326 void
2328  const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
2330 
2343 void
2345  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2346  const void *seed,
2347  size_t seedsize,
2349 
2350 
2361 void
2363  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub,
2364  const void *seed,
2365  size_t seedsize,
2367 
2368 
2377 void
2379  size_t size,
2380  gcry_mpi_t val);
2381 
2382 
2392 void
2394  const void *data,
2395  size_t size);
2396 
2397 
2404 void
2406  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2407  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
2408 
2409 
2421 int
2423  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2424  const gcry_mpi_t m,
2425  int desired_ops,
2427 
2428 
2437 void
2439  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
2440  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2442  gcry_mpi_t m);
2443 
2444 
2459 int
2461  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2462  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2463  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2465 
2466 
2473 int
2475  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2476 
2477 
2478 /* ********* Chaum-style RSA-based blind signatures ******************* */
2479 
2480 
2485 
2490 
2495 {
2501 };
2502 
2507 
2508 
2517 
2518 
2524 void
2526 
2527 
2536 size_t
2538  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2539  void **buffer);
2540 
2541 
2552  size_t buf_size);
2553 
2554 
2563  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2564 
2565 
2574  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2575 
2576 
2583 void
2585  struct GNUNET_HashCode *hc);
2586 
2587 
2593 bool
2595  const struct GNUNET_CRYPTO_RsaPublicKey *key);
2596 
2603 unsigned int
2605 
2606 
2612 void
2614 
2615 
2624 size_t
2626  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2627  void **buffer);
2628 
2629 
2640  size_t len);
2641 
2642 
2651 
2652 
2660 int
2662  const struct GNUNET_CRYPTO_RsaSignature *s2);
2663 
2671 int
2673  const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
2674  const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2675 
2676 
2684 int
2686  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2687 
2688 
2699 int
2700 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2701  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2703  void **buf,
2704  size_t *buf_size);
2705 
2706 
2717  const void *msg,
2718  size_t msg_len);
2719 
2720 
2730  const struct GNUNET_HashCode *hash);
2731 
2732 
2738 void
2740 
2741 
2749 size_t
2751  const struct GNUNET_CRYPTO_RsaSignature *sig,
2752  void **buffer);
2753 
2754 
2765  size_t buf_size);
2766 
2767 
2776 
2777 
2790  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2792 
2793 
2804 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2805  const struct GNUNET_CRYPTO_RsaSignature *sig,
2806  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2807 
2808 
2814 void
2816 
2817 
2824 void
2826  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2827  struct GNUNET_CRYPTO_CsPublicKey *pub);
2828 
2829 
2843 void
2845  const char *seed,
2846  const struct GNUNET_CRYPTO_CsPrivateKey *lts,
2847  struct GNUNET_CRYPTO_CsRSecret r[2]);
2848 
2849 
2856 void
2858  struct GNUNET_CRYPTO_CsRPublic *r_pub);
2859 
2870 void
2872  const struct GNUNET_CRYPTO_CsNonce *blind_seed,
2873  struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
2874 
2875 
2888 void
2890  const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
2891  const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
2892  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2893  const void *msg,
2894  size_t msg_len,
2895  struct GNUNET_CRYPTO_CsC blinded_c[2],
2896  struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]);
2897 
2898 
2915 unsigned int
2917  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2918  const struct GNUNET_CRYPTO_CsRSecret r[2],
2919  const struct GNUNET_CRYPTO_CsC c[2],
2920  const struct GNUNET_CRYPTO_CsNonce *nonce,
2921  struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar);
2922 
2923 
2931 void
2933  const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
2934  const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
2935  struct GNUNET_CRYPTO_CsS *signature_scalar);
2936 
2937 
2950  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2951  const void *msg,
2952  size_t msg_len);
2953 
2954 
2955 #if 0 /* keep Emacsens' auto-indent happy */
2956 {
2957 #endif
2958 #ifdef __cplusplus
2959 }
2960 #endif
2961 
2962 
2963 /* ifndef GNUNET_CRYPTO_LIB_H */
2964 #endif
2965  /* end of group addition */
2967 
2968 /* 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...
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:726
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)
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.
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:761
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 (!).
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:739
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:796
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:779
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:91
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c: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:619
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:643
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:702
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c: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:99
void GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, const void *plaintext, size_t plaintext_len, struct GNUNET_HashCode *hmac)
Calculate HMAC of a message (RFC 2104)
Definition: crypto_hash.c: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:151
int GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2, const struct GNUNET_HashCode *target)
Find out which of the two GNUNET_CRYPTO_hash codes is closer to target in the XOR metric (Kademlia).
Definition: crypto_hash.c: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:133
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
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
#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:598
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:123
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: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: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
GNUNET_SCHEDULER_Priority
Valid task priorities.
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
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
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 c1 and c2.
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.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
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.
#define GNUNET_PACKED
gcc-ism to get packed structs.
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
#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.