diff options
author | Niels Möller <nisse@lysator.liu.se> | 2015-03-19 06:43:17 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2015-03-19 06:43:17 +0100 |
commit | 0d66c601ee79bae8d8b175ad7dd0f0e8d5e56c45 (patch) | |
tree | 4ac4de05e0b3a086e07a30edc1ee929854e4adb4 /ed25519-sha512-sign.c | |
parent | 7fdb2fec724c0504a67c8a41da26984132d63d1c (diff) | |
download | nettle-0d66c601ee79bae8d8b175ad7dd0f0e8d5e56c45.tar.gz |
EdDSA interface change, use plain strings to represent keys.
Diffstat (limited to 'ed25519-sha512-sign.c')
-rw-r--r-- | ed25519-sha512-sign.c | 37 |
1 files changed, 17 insertions, 20 deletions
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 } |