summaryrefslogtreecommitdiff
path: root/ecc-hash.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2014-09-22 12:39:19 +0200
committerNiels Möller <nisse@lysator.liu.se>2014-09-22 12:39:19 +0200
commita78c9459fda9204b870350a3e075cd78d448fca2 (patch)
tree5570986a3a7ee931bc4a43b47b6fa62b6133e8cc /ecc-hash.c
parent2b552abd4edc775de854014c7b0135902ca2ecd3 (diff)
downloadnettle-a78c9459fda9204b870350a3e075cd78d448fca2.tar.gz
Introduced struct ecc_modulo.
Diffstat (limited to 'ecc-hash.c')
-rw-r--r--ecc-hash.c13
1 files changed, 8 insertions, 5 deletions
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);
}