summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-05-03 12:24:53 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-05-03 12:24:53 +0200
commit9b1065bcad0e82350e3e72e474ae425293defe42 (patch)
tree662a612de10cbc4b195b0161680f3a2cf3198d7d
parentae3ce5eaf5df138e41337c7cf4d964a031b3008d (diff)
-remove (hopefully) unnecessary clamping
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c14
-rw-r--r--src/util/crypto_ecc_gnsrecord.c22
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,
{
struct GNUNET_IDENTITY_PrivateKey privkey;
struct GNUNET_IDENTITY_PrivateKey privkey_ed;
+ struct GNUNET_TIME_Absolute start;
+ struct GNUNET_TIME_Absolute end;
privkey.type = htonl (GNUNET_GNSRECORD_TYPE_PKEY);
GNUNET_CRYPTO_ecdsa_key_create (&privkey.ecdsa_key);
+ start = GNUNET_TIME_absolute_get ();
test_with_type (&privkey);
+ end = GNUNET_TIME_absolute_get ();
+ printf ("Time: %llu ms\n", (unsigned long long)
+ GNUNET_TIME_absolute_get_difference (start,
+ end).rel_value_us);
privkey_ed.type = htonl (GNUNET_GNSRECORD_TYPE_EDKEY);
GNUNET_CRYPTO_eddsa_key_create (&privkey_ed.eddsa_key);
+ start = GNUNET_TIME_absolute_get ();
test_with_type(&privkey_ed);
+ end = GNUNET_TIME_absolute_get ();
+ printf ("Time: %llu ms\n", (unsigned long long)
+ GNUNET_TIME_absolute_get_difference (start,
+ end).rel_value_us);
+
+
}
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 (
* derived private scalar.
*/
crypto_scalarmult_ed25519_base_noclamp (zk,
- priv->s);
+ sk);
/**
* Calculate r:
@@ -163,16 +163,9 @@ GNUNET_CRYPTO_eddsa_sign_with_scalar (
crypto_core_ed25519_scalar_reduce (hram_mod, hram);
/**
- * Clamp the private scalar
- */
- sk[0] &= 248;
- sk[31] &= 127;
- sk[31] |= 64;
-
- /**
- * Calculate
- * S := r + hram * s mod L
- */
+ * Calculate
+ * S := r + hram * s mod L
+ */
crypto_core_ed25519_scalar_mul (tmp, hram_mod, sk);
crypto_core_ed25519_scalar_add (sig->s, tmp, r_mod);
@@ -328,7 +321,6 @@ GNUNET_CRYPTO_eddsa_private_key_derive (
*/
derive_h (&pub, sizeof (pub), label, context, &hc);
GNUNET_CRYPTO_mpi_scan_unsigned (&h, (unsigned char *) &hc, sizeof(hc));
-
h_mod_n = gcry_mpi_new (256);
gcry_mpi_mod (h_mod_n, h, n);
/* Convert scalar to big endian for libgcrypt */
@@ -368,12 +360,6 @@ GNUNET_CRYPTO_eddsa_private_key_derive (
/* Convert to little endian for libsodium */
for (size_t i = 0; i < 32; i++)
result->s[i] = dc[31 - i];
- /**
- * Clamp the scalar
- */
- result->s[0] &= 248;
- result->s[31] &= 127;
- result->s[31] |= 64;
sodium_memzero (dc, sizeof(dc));
gcry_mpi_release (d);