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 
880 int
881 GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code,
882  unsigned int bit);
883 
884 
897 unsigned int
899  const struct GNUNET_HashCode *second);
900 
901 
911 int
912 GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1,
913  const struct GNUNET_HashCode *h2);
914 
915 
926 int
928  const struct GNUNET_HashCode *h2,
929  const struct GNUNET_HashCode *target);
930 
931 
941 void
943  struct GNUNET_CRYPTO_AuthKey *key,
944  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
945  const void *salt,
946  size_t salt_len,
947  va_list argp);
948 
949 
959 void
961  struct GNUNET_CRYPTO_AuthKey *key,
962  const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
963  const void *salt,
964  size_t salt_len,
965  ...);
966 
967 
982 int
984  size_t out_len,
985  int xtr_algo,
986  int prf_algo,
987  const void *xts,
988  size_t xts_len,
989  const void *skm,
990  size_t skm_len,
991  ...);
992 
993 
1008 int
1010  size_t out_len,
1011  int xtr_algo,
1012  int prf_algo,
1013  const void *xts,
1014  size_t xts_len,
1015  const void *skm,
1016  size_t skm_len,
1017  va_list argp);
1018 
1019 
1031 int
1033  size_t out_len,
1034  const void *xts,
1035  size_t xts_len,
1036  const void *skm,
1037  size_t skm_len,
1038  va_list argp);
1039 
1040 
1053 void
1054 GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
1055  gcry_mpi_t n,
1056  const void *xts,
1057  size_t xts_len,
1058  const void *skm,
1059  size_t skm_len,
1060  const char *ctx);
1061 
1062 
1075 int
1076 GNUNET_CRYPTO_kdf (void *result,
1077  size_t out_len,
1078  const void *xts,
1079  size_t xts_len,
1080  const void *skm,
1081  size_t skm_len,
1082  ...);
1083 
1084 
1092 void
1094  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1096 
1104 void
1106  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1108 
1109 
1117 void
1119  const struct GNUNET_CRYPTO_EcdhePrivateKey *priv,
1121 
1122 
1129 char *
1131  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1132 
1139 char *
1141  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv);
1142 
1143 
1150 char *
1152  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv);
1153 
1154 
1161 char *
1163  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1164 
1165 
1174 int
1176  const char *enc,
1177  size_t enclen,
1179 
1180 
1189 int
1191  const char *enc,
1192  size_t enclen,
1194 
1195 
1204 int
1206  const char *enc,
1207  size_t enclen,
1209 
1210 
1228 
1229 
1247 
1248 
1253 
1254 
1266  const struct GNUNET_CONFIGURATION_Handle *cfg);
1267 
1268 
1277 
1278 
1287 
1288 
1296 int
1298 
1299 
1308 
1309 
1316 void
1318 
1319 
1326 void
1328 
1329 
1336 void
1338 
1339 
1346 const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1348 
1349 
1359 void
1360 GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name);
1361 
1362 
1372 int
1374  struct GNUNET_PeerIdentity *dst);
1375 
1376 
1381 
1382 
1388 {
1393  unsigned char q_y[256 / 8];
1394 };
1395 
1396 
1405 GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem);
1406 
1407 
1416 int
1418  gcry_mpi_point_t input);
1419 
1420 
1434 gcry_mpi_point_t
1436 
1437 
1447 gcry_mpi_point_t
1449  gcry_mpi_t val);
1450 
1451 
1461 gcry_mpi_point_t
1463  gcry_mpi_point_t p,
1464  gcry_mpi_t val);
1465 
1466 
1474 void
1476  gcry_mpi_point_t point,
1477  struct GNUNET_CRYPTO_EccPoint *bin);
1478 
1479 
1487 gcry_mpi_point_t
1489  const struct GNUNET_CRYPTO_EccPoint *bin);
1490 
1491 
1500 gcry_mpi_point_t
1502  gcry_mpi_point_t a,
1503  gcry_mpi_point_t b);
1504 
1505 
1515 void
1517  gcry_mpi_point_t *r,
1518  gcry_mpi_point_t *r_inv);
1519 
1520 
1529 void
1531  gcry_mpi_t *r,
1532  gcry_mpi_t *r_inv);
1533 
1534 
1541 gcry_mpi_t
1543 
1544 
1550 void
1551 GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p);
1552 
1553 
1559 void
1561 
1562 
1572 int
1574  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1575  struct GNUNET_HashCode *key_material);
1576 
1577 
1588 int
1590  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1591  struct GNUNET_HashCode *key_material);
1592 
1603 int
1605  const struct GNUNET_CRYPTO_EcdhePublicKey *pub,
1606  struct GNUNET_HashCode *key_material);
1607 
1608 
1619 int
1621  const struct GNUNET_CRYPTO_EddsaPublicKey *pub,
1622  struct GNUNET_HashCode *key_material);
1623 
1634 int
1636  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1637  struct GNUNET_HashCode *key_material);
1638 
1639 
1649 int
1651  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
1652  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1653  struct GNUNET_CRYPTO_EddsaSignature *sig);
1654 
1655 
1665 int
1667  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1668  const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
1669  struct GNUNET_CRYPTO_EcdsaSignature *sig);
1670 
1681 int
1683  uint32_t purpose,
1684  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1685  const struct GNUNET_CRYPTO_EddsaSignature *sig,
1686  const struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1687 
1688 
1699 int
1701  uint32_t purpose,
1702  const struct GNUNET_CRYPTO_EccSignaturePurpose *validate,
1703  const struct GNUNET_CRYPTO_EcdsaSignature *sig,
1704  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub);
1705 
1706 
1722  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv,
1723  const char *label,
1724  const char *context);
1725 
1726 
1738 void
1740  const struct GNUNET_CRYPTO_EcdsaPublicKey *pub,
1741  const char *label,
1742  const char *context,
1744 
1745 
1754 void
1755 GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val);
1756 
1757 
1767 void
1769  const void *data,
1770  size_t size);
1771 
1772 
1779 void
1781  struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1782  struct GNUNET_CRYPTO_PaillierPrivateKey *private_key);
1783 
1784 
1796 int
1798  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1799  const gcry_mpi_t m,
1800  int desired_ops,
1802 
1803 
1812 void
1814  const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key,
1815  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1817  gcry_mpi_t m);
1818 
1819 
1833 int
1835  const struct GNUNET_CRYPTO_PaillierPublicKey *public_key,
1836  const struct GNUNET_CRYPTO_PaillierCiphertext *c1,
1837  const struct GNUNET_CRYPTO_PaillierCiphertext *c2,
1839 
1840 
1847 int
1849  const struct GNUNET_CRYPTO_PaillierCiphertext *c);
1850 
1851 
1852 /* ********* Chaum-style RSA-based blind signatures ******************* */
1853 
1854 
1859 
1864 
1869 {
1874  uint32_t pre_secret[8] GNUNET_PACKED;
1875 };
1876 
1881 
1882 
1891 
1892 
1898 void
1900 
1901 
1910 size_t
1912  const struct GNUNET_CRYPTO_RsaPrivateKey *key,
1913  void **buffer);
1914 
1915 
1926  size_t buf_size);
1927 
1928 
1937  const struct GNUNET_CRYPTO_RsaPrivateKey *key);
1938 
1939 
1948  const struct GNUNET_CRYPTO_RsaPrivateKey *priv);
1949 
1950 
1957 void
1959  struct GNUNET_HashCode *hc);
1960 
1961 
1968 unsigned int
1970 
1971 
1977 void
1979 
1980 
1989 size_t
1991  const struct GNUNET_CRYPTO_RsaPublicKey *key,
1992  void **buffer);
1993 
1994 
2004 GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len);
2005 
2006 
2015 
2016 
2024 int
2026  struct GNUNET_CRYPTO_RsaSignature *s2);
2027 
2035 int
2037  struct GNUNET_CRYPTO_RsaPrivateKey *p2);
2038 
2039 
2047 int
2049  struct GNUNET_CRYPTO_RsaPublicKey *p2);
2050 
2051 
2062 int
2063 GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash,
2064  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2066  void **buf,
2067  size_t *buf_size);
2068 
2069 
2080  const void *msg,
2081  size_t msg_len);
2082 
2083 
2093  const struct GNUNET_HashCode *hash);
2094 
2095 
2101 void
2103 
2104 
2112 size_t
2114  const struct GNUNET_CRYPTO_RsaSignature *sig,
2115  void **buffer);
2116 
2117 
2128  size_t buf_size);
2129 
2130 
2139 
2140 
2153  const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks,
2155 
2156 
2166 int
2167 GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash,
2168  const struct GNUNET_CRYPTO_RsaSignature *sig,
2169  const struct GNUNET_CRYPTO_RsaPublicKey *public_key);
2170 
2171 
2172 #if 0 /* keep Emacsens' auto-indent happy */
2173 {
2174 #endif
2175 #ifdef __cplusplus
2176 }
2177 #endif
2178 
2179 
2180 /* ifndef GNUNET_CRYPTO_LIB_H */
2181 #endif
2182 /* 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_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
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: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...
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: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: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: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
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
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
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: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: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
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:1362
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: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: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: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: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:1336
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
#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
#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
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...
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
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: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...