From: Mark Wooding Date: Wed, 10 May 2017 20:17:27 +0000 (+0100) Subject: pub/ed25519.c: Don't return the `h1' private-key portion if it's not wanted. X-Git-Tag: 2.4.0~8 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/commitdiff_plain/cb2f9158c60e7ba4ae333c79407e7eb4a9c48069?ds=sidebyside pub/ed25519.c: Don't return the `h1' private-key portion if it's not wanted. Saves making a temporary buffer in `ed25519_pubkey'. --- diff --git a/pub/ed25519.c b/pub/ed25519.c index 830e5de4..4680a537 100644 --- a/pub/ed25519.c +++ b/pub/ed25519.c @@ -389,7 +389,7 @@ static void unpack_key(scaf_piece a[NPIECE], octet h1[32], sha512_init(&h); sha512_hash(&h, k, ksz); sha512_done(&h, b); b[0] &= 0xf8u; b[31] = (b[31]&0x3f) | 0x40; scaf_load(a, b, 32, NPIECE, PIECEWD); - memcpy(h1, b + 32, 32); + if (h1) memcpy(h1, b + 32, 32); } /*----- Main code ---------------------------------------------------------*/ @@ -409,9 +409,8 @@ void ed25519_pubkey(octet K[ED25519_PUBSZ], const void *k, size_t ksz) { scaf_piece a[NPIECE]; f25519 AX, AY, AZ; - octet h1[32]; - unpack_key(a, h1, k, ksz); + unpack_key(a, 0, k, ksz); ptmul(&AX, &AY, &AZ, a, BX, BY, BZ); ptencode(K, &AX, &AY, &AZ); }