GNUnet  0.11.x
gnunet_crypto_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
43 #ifndef GNUNET_CRYPTO_LIB_H
44 #define GNUNET_CRYPTO_LIB_H
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #if 0 /* keep Emacsens' auto-indent happy */
49 }
50 #endif
51 #endif
52 
53 #include <sodium.h>
54 
58 struct GNUNET_PeerIdentity;
59 
60 #include "gnunet_common.h"
61 #include <gcrypt.h>
62 
63 
68 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
69 
70 
76 {
83 
89 
95 };
96 
97 
101 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
102 
106 #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
107 
112 #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
113 
118 {
119  unsigned char encoding[104];
120 };
121 
122 
124 
125 
132 {
138  uint32_t size GNUNET_PACKED;
139 
146  uint32_t purpose GNUNET_PACKED;
147 };
148 
149 
155 {
159  unsigned char r[256 / 8];
160 
164  unsigned char s[256 / 8];
165 };
166 
167 
172 {
176  unsigned char r[256 / 8];
177 
181  unsigned char s[256 / 8];
182 };
183 
184 
192 {
198  unsigned char q_y[256 / 8];
199 };
200 
201 
207 {
212  unsigned char q_y[256 / 8];
213 };
214 
215 
220 {
221  struct GNUNET_CRYPTO_EddsaPublicKey public_key;
222 };
223 
224 
231 {
236  unsigned char q_y[256 / 8];
237 };
238 
239 
245 {
249  unsigned char d[256 / 8];
250 };
251 
257 {
261  unsigned char d[256 / 8];
262 };
263 
269 {
273  unsigned char d[256 / 8];
274 };
275 
276 
282 {
286  unsigned char s[512 / 8];
287 };
288 
289 
294 {
298  unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
299 
303  unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
304 };
305 
310 {
315 };
316 
318 
326 {
327  unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
328 
329  unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
330 };
331 
332 
337 {
339 };
340 
341 
346 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
347 
348 
353 {
357  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
358 };
359 
360 
365 {
369  unsigned char lambda[GNUNET_CRYPTO_PAILLIER_BITS / 8];
373  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
374 };
375 
376 
381 {
386  int32_t remaining_ops GNUNET_PACKED;
387 
391  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
392 };
393 
394 
395 /* **************** Functions and Macros ************* */
396 
404 void
405 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
406 
407 
416 uint8_t
417 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
418 
419 
428 uint32_t
429 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
430 
431 
438 uint16_t
440 
441 
450 uint16_t
451 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
452 
453 
463 int32_t
464 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
465 
474 void
475 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
476 
477 
486 void
488  void *buffer,
489  size_t length);
490 
491 
502 void
504  struct GNUNET_Uuid *uuid);
505 
506 
515 uint32_t
517 
518 
527 uint64_t
529 
530 
540 unsigned int *
542 
543 
550 void
553 
554 
566 ssize_t
568  const void *block,
569  size_t size,
570  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
572  void *result);
573 
574 
586 ssize_t
588  const void *block,
589  size_t size,
590  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
592  void *result);
593 
594 
604 void
607  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
608  const void *salt,
609  size_t salt_len,
610  ...);
611 
612 
621 void
624  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
625  const void *salt,
626  size_t salt_len,
627  va_list argp);
628 
629 
637 void
638 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
640 
641 
653  size_t enclen,
654  struct GNUNET_HashCode *result);
655 
656 
665 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
666  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
667 
668 
681 uint32_t
683  const struct GNUNET_HashCode *b);
684 
685 
694 void
695 GNUNET_CRYPTO_hash (const void *block,
696  size_t size,
697  struct GNUNET_HashCode *ret);
698 
699 
704 {
705  char salt[crypto_pwhash_argon2id_SALTBYTES];
706 };
707 
708 
717 void
719  const void *buf,
720  size_t buf_len,
721  struct GNUNET_HashCode *result);
722 
723 
727 struct GNUNET_HashContext;
728 
729 
735 struct GNUNET_HashContext *
737 
738 
745 struct GNUNET_HashContext *
747 
748 
756 void
758  const void *buf,
759  size_t size);
760 
761 
768 void
770  struct GNUNET_HashCode *r_hash);
771 
772 
778 void
780 
781 
793 void
794 GNUNET_CRYPTO_hmac_raw (const void *key,
795  size_t key_len,
796  const void *plaintext,
797  size_t plaintext_len,
798  struct GNUNET_HashCode *hmac);
799 
800 
810 void
812  const void *plaintext,
813  size_t plaintext_len,
814  struct GNUNET_HashCode *hmac);
815 
816 
825  void *cls,
826  const struct GNUNET_HashCode *res);
827 
828 
833 
834 
848  const char *filename,
849  size_t blocksize,
851  void *callback_cls);
852 
853 
859 void
861 
862 
870 void
872  struct GNUNET_HashCode *result);
873 
874 
883 void
885  const struct GNUNET_HashCode *b,
886  struct GNUNET_HashCode *result);
887 
888 
897 void
898 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
899  const struct GNUNET_HashCode *delta,
900  struct GNUNET_HashCode *result);
901 
902 
911 void
912 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
913  const struct GNUNET_HashCode *b,
914  struct GNUNET_HashCode *result);
915 
916 
925 void
927  const struct GNUNET_HashCode *hc,
930 
931 
941 int
943  unsigned int bit);
944 
945 
953 int
955  unsigned int bit);
956 
957 
970 unsigned int
972  const struct GNUNET_HashCode *second);
973 
974 
984 int
985 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
986  const struct GNUNET_HashCode *h2);
987 
988 
999 int
1000 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
1001  const struct GNUNET_HashCode *h2,
1002  const struct GNUNET_HashCode *target);
1003 
1004 
1014 void
1016  struct GNUNET_CRYPTO_AuthKey *key,
1017  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1018  const void *salt,
1019  size_t salt_len,
1020  va_list argp);
1021 
1022 
1032 void
1034  struct GNUNET_CRYPTO_AuthKey *key,
1035  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1036  const void *salt,
1037  size_t salt_len,
1038  ...);
1039 
1040 
1056 GNUNET_CRYPTO_hkdf (void *result,
1057  size_t out_len,
1058  int xtr_algo,
1059  int prf_algo,
1060  const void *xts,
1061  size_t xts_len,
1062  const void *skm,
1063  size_t skm_len,
1064  ...);
1065 
1066 
1083  size_t out_len,
1084  int xtr_algo,
1085  int prf_algo,
1086  const void *xts,
1087  size_t xts_len,
1088  const void *skm,
1089  size_t skm_len,
1090  va_list argp);
1091 
1092 
1106  size_t out_len,
1107  const void *xts,
1108  size_t xts_len,
1109  const void *skm,
1110  size_t skm_len,
1111  va_list argp);
1112 
1113 
1126 void
1127 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1128  gcry_mpi_t n,
1129  const void *xts,
1130  size_t xts_len,
1131  const void *skm,
1132  size_t skm_len,
1133  const char *ctx);
1134 
1135 
1149 GNUNET_CRYPTO_kdf (void *result,
1150  size_t out_len,
1151  const void *xts,
1152  size_t xts_len,
1153  const void *skm,
1154  size_t skm_len,
1155  ...);
1156 
1157 
1165 void
1167  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1169 
1177 void
1179  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1181 
1182 
1190 void
1192  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1194 
1195 
1202 char *
1204  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1205 
1212 char *
1214  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1215 
1216 
1223 char *
1225  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1226 
1227 
1234 char *
1236  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1237 
1238 
1249  const char *enc,
1250  size_t enclen,
1252 
1253 
1262 int
1264  const char *enc,
1265  size_t enclen,
1267 
1268 
1279  const char *enc,
1280  size_t enclen,
1282 
1283 
1301  int do_create,
1303 
1304 
1320 int
1322  int do_create,
1324 
1325 
1330 
1331 
1343  const struct GNUNET_CONFIGURATION_Handle *cfg);
1344 
1345 
1352 void
1354 
1355 
1362 void
1364 
1365 
1372 void
1374 
1375 
1382 void
1384 
1385 
1392 void
1394 
1395 
1402 void
1404 
1405 
1412 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1414 
1415 
1425 void
1426 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1427 
1428 
1438 int
1440  struct GNUNET_PeerIdentity *dst);
1441 
1442 
1447 
1448 
1454 {
1459  unsigned char v[256 / 8];
1460 };
1461 
1466 {
1467  unsigned char v[256 / 8];
1468 };
1469 
1478 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1479  unsigned int mem);
1480 
1481 
1490 int
1492  const struct GNUNET_CRYPTO_EccPoint *input);
1493 
1494 
1506 void
1507 GNUNET_CRYPTO_ecc_dexp (int val,
1508  struct GNUNET_CRYPTO_EccPoint*r);
1509 
1510 
1521  struct GNUNET_CRYPTO_EccPoint *r);
1522 
1523 
1534  const struct GNUNET_CRYPTO_EccScalar *val,
1535  struct GNUNET_CRYPTO_EccPoint *r);
1536 
1537 
1548  const struct GNUNET_CRYPTO_EccPoint *b,
1549  struct GNUNET_CRYPTO_EccPoint *r);
1550 
1551 
1562  struct GNUNET_CRYPTO_EccPoint *r_inv);
1563 
1564 
1572 void
1574  struct GNUNET_CRYPTO_EccScalar *r_neg);
1575 
1576 
1582 void
1584 
1585 
1591 void
1593 
1594 
1601 void
1603  struct GNUNET_CRYPTO_EccScalar *r);
1604 
1605 
1617  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1618  struct GNUNET_HashCode *key_material);
1619 
1620 
1633  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1634  struct GNUNET_HashCode *key_material);
1635 
1636 
1649  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1650  struct GNUNET_HashCode *key_material);
1651 
1652 
1665  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1666  struct GNUNET_HashCode *key_material);
1667 
1680  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1681  struct GNUNET_HashCode *key_material);
1682 
1683 
1701  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1702  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1703  struct GNUNET_CRYPTO_EddsaSignature *sig);
1704 
1705 
1718 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1719  /* check size is set correctly */ \
1720  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1721  /* check 'ps' begins with the purpose */ \
1722  GNUNET_static_assert (((void*) (ps)) == \
1723  ((void*) &(ps)->purpose)); \
1724  GNUNET_assert (GNUNET_OK == \
1725  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1726  &(ps)->purpose, \
1727  sig)); \
1728 } while (0)
1729 
1730 
1748  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1749  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1750  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1751 
1752 
1765 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1766  /* check size is set correctly */ \
1767  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1768  /* check 'ps' begins with the purpose */ \
1769  GNUNET_static_assert (((void*) (ps)) == \
1770  ((void*) &(ps)->purpose)); \
1771  GNUNET_assert (GNUNET_OK == \
1772  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1773  &(ps)->purpose, \
1774  sig)); \
1775 } while (0)
1776 
1777 
1796 int
1798  uint32_t purpose,
1799  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1800  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1801  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1802 
1803 
1818 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1819  /* check size is set correctly */ \
1820  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1821  /* check 'ps' begins with the purpose */ \
1822  GNUNET_static_assert (((void*) (ps)) == \
1823  ((void*) &(ps)->purpose)); \
1824  GNUNET_CRYPTO_eddsa_verify_ (purp, \
1825  &(ps)->purpose, \
1826  sig, \
1827  pub); \
1828  })
1829 
1830 
1849 int
1851  uint32_t purpose,
1852  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1853  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1854  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1855 
1856 
1871 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
1872  /* check size is set correctly */ \
1873  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1874  /* check 'ps' begins with the purpose */ \
1875  GNUNET_static_assert (((void*) (ps)) == \
1876  ((void*) &(ps)->purpose)); \
1877  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
1878  &(ps)->purpose, \
1879  sig, \
1880  pub); \
1881  })
1882 
1898  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1899  const char *label,
1900  const char *context);
1901 
1902 
1914 void
1916  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1917  const char *label,
1918  const char *context,
1920 
1921 
1938 void
1940  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1941  const char *label,
1942  const char *context,
1944 
1945 
1957 void
1959  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1960  const char *label,
1961  const char *context,
1963 
1964 
1980 void
1982  const struct GNUNET_CRYPTO_EddsaPrivateScalar *priv,
1983  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1984  struct GNUNET_CRYPTO_EddsaSignature *sig);
1985 
1986 
1993 void
1995  const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
1997 
1998 
2007 void
2009  size_t size,
2010  gcry_mpi_t val);
2011 
2012 
2022 void
2024  const void *data,
2025  size_t size);
2026 
2027 
2034 void
2036  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2037  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
2038 
2039 
2051 int
2053  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2054  const gcry_mpi_t m,
2055  int desired_ops,
2057 
2058 
2067 void
2069  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
2070  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2072  gcry_mpi_t m);
2073 
2074 
2088 int
2090  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2091  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2092  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2094 
2095 
2102 int
2104  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2105 
2106 
2107 /* ********* Chaum-style RSA-based blind signatures ******************* */
2108 
2109 
2114 
2119 
2124 {
2129  uint32_t pre_secret[8] GNUNET_PACKED;
2130 };
2131 
2136 
2137 
2146 
2147 
2153 void
2155 
2156 
2165 size_t
2167  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2168  void **buffer);
2169 
2170 
2181  size_t buf_size);
2182 
2183 
2192  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2193 
2194 
2203  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2204 
2205 
2212 void
2214  struct GNUNET_HashCode *hc);
2215 
2216 
2223 unsigned int
2225 
2226 
2232 void
2234 
2235 
2244 size_t
2246  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2247  void **buffer);
2248 
2249 
2259 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2260 
2261 
2270 
2271 
2279 int
2281  const struct GNUNET_CRYPTO_RsaSignature *s2);
2282 
2290 int
2292  const struct
2294 
2295 
2303 int
2305  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2306 
2307 
2318 int
2319 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2320  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2322  void **buf,
2323  size_t *buf_size);
2324 
2325 
2336  const void *msg,
2337  size_t msg_len);
2338 
2339 
2349  const struct GNUNET_HashCode *hash);
2350 
2351 
2357 void
2359 
2360 
2368 size_t
2370  const struct GNUNET_CRYPTO_RsaSignature *sig,
2371  void **buffer);
2372 
2373 
2384  size_t buf_size);
2385 
2386 
2395 
2396 
2409  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2411 
2412 
2423 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2424  const struct GNUNET_CRYPTO_RsaSignature *sig,
2425  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2426 
2427 
2428 #if 0 /* keep Emacsens' auto-indent happy */
2429 {
2430 #endif
2431 #ifdef __cplusplus
2432 }
2433 #endif
2434 
2435 
2436 /* ifndef GNUNET_CRYPTO_LIB_H */
2437 #endif
2438 /* end of gnunet_crypto_lib.h */
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:1029
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.
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:608
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_dexp_mpi(const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_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
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
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.
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
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:223
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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:744
#define GNUNET_CRYPTO_HASH_LENGTH
Length of a hash value.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static char * pkey
Public key of the zone to look in, in ASCII.
uint16_t GNUNET_CRYPTO_crc16_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition: crypto_crc.c:161
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
an RSA signature
Definition: crypto_rsa.c:63
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_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:127
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:945
int32_t GNUNET_CRYPTO_crc32_n(const void *buf, size_t len)
Compute the CRC32 checksum for the first len bytes of the buffer.
Definition: crypto_crc.c:106
void GNUNET_CRYPTO_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_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:421
int GNUNET_CRYPTO_hash_get_bit_rtl(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:180
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_symmetric_create_session_key(struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Create a new random session key.
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:1129
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&#39; this be the standard hmac function and the abov...
Definition: crypto_hash.c:274
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
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.
unsigned int GNUNET_CRYPTO_hash_matching_bits(const struct GNUNET_HashCode *first, const struct GNUNET_HashCode *second)
Determine how many low order bits match in two struct GNUNET_HashCodes.
Definition: crypto_hash.c:189
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
int GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:682
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_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
Private ECC scalar encoded for transmission.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:83
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:953
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:321
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
Private ECC key encoded for transmission.
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.
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
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.
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
GNUNET_SCHEDULER_Priority
Valid task priorities.
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.
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition: crypto_rsa.c:143
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:47
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:301
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:925
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition: crypto_ecc.c:775
void GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *delta, struct GNUNET_HashCode *result)
compute result = a + delta
Definition: crypto_hash.c:122
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
Definition: crypto_crc.c:144
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
uint8_t GNUNET_CRYPTO_crc8_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition: crypto_crc.c:179
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
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
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static pa_context * context
Pulseaudio context.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:599
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:993
A 256-bit hashcode.
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
#define max(x, y)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:435
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
Definition: crypto_rsa.c:1195
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hash_from_string2(const char *enc, size_t enclen, struct GNUNET_HashCode *result)
Convert ASCII encoding back to a &#39;struct GNUNET_HashCode&#39;.
Definition: crypto_hash.c:72
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.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:99
void GNUNET_CRYPTO_random_timeflake(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_Uuid *uuid)
Fill UUID with a timeflake pseudo-random value.
static char * value
Value of the record to add/remove.
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
int 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
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:758
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
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.
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
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_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
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:383
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.
Randomness for IVs etc.
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:90
an ECC signature using ECDSA
static char buf[2048]
static char * filename
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.
static int result
Global testing status.
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:634
A UUID, a 128 bit "random" value.
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
Definition: crypto_hash.c:382
void GNUNET_CRYPTO_paillier_decrypt(const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, gcry_mpi_t m)
Decrypt a paillier ciphertext with a private key.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private ECDSA key.
Definition: crypto_ecc.c:740
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:556
int GNUNET_CRYPTO_paillier_hom_add(const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, const struct GNUNET_CRYPTO_PaillierCiphertext *c1, const struct GNUNET_CRYPTO_PaillierCiphertext *c2, struct GNUNET_CRYPTO_PaillierCiphertext *result)
Compute a ciphertext that represents the sum of the plaintext in x1 and x2.
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:88
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
A 512-bit hashcode.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a public and a private ECC key.
Definition: crypto_ecc.c:705
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:1048
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:367
static int res
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:146
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
uint32_t GNUNET_CRYPTO_crc16_step(uint32_t sum, const void *buf, size_t len)
Perform an incremental step in a CRC16 (for TCP/IP) calculation.
Definition: crypto_crc.c:125
void GNUNET_CRYPTO_mpi_scan_unsigned(gcry_mpi_t *result, const void *data, size_t size)
Convert data buffer into MPI value.
Definition: crypto_mpi.c:131
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
void GNUNET_CRYPTO_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the &#39;proof-of-work&#39; hash (an expensive hash).
Definition: crypto_pow.c:41
Private ECC key encoded for transmission.
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
struct GNUNET_HashCode key
The key used in the DHT.
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
static unsigned int size
Size of the "table".
Definition: peer.c:67
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
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
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:260
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:340
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:461
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
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:144
Value for a salt for GNUNET_CRYPTO_pow_hash().
Context used when hashing a file.
Type of a nonce used for challenges.
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:1175
an ECC signature using EdDSA.
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
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:97
0-terminated ASCII encoding of a struct GNUNET_HashCode.
int GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:623
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
Private ECC key encoded for transmission.
The identity of the host (wraps the signing key of the peer).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition: crypto_ecc.c:718
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_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
#define GNUNET_PACKED
gcc-ism to get packed structs.
configuration data
Definition: configuration.c:84
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
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.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:446
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:582
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:201
A ECC scalar for use in point multiplications.
enum GNUNET_SCHEDULER_Priority priority
Priority we use.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static OpusEncoder * enc
OPUS encoder.
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:901
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
void GNUNET_CRYPTO_eddsa_sign_with_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes the secret scalar sk instead of the private seed w...
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
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
The private information of an RSA key pair.
Definition: crypto_rsa.c:39
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host&#39;s peer.
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&#39;s key from the file specified in the configuration...
int 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.
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
int GNUNET_CRYPTO_hash_get_bit_ltr(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:171
Constant-size pre-secret for blinding key generation.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:267
Internal structure used to cache pre-calculated values for DLOG calculation.
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_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:134
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:320
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
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:110
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:300
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.
#define GNUNET_CRYPTO_PAILLIER_BITS
Size of paillier plain texts and public keys.
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.
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:246
uint32_t data
The data value.
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_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition: crypto_rsa.c:172
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_copy(const struct GNUNET_HashContext *hc)
Make a copy of the hash computation.
Definition: crypto_hash.c:351
type for (message) authentication keys
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:364
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void * callback_cls
Closure for callback.
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.
High-quality operations are desired.
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.
unsigned int mem
How much memory should we use (relates to the number of entries in the map).
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...