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 
57 struct GNUNET_PeerIdentity;
58 
59 #include "gnunet_common.h"
60 #include <gcrypt.h>
61 
62 
67 #define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
68 
69 
75 {
82 
88 
94 };
95 
96 
100 #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8)
101 
105 #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8)
106 
111 #define GNUNET_CRYPTO_PKEY_ASCII_LENGTH 52
112 
117 {
118  unsigned char encoding[104];
119 };
120 
121 
123 
124 
131 {
137  uint32_t size GNUNET_PACKED;
138 
145  uint32_t purpose GNUNET_PACKED;
146 };
147 
148 
154 {
158  unsigned char r[256 / 8];
159 
163  unsigned char s[256 / 8];
164 };
165 
166 
171 {
175  unsigned char r[256 / 8];
176 
180  unsigned char s[256 / 8];
181 };
182 
183 
191 {
197  unsigned char q_y[256 / 8];
198 };
199 
200 
206 {
211  unsigned char q_y[256 / 8];
212 };
213 
214 
219 {
220  struct GNUNET_CRYPTO_EddsaPublicKey public_key;
221 };
222 
223 
230 {
235  unsigned char q_y[256 / 8];
236 };
237 
238 
244 {
248  unsigned char d[256 / 8];
249 };
250 
256 {
260  unsigned char d[256 / 8];
261 };
262 
268 {
272  unsigned char d[256 / 8];
273 };
274 
275 
280 {
284  unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
285 
289  unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
290 };
291 
293 
301 {
302  unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
303 
304  unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
305 };
306 
307 
312 {
314 };
315 
316 
321 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
322 
323 
328 {
332  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
333 };
334 
335 
340 {
344  unsigned char lambda[GNUNET_CRYPTO_PAILLIER_BITS / 8];
348  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
349 };
350 
351 
356 {
361  int32_t remaining_ops GNUNET_PACKED;
362 
366  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
367 };
368 
369 
370 /* **************** Functions and Macros ************* */
371 
379 void
380 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
381 
382 
391 uint8_t
392 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
393 
394 
403 uint32_t
404 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
405 
406 
413 uint16_t
414 GNUNET_CRYPTO_crc16_finish (uint32_t sum);
415 
416 
425 uint16_t
426 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
427 
428 
438 int32_t
439 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
440 
449 void
450 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
451 
452 
461 void
463  void *buffer,
464  size_t length);
465 
474 uint32_t
476 
477 
486 uint64_t
488 
489 
499 unsigned int *
501 
502 
509 void
512 
513 
525 ssize_t
527  const void *block,
528  size_t size,
529  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
531  void *result);
532 
533 
545 ssize_t
547  const void *block,
548  size_t size,
549  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
551  void *result);
552 
553 
563 void
566  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
567  const void *salt,
568  size_t salt_len,
569  ...);
570 
571 
580 void
583  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
584  const void *salt,
585  size_t salt_len,
586  va_list argp);
587 
588 
596 void
597 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
599 
600 
610 int
612  size_t enclen,
613  struct GNUNET_HashCode *result);
614 
615 
624 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
625  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
626 
627 
640 uint32_t
642  const struct GNUNET_HashCode *b);
643 
644 
653 void
654 GNUNET_CRYPTO_hash (const void *block,
655  size_t size,
656  struct GNUNET_HashCode *ret);
657 
658 
667 void
668 GNUNET_CRYPTO_pow_hash (const char *salt,
669  const void *buf,
670  size_t buf_len,
671  struct GNUNET_HashCode *result);
672 
673 
677 struct GNUNET_HashContext;
678 
679 
685 struct GNUNET_HashContext *
687 
688 
696 void
698  const void *buf,
699  size_t size);
700 
701 
708 void
710  struct GNUNET_HashCode *r_hash);
711 
712 
718 void
720 
721 
733 void
734 GNUNET_CRYPTO_hmac_raw (const void *key,
735  size_t key_len,
736  const void *plaintext,
737  size_t plaintext_len,
738  struct GNUNET_HashCode *hmac);
739 
740 
750 void
752  const void *plaintext,
753  size_t plaintext_len,
754  struct GNUNET_HashCode *hmac);
755 
756 
765  void *cls,
766  const struct GNUNET_HashCode *res);
767 
768 
773 
774 
788  const char *filename,
789  size_t blocksize,
791  void *callback_cls);
792 
793 
799 void
801 
802 
810 void
812  struct GNUNET_HashCode *result);
813 
814 
823 void
825  const struct GNUNET_HashCode *b,
826  struct GNUNET_HashCode *result);
827 
828 
837 void
838 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
839  const struct GNUNET_HashCode *delta,
840  struct GNUNET_HashCode *result);
841 
842 
851 void
852 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
853  const struct GNUNET_HashCode *b,
854  struct GNUNET_HashCode *result);
855 
856 
865 void
867  const struct GNUNET_HashCode *hc,
870 
871 
881 int
883  unsigned int bit);
884 
885 
893 int
895  unsigned int bit);
896 
897 
910 unsigned int
912  const struct GNUNET_HashCode *second);
913 
914 
924 int
925 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
926  const struct GNUNET_HashCode *h2);
927 
928 
939 int
941  const struct GNUNET_HashCode *h2,
942  const struct GNUNET_HashCode *target);
943 
944 
954 void
956  struct GNUNET_CRYPTO_AuthKey *key,
957  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
958  const void *salt,
959  size_t salt_len,
960  va_list argp);
961 
962 
972 void
974  struct GNUNET_CRYPTO_AuthKey *key,
975  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
976  const void *salt,
977  size_t salt_len,
978  ...);
979 
980 
995 int
997  size_t out_len,
998  int xtr_algo,
999  int prf_algo,
1000  const void *xts,
1001  size_t xts_len,
1002  const void *skm,
1003  size_t skm_len,
1004  ...);
1005 
1006 
1021 int
1023  size_t out_len,
1024  int xtr_algo,
1025  int prf_algo,
1026  const void *xts,
1027  size_t xts_len,
1028  const void *skm,
1029  size_t skm_len,
1030  va_list argp);
1031 
1032 
1044 int
1046  size_t out_len,
1047  const void *xts,
1048  size_t xts_len,
1049  const void *skm,
1050  size_t skm_len,
1051  va_list argp);
1052 
1053 
1066 void
1067 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1068  gcry_mpi_t n,
1069  const void *xts,
1070  size_t xts_len,
1071  const void *skm,
1072  size_t skm_len,
1073  const char *ctx);
1074 
1075 
1088 int
1089 GNUNET_CRYPTO_kdf (void *result,
1090  size_t out_len,
1091  const void *xts,
1092  size_t xts_len,
1093  const void *skm,
1094  size_t skm_len,
1095  ...);
1096 
1097 
1105 void
1107  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1109 
1117 void
1119  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1121 
1122 
1130 void
1132  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1134 
1135 
1142 char *
1144  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1145 
1152 char *
1154  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1155 
1156 
1163 char *
1165  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1166 
1167 
1174 char *
1176  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1177 
1178 
1187 int
1189  const char *enc,
1190  size_t enclen,
1192 
1193 
1202 int
1204  const char *enc,
1205  size_t enclen,
1207 
1208 
1217 int
1219  const char *enc,
1220  size_t enclen,
1222 
1223 
1239 int
1241  int do_create,
1243 
1244 
1260 int
1262  int do_create,
1264 
1265 
1270 
1271 
1283  const struct GNUNET_CONFIGURATION_Handle *cfg);
1284 
1285 
1292 void
1294 
1295 
1302 void
1304 
1305 
1312 void
1314 
1315 
1322 void
1324 
1325 
1332 void
1334 
1335 
1342 void
1344 
1345 
1352 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1354 
1355 
1365 void
1366 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1367 
1368 
1378 int
1380  struct GNUNET_PeerIdentity *dst);
1381 
1382 
1387 
1388 
1394 {
1399  unsigned char q_y[256 / 8];
1400 };
1401 
1402 
1411 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem);
1412 
1413 
1422 int
1424  gcry_mpi_point_t input);
1425 
1426 
1440 gcry_mpi_point_t
1442 
1443 
1453 gcry_mpi_point_t
1455  gcry_mpi_t val);
1456 
1457 
1467 gcry_mpi_point_t
1469  gcry_mpi_point_t p,
1470  gcry_mpi_t val);
1471 
1472 
1480 void
1482  gcry_mpi_point_t point,
1483  struct GNUNET_CRYPTO_EccPoint *bin);
1484 
1485 
1493 gcry_mpi_point_t
1495  const struct GNUNET_CRYPTO_EccPoint *bin);
1496 
1497 
1506 gcry_mpi_point_t
1508  gcry_mpi_point_t a,
1509  gcry_mpi_point_t b);
1510 
1511 
1521 void
1523  gcry_mpi_point_t *r,
1524  gcry_mpi_point_t *r_inv);
1525 
1526 
1535 void
1537  gcry_mpi_t *r,
1538  gcry_mpi_t *r_inv);
1539 
1540 
1547 gcry_mpi_t
1549 
1550 
1556 void
1557 GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1558 
1559 
1565 void
1567 
1568 
1578 int
1580  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1581  struct GNUNET_HashCode *key_material);
1582 
1583 
1594 int
1596  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1597  struct GNUNET_HashCode *key_material);
1598 
1609 int
1611  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1612  struct GNUNET_HashCode *key_material);
1613 
1614 
1625 int
1627  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1628  struct GNUNET_HashCode *key_material);
1629 
1640 int
1642  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1643  struct GNUNET_HashCode *key_material);
1644 
1645 
1661 int
1663  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1664  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1665  struct GNUNET_CRYPTO_EddsaSignature *sig);
1666 
1667 
1680 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1681  /* check size is set correctly */ \
1682  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*ps)); \
1683  /* check 'ps' begins with the purpose */ \
1684  GNUNET_static_assert (((void*) (ps)) == \
1685  ((void*) &(ps)->purpose)); \
1686  GNUNET_assert (GNUNET_OK == \
1687  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1688  &(ps)->purpose, \
1689  sig)); \
1690 } while (0)
1691 
1692 
1708 int
1710  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1711  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1712  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1713 
1714 
1727 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1728  /* check size is set correctly */ \
1729  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \
1730  /* check 'ps' begins with the purpose */ \
1731  GNUNET_static_assert (((void*) (ps)) == \
1732  ((void*) &(ps)->purpose)); \
1733  GNUNET_assert (GNUNET_OK == \
1734  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1735  &(ps)->purpose, \
1736  sig)); \
1737 } while (0)
1738 
1739 
1758 int
1760  uint32_t purpose,
1761  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1762  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1763  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1764 
1765 
1780 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1781  /* check size is set correctly */ \
1782  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \
1783  /* check 'ps' begins with the purpose */ \
1784  GNUNET_static_assert (((void*) (ps)) == \
1785  ((void*) &(ps)->purpose)); \
1786  GNUNET_CRYPTO_eddsa_verify_ (purp, \
1787  &(ps)->purpose, \
1788  sig, \
1789  pub); \
1790  })
1791 
1792 
1811 int
1813  uint32_t purpose,
1814  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1815  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1816  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1817 
1818 
1833 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
1834  /* check size is set correctly */ \
1835  GNUNET_assert (htonl ((ps)->purpose.size) == sizeof (*(ps))); \
1836  /* check 'ps' begins with the purpose */ \
1837  GNUNET_static_assert (((void*) (ps)) == \
1838  ((void*) &(ps)->purpose)); \
1839  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
1840  &(ps)->purpose, \
1841  sig, \
1842  pub); \
1843  })
1844 
1860  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1861  const char *label,
1862  const char *context);
1863 
1864 
1876 void
1878  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1879  const char *label,
1880  const char *context,
1882 
1883 
1892 void
1893 GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
1894 
1895 
1905 void
1907  const void *data,
1908  size_t size);
1909 
1910 
1917 void
1919  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1920  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
1921 
1922 
1934 int
1936  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1937  const gcry_mpi_t m,
1938  int desired_ops,
1940 
1941 
1950 void
1952  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
1953  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1955  gcry_mpi_t m);
1956 
1957 
1971 int
1973  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1974  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
1975  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
1977 
1978 
1985 int
1987  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
1988 
1989 
1990 /* ********* Chaum-style RSA-based blind signatures ******************* */
1991 
1992 
1997 
2002 
2007 {
2012  uint32_t pre_secret[8] GNUNET_PACKED;
2013 };
2014 
2019 
2020 
2029 
2030 
2036 void
2038 
2039 
2048 size_t
2050  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2051  void **buffer);
2052 
2053 
2064  size_t buf_size);
2065 
2066 
2075  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2076 
2077 
2086  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2087 
2088 
2095 void
2097  struct GNUNET_HashCode *hc);
2098 
2099 
2106 unsigned int
2108 
2109 
2115 void
2117 
2118 
2127 size_t
2129  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2130  void **buffer);
2131 
2132 
2142 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2143 
2144 
2153 
2154 
2162 int
2164  const struct GNUNET_CRYPTO_RsaSignature *s2);
2165 
2173 int
2175  const struct
2177 
2178 
2186 int
2188  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2189 
2190 
2201 int
2202 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2203  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2205  void **buf,
2206  size_t *buf_size);
2207 
2208 
2219  const void *msg,
2220  size_t msg_len);
2221 
2222 
2232  const struct GNUNET_HashCode *hash);
2233 
2234 
2240 void
2242 
2243 
2251 size_t
2253  const struct GNUNET_CRYPTO_RsaSignature *sig,
2254  void **buffer);
2255 
2256 
2267  size_t buf_size);
2268 
2269 
2278 
2279 
2292  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2294 
2295 
2305 int
2306 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2307  const struct GNUNET_CRYPTO_RsaSignature *sig,
2308  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2309 
2310 
2311 #if 0 /* keep Emacsens' auto-indent happy */
2312 {
2313 #endif
2314 #ifdef __cplusplus
2315 }
2316 #endif
2317 
2318 
2319 /* ifndef GNUNET_CRYPTO_LIB_H */
2320 #endif
2321 /* 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:126
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:267
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
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
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
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
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.
void GNUNET_CRYPTO_pow_hash(const char *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
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
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...
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...
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
#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:39
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.
int 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
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:89
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...