aboutsummaryrefslogtreecommitdiff
path: root/src/ext/ed25519
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-08-04 12:37:48 +0300
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:34 -0400
commit4ad4467fa13a0e6333fa0016a63060d5b9dd9715 (patch)
tree2be3e046037a0983d034ab428bafdda0950f47df /src/ext/ed25519
parentb89d2fa1db2379bffd2e2b4c851c3facc57b6ed8 (diff)
downloadtor-4ad4467fa13a0e6333fa0016a63060d5b9dd9715.tar.gz
tor-4ad4467fa13a0e6333fa0016a63060d5b9dd9715.zip
Don't double hash the ed25519 blind key parameter.
We used to do: h = H(BLIND_STRING | H(A | s | B | N ) when we should be doing: h = H(BLIND_STRING | A | s | B | N) Change the logic so that hs_common.c does the hashing, and our ed25519 libraries just receive the hashed parameter ready-made. That's easier than doing the hashing on the ed25519 libraries, since that means we would have to pass them a variable-length param (depending on whether 's' is set or not). Also fix the ed25519 test vectors since they were also double hashing.
Diffstat (limited to 'src/ext/ed25519')
-rw-r--r--src/ext/ed25519/donna/ed25519_tor.c8
-rw-r--r--src/ext/ed25519/ref10/blinding.c4
2 files changed, 3 insertions, 9 deletions
diff --git a/src/ext/ed25519/donna/ed25519_tor.c b/src/ext/ed25519/donna/ed25519_tor.c
index 6bc22675ae..44ec562f02 100644
--- a/src/ext/ed25519/donna/ed25519_tor.c
+++ b/src/ext/ed25519/donna/ed25519_tor.c
@@ -245,13 +245,7 @@ ed25519_donna_sign(unsigned char *sig, const unsigned char *m, size_t mlen,
static void
ed25519_donna_gettweak(unsigned char *out, const unsigned char *param)
{
- static const char str[] = "Derive temporary signing key";
- ed25519_hash_context ctx;
-
- ed25519_hash_init(&ctx);
- ed25519_hash_update(&ctx, (const unsigned char*)str, strlen(str));
- ed25519_hash_update(&ctx, param, 32);
- ed25519_hash_final(&ctx, out);
+ memcpy(out, param, 32);
out[0] &= 248; /* Is this necessary ? */
out[31] &= 63;
diff --git a/src/ext/ed25519/ref10/blinding.c b/src/ext/ed25519/ref10/blinding.c
index 31332a2719..a3b32fa80c 100644
--- a/src/ext/ed25519/ref10/blinding.c
+++ b/src/ext/ed25519/ref10/blinding.c
@@ -12,8 +12,8 @@
static void
ed25519_ref10_gettweak(unsigned char *out, const unsigned char *param)
{
- const char str[] = "Derive temporary signing key";
- crypto_hash_sha512_2(out, (const unsigned char*)str, strlen(str), param, 32);
+ memcpy(out, param, 32);
+
out[0] &= 248; /* Is this necessary necessary ? */
out[31] &= 63;
out[31] |= 64;