From 0d66c601ee79bae8d8b175ad7dd0f0e8d5e56c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 19 Mar 2015 06:43:17 +0100 Subject: EdDSA interface change, use plain strings to represent keys. --- ed25519-sha512-sign.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'ed25519-sha512-sign.c') diff --git a/ed25519-sha512-sign.c b/ed25519-sha512-sign.c index bbcd133b..6adda235 100644 --- a/ed25519-sha512-sign.c +++ b/ed25519-sha512-sign.c @@ -1,6 +1,6 @@ /* ed25519-sha512-sign.c - Copyright (C) 2014 Niels Möller + Copyright (C) 2014, 2015 Niels Möller This file is part of GNU Nettle. @@ -39,32 +39,29 @@ #include "sha2.h" void -ed25519_sha512_set_private_key (struct ed25519_private_key *priv, - const uint8_t *key) -{ - mp_size_t itch = _eddsa_expand_key_itch (&nettle_curve25519); - mp_limb_t *scratch = gmp_alloc_limbs (itch); - struct sha512_ctx ctx; - - _eddsa_expand_key (&nettle_curve25519, &nettle_sha512, &ctx, - key, priv->pub, priv->k1, priv->k2, scratch); - gmp_free_limbs (scratch, itch); -} - -void -ed25519_sha512_sign (const struct ed25519_private_key *priv, +ed25519_sha512_sign (const uint8_t *pub, + const uint8_t *priv, size_t length, const uint8_t *msg, uint8_t *signature) { - mp_size_t itch = _eddsa_sign_itch (&nettle_curve25519); + const struct ecc_curve *ecc = &nettle_curve25519; + mp_size_t itch = ecc->q.size + _eddsa_sign_itch (&nettle_curve25519); mp_limb_t *scratch = gmp_alloc_limbs (itch); +#define k2 scratch +#define scratch_out (scratch + ecc->q.size) struct sha512_ctx ctx; + uint8_t digest[SHA512_DIGEST_SIZE]; +#define k1 (digest + ED25519_KEY_SIZE) + + _eddsa_expand_key (ecc, &nettle_sha512, &ctx, priv, digest, k2); - sha512_init (&ctx); - sha512_update (&ctx, ED25519_KEY_SIZE, priv->k1); - _eddsa_sign (&nettle_curve25519, &nettle_sha512, priv->pub, + sha512_update (&ctx, ED25519_KEY_SIZE, k1); + _eddsa_sign (&nettle_curve25519, &nettle_sha512, pub, &ctx, - priv->k2, length, msg, signature, scratch); + k2, length, msg, signature, scratch_out); gmp_free_limbs (scratch, itch); +#undef k1 +#undef k2 +#undef scratch_out } -- cgit v1.2.1