Commit 1e3b6654 authored by Niels Möller's avatar Niels Möller
Browse files

(bad_random): New global variable.

(random_generate): New fake randomness generator, replacing the
real generator for the testcases.
(lsh_random): Likewise.
(test_sign): Initialize the fake randomness generator.

Rev: src/testsuite/testutils.c:1.12
parent 1bc28032
......@@ -166,17 +166,19 @@ test_mac(const char *name,
FAIL();
}
struct bad_random
/* Bous randomness generator, for testing */
struct knuth_lfib_ctx bad_random;
void
random_generate(uint32_t length, uint8_t *dst)
{
struct randomness super;
struct knuth_lfib_ctx *ctx;
};
knuth_lfib_random(&bad_random, length, dst);
}
static void
do_bad_random(struct randomness *r, uint32_t length, uint8_t *dst)
void
lsh_random(void *ctx UNUSED, unsigned length, uint8_t *dst)
{
struct bad_random *self = (struct bad_random *) r;
knuth_lfib_random(self->ctx, length, dst);
knuth_lfib_random(&bad_random, length, dst);
}
void
......@@ -193,14 +195,9 @@ test_sign(const char *name,
uint8_t *decoded;
uint32_t key_length;
struct knuth_lfib_ctx ctx;
struct bad_random r = { { STATIC_HEADER, RANDOM_GOOD /* a lie */,
do_bad_random, NULL },
&ctx
};
knuth_lfib_init(&ctx, time(NULL));
algorithms = all_signature_algorithms(&r.super);
knuth_lfib_init(&bad_random, time(NULL));
algorithms = all_signature_algorithms();
(void) name;
key_length = lsh_string_length(key);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment