Updated and generalized random number generation function

(uECC_generate_random_int). This function is also used internally.
In the new implementation when the random number is outside of the
requested range it is corrected by subtraction instead of requesting
new random number.
This commit is contained in:
Evgeni Margolis
2015-10-12 21:29:57 -07:00
committed by Ken MacKay
parent 8b3838ea5f
commit 7b115fdf93
2 changed files with 60 additions and 74 deletions
+5 -2
View File
@@ -155,8 +155,11 @@ void uECC_point_mult(uECC_word_t *result,
const uECC_word_t *scalar,
uECC_Curve curve);
/* Generates a random integer r in the range 0 < r < curve->n */
int uECC_generate_random_int(uECC_word_t *random, uECC_Curve curve);
/* Generates a random integer in the range 0 < random < top.
Both, random and top, have num_words words. */
int uECC_generate_random_int(uECC_word_t *random,
const uECC_word_t *top,
wordcount_t num_words);
#endif /* uECC_ENABLE_VLI_API */