From 91c5ea7b82652706ab30395b76bebc1bd3ef4b76 Mon Sep 17 00:00:00 2001 From: hasufell Date: Tue, 15 Apr 2014 18:21:42 +0200 Subject: [PATCH] RAND: use unsigned long instead of mp_digit if we use mp_set_int() instead of mp_set(), then we can use full unsigned long integers instead of single digits. This seems a lot safer, especially for future versions of the random algorithm. --- src/rand.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rand.c b/src/rand.c index d698164..c33bfa7 100644 --- a/src/rand.c +++ b/src/rand.c @@ -36,7 +36,7 @@ /* * static declarations */ -static mp_digit get_urnd_int_small(int *sign); +static unsigned long get_urnd_int_small(int *sign); /** @@ -46,7 +46,7 @@ static mp_digit get_urnd_int_small(int *sign); * @param sign stores the signness [out] * @return random small integer */ -static mp_digit get_urnd_int_small(int *sign) +static unsigned long get_urnd_int_small(int *sign) { int random_data; mp_digit random_int; @@ -86,11 +86,11 @@ pb_poly *ntru_get_urnd_poly_small(ntru_context *ctx) init_polynom_size(poly, &chara, ctx->N); mp_clear(&chara); - for (int i = 0; i < ctx->N; i++) { + for (unsigned int i = 0; i < ctx->N; i++) { int sign; - int c = get_urnd_int_small(&sign); + unsigned long c = get_urnd_int_small(&sign); - mp_set(&(poly->terms[i]), (mp_digit)c); + mp_set_int(&(poly->terms[i]), c); if (sign == 1) poly->terms[i].sign = 1;