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

Use size_t rather than unsigned for randomness related functions.

parent 220812bc
...@@ -117,7 +117,7 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx) ...@@ -117,7 +117,7 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx)
/* NOTE: Not at all optimized. */ /* NOTE: Not at all optimized. */
void void
knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
unsigned n, uint32_t *a) size_t n, uint32_t *a)
{ {
unsigned i; unsigned i;
...@@ -128,7 +128,7 @@ knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, ...@@ -128,7 +128,7 @@ knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
/* NOTE: Not at all optimized. */ /* NOTE: Not at all optimized. */
void void
knuth_lfib_random(struct knuth_lfib_ctx *ctx, knuth_lfib_random(struct knuth_lfib_ctx *ctx,
unsigned n, uint8_t *dst) size_t n, uint8_t *dst)
{ {
/* Use 24 bits from each number, xoring together some of the /* Use 24 bits from each number, xoring together some of the
bits. */ bits. */
......
...@@ -61,12 +61,12 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx); ...@@ -61,12 +61,12 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx);
/* Get an array of numbers */ /* Get an array of numbers */
void void
knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, knuth_lfib_get_array(struct knuth_lfib_ctx *ctx,
unsigned n, uint32_t *a); size_t n, uint32_t *a);
/* Get an array of octets. */ /* Get an array of octets. */
void void
knuth_lfib_random(struct knuth_lfib_ctx *ctx, knuth_lfib_random(struct knuth_lfib_ctx *ctx,
unsigned n, uint8_t *dst); size_t n, uint8_t *dst);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -34,7 +34,7 @@ extern "C" { ...@@ -34,7 +34,7 @@ extern "C" {
/* Randomness. Used by key generation and dsa signature creation. */ /* Randomness. Used by key generation and dsa signature creation. */
typedef void nettle_random_func(void *ctx, typedef void nettle_random_func(void *ctx,
unsigned length, uint8_t *dst); size_t length, uint8_t *dst);
/* Progress report function, mainly for key generation. */ /* Progress report function, mainly for key generation. */
typedef void nettle_progress_func(void *ctx, int c); typedef void nettle_progress_func(void *ctx, int c);
......
...@@ -87,17 +87,17 @@ yarrow256_init(struct yarrow256_ctx *ctx, ...@@ -87,17 +87,17 @@ yarrow256_init(struct yarrow256_ctx *ctx,
void void
yarrow256_seed(struct yarrow256_ctx *ctx, yarrow256_seed(struct yarrow256_ctx *ctx,
unsigned length, size_t length,
const uint8_t *seed_file); const uint8_t *seed_file);
/* Returns 1 on reseed */ /* Returns 1 on reseed */
int int
yarrow256_update(struct yarrow256_ctx *ctx, yarrow256_update(struct yarrow256_ctx *ctx,
unsigned source, unsigned entropy, unsigned source, unsigned entropy,
unsigned length, const uint8_t *data); size_t length, const uint8_t *data);
void void
yarrow256_random(struct yarrow256_ctx *ctx, unsigned length, uint8_t *dst); yarrow256_random(struct yarrow256_ctx *ctx, size_t length, uint8_t *dst);
int int
yarrow256_is_seeded(struct yarrow256_ctx *ctx); yarrow256_is_seeded(struct yarrow256_ctx *ctx);
......
...@@ -101,7 +101,7 @@ yarrow256_init(struct yarrow256_ctx *ctx, ...@@ -101,7 +101,7 @@ yarrow256_init(struct yarrow256_ctx *ctx,
void void
yarrow256_seed(struct yarrow256_ctx *ctx, yarrow256_seed(struct yarrow256_ctx *ctx,
unsigned length, size_t length,
const uint8_t *seed_file) const uint8_t *seed_file)
{ {
assert(length > 0); assert(length > 0);
...@@ -228,7 +228,7 @@ yarrow256_slow_reseed(struct yarrow256_ctx *ctx) ...@@ -228,7 +228,7 @@ yarrow256_slow_reseed(struct yarrow256_ctx *ctx)
int int
yarrow256_update(struct yarrow256_ctx *ctx, yarrow256_update(struct yarrow256_ctx *ctx,
unsigned source_index, unsigned entropy, unsigned source_index, unsigned entropy,
unsigned length, const uint8_t *data) size_t length, const uint8_t *data)
{ {
enum yarrow_pool_id current; enum yarrow_pool_id current;
struct yarrow_source *source; struct yarrow_source *source;
...@@ -315,7 +315,7 @@ yarrow_gate(struct yarrow256_ctx *ctx) ...@@ -315,7 +315,7 @@ yarrow_gate(struct yarrow256_ctx *ctx)
} }
void void
yarrow256_random(struct yarrow256_ctx *ctx, unsigned length, uint8_t *dst) yarrow256_random(struct yarrow256_ctx *ctx, size_t length, uint8_t *dst)
{ {
assert(ctx->seeded); assert(ctx->seeded);
......
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