summaryrefslogtreecommitdiff
path: root/ed25519-sha512-verify.c
diff options
context:
space:
mode:
Diffstat (limited to 'ed25519-sha512-verify.c')
-rw-r--r--ed25519-sha512-verify.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/ed25519-sha512-verify.c b/ed25519-sha512-verify.c
index 763a9b04..fc9cd010 100644
--- a/ed25519-sha512-verify.c
+++ b/ed25519-sha512-verify.c
@@ -1,6 +1,6 @@
/* ed25519-sha512-verify.c
- Copyright (C) 2014 Niels Möller
+ Copyright (C) 2014, 2015 Niels Möller
This file is part of GNU Nettle.
@@ -41,35 +41,25 @@
#include "sha2.h"
int
-ed25519_sha512_set_public_key (struct ed25519_public_key *pub,
- const uint8_t *key)
-{
- mp_size_t itch = _eddsa_decompress_itch (&nettle_curve25519);
- mp_limb_t *scratch = gmp_alloc_limbs (itch);
- int res;
-
- memcpy (pub->pub, key, sizeof(pub->pub));
- res = _eddsa_decompress (&nettle_curve25519,
- pub->A, key, scratch);
-
- gmp_free_limbs (scratch, itch);
- return res;
-}
-
-int
-ed25519_sha512_verify (const struct ed25519_public_key *pub,
+ed25519_sha512_verify (const uint8_t *pub,
size_t length, const uint8_t *msg,
const uint8_t *signature)
{
- mp_size_t itch = _eddsa_verify_itch (&nettle_curve25519);
+ const struct ecc_curve *ecc = &nettle_curve25519;
+ mp_size_t itch = 3*ecc->p.size + _eddsa_verify_itch (&nettle_curve25519);
mp_limb_t *scratch = gmp_alloc_limbs (itch);
struct sha512_ctx ctx;
int res;
-
- res = _eddsa_verify (&nettle_curve25519, &nettle_sha512,
- pub->pub, pub->A, &ctx,
- length, msg, signature,
- scratch);
+#define A scratch
+#define scratch_out (scratch + 3*ecc->p.size)
+ res = (_eddsa_decompress (&nettle_curve25519,
+ A, pub, scratch_out)
+ && _eddsa_verify (ecc, &nettle_sha512,
+ pub, A, &ctx,
+ length, msg, signature,
+ scratch_out));
gmp_free_limbs (scratch, itch);
return res;
+#undef A
+#undef scratch_out
}