GNUnet  0.19.4
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 #if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
48 #error "Only <gnunet_util_lib.h> can be included directly."
49 #endif
50 
51 #ifndef GNUNET_CRYPTO_LIB_H
52 #define GNUNET_CRYPTO_LIB_H
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #if 0 /* keep Emacsens' auto-indent happy */
57 }
58 #endif
59 #endif
60 
61 
62 #include <stdbool.h>
63 #include <sodium.h>
64 
68 struct GNUNET_PeerIdentity;
69 
70 #include <gcrypt.h>
71 
72 
77 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
78 
79 
85 {
92 
98 
104 };
105 
106 
110 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
111 
115 #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
116 
121 #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
122 
127 {
128  unsigned char encoding[104];
129 };
130 
131 
133 
134 
141 {
147  uint32_t size GNUNET_PACKED;
148 
156 };
157 
158 
164 {
168  unsigned char r[256 / 8];
169 
173  unsigned char s[256 / 8];
174 };
175 
176 
181 {
185  unsigned char r[256 / 8];
186 
190  unsigned char s[256 / 8];
191 };
192 
193 
201 {
207  unsigned char q_y[256 / 8];
208 };
209 
210 
216 {
221  unsigned char q_y[256 / 8];
222 };
223 
224 
229 {
231 };
232 
233 
240 {
245  unsigned char q_y[256 / 8];
246 };
247 
248 
254 {
258  unsigned char d[256 / 8];
259 };
260 
266 {
270  unsigned char d[256 / 8];
271 };
272 
278 {
282  unsigned char d[256 / 8];
283 };
284 
285 
291 {
295  unsigned char s[512 / 8];
296 };
297 
304 {
309  unsigned char a[256 / 8];
310 
315  unsigned char b[256 / 8];
316 };
317 
318 
326 {
332  unsigned char q_y[256 / 8];
333 };
334 
339 {
343  unsigned char r[256 / 8];
344 
348  unsigned char s[256 / 8];
349 };
350 
351 
356 {
361 
366 };
367 
372 {
377 };
378 
380 
388 {
390 
392 };
393 
394 
399 {
401 };
402 
403 
408 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
409 
410 
415 {
419  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
420 };
421 
422 
427 {
435  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
436 };
437 
438 
443 {
449 
453  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
454 };
455 
456 
461 {
465  unsigned char d[crypto_core_ed25519_SCALARBYTES];
466 };
467 
468 
473 {
478  unsigned char y[crypto_core_ed25519_BYTES];
479 };
480 
481 
486 {
488 };
489 
490 
495 {
497 };
498 
499 
504 {
507 };
508 
509 
514 {
516 };
517 
518 
523 {
525 };
526 
527 
532 {
534 };
535 
536 
541 {
543 };
544 
545 
550 {
552 };
553 
554 
559 {
565 };
566 
567 
572 {
573  /*a nonce*/
574  unsigned char nonce[256 / 8];
575 };
576 
577 
578 /* **************** Functions and Macros ************* */
579 
587 void
588 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
589 
590 
599 uint8_t
600 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
601 
602 
611 uint32_t
612 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
613 
614 
621 uint16_t
623 
624 
633 uint16_t
634 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
635 
636 
646 int32_t
647 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
648 
657 void
658 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
659 
660 
669 void
671  void *buffer,
672  size_t length);
673 
674 
685 void
687  struct GNUNET_Uuid *uuid);
688 
689 
698 uint32_t
700 
701 
710 uint64_t
712 
713 
723 unsigned int *
725 
726 
733 void
736 
737 
749 ssize_t
751  const void *block,
752  size_t size,
753  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
755  void *result);
756 
757 
769 ssize_t
771  const void *block,
772  size_t size,
773  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
775  void *result);
776 
777 
787 void
790  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
791  const void *salt,
792  size_t salt_len,
793  ...);
794 
795 
804 void
807  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
808  const void *salt,
809  size_t salt_len,
810  va_list argp);
811 
812 
820 void
821 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
823 
824 
836  size_t enclen,
837  struct GNUNET_HashCode *result);
838 
839 
848 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
849  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
850 
851 
864 uint32_t
866  const struct GNUNET_HashCode *b);
867 
868 
877 void
878 GNUNET_CRYPTO_hash (const void *block,
879  size_t size,
880  struct GNUNET_HashCode *ret);
881 
882 
887 {
888  char salt[crypto_pwhash_argon2id_SALTBYTES];
889 };
890 
891 
900 void
902  const void *buf,
903  size_t buf_len,
904  struct GNUNET_HashCode *result);
905 
906 
910 struct GNUNET_HashContext;
911 
912 
918 struct GNUNET_HashContext *
920 
921 
928 struct GNUNET_HashContext *
930 
931 
939 void
941  const void *buf,
942  size_t size);
943 
944 
951 void
953  struct GNUNET_HashCode *r_hash);
954 
955 
961 void
963 
964 
976 void
977 GNUNET_CRYPTO_hmac_raw (const void *key,
978  size_t key_len,
979  const void *plaintext,
980  size_t plaintext_len,
981  struct GNUNET_HashCode *hmac);
982 
983 
993 void
995  const void *plaintext,
996  size_t plaintext_len,
997  struct GNUNET_HashCode *hmac);
998 
999 
1007 typedef void
1009  void *cls,
1010  const struct GNUNET_HashCode *res);
1011 
1012 
1017 
1018 
1032  const char *filename,
1033  size_t blocksize,
1035  void *callback_cls);
1036 
1037 
1043 void
1045 
1046 
1054 void
1056  struct GNUNET_HashCode *result);
1057 
1058 
1067 void
1069  const struct GNUNET_HashCode *b,
1070  struct GNUNET_HashCode *result);
1071 
1072 
1081 void
1082 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
1083  const struct GNUNET_HashCode *delta,
1084  struct GNUNET_HashCode *result);
1085 
1086 
1095 void
1096 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
1097  const struct GNUNET_HashCode *b,
1098  struct GNUNET_HashCode *result);
1099 
1100 
1107 unsigned int
1109 
1110 
1117 unsigned int
1119 
1120 
1129 void
1131  const struct GNUNET_HashCode *hc,
1132  struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
1134 
1135 
1145 int
1146 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
1147  const struct GNUNET_HashCode *h2);
1148 
1149 
1160 int
1161 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
1162  const struct GNUNET_HashCode *h2,
1163  const struct GNUNET_HashCode *target);
1164 
1165 
1175 void
1177  struct GNUNET_CRYPTO_AuthKey *key,
1178  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1179  const void *salt,
1180  size_t salt_len,
1181  va_list argp);
1182 
1183 
1193 void
1195  struct GNUNET_CRYPTO_AuthKey *key,
1196  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1197  const void *salt,
1198  size_t salt_len,
1199  ...);
1200 
1201 
1217 GNUNET_CRYPTO_hkdf (void *result,
1218  size_t out_len,
1219  int xtr_algo,
1220  int prf_algo,
1221  const void *xts,
1222  size_t xts_len,
1223  const void *skm,
1224  size_t skm_len,
1225  ...);
1226 
1227 
1244  size_t out_len,
1245  int xtr_algo,
1246  int prf_algo,
1247  const void *xts,
1248  size_t xts_len,
1249  const void *skm,
1250  size_t skm_len,
1251  va_list argp);
1252 
1253 
1267  size_t out_len,
1268  const void *xts,
1269  size_t xts_len,
1270  const void *skm,
1271  size_t skm_len,
1272  va_list argp);
1273 
1274 
1287 void
1288 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1289  gcry_mpi_t n,
1290  const void *xts,
1291  size_t xts_len,
1292  const void *skm,
1293  size_t skm_len,
1294  const char *ctx);
1295 
1296 
1310 GNUNET_CRYPTO_kdf (void *result,
1311  size_t out_len,
1312  const void *xts,
1313  size_t xts_len,
1314  const void *skm,
1315  size_t skm_len,
1316  ...);
1317 
1318 
1326 void
1328  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1330 
1338 void
1340  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1342 
1350 void
1352  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
1354 
1362 void
1364  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1366 
1367 
1374 char *
1376  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1377 
1384 char *
1386  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1387 
1388 
1395 char *
1397  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1398 
1399 
1406 char *
1408  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1409 
1410 
1421  const char *enc,
1422  size_t enclen,
1424 
1425 
1436  const char *enc,
1437  size_t enclen,
1438  struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1439 
1440 
1451  const char *enc,
1452  size_t enclen,
1454 
1455 
1473  int do_create,
1475 
1476 
1494  int do_create,
1496 
1497 
1502 
1503 
1515  const struct GNUNET_CONFIGURATION_Handle *cfg);
1516 
1517 
1524 void
1526 
1527 
1534 void
1536 
1537 
1544 void
1546 
1556 void
1558  const void *seed,
1559  size_t seedsize,
1561 
1568 void
1570 
1571 
1578 void
1580 
1581 
1588 void
1590 
1597 void
1599 
1606 void
1608 
1609 
1616 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1618 
1619 
1629 void
1630 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1631 
1632 
1644  struct GNUNET_PeerIdentity *dst);
1645 
1646 
1651 
1652 
1658 {
1663  unsigned char v[256 / 8];
1664 };
1665 
1670 {
1671  unsigned char v[256 / 8];
1672 };
1673 
1682 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1683  unsigned int mem);
1684 
1685 
1694 int
1696  const struct GNUNET_CRYPTO_EccPoint *input);
1697 
1698 
1710 void
1711 GNUNET_CRYPTO_ecc_dexp (int val,
1712  struct GNUNET_CRYPTO_EccPoint*r);
1713 
1714 
1725  struct GNUNET_CRYPTO_EccPoint *r);
1726 
1727 
1738  const struct GNUNET_CRYPTO_EccScalar *val,
1739  struct GNUNET_CRYPTO_EccPoint *r);
1740 
1741 
1752  const struct GNUNET_CRYPTO_EccPoint *b,
1753  struct GNUNET_CRYPTO_EccPoint *r);
1754 
1755 
1766  struct GNUNET_CRYPTO_EccPoint *r_inv);
1767 
1768 
1776 void
1778  struct GNUNET_CRYPTO_EccScalar *r_neg);
1779 
1780 
1786 void
1788 
1789 
1795 void
1797 
1798 
1805 void
1807  struct GNUNET_CRYPTO_EccScalar *r);
1808 
1809 
1821  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1822  struct GNUNET_HashCode *key_material);
1823 
1824 
1837  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1838  struct GNUNET_HashCode *key_material);
1839 
1840 
1853  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1854  struct GNUNET_HashCode *key_material);
1855 
1856 
1869  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1870  struct GNUNET_HashCode *key_material);
1871 
1884  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1885  struct GNUNET_HashCode *key_material);
1886 
1887 
1905  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1906  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1907  struct GNUNET_CRYPTO_EddsaSignature *sig);
1908 
1909 
1922 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1923  /* check size is set correctly */ \
1924  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1925  /* check 'ps' begins with the purpose */ \
1926  GNUNET_static_assert (((void*) (ps)) == \
1927  ((void*) &(ps)->purpose)); \
1928  GNUNET_assert (GNUNET_OK == \
1929  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1930  &(ps)->purpose, \
1931  sig)); \
1932 } while (0)
1933 
1934 
1952  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1953  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1954  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1955 
1967  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1968  void *data,
1969  size_t size,
1970  struct GNUNET_CRYPTO_EddsaSignature *sig);
1971 
1984 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1985  /* check size is set correctly */ \
1986  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1987  /* check 'ps' begins with the purpose */ \
1988  GNUNET_static_assert (((void*) (ps)) == \
1989  ((void*) &(ps)->purpose)); \
1990  GNUNET_assert (GNUNET_OK == \
1991  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1992  &(ps)->purpose, \
1993  sig)); \
1994 } while (0)
1995 
2013  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2014  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2015  struct GNUNET_CRYPTO_Edx25519Signature *sig);
2016 
2017 
2031 #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do { \
2032  /* check size is set correctly */ \
2033  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2034  /* check 'ps' begins with the purpose */ \
2035  GNUNET_static_assert (((void*) (ps)) == \
2036  ((void*) &(ps)->purpose)); \
2037  GNUNET_assert (GNUNET_OK == \
2038  GNUNET_CRYPTO_edx25519_sign_ (priv, \
2039  &(ps)->purpose, \
2040  sig)); \
2041 } while (0)
2042 
2043 
2064  uint32_t purpose,
2065  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2066  const struct GNUNET_CRYPTO_EddsaSignature *sig,
2067  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
2068 
2069 
2084 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
2085  /* check size is set correctly */ \
2086  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2087  /* check 'ps' begins with the purpose */ \
2088  GNUNET_static_assert (((void*) (ps)) == \
2089  ((void*) &(ps)->purpose)); \
2090  GNUNET_CRYPTO_eddsa_verify_ (purp, \
2091  &(ps)->purpose, \
2092  sig, \
2093  pub); \
2094  })
2095 
2116  uint32_t purpose,
2117  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2118  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
2119  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
2120 
2121 
2136 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
2137  /* check size is set correctly */ \
2138  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2139  /* check 'ps' begins with the purpose */ \
2140  GNUNET_static_assert (((void*) (ps)) == \
2141  ((void*) &(ps)->purpose)); \
2142  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
2143  &(ps)->purpose, \
2144  sig, \
2145  pub); \
2146  })
2147 
2168  uint32_t purpose,
2169  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
2170  const struct GNUNET_CRYPTO_Edx25519Signature *sig,
2171  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub);
2172 
2173 
2188 #define GNUNET_CRYPTO_edx25519_verify(purp,ps,sig,pub) ({ \
2189  /* check size is set correctly */ \
2190  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
2191  /* check 'ps' begins with the purpose */ \
2192  GNUNET_static_assert (((void*) (ps)) == \
2193  ((void*) &(ps)->purpose)); \
2194  GNUNET_CRYPTO_edx25519_verify_ (purp, \
2195  &(ps)->purpose, \
2196  sig, \
2197  pub); \
2198  })
2199 
2215  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
2216  const char *label,
2217  const char *context);
2218 
2219 
2231 void
2233  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
2234  const char *label,
2235  const char *context,
2237 
2252  const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
2253  const char *label,
2254  const char *context,
2255  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2256  struct GNUNET_CRYPTO_EcdsaSignature *sig);
2257 
2258 
2275 void
2277  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
2278  const char *label,
2279  const char *context,
2281 
2282 
2294 void
2296  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
2297  const char *label,
2298  const char *context,
2300 
2301 
2317  const struct GNUNET_CRYPTO_EddsaPrivateKey *pkey,
2318  const char *label,
2319  const char *context,
2320  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
2321  struct GNUNET_CRYPTO_EddsaSignature *sig);
2322 
2323 
2330 void
2332  const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
2334 
2347 void
2349  const struct GNUNET_CRYPTO_Edx25519PrivateKey *priv,
2350  const void *seed,
2351  size_t seedsize,
2353 
2354 
2365 void
2367  const struct GNUNET_CRYPTO_Edx25519PublicKey *pub,
2368  const void *seed,
2369  size_t seedsize,
2371 
2372 
2381 void
2383  size_t size,
2384  gcry_mpi_t val);
2385 
2386 
2396 void
2398  const void *data,
2399  size_t size);
2400 
2401 
2408 void
2410  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2411  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
2412 
2413 
2425 int
2427  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2428  const gcry_mpi_t m,
2429  int desired_ops,
2431 
2432 
2441 void
2443  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
2444  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2446  gcry_mpi_t m);
2447 
2448 
2463 int
2465  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2466  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2467  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2469 
2470 
2477 int
2479  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2480 
2481 
2482 /* ********* Chaum-style RSA-based blind signatures ******************* */
2483 
2484 
2489 
2494 
2499 {
2505 };
2506 
2511 
2512 
2521 
2522 
2528 void
2530 
2531 
2540 size_t
2542  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2543  void **buffer);
2544 
2545 
2556  size_t buf_size);
2557 
2558 
2567  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2568 
2569 
2578  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2579 
2580 
2587 void
2589  struct GNUNET_HashCode *hc);
2590 
2591 
2597 bool
2599  const struct GNUNET_CRYPTO_RsaPublicKey *key);
2600 
2607 unsigned int
2609 
2610 
2616 void
2618 
2619 
2628 size_t
2630  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2631  void **buffer);
2632 
2633 
2644  size_t len);
2645 
2646 
2655 
2656 
2664 int
2666  const struct GNUNET_CRYPTO_RsaSignature *s2);
2667 
2675 int
2677  const struct GNUNET_CRYPTO_RsaPrivateKey *p1,
2678  const struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2679 
2680 
2688 int
2690  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2691 
2692 
2703 int
2704 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2705  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2707  void **buf,
2708  size_t *buf_size);
2709 
2710 
2721  const void *msg,
2722  size_t msg_len);
2723 
2724 
2734  const struct GNUNET_HashCode *hash);
2735 
2736 
2742 void
2744 
2745 
2753 size_t
2755  const struct GNUNET_CRYPTO_RsaSignature *sig,
2756  void **buffer);
2757 
2758 
2769  size_t buf_size);
2770 
2771 
2780 
2781 
2794  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2796 
2797 
2808 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2809  const struct GNUNET_CRYPTO_RsaSignature *sig,
2810  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2811 
2812 
2818 void
2820 
2821 
2828 void
2830  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2831  struct GNUNET_CRYPTO_CsPublicKey *pub);
2832 
2833 
2847 void
2849  const char *seed,
2850  const struct GNUNET_CRYPTO_CsPrivateKey *lts,
2851  struct GNUNET_CRYPTO_CsRSecret r[2]);
2852 
2853 
2860 void
2862  struct GNUNET_CRYPTO_CsRPublic *r_pub);
2863 
2874 void
2876  const struct GNUNET_CRYPTO_CsNonce *blind_seed,
2877  struct GNUNET_CRYPTO_CsBlindingSecret bs[2]);
2878 
2879 
2892 void
2894  const struct GNUNET_CRYPTO_CsBlindingSecret bs[2],
2895  const struct GNUNET_CRYPTO_CsRPublic r_pub[2],
2896  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2897  const void *msg,
2898  size_t msg_len,
2899  struct GNUNET_CRYPTO_CsC blinded_c[2],
2900  struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]);
2901 
2902 
2919 unsigned int
2921  const struct GNUNET_CRYPTO_CsPrivateKey *priv,
2922  const struct GNUNET_CRYPTO_CsRSecret r[2],
2923  const struct GNUNET_CRYPTO_CsC c[2],
2924  const struct GNUNET_CRYPTO_CsNonce *nonce,
2925  struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar);
2926 
2927 
2935 void
2937  const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar,
2938  const struct GNUNET_CRYPTO_CsBlindingSecret *bs,
2939  struct GNUNET_CRYPTO_CsS *signature_scalar);
2940 
2941 
2954  const struct GNUNET_CRYPTO_CsPublicKey *pub,
2955  const void *msg,
2956  size_t msg_len);
2957 
2958 
2959 #if 0 /* keep Emacsens' auto-indent happy */
2960 {
2961 #endif
2962 #ifdef __cplusplus
2963 }
2964 #endif
2965 
2966 
2967 /* ifndef GNUNET_CRYPTO_LIB_H */
2968 #endif
2969  /* end of group addition */
2971 
2972 /* 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:47
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:38
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
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:329
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:166
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:341
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:70
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:1075
#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:132
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_raw(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, void *data, size_t size, struct GNUNET_CRYPTO_EddsaSignature *sig)
Definition: crypto_ecc.c: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:1039
#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:991
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:349
void GNUNET_CRYPTO_cs_r_get_public(const struct GNUNET_CRYPTO_CsRSecret *r_priv, struct GNUNET_CRYPTO_CsRPublic *r_pub)
Extract the public R of the given secret r.
Definition: crypto_cs.c:97
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:173
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:95
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:1175
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:106
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:365
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_decode(const void *buf, size_t buf_size)
Decode the private key from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:204
void GNUNET_CRYPTO_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:1094
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:602
void GNUNET_CRYPTO_cs_private_key_get_public(const struct GNUNET_CRYPTO_CsPrivateKey *priv, struct GNUNET_CRYPTO_CsPublicKey *pub)
Extract the public key of the given private key.
Definition: crypto_cs.c:52
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:300
int GNUNET_CRYPTO_paillier_encrypt(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const gcry_mpi_t m, int desired_ops, struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext)
Encrypt a plaintext with a paillier public key.
bool GNUNET_CRYPTO_rsa_public_key_check(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Check if key is well-formed.
Definition: crypto_rsa.c:301
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
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:78
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:38
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:680
void GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc)
Compute hash over the public key.
Definition: crypto_rsa.c:407
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
Definition: crypto_hash.c:407
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:42
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:268
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:423
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
Definition: crypto_hash.c:376
void GNUNET_CRYPTO_mpi_print_unsigned(void *buf, size_t size, gcry_mpi_t val)
Output the given MPI value to the given buffer in network byte order.
Definition: crypto_mpi.c:79
GNUNET_SCHEDULER_Priority
Valid task priorities.
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:231
#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:325
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
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:261
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
Extract the public key of the given private scalar.
int GNUNET_CRYPTO_rsa_private_key_cmp(const struct GNUNET_CRYPTO_RsaPrivateKey *p1, const struct GNUNET_CRYPTO_RsaPrivateKey *p2)
Compare the values of two private keys.
Definition: crypto_rsa.c:654
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:389
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:999
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:1241
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:971
int GNUNET_CRYPTO_paillier_hom_add(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *c1, const struct GNUNET_CRYPTO_PaillierCiphertext *c2, struct GNUNET_CRYPTO_PaillierCiphertext *result)
Compute a ciphertext that represents the sum of the plaintext in c1 and c2.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_private_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a string representing a private key to a private key.
Definition: crypto_ecc.c:382
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:312
int GNUNET_CRYPTO_rsa_public_key_cmp(const struct GNUNET_CRYPTO_RsaPublicKey *p1, const struct GNUNET_CRYPTO_RsaPublicKey *p2)
Compare the values of two public keys.
Definition: crypto_rsa.c:628
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_private_key_get_public(const struct GNUNET_CRYPTO_RsaPrivateKey *priv)
Extract the public key of the given private key.
Definition: crypto_rsa.c:233
void GNUNET_CRYPTO_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.
void GNUNET_CRYPTO_cs_private_key_generate(struct GNUNET_CRYPTO_CsPrivateKey *priv)
Create a new random private key.
Definition: crypto_cs.c:45
void GNUNET_CRYPTO_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:181
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition: crypto_rsa.c:144
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:1221
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:947
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:790
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:68
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
type for (message) authentication keys
unsigned char key[(512/8)]
Type of 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:41
The public information of an RSA key pair.
Definition: crypto_rsa.c:53
an RSA signature
Definition: crypto_rsa.c:65
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.