diff --git a/src/rand.c b/src/rand.c index 5d4d430..2e8f602 100644 --- a/src/rand.c +++ b/src/rand.c @@ -43,13 +43,14 @@ static mp_digit get_int_dev_random(void); static mp_digit get_int_dev_urandom(void); static mp_digit get_random_ternary(mp_digit random_int, int* sign); -static mp_int *get_random_bigint(mp_int *upper_bound, mp_int *lower_bound, +static mp_int *get_random_bigint(mp_int *upper_bound, + mp_int *lower_bound, int entropy_source); static unsigned int check_allowed_zeros(pb_poly *polynom); /** * Reads a single mp_digit out of /dev/random and returns this mp_digit - * + * * @return the randomly chosen integer */ static mp_digit get_int_dev_random(void) @@ -126,11 +127,12 @@ static mp_digit get_random_ternary(mp_digit random_int, int* sign) * entropy_source random_int TODO * @return a mp_int with the random number */ -static mp_int *get_random_bigint(mp_int *upper_bound, mp_int *lower_bound, +static mp_int *get_random_bigint(mp_int *upper_bound, + mp_int *lower_bound, int entropy_source) { - mp_int result; - init_integer(&result); + mp_int *result = NULL; + init_integer(result); //TODO @@ -193,14 +195,19 @@ pb_poly *ntru_get_random_poly_ternary(size_t length, int entropy_source) /** * Gets a random polynomial with coefficients - * from the the borders of lower_bound to upper_bound using the given entropy source + * from the the borders of lower_bound to upper_bound + * using the given entropy source * * @param length the amount of coefficients * @param entropy_source the source of entropy you want * @return newly allocated polynomial, must be freed with delete_polynom() */ -pb_poly *ntru_get_random_poly(int length, int entropy_source, mp_int *upper_bound, +pb_poly *ntru_get_random_poly(int length, + int entropy_source, + mp_int *upper_bound, mp_int *lower_bound) { //TODO + + return NULL; } diff --git a/src/rand.h b/src/rand.h index b4b073f..1741b4b 100644 --- a/src/rand.h +++ b/src/rand.h @@ -22,6 +22,7 @@ #ifndef NTRU_RAND_H #define NTRU_RAND_H + #include "context.h" #include @@ -36,8 +37,12 @@ */ #define GET_INT_FROM_RRAND 3 -pb_poly *ntru_get_random_poly_ternary(int length, int entropy_source); -pb_poly *ntru_get_random_poly(size_t length, int entropy_source, mp_int *upper_bound, + +pb_poly *ntru_get_random_poly_ternary(size_t length, int entropy_source); +pb_poly *ntru_get_random_poly(int length, + int entropy_source, + mp_int *upper_bound, mp_int *lower_bound); + #endif /* NTRU_RAND_H */