Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedicate a full r hash block to attacker unknown bytes #1368

Merged
merged 5 commits into from
Nov 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ed25519-donna/ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,22 @@ ED25519_FN(ed25519_sign) (const unsigned char *m, size_t mlen, const ed25519_sec
ge25519 ALIGN(16) R;
hash_512bits extsk, hashr, hram;
unsigned char randr[32];
static const unsigned char rzero[64] = {0};
rkeene marked this conversation as resolved.
Show resolved Hide resolved

ed25519_extsk(extsk, sk);

/* r = H(aExt[32..64], randr, m) */
/* r = H(aExt[32..63], randr[0..31], zero[0..63], m) */
ed25519_hash_init(&ctx);
ed25519_hash_update(&ctx, extsk + 32, 32);
ed25519_randombytes_unsafe(randr, 32);
ed25519_hash_update(&ctx, randr, 32);
/*
* Pad the rest of the hash block (which is 128
* bytes in size in our case) with zeros.
* This puts the message (possibly known to a side
* channel attacker) in a separate block.
*/
ed25519_hash_update(&ctx, rzero, 64);
ed25519_hash_update(&ctx, m, mlen);
ed25519_hash_final(&ctx, hashr);
expand256_modm(r, hashr, 64);
Expand Down