From 69054316e9429e95168de7fa3388b416de85c432 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 22 Jul 2021 01:27:04 +0200 Subject: WIP extend prng to 2 outputs --- src/prng.h | 2 +- src/prng_mbed.c | 4 +++- src/prng_md5.c | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/prng.h b/src/prng.h index 5a3da02..9c32d08 100644 --- a/src/prng.h +++ b/src/prng.h @@ -24,4 +24,4 @@ prng_context_t *prng_alloc(); void prng_setup(prng_context_t *ctx); void prng_starts(prng_context_t *ctx); void prng_update(prng_context_t *ctx, const uint8_t *input, size_t ilen); -void prng_finish(prng_context_t *ctx, uint8_t *output); +void prng_finish(prng_context_t *ctx, uint8_t *output, uint8_t *output2); diff --git a/src/prng_mbed.c b/src/prng_mbed.c index ae5d3b8..7a3a6d1 100644 --- a/src/prng_mbed.c +++ b/src/prng_mbed.c @@ -52,11 +52,13 @@ void prng_update(prng_context_t *ctx, const uint8_t *input, size_t ilen) mbedtls_md_update(&ctx->md, (const unsigned char *) input, ilen); } -void prng_finish(prng_context_t *ctx, uint8_t *output) +void prng_finish(prng_context_t *ctx, uint8_t *output, uint8_t *output2) { uint8_t tmp[160]; mbedtls_md_finish(&ctx->md, tmp); memcpy(output, tmp, 8); + if (output2) + memcpy(output2, tmp + 8, 8); } #if 0 diff --git a/src/prng_md5.c b/src/prng_md5.c index 77682a2..21199d4 100644 --- a/src/prng_md5.c +++ b/src/prng_md5.c @@ -49,11 +49,13 @@ void prng_update(prng_context_t *ctx, const uint8_t *input, size_t ilen) md5_hash(input, ilen, &ctx->md5); } -void prng_finish(prng_context_t *ctx, uint8_t *output) +void prng_finish(prng_context_t *ctx, uint8_t *output, uint8_t *output2) { uint8_t tmp[16]; md5_end(tmp, &ctx->md5); memcpy(output, tmp, 8); + if (output2) + memcpy(output2, tmp + 8, 8); } #if 0 -- cgit v1.2.3