Add randombytes_buf_deterministic()

This commit is contained in:
Frank Denis
2017-02-19 18:40:29 +01:00
parent 70c2796ae5
commit cafb0a695b
6 changed files with 47 additions and 4 deletions
+17 -3
View File
@@ -27,9 +27,16 @@ static int compat_tests(void)
static int randombytes_tests(void)
{
unsigned int f = 0U;
unsigned int i;
uint32_t n;
const static unsigned char seed[randombytes_SEEDBYTES] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
};
unsigned char out[100];
unsigned int f = 0U;
unsigned int i;
uint32_t n;
#ifdef __EMSCRIPTEN__
assert(strcmp(randombytes_implementation_name(), "js") == 0);
@@ -92,6 +99,13 @@ static int randombytes_tests(void)
}
}
assert(randombytes_uniform(1U) == 0U);
randombytes_buf_deterministic(out, sizeof out, seed);
for (i = 0; i < sizeof out; ++i) {
printf("%02x", out[i]);
}
printf(" (deterministic)\n");
randombytes_close();
randombytes(x, 1U);