From: Niels Möller Date: Fri, 26 Apr 2013 08:53:36 +0000 (+0200) Subject: Use size_t rather than unsigned for randomness related functions. X-Git-Tag: nettle_3.0_release_20140607~251 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb7c996e529a49b5eedeb064df275378486987d7;p=thirdparty%2Fnettle.git Use size_t rather than unsigned for randomness related functions. --- diff --git a/knuth-lfib.c b/knuth-lfib.c index e07c7af6..6f7bd623 100644 --- a/knuth-lfib.c +++ b/knuth-lfib.c @@ -117,7 +117,7 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx) /* NOTE: Not at all optimized. */ void knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, - unsigned n, uint32_t *a) + size_t n, uint32_t *a) { unsigned i; @@ -128,7 +128,7 @@ knuth_lfib_get_array(struct knuth_lfib_ctx *ctx, /* NOTE: Not at all optimized. */ void 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 bits. */ diff --git a/knuth-lfib.h b/knuth-lfib.h index 85dce637..304f8881 100644 --- a/knuth-lfib.h +++ b/knuth-lfib.h @@ -61,12 +61,12 @@ knuth_lfib_get(struct knuth_lfib_ctx *ctx); /* Get an array of numbers */ void 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. */ void knuth_lfib_random(struct knuth_lfib_ctx *ctx, - unsigned n, uint8_t *dst); + size_t n, uint8_t *dst); #ifdef __cplusplus } diff --git a/nettle-types.h b/nettle-types.h index df68cc2b..0c372723 100644 --- a/nettle-types.h +++ b/nettle-types.h @@ -34,7 +34,7 @@ extern "C" { /* Randomness. Used by key generation and dsa signature creation. */ 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. */ typedef void nettle_progress_func(void *ctx, int c); diff --git a/yarrow.h b/yarrow.h index 8a0de5f6..fc6ccf9c 100644 --- a/yarrow.h +++ b/yarrow.h @@ -87,17 +87,17 @@ yarrow256_init(struct yarrow256_ctx *ctx, void yarrow256_seed(struct yarrow256_ctx *ctx, - unsigned length, + size_t length, const uint8_t *seed_file); /* Returns 1 on reseed */ int yarrow256_update(struct yarrow256_ctx *ctx, unsigned source, unsigned entropy, - unsigned length, const uint8_t *data); + size_t length, const uint8_t *data); 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 yarrow256_is_seeded(struct yarrow256_ctx *ctx); diff --git a/yarrow256.c b/yarrow256.c index 39cb9366..800e4fd6 100644 --- a/yarrow256.c +++ b/yarrow256.c @@ -101,7 +101,7 @@ yarrow256_init(struct yarrow256_ctx *ctx, void yarrow256_seed(struct yarrow256_ctx *ctx, - unsigned length, + size_t length, const uint8_t *seed_file) { assert(length > 0); @@ -228,7 +228,7 @@ yarrow256_slow_reseed(struct yarrow256_ctx *ctx) int yarrow256_update(struct yarrow256_ctx *ctx, unsigned source_index, unsigned entropy, - unsigned length, const uint8_t *data) + size_t length, const uint8_t *data) { enum yarrow_pool_id current; struct yarrow_source *source; @@ -315,7 +315,7 @@ yarrow_gate(struct yarrow256_ctx *ctx) } 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);