cangrepp

Some cryptographic attacks
Log | Files | Refs | README

commit ca1641f4689789764514652a855c3ce55850bdef
parent ace98028e9d3891ff28dce38464e739b79b34b8d
Author: olikru <olikru@tkruger.se>
Date:   Mon, 15 Jan 2024 17:22:16 +0100

add the first unit test

Diffstat:
Mtest_angrepp.c | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/test_angrepp.c b/test_angrepp.c @@ -2,4 +2,24 @@ #include <stdio.h> #include <stdlib.h> -int main() { printf("test unimplemented\n"); } +#include "cyclefind.h" + +//uint64_t cyclefind_floyd(uint64_t *mu, uint64_t x0, uint64_t (*f)(uint64_t)) + +static uint64_t test_f(uint64_t x) { + return (3 * x + 7) % 18; +} + +static void test_cyclefind_floyd() { + uint64_t lambda, mu; + lambda = cyclefind_floyd(&mu, 4, &test_f); + + assert(lambda == 2); + assert(mu == 1); +} + +int main() { + test_cyclefind_floyd(); + + printf("test ok\n"); +}