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 
716 struct GNUNET_HashContext *
718 
719 
727 void
729  const void *buf,
730  size_t size);
731 
732 
739 void
741  struct GNUNET_HashCode *r_hash);
742 
743 
749 void
751 
752 
764 void
765 GNUNET_CRYPTO_hmac_raw (const void *key,
766  size_t key_len,
767  const void *plaintext,
768  size_t plaintext_len,
769  struct GNUNET_HashCode *hmac);
770 
771 
781 void
783  const void *plaintext,
784  size_t plaintext_len,
785  struct GNUNET_HashCode *hmac);
786 
787 
796  void *cls,
797  const struct GNUNET_HashCode *res);
798 
799 
804 
805 
819  const char *filename,
820  size_t blocksize,
822  void *callback_cls);
823 
824 
830 void
832 
833 
841 void
843  struct GNUNET_HashCode *result);
844 
845 
854 void
856  const struct GNUNET_HashCode *b,
857  struct GNUNET_HashCode *result);
858 
859 
868 void
869 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
870  const struct GNUNET_HashCode *delta,
871  struct GNUNET_HashCode *result);
872 
873 
882 void
883 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
884  const struct GNUNET_HashCode *b,
885  struct GNUNET_HashCode *result);
886 
887 
896 void
898  const struct GNUNET_HashCode *hc,
901 
902 
912 int
914  unsigned int bit);
915 
916 
924 int
926  unsigned int bit);
927 
928 
941 unsigned int
943  const struct GNUNET_HashCode *second);
944 
945 
955 int
956 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
957  const struct GNUNET_HashCode *h2);
958 
959 
970 int
972  const struct GNUNET_HashCode *h2,
973  const struct GNUNET_HashCode *target);
974 
975 
985 void
987  struct GNUNET_CRYPTO_AuthKey *key,
988  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
989  const void *salt,
990  size_t salt_len,
991  va_list argp);
992 
993 
1003 void
1005  struct GNUNET_CRYPTO_AuthKey *key,
1006  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1007  const void *salt,
1008  size_t salt_len,
1009  ...);
1010 
1011 
1027 GNUNET_CRYPTO_hkdf (void *result,
1028  size_t out_len,
1029  int xtr_algo,
1030  int prf_algo,
1031  const void *xts,
1032  size_t xts_len,
1033  const void *skm,
1034  size_t skm_len,
1035  ...);
1036 
1037 
1054  size_t out_len,
1055  int xtr_algo,
1056  int prf_algo,
1057  const void *xts,
1058  size_t xts_len,
1059  const void *skm,
1060  size_t skm_len,
1061  va_list argp);
1062 
1063 
1077  size_t out_len,
1078  const void *xts,
1079  size_t xts_len,
1080  const void *skm,
1081  size_t skm_len,
1082  va_list argp);
1083 
1084 
1097 void
1098 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1099  gcry_mpi_t n,
1100  const void *xts,
1101  size_t xts_len,
1102  const void *skm,
1103  size_t skm_len,
1104  const char *ctx);
1105 
1106 
1120 GNUNET_CRYPTO_kdf (void *result,
1121  size_t out_len,
1122  const void *xts,
1123  size_t xts_len,
1124  const void *skm,
1125  size_t skm_len,
1126  ...);
1127 
1128 
1136 void
1138  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1140 
1148 void
1150  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1152 
1153 
1161 void
1163  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1165 
1166 
1173 char *
1175  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1176 
1183 char *
1185  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1186 
1187 
1194 char *
1196  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1197 
1198 
1205 char *
1207  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1208 
1209 
1220  const char *enc,
1221  size_t enclen,
1223 
1224 
1233 int
1235  const char *enc,
1236  size_t enclen,
1238 
1239 
1250  const char *enc,
1251  size_t enclen,
1253 
1254 
1272  int do_create,
1274 
1275 
1291 int
1293  int do_create,
1295 
1296 
1301 
1302 
1314  const struct GNUNET_CONFIGURATION_Handle *cfg);
1315 
1316 
1323 void
1325 
1326 
1333 void
1335 
1336 
1343 void
1345 
1346 
1353 void
1355 
1356 
1363 void
1365 
1366 
1373 void
1375 
1376 
1383 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1385 
1386 
1396 void
1397 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1398 
1399 
1409 int
1411  struct GNUNET_PeerIdentity *dst);
1412 
1413 
1418 
1419 
1425 {
1430  unsigned char q_y[256 / 8];
1431 };
1432 
1433 
1442 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem);
1443 
1444 
1453 int
1455  gcry_mpi_point_t input);
1456 
1457 
1471 gcry_mpi_point_t
1473 
1474 
1484 gcry_mpi_point_t
1486  gcry_mpi_t val);
1487 
1488 
1498 gcry_mpi_point_t
1500  gcry_mpi_point_t p,
1501  gcry_mpi_t val);
1502 
1503 
1511 void
1513  gcry_mpi_point_t point,
1514  struct GNUNET_CRYPTO_EccPoint *bin);
1515 
1516 
1524 gcry_mpi_point_t
1526  const struct GNUNET_CRYPTO_EccPoint *bin);
1527 
1528 
1537 gcry_mpi_point_t
1539  gcry_mpi_point_t a,
1540  gcry_mpi_point_t b);
1541 
1542 
1552 void
1554  gcry_mpi_point_t *r,
1555  gcry_mpi_point_t *r_inv);
1556 
1557 
1566 void
1568  gcry_mpi_t *r,
1569  gcry_mpi_t *r_inv);
1570 
1571 
1578 gcry_mpi_t
1580 
1581 
1587 void
1588 GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1589 
1590 
1596 void
1598 
1599 
1611  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1612  struct GNUNET_HashCode *key_material);
1613 
1614 
1627  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1628  struct GNUNET_HashCode *key_material);
1629 
1642  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1643  struct GNUNET_HashCode *key_material);
1644 
1645 
1658  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1659  struct GNUNET_HashCode *key_material);
1660 
1673  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1674  struct GNUNET_HashCode *key_material);
1675 
1676 
1694  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1695  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1696  struct GNUNET_CRYPTO_EddsaSignature *sig);
1697 
1698 
1711 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1712  /* check size is set correctly */ \
1713  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1714  /* check 'ps' begins with the purpose */ \
1715  GNUNET_static_assert (((void*) (ps)) == \
1716  ((void*) &(ps)->purpose)); \
1717  GNUNET_assert (GNUNET_OK == \
1718  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1719  &(ps)->purpose, \
1720  sig)); \
1721 } while (0)
1722 
1723 
1741  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1742  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1743  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1744 
1745 
1758 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1759  /* check size is set correctly */ \
1760  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1761  /* check 'ps' begins with the purpose */ \
1762  GNUNET_static_assert (((void*) (ps)) == \
1763  ((void*) &(ps)->purpose)); \
1764  GNUNET_assert (GNUNET_OK == \
1765  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1766  &(ps)->purpose, \
1767  sig)); \
1768 } while (0)
1769 
1770 
1789 int
1791  uint32_t purpose,
1792  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1793  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1794  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1795 
1796 
1811 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1812  /* check size is set correctly */ \
1813  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1814  /* check 'ps' begins with the purpose */ \
1815  GNUNET_static_assert (((void*) (ps)) == \
1816  ((void*) &(ps)->purpose)); \
1817  GNUNET_CRYPTO_eddsa_verify_ (purp, \
1818  &(ps)->purpose, \
1819  sig, \
1820  pub); \
1821  })
1822 
1823 
1842 int
1844  uint32_t purpose,
1845  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1846  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1847  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1848 
1849 
1864 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
1865  /* check size is set correctly */ \
1866  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1867  /* check 'ps' begins with the purpose */ \
1868  GNUNET_static_assert (((void*) (ps)) == \
1869  ((void*) &(ps)->purpose)); \
1870  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
1871  &(ps)->purpose, \
1872  sig, \
1873  pub); \
1874  })
1875 
1891  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1892  const char *label,
1893  const char *context);
1894 
1895 
1907 void
1909  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1910  const char *label,
1911  const char *context,
1913 
1914 
1923 void
1924 GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
1925 
1926 
1936 void
1938  const void *data,
1939  size_t size);
1940 
1941 
1948 void
1950  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1951  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
1952 
1953 
1965 int
1967  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1968  const gcry_mpi_t m,
1969  int desired_ops,
1971 
1972 
1981 void
1983  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
1984  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1986  gcry_mpi_t m);
1987 
1988 
2002 int
2004  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2005  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2006  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2008 
2009 
2016 int
2018  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2019 
2020 
2021 /* ********* Chaum-style RSA-based blind signatures ******************* */
2022 
2023 
2028 
2033 
2038 {
2043  uint32_t pre_secret[8] GNUNET_PACKED;
2044 };
2045 
2050 
2051 
2060 
2061 
2067 void
2069 
2070 
2079 size_t
2081  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2082  void **buffer);
2083 
2084 
2095  size_t buf_size);
2096 
2097 
2106  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2107 
2108 
2117  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2118 
2119 
2126 void
2128  struct GNUNET_HashCode *hc);
2129 
2130 
2137 unsigned int
2139 
2140 
2146 void
2148 
2149 
2158 size_t
2160  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2161  void **buffer);
2162 
2163 
2173 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2174 
2175 
2184 
2185 
2193 int
2195  const struct GNUNET_CRYPTO_RsaSignature *s2);
2196 
2204 int
2206  const struct
2208 
2209 
2217 int
2219  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2220 
2221 
2232 int
2233 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2234  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2236  void **buf,
2237  size_t *buf_size);
2238 
2239 
2250  const void *msg,
2251  size_t msg_len);
2252 
2253 
2263  const struct GNUNET_HashCode *hash);
2264 
2265 
2271 void
2273 
2274 
2282 size_t
2284  const struct GNUNET_CRYPTO_RsaSignature *sig,
2285  void **buffer);
2286 
2287 
2298  size_t buf_size);
2299 
2300 
2309 
2310 
2323  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2325 
2326 
2337 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2338  const struct GNUNET_CRYPTO_RsaSignature *sig,
2339  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2340 
2341 
2342 #if 0 /* keep Emacsens' auto-indent happy */
2343 {
2344 #endif
2345 #ifdef __cplusplus
2346 }
2347 #endif
2348 
2349 
2350 /* ifndef GNUNET_CRYPTO_LIB_H */
2351 #endif
2352 /* 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:1028
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
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:465
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:776
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
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: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:944
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:398
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:405
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
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.
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:1128
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.
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:662
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
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:952
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.
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: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:924
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:884
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:579
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:992
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 ...
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:419
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:1194
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
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:99
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:366
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:867
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:235
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:341
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
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:634
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_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
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:849
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:529
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:685
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:1047
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:289
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:208
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:170
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:197
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:445
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
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.
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:1174
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:181
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:603
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:827
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:412
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:316
#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.
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:430
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
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:900
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
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:262
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...
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.
Definition: crypto_ecc.c:734
#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:246
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.
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: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...