From c0ea0a1f957c14bee8469b71db6e12e6f505caaf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Wed, 25 Mar 2015 22:26:24 +0100
Subject: [PATCH] Fixed allocation bug and overwrite in
 ed25519_sha512_public_key.

---
 ChangeLog               | 5 +++++
 ed25519-sha512-pubkey.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f6b2808b..59f54d5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-25  Niels Möller  <nisse@diamant.hack.org>
+
+	* ed25519-sha512-pubkey.c: Fix stack overwrite. The digest array
+	must have room for a complete sha512 digest.
+
 2015-03-19  Niels Möller  <nisse@diamant.hack.org>
 
 	* Makefile.in (OPT_HOGWEED_SOURCES): Deleted make variable.
diff --git a/ed25519-sha512-pubkey.c b/ed25519-sha512-pubkey.c
index 677759c3..438446e2 100644
--- a/ed25519-sha512-pubkey.c
+++ b/ed25519-sha512-pubkey.c
@@ -43,7 +43,7 @@ ed25519_sha512_public_key (uint8_t *pub, const uint8_t *priv)
 {
   const struct ecc_curve *ecc = &_nettle_curve25519;
   struct sha512_ctx ctx;
-  uint8_t digest[ED25519_KEY_SIZE];
+  uint8_t digest[SHA512_DIGEST_SIZE];
   mp_size_t itch = ecc->q.size + _eddsa_public_key_itch (ecc);
   mp_limb_t *scratch = gmp_alloc_limbs (itch);
 
-- 
GitLab