diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gnsrecord/test_gnsrecord_crypto.c | 14 | ||||
-rw-r--r-- | src/util/crypto_ecc_gnsrecord.c | 22 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c index 9394f562d..b9b2b5ba5 100644 --- a/src/gnsrecord/test_gnsrecord_crypto.c +++ b/src/gnsrecord/test_gnsrecord_crypto.c | |||
@@ -148,15 +148,29 @@ run (void *cls, | |||
148 | { | 148 | { |
149 | struct GNUNET_IDENTITY_PrivateKey privkey; | 149 | struct GNUNET_IDENTITY_PrivateKey privkey; |
150 | struct GNUNET_IDENTITY_PrivateKey privkey_ed; | 150 | struct GNUNET_IDENTITY_PrivateKey privkey_ed; |
151 | struct GNUNET_TIME_Absolute start; | ||
152 | struct GNUNET_TIME_Absolute end; | ||
151 | 153 | ||
152 | 154 | ||
153 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); | 155 | privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY); |
154 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); | 156 | GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key); |
157 | start = GNUNET_TIME_absolute_get (); | ||
155 | test_with_type (&privkey); | 158 | test_with_type (&privkey); |
159 | end = GNUNET_TIME_absolute_get (); | ||
160 | printf ("Time: %llu ms\n", (unsigned long long) | ||
161 | GNUNET_TIME_absolute_get_difference (start, | ||
162 | end).rel_value_us); | ||
156 | 163 | ||
157 | privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY); | 164 | privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY); |
158 | GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key); | 165 | GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key); |
166 | start = GNUNET_TIME_absolute_get (); | ||
159 | test_with_type(&privkey_ed); | 167 | test_with_type(&privkey_ed); |
168 | end = GNUNET_TIME_absolute_get (); | ||
169 | printf ("Time: %llu ms\n", (unsigned long long) | ||
170 | GNUNET_TIME_absolute_get_difference (start, | ||
171 | end).rel_value_us); | ||
172 | |||
173 | |||
160 | } | 174 | } |
161 | 175 | ||
162 | 176 | ||
diff --git a/src/util/crypto_ecc_gnsrecord.c b/src/util/crypto_ecc_gnsrecord.c index 213f05863..93bd9907e 100644 --- a/src/util/crypto_ecc_gnsrecord.c +++ b/src/util/crypto_ecc_gnsrecord.c | |||
@@ -115,7 +115,7 @@ GNUNET_CRYPTO_eddsa_sign_with_scalar ( | |||
115 | * derived private scalar. | 115 | * derived private scalar. |
116 | */ | 116 | */ |
117 | crypto_scalarmult_ed25519_base_noclamp (zk, | 117 | crypto_scalarmult_ed25519_base_noclamp (zk, |
118 | priv->s); | 118 | sk); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Calculate r: | 121 | * Calculate r: |
@@ -163,16 +163,9 @@ GNUNET_CRYPTO_eddsa_sign_with_scalar ( | |||
163 | crypto_core_ed25519_scalar_reduce (hram_mod, hram); | 163 | crypto_core_ed25519_scalar_reduce (hram_mod, hram); |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Clamp the private scalar | 166 | * Calculate |
167 | */ | 167 | * S := r + hram * s mod L |
168 | sk[0] &= 248; | 168 | */ |
169 | sk[31] &= 127; | ||
170 | sk[31] |= 64; | ||
171 | |||
172 | /** | ||
173 | * Calculate | ||
174 | * S := r + hram * s mod L | ||
175 | */ | ||
176 | crypto_core_ed25519_scalar_mul (tmp, hram_mod, sk); | 169 | crypto_core_ed25519_scalar_mul (tmp, hram_mod, sk); |
177 | crypto_core_ed25519_scalar_add (sig->s, tmp, r_mod); | 170 | crypto_core_ed25519_scalar_add (sig->s, tmp, r_mod); |
178 | 171 | ||
@@ -328,7 +321,6 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
328 | */ | 321 | */ |
329 | derive_h (&pub, sizeof (pub), label, context, &hc); | 322 | derive_h (&pub, sizeof (pub), label, context, &hc); |
330 | GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc)); | 323 | GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc)); |
331 | |||
332 | h_mod_n = gcry_mpi_new (256); | 324 | h_mod_n = gcry_mpi_new (256); |
333 | gcry_mpi_mod (h_mod_n, h, n); | 325 | gcry_mpi_mod (h_mod_n, h, n); |
334 | /* Convert scalar to big endian for libgcrypt */ | 326 | /* Convert scalar to big endian for libgcrypt */ |
@@ -368,12 +360,6 @@ GNUNET_CRYPTO_eddsa_private_key_derive ( | |||
368 | /* Convert to little endian for libsodium */ | 360 | /* Convert to little endian for libsodium */ |
369 | for (size_t i = 0; i < 32; i++) | 361 | for (size_t i = 0; i < 32; i++) |
370 | result->s[i] = dc[31 - i]; | 362 | result->s[i] = dc[31 - i]; |
371 | /** | ||
372 | * Clamp the scalar | ||
373 | */ | ||
374 | result->s[0] &= 248; | ||
375 | result->s[31] &= 127; | ||
376 | result->s[31] |= 64; | ||
377 | 363 | ||
378 | sodium_memzero (dc, sizeof(dc)); | 364 | sodium_memzero (dc, sizeof(dc)); |
379 | gcry_mpi_release (d); | 365 | gcry_mpi_release (d); |