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 
189 {
195  unsigned char q_y[256 / 8];
196 };
197 
198 
204 {
209  unsigned char q_y[256 / 8];
210 };
211 
212 
217 {
218  struct GNUNET_CRYPTO_EddsaPublicKey public_key;
219 };
220 
221 
228 {
233  unsigned char q_y[256 / 8];
234 };
235 
236 
242 {
246  unsigned char d[256 / 8];
247 };
248 
254 {
258  unsigned char d[256 / 8];
259 };
260 
266 {
270  unsigned char d[256 / 8];
271 };
272 
273 
278 {
282  unsigned char aes_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
283 
287  unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH];
288 };
289 
291 
299 {
300  unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
301 
302  unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2];
303 };
304 
305 
310 {
312 };
313 
314 
319 #define GNUNET_CRYPTO_PAILLIER_BITS 2048
320 
321 
326 {
330  unsigned char n[GNUNET_CRYPTO_PAILLIER_BITS / 8];
331 };
332 
333 
338 {
342  unsigned char lambda[GNUNET_CRYPTO_PAILLIER_BITS / 8];
346  unsigned char mu[GNUNET_CRYPTO_PAILLIER_BITS / 8];
347 };
348 
349 
354 {
359  int32_t remaining_ops GNUNET_PACKED;
360 
364  unsigned char bits[GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8];
365 };
366 
367 
368 /* **************** Functions and Macros ************* */
369 
377 void
378 GNUNET_CRYPTO_seed_weak_random (int32_t seed);
379 
380 
389 uint8_t
390 GNUNET_CRYPTO_crc8_n (const void *buf, size_t len);
391 
392 
401 uint32_t
402 GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len);
403 
404 
411 uint16_t
412 GNUNET_CRYPTO_crc16_finish (uint32_t sum);
413 
414 
423 uint16_t
424 GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
425 
426 
436 int32_t
437 GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
438 
447 void
448 GNUNET_CRYPTO_zero_keys (void *buffer, size_t length);
449 
450 
459 void
461  void *buffer,
462  size_t length);
463 
472 uint32_t
474 
475 
484 uint64_t
486 
487 
497 unsigned int *
499 
500 
507 void
510 
511 
523 ssize_t
525  const void *block,
526  size_t size,
527  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
529  void *result);
530 
531 
543 ssize_t
545  const void *block,
546  size_t size,
547  const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
549  void *result);
550 
551 
561 void
564  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
565  const void *salt,
566  size_t salt_len,
567  ...);
568 
569 
578 void
581  const struct GNUNET_CRYPTO_SymmetricSessionKey *skey,
582  const void *salt,
583  size_t salt_len,
584  va_list argp);
585 
586 
594 void
595 GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
597 
598 
608 int
610  size_t enclen,
611  struct GNUNET_HashCode *result);
612 
613 
622 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
623  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
624 
625 
638 uint32_t
640  const struct GNUNET_HashCode *b);
641 
642 
651 void
652 GNUNET_CRYPTO_hash (const void *block,
653  size_t size,
654  struct GNUNET_HashCode *ret);
655 
656 
665 void
666 GNUNET_CRYPTO_pow_hash (const char *salt,
667  const void *buf,
668  size_t buf_len,
669  struct GNUNET_HashCode *result);
670 
671 
675 struct GNUNET_HashContext;
676 
677 
683 struct GNUNET_HashContext *
685 
686 
694 void
696  const void *buf,
697  size_t size);
698 
699 
706 void
708  struct GNUNET_HashCode *r_hash);
709 
710 
716 void
718 
719 
731 void
732 GNUNET_CRYPTO_hmac_raw (const void *key,
733  size_t key_len,
734  const void *plaintext,
735  size_t plaintext_len,
736  struct GNUNET_HashCode *hmac);
737 
738 
748 void
750  const void *plaintext,
751  size_t plaintext_len,
752  struct GNUNET_HashCode *hmac);
753 
754 
763  void *cls,
764  const struct GNUNET_HashCode *res);
765 
766 
771 
772 
786  const char *filename,
787  size_t blocksize,
789  void *callback_cls);
790 
791 
797 void
799 
800 
808 void
810  struct GNUNET_HashCode *result);
811 
812 
821 void
823  const struct GNUNET_HashCode *b,
824  struct GNUNET_HashCode *result);
825 
826 
835 void
836 GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a,
837  const struct GNUNET_HashCode *delta,
838  struct GNUNET_HashCode *result);
839 
840 
849 void
850 GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a,
851  const struct GNUNET_HashCode *b,
852  struct GNUNET_HashCode *result);
853 
854 
863 void
865  const struct GNUNET_HashCode *hc,
868 
869 
878 int
879 GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code,
880  unsigned int bit);
881 
882 
895 unsigned int
897  const struct GNUNET_HashCode *second);
898 
899 
909 int
910 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
911  const struct GNUNET_HashCode *h2);
912 
913 
924 int
926  const struct GNUNET_HashCode *h2,
927  const struct GNUNET_HashCode *target);
928 
929 
939 void
941  struct GNUNET_CRYPTO_AuthKey *key,
942  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
943  const void *salt,
944  size_t salt_len,
945  va_list argp);
946 
947 
957 void
959  struct GNUNET_CRYPTO_AuthKey *key,
960  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
961  const void *salt,
962  size_t salt_len,
963  ...);
964 
965 
980 int
982  size_t out_len,
983  int xtr_algo,
984  int prf_algo,
985  const void *xts,
986  size_t xts_len,
987  const void *skm,
988  size_t skm_len,
989  ...);
990 
991 
1006 int
1008  size_t out_len,
1009  int xtr_algo,
1010  int prf_algo,
1011  const void *xts,
1012  size_t xts_len,
1013  const void *skm,
1014  size_t skm_len,
1015  va_list argp);
1016 
1017 
1029 int
1031  size_t out_len,
1032  const void *xts,
1033  size_t xts_len,
1034  const void *skm,
1035  size_t skm_len,
1036  va_list argp);
1037 
1038 
1051 void
1052 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1053  gcry_mpi_t n,
1054  const void *xts,
1055  size_t xts_len,
1056  const void *skm,
1057  size_t skm_len,
1058  const char *ctx);
1059 
1060 
1073 int
1074 GNUNET_CRYPTO_kdf (void *result,
1075  size_t out_len,
1076  const void *xts,
1077  size_t xts_len,
1078  const void *skm,
1079  size_t skm_len,
1080  ...);
1081 
1082 
1090 void
1092  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1094 
1102 void
1104  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1106 
1107 
1115 void
1117  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1119 
1120 
1127 char *
1129  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1130 
1137 char *
1139  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1140 
1141 
1148 char *
1150  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1151 
1152 
1159 char *
1161  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1162 
1163 
1172 int
1174  const char *enc,
1175  size_t enclen,
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 
1226 
1227 
1245 
1246 
1251 
1252 
1264  const struct GNUNET_CONFIGURATION_Handle *cfg);
1265 
1266 
1275 
1276 
1285 
1286 
1294 int
1296 
1297 
1306 
1307 
1314 void
1316 
1317 
1324 void
1326 
1327 
1334 void
1336 
1337 
1344 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1346 
1347 
1357 void
1358 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1359 
1360 
1370 int
1372  struct GNUNET_PeerIdentity *dst);
1373 
1374 
1379 
1380 
1386 {
1391  unsigned char q_y[256 / 8];
1392 };
1393 
1394 
1403 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem);
1404 
1405 
1414 int
1416  gcry_mpi_point_t input);
1417 
1418 
1432 gcry_mpi_point_t
1434 
1435 
1445 gcry_mpi_point_t
1447  gcry_mpi_t val);
1448 
1449 
1459 gcry_mpi_point_t
1461  gcry_mpi_point_t p,
1462  gcry_mpi_t val);
1463 
1464 
1472 void
1474  gcry_mpi_point_t point,
1475  struct GNUNET_CRYPTO_EccPoint *bin);
1476 
1477 
1485 gcry_mpi_point_t
1487  const struct GNUNET_CRYPTO_EccPoint *bin);
1488 
1489 
1498 gcry_mpi_point_t
1500  gcry_mpi_point_t a,
1501  gcry_mpi_point_t b);
1502 
1503 
1513 void
1515  gcry_mpi_point_t *r,
1516  gcry_mpi_point_t *r_inv);
1517 
1518 
1527 void
1529  gcry_mpi_t *r,
1530  gcry_mpi_t *r_inv);
1531 
1532 
1539 gcry_mpi_t
1541 
1542 
1548 void
1549 GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1550 
1551 
1557 void
1559 
1560 
1570 int
1572  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1573  struct GNUNET_HashCode *key_material);
1574 
1575 
1586 int
1588  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1589  struct GNUNET_HashCode *key_material);
1590 
1601 int
1603  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1604  struct GNUNET_HashCode *key_material);
1605 
1606 
1617 int
1619  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1620  struct GNUNET_HashCode *key_material);
1621 
1632 int
1634  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1635  struct GNUNET_HashCode *key_material);
1636 
1637 
1647 int
1649  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1650  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1651  struct GNUNET_CRYPTO_EddsaSignature *sig);
1652 
1653 
1663 int
1665  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1666  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1667  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1668 
1679 int
1681  uint32_t purpose,
1682  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1683  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1684  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1685 
1686 
1697 int
1699  uint32_t purpose,
1700  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1701  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1702  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1703 
1704 
1720  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1721  const char *label,
1722  const char *context);
1723 
1724 
1736 void
1738  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1739  const char *label,
1740  const char *context,
1742 
1743 
1752 void
1753 GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
1754 
1755 
1765 void
1767  const void *data,
1768  size_t size);
1769 
1770 
1777 void
1779  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1780  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
1781 
1782 
1794 int
1796  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1797  const gcry_mpi_t m,
1798  int desired_ops,
1800 
1801 
1810 void
1812  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
1813  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1815  gcry_mpi_t m);
1816 
1817 
1831 int
1833  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1834  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
1835  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
1837 
1838 
1845 int
1847  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
1848 
1849 
1850 /* ********* Chaum-style RSA-based blind signatures ******************* */
1851 
1852 
1857 
1862 
1867 {
1872  uint32_t pre_secret[8] GNUNET_PACKED;
1873 };
1874 
1879 
1880 
1889 
1890 
1896 void
1898 
1899 
1908 size_t
1910  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
1911  char **buffer);
1912 
1913 
1923 GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, size_t len);
1924 
1925 
1934  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
1935 
1936 
1945  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
1946 
1947 
1954 void
1956  struct GNUNET_HashCode *hc);
1957 
1958 
1965 unsigned int
1967 
1968 
1974 void
1976 
1977 
1986 size_t
1988  const struct GNUNET_CRYPTO_RsaPublicKey *key,
1989  char **buffer);
1990 
1991 
2001 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2002 
2003 
2012 
2013 
2021 int
2023  struct GNUNET_CRYPTO_RsaSignature *s2);
2024 
2032 int
2034  struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2035 
2036 
2044 int
2046  struct GNUNET_CRYPTO_RsaPublicKey *p2);
2047 
2048 
2059 int
2060 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2061  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2063  char **buf,
2064  size_t *buf_size);
2065 
2066 
2077  const void *msg,
2078  size_t msg_len);
2079 
2080 
2090  const struct GNUNET_HashCode *hash);
2091 
2092 
2098 void
2100 
2101 
2109 size_t
2111  const struct GNUNET_CRYPTO_RsaSignature *sig,
2112  char **buffer);
2113 
2114 
2124 GNUNET_CRYPTO_rsa_signature_decode (const char *buf, size_t len);
2125 
2126 
2135 
2136 
2149  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2151 
2152 
2162 int
2163 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2164  const struct GNUNET_CRYPTO_RsaSignature *sig,
2165  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2166 
2167 
2168 #if 0 /* keep Emacsens' auto-indent happy */
2169 {
2170 #endif
2171 #ifdef __cplusplus
2172 }
2173 #endif
2174 
2175 
2176 /* ifndef GNUNET_CRYPTO_LIB_H */
2177 #endif
2178 /* 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:1163
int GNUNET_CRYPTO_ecdhe_key_create2(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:521
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:1071
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:615
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:979
Point on a curve (always for Curve25519) encoded in a format suitable for network transmission (ECDH)...
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
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:325
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...
#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:1126
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:776
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:1058
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:461
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:474
size_t GNUNET_CRYPTO_rsa_public_key_encode(const struct GNUNET_CRYPTO_RsaPublicKey *key, char **buffer)
Encode the public key in a format suitable for storing it into a file.
Definition: crypto_rsa.c:346
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:403
size_t GNUNET_CRYPTO_rsa_signature_encode(const struct GNUNET_CRYPTO_RsaSignature *sig, char **buffer)
Encode the given signature in a format suitable for storing it into a file.
Definition: crypto_rsa.c:1073
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:272
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_create(void)
Create a new private key.
Definition: crypto_ecc.c:538
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:745
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:875
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_CRYPTO_EcdhePrivateKey * GNUNET_CRYPTO_ecdhe_key_create(void)
Create a new private key.
Definition: crypto_ecc.c:499
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:291
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:466
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:451
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
int GNUNET_CRYPTO_rsa_private_key_cmp(struct GNUNET_CRYPTO_RsaPrivateKey *p1, struct GNUNET_CRYPTO_RsaPrivateKey *p2)
Compare the values of two private keys.
Definition: crypto_rsa.c:689
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:438
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:1033
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.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static pa_context * context
Pulseaudio context.
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:1282
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
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:687
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:1359
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create(void)
Create a new private key.
Definition: crypto_ecc.c:594
int GNUNET_CRYPTO_rsa_public_key_cmp(struct GNUNET_CRYPTO_RsaPublicKey *p1, struct GNUNET_CRYPTO_RsaPublicKey *p2)
Compare the values of two public keys.
Definition: crypto_rsa.c:656
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:844
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:1040
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:423
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:256
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:532
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_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:42
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:1101
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:1192
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:322
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:223
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:172
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:206
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:378
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_create_from_file(const char *filename)
Create a new private key by reading it from a file.
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:492
int GNUNET_CRYPTO_hash_get_bit(const struct GNUNET_HashCode *code, unsigned int bit)
Obtain a bit from a hashcode.
Definition: crypto_hash.c:251
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.
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:1333
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:189
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_rsa_signature_cmp(struct GNUNET_CRYPTO_RsaSignature *s1, struct GNUNET_CRYPTO_RsaSignature *s2)
Compare the values of two signatures.
Definition: crypto_rsa.c:623
int GNUNET_CRYPTO_rsa_blind(const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, char **buf, size_t *buf_size)
Blinds the given message with the given blinding key.
Definition: crypto_rsa.c:841
#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:390
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:487
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:357
size_t GNUNET_CRYPTO_rsa_private_key_encode(const struct GNUNET_CRYPTO_RsaPrivateKey *key, char **buffer)
Encode the private key in a format suitable for storing it into a file.
Definition: crypto_rsa.c:199
#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
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:294
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const char *buf, size_t len)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:1121
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:1002
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:289
GNUNET_CRYPTO_HashCompletedCallback callback
Function to call upon completion.
The private information of an RSA key pair.
Definition: crypto_rsa.c:39
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_file(const char *filename)
Create a new private key by reading it from a file.
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
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
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_decode(const char *buf, size_t len)
Decode the private key from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:230
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:935
#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:356
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:509
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...