aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_ksk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_ksk.c')
-rw-r--r--src/util/crypto_ksk.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/util/crypto_ksk.c b/src/util/crypto_ksk.c
index 274457b61..0c091099e 100644
--- a/src/util/crypto_ksk.c
+++ b/src/util/crypto_ksk.c
@@ -70,11 +70,11 @@ struct GNUNET_CRYPTO_RsaPrivateKey
70 70
71 71
72static void 72static void
73mpz_randomize (gcry_mpi_t n, unsigned int nbits, GNUNET_HashCode * rnd) 73mpz_randomize (gcry_mpi_t n, unsigned int nbits, struct GNUNET_HashCode * rnd)
74{ 74{
75 GNUNET_HashCode hc; 75 struct GNUNET_HashCode hc;
76 GNUNET_HashCode tmp; 76 struct GNUNET_HashCode tmp;
77 int bits_per_hc = sizeof (GNUNET_HashCode) * 8; 77 int bits_per_hc = sizeof (struct GNUNET_HashCode) * 8;
78 int cnt; 78 int cnt;
79 int i; 79 int i;
80 80
@@ -88,8 +88,8 @@ mpz_randomize (gcry_mpi_t n, unsigned int nbits, GNUNET_HashCode * rnd)
88 int j; 88 int j;
89 89
90 if (i > 0) 90 if (i > 0)
91 GNUNET_CRYPTO_hash (&hc, sizeof (GNUNET_HashCode), &tmp); 91 GNUNET_CRYPTO_hash (&hc, sizeof (struct GNUNET_HashCode), &tmp);
92 for (j = 0; j < sizeof (GNUNET_HashCode) / sizeof (uint32_t); j++) 92 for (j = 0; j < sizeof (struct GNUNET_HashCode) / sizeof (uint32_t); j++)
93 { 93 {
94#if HAVE_GCRY_MPI_LSHIFT 94#if HAVE_GCRY_MPI_LSHIFT
95 gcry_mpi_lshift (n, n, sizeof (uint32_t) * 8); 95 gcry_mpi_lshift (n, n, sizeof (uint32_t) * 8);
@@ -101,7 +101,7 @@ mpz_randomize (gcry_mpi_t n, unsigned int nbits, GNUNET_HashCode * rnd)
101 } 101 }
102 hc = tmp; 102 hc = tmp;
103 } 103 }
104 GNUNET_CRYPTO_hash (&hc, sizeof (GNUNET_HashCode), rnd); 104 GNUNET_CRYPTO_hash (&hc, sizeof (struct GNUNET_HashCode), rnd);
105 i = gcry_mpi_get_nbits (n); 105 i = gcry_mpi_get_nbits (n);
106 while (i > nbits) 106 while (i > nbits)
107 gcry_mpi_clear_bit (n, --i); 107 gcry_mpi_clear_bit (n, --i);
@@ -137,7 +137,7 @@ mpz_tdiv_q_2exp (gcry_mpi_t q, gcry_mpi_t n, unsigned int b)
137 * Return true if n is probably a prime 137 * Return true if n is probably a prime
138 */ 138 */
139static int 139static int
140is_prime (gcry_mpi_t n, int steps, GNUNET_HashCode * hc) 140is_prime (gcry_mpi_t n, int steps, struct GNUNET_HashCode * hc)
141{ 141{
142 gcry_mpi_t x; 142 gcry_mpi_t x;
143 gcry_mpi_t y; 143 gcry_mpi_t y;
@@ -218,7 +218,7 @@ adjust (unsigned char *buf, size_t size, size_t target)
218 218
219 219
220static void 220static void
221gen_prime (gcry_mpi_t * ptest, unsigned int nbits, GNUNET_HashCode * hc) 221gen_prime (gcry_mpi_t * ptest, unsigned int nbits, struct GNUNET_HashCode * hc)
222{ 222{
223 /* Note: 2 is not included because it can be tested more easily by 223 /* Note: 2 is not included because it can be tested more easily by
224 * looking at bit 0. The last entry in this list is marked by a zero */ 224 * looking at bit 0. The last entry in this list is marked by a zero */
@@ -400,7 +400,7 @@ gen_prime (gcry_mpi_t * ptest, unsigned int nbits, GNUNET_HashCode * hc)
400 */ 400 */
401static void 401static void
402generate_kblock_key (KBlock_secret_key *sk, unsigned int nbits, 402generate_kblock_key (KBlock_secret_key *sk, unsigned int nbits,
403 GNUNET_HashCode * hc) 403 struct GNUNET_HashCode * hc)
404{ 404{
405 gcry_mpi_t t1, t2; 405 gcry_mpi_t t1, t2;
406 gcry_mpi_t phi; /* helper: (p-1)(q-1) */ 406 gcry_mpi_t phi; /* helper: (p-1)(q-1) */
@@ -490,10 +490,10 @@ GNUNET_NETWORK_STRUCT_END
490 * given HashCode as input to the PRNG. 490 * given HashCode as input to the PRNG.
491 */ 491 */
492static struct KskRsaPrivateKeyBinaryEncoded * 492static struct KskRsaPrivateKeyBinaryEncoded *
493makeKblockKeyInternal (const GNUNET_HashCode * hc) 493makeKblockKeyInternal (const struct GNUNET_HashCode * hc)
494{ 494{
495 KBlock_secret_key sk; 495 KBlock_secret_key sk;
496 GNUNET_HashCode hx; 496 struct GNUNET_HashCode hx;
497 unsigned char *pbu[6]; 497 unsigned char *pbu[6];
498 gcry_mpi_t *pkv[6]; 498 gcry_mpi_t *pkv[6];
499 size_t sizes[6]; 499 size_t sizes[6];
@@ -564,7 +564,7 @@ struct KBlockKeyCacheLine
564 /** 564 /**
565 * Hash from which the key was generated. 565 * Hash from which the key was generated.
566 */ 566 */
567 GNUNET_HashCode hc; 567 struct GNUNET_HashCode hc;
568 568
569 /** 569 /**
570 * The encoded key. 570 * The encoded key.
@@ -594,13 +594,13 @@ static unsigned int cacheSize;
594 * @return corresponding private key; must not be freed! 594 * @return corresponding private key; must not be freed!
595 */ 595 */
596struct GNUNET_CRYPTO_RsaPrivateKey * 596struct GNUNET_CRYPTO_RsaPrivateKey *
597GNUNET_CRYPTO_rsa_key_create_from_hash (const GNUNET_HashCode * hc) 597GNUNET_CRYPTO_rsa_key_create_from_hash (const struct GNUNET_HashCode * hc)
598{ 598{
599 struct KBlockKeyCacheLine *line; 599 struct KBlockKeyCacheLine *line;
600 unsigned int i; 600 unsigned int i;
601 601
602 for (i = 0; i < cacheSize; i++) 602 for (i = 0; i < cacheSize; i++)
603 if (0 == memcmp (hc, &cache[i]->hc, sizeof (GNUNET_HashCode))) 603 if (0 == memcmp (hc, &cache[i]->hc, sizeof (struct GNUNET_HashCode)))
604 return GNUNET_CRYPTO_rsa_decode_key ((const char*) cache[i]->pke, 604 return GNUNET_CRYPTO_rsa_decode_key ((const char*) cache[i]->pke,
605 ntohs (cache[i]->pke->len)); 605 ntohs (cache[i]->pke->len));
606 line = GNUNET_malloc (sizeof (struct KBlockKeyCacheLine)); 606 line = GNUNET_malloc (sizeof (struct KBlockKeyCacheLine));