From a78c9459fda9204b870350a3e075cd78d448fca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 22 Sep 2014 12:39:19 +0200 Subject: Introduced struct ecc_modulo. --- ecc-hash.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ecc-hash.c') diff --git a/ecc-hash.c b/ecc-hash.c index 547e8dbd..780d0a66 100644 --- a/ecc-hash.c +++ b/ecc-hash.c @@ -47,17 +47,20 @@ Requires ecc->size + 1 limbs, the extra limb may be needed for unusual limb sizes. */ + +/* FIXME: Take a struct ecc_modulo * as argument, and it would make + more sense to pass q than p. */ void ecc_hash (const struct ecc_curve *ecc, mp_limb_t *hp, size_t length, const uint8_t *digest) { - if (length > ((size_t) ecc->bit_size + 7) / 8) - length = (ecc->bit_size + 7) / 8; + if (length > ((size_t) ecc->p.bit_size + 7) / 8) + length = (ecc->p.bit_size + 7) / 8; - mpn_set_base256 (hp, ecc->size + 1, digest, length); + mpn_set_base256 (hp, ecc->p.size + 1, digest, length); - if (8 * length > ecc->bit_size) + if (8 * length > ecc->p.bit_size) /* We got a few extra bits, at the low end. Discard them. */ - mpn_rshift (hp, hp, ecc->size + 1, 8*length - ecc->bit_size); + mpn_rshift (hp, hp, ecc->p.size + 1, 8*length - ecc->p.bit_size); } -- cgit v1.2.1