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 
281 {
285  unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
286 
290  unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
291 };
292 
297 {
302 };
303 
305 
313 {
314  unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
315 
316  unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
317 };
318 
319 
324 {
326 };
327 
328 
333 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
334 
335 
340 {
344  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
345 };
346 
347 
352 {
356  unsigned char lambda[GNUNET_CRYPTO_PAILLIER_BITS / 8];
360  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
361 };
362 
363 
368 {
373  int32_t remaining_ops GNUNET_PACKED;
374 
378  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
379 };
380 
381 
382 /* **************** Functions and Macros ************* */
383 
391 void
392 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
393 
394 
403 uint8_t
404 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
405 
406 
415 uint32_t
416 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
417 
418 
425 uint16_t
426 GNUNET_CRYPTO_crc16_finish (uint32_t sum);
427 
428 
437 uint16_t
438 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
439 
440 
450 int32_t
451 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
452 
461 void
462 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
463 
464 
473 void
475  void *buffer,
476  size_t length);
477 
486 uint32_t
488 
489 
498 uint64_t
500 
501 
511 unsigned int *
513 
514 
521 void
524 
525 
537 ssize_t
539  const void *block,
540  size_t size,
541  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
543  void *result);
544 
545 
557 ssize_t
559  const void *block,
560  size_t size,
561  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
563  void *result);
564 
565 
575 void
578  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
579  const void *salt,
580  size_t salt_len,
581  ...);
582 
583 
592 void
595  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
596  const void *salt,
597  size_t salt_len,
598  va_list argp);
599 
600 
608 void
609 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
611 
612 
624  size_t enclen,
625  struct GNUNET_HashCode *result);
626 
627 
636 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
637  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
638 
639 
652 uint32_t
654  const struct GNUNET_HashCode *b);
655 
656 
665 void
666 GNUNET_CRYPTO_hash (const void *block,
667  size_t size,
668  struct GNUNET_HashCode *ret);
669 
670 
675 {
676  char salt[crypto_pwhash_argon2id_SALTBYTES];
677 };
678 
679 
688 void
690  const void *buf,
691  size_t buf_len,
692  struct GNUNET_HashCode *result);
693 
694 
698 struct GNUNET_HashContext;
699 
700 
706 struct GNUNET_HashContext *
708 
709 
717 void
719  const void *buf,
720  size_t size);
721 
722 
729 void
731  struct GNUNET_HashCode *r_hash);
732 
733 
739 void
741 
742 
754 void
755 GNUNET_CRYPTO_hmac_raw (const void *key,
756  size_t key_len,
757  const void *plaintext,
758  size_t plaintext_len,
759  struct GNUNET_HashCode *hmac);
760 
761 
771 void
773  const void *plaintext,
774  size_t plaintext_len,
775  struct GNUNET_HashCode *hmac);
776 
777 
786  void *cls,
787  const struct GNUNET_HashCode *res);
788 
789 
794 
795 
809  const char *filename,
810  size_t blocksize,
812  void *callback_cls);
813 
814 
820 void
822 
823 
831 void
833  struct GNUNET_HashCode *result);
834 
835 
844 void
846  const struct GNUNET_HashCode *b,
847  struct GNUNET_HashCode *result);
848 
849 
858 void
859 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
860  const struct GNUNET_HashCode *delta,
861  struct GNUNET_HashCode *result);
862 
863 
872 void
873 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
874  const struct GNUNET_HashCode *b,
875  struct GNUNET_HashCode *result);
876 
877 
886 void
888  const struct GNUNET_HashCode *hc,
891 
892 
902 int
904  unsigned int bit);
905 
906 
914 int
916  unsigned int bit);
917 
918 
931 unsigned int
933  const struct GNUNET_HashCode *second);
934 
935 
945 int
946 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
947  const struct GNUNET_HashCode *h2);
948 
949 
960 int
962  const struct GNUNET_HashCode *h2,
963  const struct GNUNET_HashCode *target);
964 
965 
975 void
977  struct GNUNET_CRYPTO_AuthKey *key,
978  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
979  const void *salt,
980  size_t salt_len,
981  va_list argp);
982 
983 
993 void
995  struct GNUNET_CRYPTO_AuthKey *key,
996  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
997  const void *salt,
998  size_t salt_len,
999  ...);
1000 
1001 
1016 int
1017 GNUNET_CRYPTO_hkdf (void *result,
1018  size_t out_len,
1019  int xtr_algo,
1020  int prf_algo,
1021  const void *xts,
1022  size_t xts_len,
1023  const void *skm,
1024  size_t skm_len,
1025  ...);
1026 
1027 
1042 int
1044  size_t out_len,
1045  int xtr_algo,
1046  int prf_algo,
1047  const void *xts,
1048  size_t xts_len,
1049  const void *skm,
1050  size_t skm_len,
1051  va_list argp);
1052 
1053 
1065 int
1067  size_t out_len,
1068  const void *xts,
1069  size_t xts_len,
1070  const void *skm,
1071  size_t skm_len,
1072  va_list argp);
1073 
1074 
1087 void
1088 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1089  gcry_mpi_t n,
1090  const void *xts,
1091  size_t xts_len,
1092  const void *skm,
1093  size_t skm_len,
1094  const char *ctx);
1095 
1096 
1109 int
1110 GNUNET_CRYPTO_kdf (void *result,
1111  size_t out_len,
1112  const void *xts,
1113  size_t xts_len,
1114  const void *skm,
1115  size_t skm_len,
1116  ...);
1117 
1118 
1126 void
1128  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1130 
1138 void
1140  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1142 
1143 
1151 void
1153  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1155 
1156 
1163 char *
1165  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1166 
1173 char *
1175  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1176 
1177 
1184 char *
1186  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1187 
1188 
1195 char *
1197  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1198 
1199 
1208 int
1210  const char *enc,
1211  size_t enclen,
1213 
1214 
1223 int
1225  const char *enc,
1226  size_t enclen,
1228 
1229 
1238 int
1240  const char *enc,
1241  size_t enclen,
1243 
1244 
1260 int
1262  int do_create,
1264 
1265 
1281 int
1283  int do_create,
1285 
1286 
1291 
1292 
1304  const struct GNUNET_CONFIGURATION_Handle *cfg);
1305 
1306 
1313 void
1315 
1316 
1323 void
1325 
1326 
1333 void
1335 
1336 
1343 void
1345 
1346 
1353 void
1355 
1356 
1363 void
1365 
1366 
1373 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1375 
1376 
1386 void
1387 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1388 
1389 
1399 int
1401  struct GNUNET_PeerIdentity *dst);
1402 
1403 
1408 
1409 
1415 {
1420  unsigned char q_y[256 / 8];
1421 };
1422 
1423 
1432 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem);
1433 
1434 
1443 int
1445  gcry_mpi_point_t input);
1446 
1447 
1461 gcry_mpi_point_t
1463 
1464 
1474 gcry_mpi_point_t
1476  gcry_mpi_t val);
1477 
1478 
1488 gcry_mpi_point_t
1490  gcry_mpi_point_t p,
1491  gcry_mpi_t val);
1492 
1493 
1501 void
1503  gcry_mpi_point_t point,
1504  struct GNUNET_CRYPTO_EccPoint *bin);
1505 
1506 
1514 gcry_mpi_point_t
1516  const struct GNUNET_CRYPTO_EccPoint *bin);
1517 
1518 
1527 gcry_mpi_point_t
1529  gcry_mpi_point_t a,
1530  gcry_mpi_point_t b);
1531 
1532 
1542 void
1544  gcry_mpi_point_t *r,
1545  gcry_mpi_point_t *r_inv);
1546 
1547 
1556 void
1558  gcry_mpi_t *r,
1559  gcry_mpi_t *r_inv);
1560 
1561 
1568 gcry_mpi_t
1570 
1571 
1577 void
1578 GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1579 
1580 
1586 void
1588 
1589 
1599 int
1601  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1602  struct GNUNET_HashCode *key_material);
1603 
1604 
1615 int
1617  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1618  struct GNUNET_HashCode *key_material);
1619 
1630 int
1632  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1633  struct GNUNET_HashCode *key_material);
1634 
1635 
1646 int
1648  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1649  struct GNUNET_HashCode *key_material);
1650 
1661 int
1663  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1664  struct GNUNET_HashCode *key_material);
1665 
1666 
1682 int
1684  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1685  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1686  struct GNUNET_CRYPTO_EddsaSignature *sig);
1687 
1688 
1701 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1702  /* check size is set correctly */ \
1703  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*ps)); \
1704  /* check 'ps' begins with the purpose */ \
1705  GNUNET_static_assert (((void*) (ps)) == \
1706  ((void*) &(ps)->purpose)); \
1707  GNUNET_assert (GNUNET_OK == \
1708  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1709  &(ps)->purpose, \
1710  sig)); \
1711 } while (0)
1712 
1713 
1729 int
1731  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1732  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1733  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1734 
1735 
1748 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1749  /* check size is set correctly */ \
1750  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \
1751  /* check 'ps' begins with the purpose */ \
1752  GNUNET_static_assert (((void*) (ps)) == \
1753  ((void*) &(ps)->purpose)); \
1754  GNUNET_assert (GNUNET_OK == \
1755  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1756  &(ps)->purpose, \
1757  sig)); \
1758 } while (0)
1759 
1760 
1779 int
1781  uint32_t purpose,
1782  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1783  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1784  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1785 
1786 
1801 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1802  /* check size is set correctly */ \
1803  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1804  /* check 'ps' begins with the purpose */ \
1805  GNUNET_static_assert (((void*) (ps)) == \
1806  ((void*) &(ps)->purpose)); \
1807  GNUNET_CRYPTO_eddsa_verify_ (purp, \
1808  &(ps)->purpose, \
1809  sig, \
1810  pub); \
1811  })
1812 
1813 
1832 int
1834  uint32_t purpose,
1835  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1836  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1837  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1838 
1839 
1854 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
1855  /* check size is set correctly */ \
1856  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \
1857  /* check 'ps' begins with the purpose */ \
1858  GNUNET_static_assert (((void*) (ps)) == \
1859  ((void*) &(ps)->purpose)); \
1860  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
1861  &(ps)->purpose, \
1862  sig, \
1863  pub); \
1864  })
1865 
1881  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1882  const char *label,
1883  const char *context);
1884 
1885 
1897 void
1899  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1900  const char *label,
1901  const char *context,
1903 
1904 
1913 void
1914 GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
1915 
1916 
1926 void
1928  const void *data,
1929  size_t size);
1930 
1931 
1938 void
1940  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1941  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
1942 
1943 
1955 int
1957  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1958  const gcry_mpi_t m,
1959  int desired_ops,
1961 
1962 
1971 void
1973  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
1974  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1976  gcry_mpi_t m);
1977 
1978 
1992 int
1994  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1995  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
1996  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
1998 
1999 
2006 int
2008  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2009 
2010 
2011 /* ********* Chaum-style RSA-based blind signatures ******************* */
2012 
2013 
2018 
2023 
2028 {
2033  uint32_t pre_secret[8] GNUNET_PACKED;
2034 };
2035 
2040 
2041 
2050 
2051 
2057 void
2059 
2060 
2069 size_t
2071  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2072  void **buffer);
2073 
2074 
2085  size_t buf_size);
2086 
2087 
2096  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2097 
2098 
2107  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2108 
2109 
2116 void
2118  struct GNUNET_HashCode *hc);
2119 
2120 
2127 unsigned int
2129 
2130 
2136 void
2138 
2139 
2148 size_t
2150  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2151  void **buffer);
2152 
2153 
2163 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2164 
2165 
2174 
2175 
2183 int
2185  const struct GNUNET_CRYPTO_RsaSignature *s2);
2186 
2194 int
2196  const struct
2198 
2199 
2207 int
2209  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2210 
2211 
2222 int
2223 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2224  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2226  void **buf,
2227  size_t *buf_size);
2228 
2229 
2240  const void *msg,
2241  size_t msg_len);
2242 
2243 
2253  const struct GNUNET_HashCode *hash);
2254 
2255 
2261 void
2263 
2264 
2272 size_t
2274  const struct GNUNET_CRYPTO_RsaSignature *sig,
2275  void **buffer);
2276 
2277 
2288  size_t buf_size);
2289 
2290 
2299 
2300 
2313  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2315 
2316 
2326 int
2327 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2328  const struct GNUNET_CRYPTO_RsaSignature *sig,
2329  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2330 
2331 
2332 #if 0 /* keep Emacsens' auto-indent happy */
2333 {
2334 #endif
2335 #ifdef __cplusplus
2336 }
2337 #endif
2338 
2339 
2340 /* ifndef GNUNET_CRYPTO_LIB_H */
2341 #endif
2342 /* 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:1166
int 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:1056
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:689
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:230
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:569
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.
Definition: crypto_ecc.c:963
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:342
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
gcry_mpi_point_t GNUNET_CRYPTO_ecc_bin_to_point(struct GNUNET_CRYPTO_EccDlogContext *edc, const struct GNUNET_CRYPTO_EccPoint *bin)
Convert binary representation of a point to computational representation.
void GNUNET_CRYPTO_ecc_rnd_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_t *r, gcry_mpi_t *r_inv)
Obtain a random scalar for point multiplication on the curve and its multiplicative inverse...
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:841
#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.
int 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
int 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:1111
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:1061
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:470
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:483
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:268
gcry_mpi_t GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccDlogContext *edc)
Generate a random value mod n.
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.
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:420
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key from command line option, or NULL.
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:289
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
int 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.
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:819
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
int 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:850
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:1076
int 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
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:483
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.
Context for cummulative hashing.
Definition: crypto_hash.c:468
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:127
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
GNUNET_SCHEDULER_Priority
Valid task priorities.
void GNUNET_CRYPTO_ecc_point_to_bin(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_point_t point, struct GNUNET_CRYPTO_EccPoint *bin)
Convert point value to binary representation.
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:149
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:455
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:1036
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
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:182
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:199
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static pa_context * context
Pulseaudio context.
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:1124
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.
int 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:1285
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
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:508
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:1363
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:98
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:144
int 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:1024
static char * value
Value of the record to add/remove.
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:432
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
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:265
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
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:443
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.
gcry_mpi_point_t GNUNET_CRYPTO_ecc_add(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_point_t a, gcry_mpi_point_t b)
Add two points on the elliptic curve.
an ECC signature using ECDSA
static char buf[2048]
static char * filename
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:721
void GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc)
Abort hashing, do not bother calculating final result.
Definition: crypto_hash.c:549
void GNUNET_CRYPTO_ecc_rnd(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_point_t *r, gcry_mpi_point_t *r_inv)
Obtain a random point on the curve and its additive inverse.
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
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:623
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.
A 512-bit hashcode.
int 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:1084
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:1195
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:419
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:222
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:331
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:232
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:73
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:176
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:215
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:395
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:509
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.
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:544
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
gcry_mpi_point_t GNUNET_CRYPTO_ecc_dexp(struct GNUNET_CRYPTO_EccDlogContext *edc, int val)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
Value for a salt for GNUNET_CRYPTO_pow_hash().
Context used when hashing a file.
int 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:645
gcry_mpi_point_t GNUNET_CRYPTO_ecc_dexp_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_t val)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
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:1337
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:193
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:96
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:745
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.
int 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:399
The identity of the host (wraps the signing key of the peer).
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:496
int 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:366
#define GNUNET_PACKED
gcc-ism to get packed structs.
configuration data
Definition: configuration.c:84
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:524
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:656
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:311
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:1005
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
int 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:707
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:298
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.
void GNUNET_CRYPTO_ecc_free(gcry_mpi_point_t p)
Free a point value returned by the API.
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...
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:265
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:252
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:305
int 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
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:202
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:162
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:346
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.
Definition: crypto_ecc.c:911
#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.
int GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_point_t input)
Calculate ECC discrete logarithm for small factors.
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:373
uint32_t data
The data value.
gcry_mpi_point_t GNUNET_CRYPTO_ecc_pmul_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, gcry_mpi_point_t p, gcry_mpi_t val)
Multiply the point p on the elliptic curve by val.
int 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
unsigned int max
Maximum absolute value the calculation supports.
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition: crypto_rsa.c:183
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:526
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...
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...