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

Add a compile-time switch to use secret key values directly #850

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions src/libsodium/crypto_sign/ed25519/ref10/keypair.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk,
{
ge25519_p3 A;

#ifdef ED25519_NOSHA512SK
memcpy(sk, seed, 32);
#else
crypto_hash_sha512(sk, seed, 32);
#endif
sk[0] &= 248;
sk[31] &= 127;
sk[31] |= 64;
Expand Down Expand Up @@ -72,7 +76,11 @@ crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk,
{
unsigned char h[crypto_hash_sha512_BYTES];

#ifdef ED25519_NOSHA512SK
memcpy(h, ed25519_sk, 32);
#else
crypto_hash_sha512(h, ed25519_sk, 32);
#endif
h[0] &= 248;
h[31] &= 127;
h[31] |= 64;
Expand Down
5 changes: 5 additions & 0 deletions src/libsodium/crypto_sign/ed25519/ref10/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ _crypto_sign_ed25519_detached(unsigned char *sig, unsigned long long *siglen_p,

_crypto_sign_ed25519_ref10_hinit(&hs, prehashed);

#ifdef ED25519_NOSHA512SK
memcpy( az, sk, 32 );
memcpy( az + 32, sk, 32 );
#else
crypto_hash_sha512(az, sk, 32);
#endif
#ifdef ED25519_NONDETERMINISTIC
_crypto_sign_ed25519_synthetic_r_hv(&hs, nonce /* Z */, az);
#else
Expand Down