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 
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 {
222 };
223 
224 
231 {
236  unsigned char q_y[256 / 8];
237 };
238 
239 
245 {
249  unsigned char d[256 / 8];
250 };
251 
257 {
261  unsigned char d[256 / 8];
262 };
263 
269 {
273  unsigned char d[256 / 8];
274 };
275 
276 
282 {
286  unsigned char s[512 / 8];
287 };
288 
289 
294 {
299 
304 };
305 
310 {
315 };
316 
318 
326 {
328 
330 };
331 
332 
337 {
339 };
340 
341 
346 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
347 
348 
353 {
357  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
358 };
359 
360 
365 {
373  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
374 };
375 
376 
381 {
387 
391  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
392 };
393 
394 
395 /* **************** Functions and Macros ************* */
396 
404 void
405 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
406 
407 
416 uint8_t
417 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
418 
419 
428 uint32_t
429 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
430 
431 
438 uint16_t
440 
441 
450 uint16_t
451 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
452 
453 
463 int32_t
464 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
465 
474 void
475 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
476 
477 
486 void
488  void *buffer,
489  size_t length);
490 
491 
502 void
504  struct GNUNET_Uuid *uuid);
505 
506 
515 uint32_t
517 
518 
527 uint64_t
529 
530 
540 unsigned int *
542 
543 
550 void
553 
554 
566 ssize_t
568  const void *block,
569  size_t size,
570  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
572  void *result);
573 
574 
586 ssize_t
588  const void *block,
589  size_t size,
590  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
592  void *result);
593 
594 
604 void
607  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
608  const void *salt,
609  size_t salt_len,
610  ...);
611 
612 
621 void
624  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
625  const void *salt,
626  size_t salt_len,
627  va_list argp);
628 
629 
637 void
638 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
640 
641 
653  size_t enclen,
654  struct GNUNET_HashCode *result);
655 
656 
665 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
666  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
667 
668 
681 uint32_t
683  const struct GNUNET_HashCode *b);
684 
685 
694 void
695 GNUNET_CRYPTO_hash (const void *block,
696  size_t size,
697  struct GNUNET_HashCode *ret);
698 
699 
704 {
705  char salt[crypto_pwhash_argon2id_SALTBYTES];
706 };
707 
708 
717 void
719  const void *buf,
720  size_t buf_len,
721  struct GNUNET_HashCode *result);
722 
723 
727 struct GNUNET_HashContext;
728 
729 
735 struct GNUNET_HashContext *
737 
738 
745 struct GNUNET_HashContext *
747 
748 
756 void
758  const void *buf,
759  size_t size);
760 
761 
768 void
770  struct GNUNET_HashCode *r_hash);
771 
772 
778 void
780 
781 
793 void
794 GNUNET_CRYPTO_hmac_raw (const void *key,
795  size_t key_len,
796  const void *plaintext,
797  size_t plaintext_len,
798  struct GNUNET_HashCode *hmac);
799 
800 
810 void
812  const void *plaintext,
813  size_t plaintext_len,
814  struct GNUNET_HashCode *hmac);
815 
816 
824 typedef void
826  void *cls,
827  const struct GNUNET_HashCode *res);
828 
829 
834 
835 
849  const char *filename,
850  size_t blocksize,
852  void *callback_cls);
853 
854 
860 void
862 
863 
871 void
873  struct GNUNET_HashCode *result);
874 
875 
884 void
886  const struct GNUNET_HashCode *b,
887  struct GNUNET_HashCode *result);
888 
889 
898 void
899 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
900  const struct GNUNET_HashCode *delta,
901  struct GNUNET_HashCode *result);
902 
903 
912 void
913 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
914  const struct GNUNET_HashCode *b,
915  struct GNUNET_HashCode *result);
916 
917 
926 void
928  const struct GNUNET_HashCode *hc,
931 
932 
942 int
944  unsigned int bit);
945 
946 
954 int
956  unsigned int bit);
957 
958 
971 unsigned int
973  const struct GNUNET_HashCode *second);
974 
975 
985 int
986 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
987  const struct GNUNET_HashCode *h2);
988 
989 
1000 int
1001 GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1,
1002  const struct GNUNET_HashCode *h2,
1003  const struct GNUNET_HashCode *target);
1004 
1005 
1015 void
1017  struct GNUNET_CRYPTO_AuthKey *key,
1018  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1019  const void *salt,
1020  size_t salt_len,
1021  va_list argp);
1022 
1023 
1033 void
1035  struct GNUNET_CRYPTO_AuthKey *key,
1036  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
1037  const void *salt,
1038  size_t salt_len,
1039  ...);
1040 
1041 
1057 GNUNET_CRYPTO_hkdf (void *result,
1058  size_t out_len,
1059  int xtr_algo,
1060  int prf_algo,
1061  const void *xts,
1062  size_t xts_len,
1063  const void *skm,
1064  size_t skm_len,
1065  ...);
1066 
1067 
1084  size_t out_len,
1085  int xtr_algo,
1086  int prf_algo,
1087  const void *xts,
1088  size_t xts_len,
1089  const void *skm,
1090  size_t skm_len,
1091  va_list argp);
1092 
1093 
1107  size_t out_len,
1108  const void *xts,
1109  size_t xts_len,
1110  const void *skm,
1111  size_t skm_len,
1112  va_list argp);
1113 
1114 
1127 void
1128 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1129  gcry_mpi_t n,
1130  const void *xts,
1131  size_t xts_len,
1132  const void *skm,
1133  size_t skm_len,
1134  const char *ctx);
1135 
1136 
1150 GNUNET_CRYPTO_kdf (void *result,
1151  size_t out_len,
1152  const void *xts,
1153  size_t xts_len,
1154  const void *skm,
1155  size_t skm_len,
1156  ...);
1157 
1158 
1166 void
1168  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1170 
1178 void
1180  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1182 
1183 
1191 void
1193  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1195 
1196 
1203 char *
1205  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1206 
1213 char *
1215  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1216 
1217 
1224 char *
1226  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1227 
1228 
1235 char *
1237  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1238 
1239 
1250  const char *enc,
1251  size_t enclen,
1253 
1254 
1263 int
1265  const char *enc,
1266  size_t enclen,
1268 
1269 
1280  const char *enc,
1281  size_t enclen,
1283 
1284 
1302  int do_create,
1304 
1305 
1321 int
1323  int do_create,
1325 
1326 
1331 
1332 
1344  const struct GNUNET_CONFIGURATION_Handle *cfg);
1345 
1346 
1353 void
1355 
1356 
1363 void
1365 
1366 
1373 void
1375 
1376 
1383 void
1385 
1386 
1393 void
1395 
1396 
1403 void
1405 
1406 
1413 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1415 
1416 
1426 void
1427 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1428 
1429 
1439 int
1441  struct GNUNET_PeerIdentity *dst);
1442 
1443 
1448 
1449 
1455 {
1460  unsigned char v[256 / 8];
1461 };
1462 
1467 {
1468  unsigned char v[256 / 8];
1469 };
1470 
1479 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max,
1480  unsigned int mem);
1481 
1482 
1491 int
1493  const struct GNUNET_CRYPTO_EccPoint *input);
1494 
1495 
1507 void
1508 GNUNET_CRYPTO_ecc_dexp (int val,
1509  struct GNUNET_CRYPTO_EccPoint*r);
1510 
1511 
1522  struct GNUNET_CRYPTO_EccPoint *r);
1523 
1524 
1535  const struct GNUNET_CRYPTO_EccScalar *val,
1536  struct GNUNET_CRYPTO_EccPoint *r);
1537 
1538 
1549  const struct GNUNET_CRYPTO_EccPoint *b,
1550  struct GNUNET_CRYPTO_EccPoint *r);
1551 
1552 
1563  struct GNUNET_CRYPTO_EccPoint *r_inv);
1564 
1565 
1573 void
1575  struct GNUNET_CRYPTO_EccScalar *r_neg);
1576 
1577 
1583 void
1585 
1586 
1592 void
1594 
1595 
1602 void
1604  struct GNUNET_CRYPTO_EccScalar *r);
1605 
1606 
1618  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1619  struct GNUNET_HashCode *key_material);
1620 
1621 
1634  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1635  struct GNUNET_HashCode *key_material);
1636 
1637 
1650  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1651  struct GNUNET_HashCode *key_material);
1652 
1653 
1666  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1667  struct GNUNET_HashCode *key_material);
1668 
1681  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1682  struct GNUNET_HashCode *key_material);
1683 
1684 
1702  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1703  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1704  struct GNUNET_CRYPTO_EddsaSignature *sig);
1705 
1706 
1719 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do { \
1720  /* check size is set correctly */ \
1721  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)); \
1722  /* check 'ps' begins with the purpose */ \
1723  GNUNET_static_assert (((void*) (ps)) == \
1724  ((void*) &(ps)->purpose)); \
1725  GNUNET_assert (GNUNET_OK == \
1726  GNUNET_CRYPTO_eddsa_sign_ (priv, \
1727  &(ps)->purpose, \
1728  sig)); \
1729 } while (0)
1730 
1731 
1749  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1750  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1751  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1752 
1753 
1766 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do { \
1767  /* check size is set correctly */ \
1768  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1769  /* check 'ps' begins with the purpose */ \
1770  GNUNET_static_assert (((void*) (ps)) == \
1771  ((void*) &(ps)->purpose)); \
1772  GNUNET_assert (GNUNET_OK == \
1773  GNUNET_CRYPTO_ecdsa_sign_ (priv, \
1774  &(ps)->purpose, \
1775  sig)); \
1776 } while (0)
1777 
1778 
1797 int
1799  uint32_t purpose,
1800  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1801  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1802  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1803 
1804 
1819 #define GNUNET_CRYPTO_eddsa_verify(purp,ps,sig,pub) ({ \
1820  /* check size is set correctly */ \
1821  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1822  /* check 'ps' begins with the purpose */ \
1823  GNUNET_static_assert (((void*) (ps)) == \
1824  ((void*) &(ps)->purpose)); \
1825  GNUNET_CRYPTO_eddsa_verify_ (purp, \
1826  &(ps)->purpose, \
1827  sig, \
1828  pub); \
1829  })
1830 
1831 
1850 int
1852  uint32_t purpose,
1853  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1854  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1855  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1856 
1857 
1872 #define GNUNET_CRYPTO_ecdsa_verify(purp,ps,sig,pub) ({ \
1873  /* check size is set correctly */ \
1874  GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps))); \
1875  /* check 'ps' begins with the purpose */ \
1876  GNUNET_static_assert (((void*) (ps)) == \
1877  ((void*) &(ps)->purpose)); \
1878  GNUNET_CRYPTO_ecdsa_verify_ (purp, \
1879  &(ps)->purpose, \
1880  sig, \
1881  pub); \
1882  })
1883 
1899  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1900  const char *label,
1901  const char *context);
1902 
1903 
1915 void
1917  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1918  const char *label,
1919  const char *context,
1921 
1922 
1939 void
1941  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1942  const char *label,
1943  const char *context,
1945 
1946 
1958 void
1960  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1961  const char *label,
1962  const char *context,
1964 
1965 
1981 void
1983  const struct GNUNET_CRYPTO_EddsaPrivateScalar *priv,
1984  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1985  struct GNUNET_CRYPTO_EddsaSignature *sig);
1986 
1987 
1994 void
1996  const struct GNUNET_CRYPTO_EddsaPrivateScalar *s,
1998 
1999 
2008 void
2010  size_t size,
2011  gcry_mpi_t val);
2012 
2013 
2023 void
2025  const void *data,
2026  size_t size);
2027 
2028 
2035 void
2037  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2038  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
2039 
2040 
2052 int
2054  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2055  const gcry_mpi_t m,
2056  int desired_ops,
2058 
2059 
2068 void
2070  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
2071  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2073  gcry_mpi_t m);
2074 
2075 
2089 int
2091  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
2092  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
2093  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
2095 
2096 
2103 int
2105  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
2106 
2107 
2108 /* ********* Chaum-style RSA-based blind signatures ******************* */
2109 
2110 
2115 
2120 
2125 {
2131 };
2132 
2137 
2138 
2147 
2148 
2154 void
2156 
2157 
2166 size_t
2168  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
2169  void **buffer);
2170 
2171 
2182  size_t buf_size);
2183 
2184 
2193  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
2194 
2195 
2204  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
2205 
2206 
2213 void
2215  struct GNUNET_HashCode *hc);
2216 
2217 
2224 unsigned int
2226 
2227 
2233 void
2235 
2236 
2245 size_t
2247  const struct GNUNET_CRYPTO_RsaPublicKey *key,
2248  void **buffer);
2249 
2250 
2260 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2261 
2262 
2271 
2272 
2280 int
2282  const struct GNUNET_CRYPTO_RsaSignature *s2);
2283 
2291 int
2293  const struct
2295 
2296 
2304 int
2306  const struct GNUNET_CRYPTO_RsaPublicKey *p2);
2307 
2308 
2319 int
2320 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2321  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2323  void **buf,
2324  size_t *buf_size);
2325 
2326 
2337  const void *msg,
2338  size_t msg_len);
2339 
2340 
2350  const struct GNUNET_HashCode *hash);
2351 
2352 
2358 void
2360 
2361 
2369 size_t
2371  const struct GNUNET_CRYPTO_RsaSignature *sig,
2372  void **buffer);
2373 
2374 
2385  size_t buf_size);
2386 
2387 
2396 
2397 
2410  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2412 
2413 
2424 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2425  const struct GNUNET_CRYPTO_RsaSignature *sig,
2426  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2427 
2428 
2429 #if 0 /* keep Emacsens' auto-indent happy */
2430 {
2431 #endif
2432 #ifdef __cplusplus
2433 }
2434 #endif
2435 
2436 
2437 /* ifndef GNUNET_CRYPTO_LIB_H */
2438 #endif
2439 /* end of gnunet_crypto_lib.h */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static int res
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static pa_context * context
Pulseaudio context.
static OpusEncoder * enc
OPUS encoder.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static int result
Global testing status.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
static struct GNUNET_CRYPTO_EccDlogContext * edc
Context for DLOG operations on a curve.
static char buf[2048]
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
GNUNET_SCHEDULER_Priority
Valid task priorities.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
#define GNUNET_PACKED
gcc-ism to get packed structs.
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:1044
#define GNUNET_CRYPTO_HASH_LENGTH
Length of a hash value.
void(* GNUNET_CRYPTO_HashCompletedCallback)(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over the specified file has completed.
void GNUNET_CRYPTO_mpi_scan_unsigned(gcry_mpi_t *result, const void *data, size_t size)
Convert data buffer into MPI value.
Definition: crypto_mpi.c:131
int GNUNET_CRYPTO_paillier_hom_get_remaining(const struct GNUNET_CRYPTO_PaillierCiphertext *c)
Get the number of remaining supported homomorphic operations.
void GNUNET_CRYPTO_ecc_rnd_mpi(struct GNUNET_CRYPTO_EccScalar *r, struct GNUNET_CRYPTO_EccScalar *r_neg)
Obtain a random scalar for point multiplication on the curve and its additive inverse.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:1008
#define GNUNET_CRYPTO_PAILLIER_BITS
Size of paillier plain texts and public keys.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:960
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:321
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:224
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_dexp_mpi(const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition: crypto_rsa.c:172
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_pmul_mpi(const struct GNUNET_CRYPTO_EccPoint *p, const struct GNUNET_CRYPTO_EccScalar *val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the point p on the elliptic curve by val.
void GNUNET_CRYPTO_kdf_mod_mpi(gcry_mpi_t *r, gcry_mpi_t n, const void *xts, size_t xts_len, const void *skm, size_t skm_len, const char *ctx)
Deterministically generate a pseudo-random number uniformly from the integers modulo a libgcrypt mpi.
Definition: crypto_kdf.c:127
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:1144
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:332
int GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, const struct GNUNET_CRYPTO_EccPoint *input)
Calculate ECC discrete logarithm for small factors.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:340
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
void GNUNET_CRYPTO_ecc_scalar_from_int(int64_t val, struct GNUNET_CRYPTO_EccScalar *r)
Create a scalar from int value.
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:1063
uint16_t GNUNET_CRYPTO_crc16_finish(uint32_t sum)
Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
Definition: crypto_crc.c:144
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:571
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
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.
#define GNUNET_CRYPTO_AES_KEY_LENGTH
length of the sessionkey in bytes (256 BIT sessionkey)
char * GNUNET_CRYPTO_eddsa_public_key_to_string(const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:251
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_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:357
unsigned int GNUNET_CRYPTO_rsa_public_key_len(const struct GNUNET_CRYPTO_RsaPublicKey *key)
Obtain the length of the RSA key in bits.
Definition: crypto_rsa.c:649
int GNUNET_CRYPTO_hash_get_bit_rtl(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:180
void GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc)
Compute hash over the public key.
Definition: crypto_rsa.c:382
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_pow_hash(const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
Calculate the 'proof-of-work' hash (an expensive hash).
Definition: crypto_pow.c:41
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:267
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:398
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
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_eddsa_private_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPrivateKey *pub)
Convert a string representing a private key to a private key.
Definition: crypto_ecc.c:382
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
void GNUNET_CRYPTO_paillier_create(struct GNUNET_CRYPTO_PaillierPublicKey *public_key, struct GNUNET_CRYPTO_PaillierPrivateKey *private_key)
Create a freshly generated paillier public key.
void GNUNET_CRYPTO_eddsa_key_get_public_from_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *s, struct GNUNET_CRYPTO_EddsaPublicKey *pkey)
Extract the public key of the given private scalar.
int GNUNET_CRYPTO_rsa_private_key_cmp(const struct GNUNET_CRYPTO_RsaPrivateKey *p1, const struct GNUNET_CRYPTO_RsaPrivateKey *p2)
Compare the values of two private keys.
Definition: crypto_rsa.c:623
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:364
struct GNUNET_CRYPTO_EccDlogContext * GNUNET_CRYPTO_ecc_dlog_prepare(unsigned int max, unsigned int mem)
Do pre-calculation for ECC discrete logarithm for small factors.
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, void **buffer)
Encode the given signature in a format suitable for storing it into a file.
Definition: crypto_rsa.c:968
void GNUNET_CRYPTO_ecc_dexp(int val, struct GNUNET_CRYPTO_EccPoint *r)
Multiply the generator g of the elliptic curve by val to obtain the point on the curve representing v...
void GNUNET_CRYPTO_symmetric_derive_iv_v(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len, va_list argp)
Derive an IV.
void GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc)
Release precalculated values.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig)
Duplicate the given rsa signature.
Definition: crypto_rsa.c:1210
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:940
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.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_rnd(struct GNUNET_CRYPTO_EccPoint *r, struct GNUNET_CRYPTO_EccPoint *r_inv)
Obtain a random point on the curve and its additive inverse.
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:597
void GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccScalar *r)
Generate a random value mod n.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_private_key_get_public(const struct GNUNET_CRYPTO_RsaPrivateKey *priv)
Extract the public key of the given private key.
Definition: crypto_rsa.c:232
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_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' this be the standard hmac function and the abov...
Definition: crypto_hash.c:274
void GNUNET_CRYPTO_eddsa_sign_with_scalar(const struct GNUNET_CRYPTO_EddsaPrivateScalar *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
This is a signature function for EdDSA which takes the secret scalar sk instead of the private seed w...
char * GNUNET_CRYPTO_ecdsa_private_key_to_string(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv)
Convert a private key to a string.
Definition: crypto_ecc.c:305
char * GNUNET_CRYPTO_eddsa_private_key_to_string(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
Convert a private key to a string.
Definition: crypto_ecc.c:278
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, void **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition: crypto_rsa.c:180
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition: crypto_rsa.c:143
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:1190
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_add(const struct GNUNET_CRYPTO_EccPoint *a, const struct GNUNET_CRYPTO_EccPoint *b, struct GNUNET_CRYPTO_EccPoint *r)
Add two points on the elliptic curve.
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:916
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:759
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a public and a private ECC key.
Definition: crypto_ecc.c:705
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:435
int GNUNET_CRYPTO_eddsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EddsaSignature *sig, const struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Verify EdDSA signature.
Definition: crypto_ecc.c:682
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
void GNUNET_CRYPTO_eddsa_private_key_derive(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPrivateScalar *result)
Derive a private scalar from a given private key and a label.
void GNUNET_CRYPTO_symmetric_create_session_key(struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Create a new random session key.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
int GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:623
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.
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_random_timeflake(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_Uuid *uuid)
Fill UUID with a timeflake pseudo-random value.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:197
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private ECDSA key.
Definition: crypto_ecc.c:740
void GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:428
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdsa_sign_(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EcdsaSignature *sig)
ECDSA Sign a given block.
Definition: crypto_ecc.c:549
void GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name)
Setup a hostkey file for a peer given the name of the configuration file (!).
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a ECDH public key and a private EdDSA key.
Definition: crypto_ecc.c:718
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:481
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EcDSA public key and a private ECDH key.
Definition: crypto_ecc.c:775
void GNUNET_CRYPTO_eddsa_key_create(struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:461
void GNUNET_CRYPTO_symmetric_derive_iv(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len,...)
Derive an IV.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, const struct GNUNET_CRYPTO_EddsaPublicKey *pub, struct GNUNET_HashCode *key_material)
Derive key material from a EdDSA public key and a private ECDH key.
Definition: crypto_ecc.c:758
GNUNET_CRYPTO_Quality
Desired quality level for random numbers.
void GNUNET_CRYPTO_seed_weak_random(int32_t seed)
Seed a weak random generator.
Definition: crypto_random.c:97
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:446
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_sign_(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:599
void GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:421
void GNUNET_CRYPTO_eddsa_public_key_derive(const struct GNUNET_CRYPTO_EddsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EddsaPublicKey *result)
Derive a public key from a given public key and a label.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:186
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.
unsigned int * GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n)
Get an array with a random permutation of the numbers 0...n-1.
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
void GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:414
void GNUNET_CRYPTO_ecdhe_key_get_public(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, struct GNUNET_CRYPTO_EcdhePublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:213
ssize_t GNUNET_CRYPTO_symmetric_decrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Decrypt a given block using a symmetric sessionkey.
@ GNUNET_CRYPTO_QUALITY_STRONG
High-quality operations are desired.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
void GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = b - a
Definition: crypto_hash.c:110
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:55
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:99
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_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
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
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_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:167
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
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
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
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
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:343
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hash_from_string2(const char *enc, size_t enclen, struct GNUNET_HashCode *result)
Convert ASCII encoding back to a 'struct GNUNET_HashCode'.
Definition: crypto_hash.c:72
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
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
uint16_t GNUNET_CRYPTO_crc16_n(const void *buf, size_t len)
Calculate the checksum of a buffer in one step.
Definition: crypto_crc.c:161
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
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_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
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
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
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:67
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
Type of a nonce used for challenges.
struct GNUNET_ShortHashCode value
The value of the nonce.
type for (message) authentication keys
unsigned char key[(512/8)]
Internal structure used to cache pre-calculated values for DLOG calculation.
unsigned int mem
How much memory should we use (relates to the number of entries in the map).
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
unsigned char v[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
A ECC scalar for use in point multiplications.
unsigned char v[256/8]
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!...
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
an ECC signature using ECDSA
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Private ECC key encoded for transmission.
unsigned char d[256/8]
d is a value mod n, where n has at most 256 bits.
Private ECC scalar encoded for transmission.
unsigned char s[512/8]
s is the expandedprivate 512-bit scalar of a private key.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
unsigned char q_y[256/8]
Point Q consists of a y-value mod p (256 bits); the x-value is always positive.
an ECC signature using EdDSA.
unsigned char s[256/8]
S value.
unsigned char r[256/8]
R value.
Context used when hashing a file.
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
void * callback_cls
Closure for callback.
enum GNUNET_SCHEDULER_Priority priority
Priority we use.
0-terminated ASCII encoding of a struct GNUNET_HashCode.
int32_t remaining_ops
Guaranteed minimum number of homomorphic operations with this ciphertext, in network byte order (NBO)...
unsigned char bits[2048 *2/8]
The bits of the ciphertext.
unsigned char mu[2048/8]
Mu-component of the private key.
unsigned char lambda[2048/8]
Lambda-component of the private key.
unsigned char n[2048/8]
N value.
Value for a salt for GNUNET_CRYPTO_pow_hash().
char salt[crypto_pwhash_argon2id_SALTBYTES]
Constant-size pre-secret for blinding key generation.
uint32_t pre_secret[8]
Bits used to generate the blinding key.
The private information of an RSA key pair.
Definition: crypto_rsa.c:40
The public information of an RSA key pair.
Definition: crypto_rsa.c:52
an RSA signature
Definition: crypto_rsa.c:64
unsigned char twofish_key[(256/8)]
Actual key for TwoFish.
unsigned char aes_key[(256/8)]
Actual key for AES.
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
A 256-bit hashcode.
A UUID, a 128 bit "random" value.