From b8bfc32ff2fe1084614332bdda4d3b7805f62da0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 26 Apr 2013 10:28:57 +0200
Subject: [PATCH] Use size_t rather than unsigned for all hash-related
 functions.

---
 examples/nettle-openssl.c | 10 ++++-----
 gcm-aes.c                 |  4 ++--
 gcm.c                     |  6 +++---
 gcm.h                     |  8 +++----
 gosthash94.c              |  4 ++--
 gosthash94.h              |  4 ++--
 hmac-md5.c                |  6 +++---
 hmac-ripemd160.c          |  6 +++---
 hmac-sha1.c               |  6 +++---
 hmac-sha224.c             |  4 ++--
 hmac-sha256.c             |  6 +++---
 hmac-sha384.c             |  4 ++--
 hmac-sha512.c             |  6 +++---
 hmac.c                    |  6 +++---
 hmac.h                    | 44 +++++++++++++++++++--------------------
 md2.c                     |  4 ++--
 md2.h                     |  4 ++--
 md4.c                     |  4 ++--
 md4.h                     |  4 ++--
 md5.c                     |  4 ++--
 md5.h                     |  4 ++--
 nettle-internal.h         |  6 +++---
 nettle-types.h            |  4 ++--
 ripemd160.c               |  4 ++--
 ripemd160.h               |  4 ++--
 sha1.c                    |  4 ++--
 sha1.h                    |  4 ++--
 sha2.h                    | 12 +++++------
 sha256.c                  |  8 +++----
 sha3-224.c                |  4 ++--
 sha3-256.c                |  4 ++--
 sha3-384.c                |  4 ++--
 sha3-512.c                |  4 ++--
 sha3.c                    |  2 +-
 sha3.h                    | 18 ++++++++--------
 sha512.c                  |  8 +++----
 umac.h                    | 24 ++++++++++-----------
 umac128.c                 |  6 +++---
 umac32.c                  |  6 +++---
 umac64.c                  |  6 +++---
 umac96.c                  |  6 +++---
 41 files changed, 143 insertions(+), 143 deletions(-)

diff --git a/examples/nettle-openssl.c b/examples/nettle-openssl.c
index 5805b662..8ef0c025 100644
--- a/examples/nettle-openssl.c
+++ b/examples/nettle-openssl.c
@@ -308,8 +308,8 @@ openssl_md5_init(void *ctx)
 static nettle_hash_update_func openssl_md5_update;
 static void
 openssl_md5_update(void *ctx,
-		    unsigned length,
-		    const uint8_t *src)
+		   size_t length,
+		   const uint8_t *src)
 {
   MD5_Update(ctx, src, length);
 }
@@ -317,7 +317,7 @@ openssl_md5_update(void *ctx,
 static nettle_hash_digest_func openssl_md5_digest;
 static void
 openssl_md5_digest(void *ctx,
-		    unsigned length, uint8_t *dst)
+		   size_t length, uint8_t *dst)
 {
   assert(length == SHA_DIGEST_LENGTH);
   MD5_Final(dst, ctx);
@@ -344,7 +344,7 @@ openssl_sha1_init(void *ctx)
 static nettle_hash_update_func openssl_sha1_update;
 static void
 openssl_sha1_update(void *ctx,
-		    unsigned length,
+		    size_t length,
 		    const uint8_t *src)
 {
   SHA1_Update(ctx, src, length);
@@ -353,7 +353,7 @@ openssl_sha1_update(void *ctx,
 static nettle_hash_digest_func openssl_sha1_digest;
 static void
 openssl_sha1_digest(void *ctx,
-		    unsigned length, uint8_t *dst)
+		    size_t length, uint8_t *dst)
 {
   assert(length == SHA_DIGEST_LENGTH);
   SHA1_Final(dst, ctx);
diff --git a/gcm-aes.c b/gcm-aes.c
index 194a0d82..7873fbb1 100644
--- a/gcm-aes.c
+++ b/gcm-aes.c
@@ -43,7 +43,7 @@ gcm_aes_set_iv(struct gcm_aes_ctx *ctx,
 }
 
 void
-gcm_aes_update(struct gcm_aes_ctx *ctx, unsigned length, const uint8_t *data)
+gcm_aes_update(struct gcm_aes_ctx *ctx, size_t length, const uint8_t *data)
 {
   GCM_UPDATE(ctx, length, data);
 }
@@ -64,7 +64,7 @@ gcm_aes_decrypt(struct gcm_aes_ctx *ctx,
 
 void
 gcm_aes_digest(struct gcm_aes_ctx *ctx,
-	       unsigned length, uint8_t *digest)
+	       size_t length, uint8_t *digest)
 {
   GCM_DIGEST(ctx, aes_encrypt, length, digest);
   
diff --git a/gcm.c b/gcm.c
index de5321e7..6893d515 100644
--- a/gcm.c
+++ b/gcm.c
@@ -349,7 +349,7 @@ gcm_set_key(struct gcm_key *key,
 
 static void
 gcm_hash(const struct gcm_key *key, union gcm_block *x,
-	 unsigned length, const uint8_t *data)
+	 size_t length, const uint8_t *data)
 {
   for (; length >= GCM_BLOCK_SIZE;
        length -= GCM_BLOCK_SIZE, data += GCM_BLOCK_SIZE)
@@ -412,7 +412,7 @@ gcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,
 
 void
 gcm_update(struct gcm_ctx *ctx, const struct gcm_key *key,
-	   unsigned length, const uint8_t *data)
+	   size_t length, const uint8_t *data)
 {
   assert(ctx->auth_size % GCM_BLOCK_SIZE == 0);
   assert(ctx->data_size == 0);
@@ -488,7 +488,7 @@ gcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
 void
 gcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key,
 	   void *cipher, nettle_crypt_func *f,
-	   unsigned length, uint8_t *digest)
+	   size_t length, uint8_t *digest)
 {
   uint8_t buffer[GCM_BLOCK_SIZE];
 
diff --git a/gcm.h b/gcm.h
index b42c9957..f50c7363 100644
--- a/gcm.h
+++ b/gcm.h
@@ -98,7 +98,7 @@ gcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,
 
 void
 gcm_update(struct gcm_ctx *ctx, const struct gcm_key *key,
-	   unsigned length, const uint8_t *data);
+	   size_t length, const uint8_t *data);
 
 void
 gcm_encrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
@@ -113,7 +113,7 @@ gcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,
 void
 gcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key,
 	   void *cipher, nettle_crypt_func *f,
-	   unsigned length, uint8_t *digest);
+	   size_t length, uint8_t *digest);
 
 /* Convenience macrology (not sure how useful it is) */
 
@@ -166,7 +166,7 @@ gcm_aes_set_iv(struct gcm_aes_ctx *ctx,
 
 void
 gcm_aes_update(struct gcm_aes_ctx *ctx,
-	       unsigned length, const uint8_t *data);
+	       size_t length, const uint8_t *data);
 
 void
 gcm_aes_encrypt(struct gcm_aes_ctx *ctx,
@@ -177,7 +177,7 @@ gcm_aes_decrypt(struct gcm_aes_ctx *ctx,
 		size_t length, uint8_t *dst, const uint8_t *src);
 
 void
-gcm_aes_digest(struct gcm_aes_ctx *ctx, unsigned length, uint8_t *digest);
+gcm_aes_digest(struct gcm_aes_ctx *ctx, size_t length, uint8_t *digest);
 
 #ifdef __cplusplus
 }
diff --git a/gosthash94.c b/gosthash94.c
index ba0171b4..a671b4fe 100644
--- a/gosthash94.c
+++ b/gosthash94.c
@@ -525,7 +525,7 @@ gost_compute_sum_and_hash (struct gosthash94_ctx *ctx, const uint8_t *block)
  */
 void
 gosthash94_update (struct gosthash94_ctx *ctx,
-		   unsigned length, const uint8_t *msg)
+		   size_t length, const uint8_t *msg)
 {
     unsigned index = (unsigned) ctx->length & 31;
     ctx->length += length;
@@ -564,7 +564,7 @@ gosthash94_update (struct gosthash94_ctx *ctx,
  */
 void
 gosthash94_digest (struct gosthash94_ctx *ctx,
-		   unsigned length, uint8_t *result)
+		   size_t length, uint8_t *result)
 {
     unsigned index = ctx->length & 31;
     uint32_t msg32[8];
diff --git a/gosthash94.h b/gosthash94.h
index ff76b238..f1d91800 100644
--- a/gosthash94.h
+++ b/gosthash94.h
@@ -77,9 +77,9 @@ struct gosthash94_ctx
 
 void gosthash94_init(struct gosthash94_ctx *ctx);
 void gosthash94_update(struct gosthash94_ctx *ctx,
-		       unsigned length, const uint8_t *msg);
+		       size_t length, const uint8_t *msg);
 void gosthash94_digest(struct gosthash94_ctx *ctx,
-		       unsigned length, uint8_t *result);
+		       size_t length, uint8_t *result);
 
 #ifdef __cplusplus
 }
diff --git a/hmac-md5.c b/hmac-md5.c
index 62b61307..94bd44d9 100644
--- a/hmac-md5.c
+++ b/hmac-md5.c
@@ -31,21 +31,21 @@
 
 void
 hmac_md5_set_key(struct hmac_md5_ctx *ctx,
-		 unsigned key_length, const uint8_t *key)
+		 size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_md5, key_length, key);
 }
 
 void
 hmac_md5_update(struct hmac_md5_ctx *ctx,
-		unsigned length, const uint8_t *data)
+		size_t length, const uint8_t *data)
 {
   md5_update(&ctx->state, length, data);
 }
 
 void
 hmac_md5_digest(struct hmac_md5_ctx *ctx,
-		unsigned length, uint8_t *digest)
+		size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_md5, length, digest);
 }
diff --git a/hmac-ripemd160.c b/hmac-ripemd160.c
index 7ba0064b..126fd93d 100644
--- a/hmac-ripemd160.c
+++ b/hmac-ripemd160.c
@@ -31,21 +31,21 @@
 
 void
 hmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx,
-		       unsigned key_length, const uint8_t *key)
+		       size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_ripemd160, key_length, key);
 }
 
 void
 hmac_ripemd160_update(struct hmac_ripemd160_ctx *ctx,
-		      unsigned length, const uint8_t *data)
+		      size_t length, const uint8_t *data)
 {
   ripemd160_update(&ctx->state, length, data);
 }
 
 void
 hmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx,
-		      unsigned length, uint8_t *digest)
+		      size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_ripemd160, length, digest);
 }
diff --git a/hmac-sha1.c b/hmac-sha1.c
index 54637d36..1c763377 100644
--- a/hmac-sha1.c
+++ b/hmac-sha1.c
@@ -31,21 +31,21 @@
 
 void
 hmac_sha1_set_key(struct hmac_sha1_ctx *ctx,
-		  unsigned key_length, const uint8_t *key)
+		  size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_sha1, key_length, key);
 }
 
 void
 hmac_sha1_update(struct hmac_sha1_ctx *ctx,
-		 unsigned length, const uint8_t *data)
+		 size_t length, const uint8_t *data)
 {
   sha1_update(&ctx->state, length, data);
 }
 
 void
 hmac_sha1_digest(struct hmac_sha1_ctx *ctx,
-		 unsigned length, uint8_t *digest)
+		 size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_sha1, length, digest);
 }
diff --git a/hmac-sha224.c b/hmac-sha224.c
index 79898ccb..8a8992df 100644
--- a/hmac-sha224.c
+++ b/hmac-sha224.c
@@ -31,14 +31,14 @@
 
 void
 hmac_sha224_set_key(struct hmac_sha224_ctx *ctx,
-		    unsigned key_length, const uint8_t *key)
+		    size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_sha224, key_length, key);
 }
 
 void
 hmac_sha224_digest(struct hmac_sha224_ctx *ctx,
-		   unsigned length, uint8_t *digest)
+		   size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_sha224, length, digest);
 }
diff --git a/hmac-sha256.c b/hmac-sha256.c
index 6a592660..09c59189 100644
--- a/hmac-sha256.c
+++ b/hmac-sha256.c
@@ -31,21 +31,21 @@
 
 void
 hmac_sha256_set_key(struct hmac_sha256_ctx *ctx,
-		    unsigned key_length, const uint8_t *key)
+		    size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_sha256, key_length, key);
 }
 
 void
 hmac_sha256_update(struct hmac_sha256_ctx *ctx,
-		   unsigned length, const uint8_t *data)
+		   size_t length, const uint8_t *data)
 {
   sha256_update(&ctx->state, length, data);
 }
 
 void
 hmac_sha256_digest(struct hmac_sha256_ctx *ctx,
-		   unsigned length, uint8_t *digest)
+		   size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_sha256, length, digest);
 }
diff --git a/hmac-sha384.c b/hmac-sha384.c
index 46d0e42d..ba3c2553 100644
--- a/hmac-sha384.c
+++ b/hmac-sha384.c
@@ -31,14 +31,14 @@
 
 void
 hmac_sha384_set_key(struct hmac_sha512_ctx *ctx,
-		    unsigned key_length, const uint8_t *key)
+		    size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_sha384, key_length, key);
 }
 
 void
 hmac_sha384_digest(struct hmac_sha512_ctx *ctx,
-		   unsigned length, uint8_t *digest)
+		   size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_sha384, length, digest);
 }
diff --git a/hmac-sha512.c b/hmac-sha512.c
index 14b40ceb..ff6a029e 100644
--- a/hmac-sha512.c
+++ b/hmac-sha512.c
@@ -31,21 +31,21 @@
 
 void
 hmac_sha512_set_key(struct hmac_sha512_ctx *ctx,
-		    unsigned key_length, const uint8_t *key)
+		    size_t key_length, const uint8_t *key)
 {
   HMAC_SET_KEY(ctx, &nettle_sha512, key_length, key);
 }
 
 void
 hmac_sha512_update(struct hmac_sha512_ctx *ctx,
-		   unsigned length, const uint8_t *data)
+		   size_t length, const uint8_t *data)
 {
   sha512_update(&ctx->state, length, data);
 }
 
 void
 hmac_sha512_digest(struct hmac_sha512_ctx *ctx,
-		   unsigned length, uint8_t *digest)
+		   size_t length, uint8_t *digest)
 {
   HMAC_DIGEST(ctx, &nettle_sha512, length, digest);
 }
diff --git a/hmac.c b/hmac.c
index 8c363b13..571a742f 100644
--- a/hmac.c
+++ b/hmac.c
@@ -43,7 +43,7 @@
 void
 hmac_set_key(void *outer, void *inner, void *state,
 	     const struct nettle_hash *hash,
-	     unsigned key_length, const uint8_t *key)
+	     size_t key_length, const uint8_t *key)
 {
   TMP_DECL(pad, uint8_t, NETTLE_MAX_HASH_BLOCK_SIZE);
   TMP_ALLOC(pad, hash->block_size);
@@ -85,7 +85,7 @@ hmac_set_key(void *outer, void *inner, void *state,
 void
 hmac_update(void *state,
 	    const struct nettle_hash *hash,
-	    unsigned length, const uint8_t *data)
+	    size_t length, const uint8_t *data)
 {
   hash->update(state, length, data);
 }
@@ -93,7 +93,7 @@ hmac_update(void *state,
 void
 hmac_digest(const void *outer, const void *inner, void *state,
 	    const struct nettle_hash *hash, 	    
-	    unsigned length, uint8_t *dst)
+	    size_t length, uint8_t *dst)
 {
   TMP_DECL(digest, uint8_t, NETTLE_MAX_HASH_DIGEST_SIZE);
   TMP_ALLOC(digest, hash->digest_size);
diff --git a/hmac.h b/hmac.h
index c6cb0e06..562bdd77 100644
--- a/hmac.h
+++ b/hmac.h
@@ -64,19 +64,19 @@ extern "C" {
 void
 hmac_set_key(void *outer, void *inner, void *state,
 	     const struct nettle_hash *hash,
-	     unsigned length, const uint8_t *key);
+	     size_t length, const uint8_t *key);
 
 /* This function is not strictly needed, it's s just the same as the
  * hash update function. */
 void
 hmac_update(void *state,
 	    const struct nettle_hash *hash,
-	    unsigned length, const uint8_t *data);
+	    size_t length, const uint8_t *data);
 
 void
 hmac_digest(const void *outer, const void *inner, void *state,
 	    const struct nettle_hash *hash,
-	    unsigned length, uint8_t *digest);
+	    size_t length, uint8_t *digest);
 
 
 #define HMAC_CTX(type) \
@@ -97,15 +97,15 @@ struct hmac_md5_ctx HMAC_CTX(struct md5_ctx);
 
 void
 hmac_md5_set_key(struct hmac_md5_ctx *ctx,
-		 unsigned key_length, const uint8_t *key);
+		 size_t key_length, const uint8_t *key);
 
 void
 hmac_md5_update(struct hmac_md5_ctx *ctx,
-		unsigned length, const uint8_t *data);
+		size_t length, const uint8_t *data);
 
 void
 hmac_md5_digest(struct hmac_md5_ctx *ctx,
-		unsigned length, uint8_t *digest);
+		size_t length, uint8_t *digest);
 
 
 /* hmac-ripemd160 */
@@ -113,15 +113,15 @@ struct hmac_ripemd160_ctx HMAC_CTX(struct ripemd160_ctx);
 
 void
 hmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx,
-		       unsigned key_length, const uint8_t *key);
+		       size_t key_length, const uint8_t *key);
 
 void
 hmac_ripemd160_update(struct hmac_ripemd160_ctx *ctx,
-		      unsigned length, const uint8_t *data);
+		      size_t length, const uint8_t *data);
 
 void
 hmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx,
-		      unsigned length, uint8_t *digest);
+		      size_t length, uint8_t *digest);
 
 
 /* hmac-sha1 */
@@ -129,71 +129,71 @@ struct hmac_sha1_ctx HMAC_CTX(struct sha1_ctx);
 
 void
 hmac_sha1_set_key(struct hmac_sha1_ctx *ctx,
-		  unsigned key_length, const uint8_t *key);
+		  size_t key_length, const uint8_t *key);
 
 void
 hmac_sha1_update(struct hmac_sha1_ctx *ctx,
-		 unsigned length, const uint8_t *data);
+		 size_t length, const uint8_t *data);
 
 void
 hmac_sha1_digest(struct hmac_sha1_ctx *ctx,
-		 unsigned length, uint8_t *digest);
+		 size_t length, uint8_t *digest);
 
 /* hmac-sha256 */
 struct hmac_sha256_ctx HMAC_CTX(struct sha256_ctx);
 
 void
 hmac_sha256_set_key(struct hmac_sha256_ctx *ctx,
-		    unsigned key_length, const uint8_t *key);
+		    size_t key_length, const uint8_t *key);
 
 void
 hmac_sha256_update(struct hmac_sha256_ctx *ctx,
-		   unsigned length, const uint8_t *data);
+		   size_t length, const uint8_t *data);
 
 void
 hmac_sha256_digest(struct hmac_sha256_ctx *ctx,
-		   unsigned length, uint8_t *digest);
+		   size_t length, uint8_t *digest);
 
 /* hmac-sha224 */
 #define hmac_sha224_ctx hmac_sha256_ctx
 
 void
 hmac_sha224_set_key(struct hmac_sha224_ctx *ctx,
-		    unsigned key_length, const uint8_t *key);
+		    size_t key_length, const uint8_t *key);
 
 #define hmac_sha224_update nettle_hmac_sha256_update
 
 void
 hmac_sha224_digest(struct hmac_sha224_ctx *ctx,
-		   unsigned length, uint8_t *digest);
+		   size_t length, uint8_t *digest);
 
 /* hmac-sha512 */
 struct hmac_sha512_ctx HMAC_CTX(struct sha512_ctx);
 
 void
 hmac_sha512_set_key(struct hmac_sha512_ctx *ctx,
-		    unsigned key_length, const uint8_t *key);
+		    size_t key_length, const uint8_t *key);
 
 void
 hmac_sha512_update(struct hmac_sha512_ctx *ctx,
-		   unsigned length, const uint8_t *data);
+		   size_t length, const uint8_t *data);
 
 void
 hmac_sha512_digest(struct hmac_sha512_ctx *ctx,
-		   unsigned length, uint8_t *digest);
+		   size_t length, uint8_t *digest);
 
 /* hmac-sha384 */
 #define hmac_sha384_ctx hmac_sha512_ctx
 
 void
 hmac_sha384_set_key(struct hmac_sha512_ctx *ctx,
-		    unsigned key_length, const uint8_t *key);
+		    size_t key_length, const uint8_t *key);
 
 #define hmac_sha384_update nettle_hmac_sha512_update
 
 void
 hmac_sha384_digest(struct hmac_sha512_ctx *ctx,
-		   unsigned length, uint8_t *digest);
+		   size_t length, uint8_t *digest);
 
 #ifdef __cplusplus
 }
diff --git a/md2.c b/md2.c
index a39f733b..72543de7 100644
--- a/md2.c
+++ b/md2.c
@@ -106,7 +106,7 @@ md2_init(struct md2_ctx *ctx)
 
 void
 md2_update(struct md2_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data)
 {
   MD_UPDATE(ctx, length, data, md2_transform, (void)0);
@@ -114,7 +114,7 @@ md2_update(struct md2_ctx *ctx,
 
 void
 md2_digest(struct md2_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest)
 {
   unsigned left;
diff --git a/md2.h b/md2.h
index 08070205..9bf47e55 100644
--- a/md2.h
+++ b/md2.h
@@ -53,12 +53,12 @@ md2_init(struct md2_ctx *ctx);
 
 void
 md2_update(struct md2_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data);
 
 void
 md2_digest(struct md2_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest);
 
 
diff --git a/md4.c b/md4.c
index ad093cab..80d50f6b 100644
--- a/md4.c
+++ b/md4.c
@@ -67,7 +67,7 @@ md4_init(struct md4_ctx *ctx)
 
 void
 md4_update(struct md4_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data)
 {
   MD_UPDATE(ctx, length, data, md4_compress, MD_INCR(ctx));
@@ -75,7 +75,7 @@ md4_update(struct md4_ctx *ctx,
 
 void
 md4_digest(struct md4_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest)
 {
   uint32_t data[MD4_DATA_LENGTH];
diff --git a/md4.h b/md4.h
index 1edc8443..5b805c22 100644
--- a/md4.h
+++ b/md4.h
@@ -57,12 +57,12 @@ md4_init(struct md4_ctx *ctx);
 
 void
 md4_update(struct md4_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data);
 
 void
 md4_digest(struct md4_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest);
 
 
diff --git a/md5.c b/md5.c
index 484753ce..32c3583e 100644
--- a/md5.c
+++ b/md5.c
@@ -57,7 +57,7 @@ md5_init(struct md5_ctx *ctx)
 
 void
 md5_update(struct md5_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data)
 {
   MD_UPDATE(ctx, length, data, COMPRESS, MD_INCR(ctx));
@@ -65,7 +65,7 @@ md5_update(struct md5_ctx *ctx,
 
 void
 md5_digest(struct md5_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest)
 {
   uint32_t high, low;
diff --git a/md5.h b/md5.h
index 31ad40e9..2899cdfc 100644
--- a/md5.h
+++ b/md5.h
@@ -56,12 +56,12 @@ md5_init(struct md5_ctx *ctx);
 
 void
 md5_update(struct md5_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   const uint8_t *data);
 
 void
 md5_digest(struct md5_ctx *ctx,
-	   unsigned length,
+	   size_t length,
 	   uint8_t *digest);
 
 /* Internal compression function. STATE points to 4 uint32_t words,
diff --git a/nettle-internal.h b/nettle-internal.h
index 71452d45..e094064f 100644
--- a/nettle-internal.h
+++ b/nettle-internal.h
@@ -83,12 +83,12 @@ struct nettle_aead
 {
   const char *name;
   
-  unsigned context_size;
+  size_t context_size;
   /* Block size of the input, and the size of the output digest */
-  unsigned block_size;
+  size_t block_size;
 
   /* Suggested key size; other sizes are sometimes possible. */
-  unsigned key_size;
+  size_t key_size;
 
   nettle_set_key_func *set_key;
   nettle_set_key_func *set_iv;
diff --git a/nettle-types.h b/nettle-types.h
index 5f7738e7..df68cc2b 100644
--- a/nettle-types.h
+++ b/nettle-types.h
@@ -60,10 +60,10 @@ typedef void nettle_crypt_func(void *ctx,
 /* Hash algorithms */
 typedef void nettle_hash_init_func(void *ctx);
 typedef void nettle_hash_update_func(void *ctx,
-				     unsigned length,
+				     size_t length,
 				     const uint8_t *src);
 typedef void nettle_hash_digest_func(void *ctx,
-				     unsigned length, uint8_t *dst);
+				     size_t length, uint8_t *dst);
 
 /* ASCII armor codecs. NOTE: Experimental and subject to change. */
 
diff --git a/ripemd160.c b/ripemd160.c
index 9011b9ee..92a6414f 100644
--- a/ripemd160.c
+++ b/ripemd160.c
@@ -165,13 +165,13 @@ ripemd160_init(struct ripemd160_ctx *ctx)
  * of DATA with length LENGTH.
  */
 void
-ripemd160_update(struct ripemd160_ctx *ctx, unsigned length, const uint8_t *data)
+ripemd160_update(struct ripemd160_ctx *ctx, size_t length, const uint8_t *data)
 {
   MD_UPDATE(ctx, length, data, COMPRESS, MD_INCR(ctx));
 }
 
 void
-ripemd160_digest(struct ripemd160_ctx *ctx, unsigned length, uint8_t *digest)
+ripemd160_digest(struct ripemd160_ctx *ctx, size_t length, uint8_t *digest)
 {
   uint32_t high, low;
 
diff --git a/ripemd160.h b/ripemd160.h
index c3746966..eca98736 100644
--- a/ripemd160.h
+++ b/ripemd160.h
@@ -58,12 +58,12 @@ ripemd160_init(struct ripemd160_ctx *ctx);
 
 void
 ripemd160_update(struct ripemd160_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data);
 
 void
 ripemd160_digest(struct ripemd160_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 uint8_t *digest);
 
 /* Internal compression function. STATE points to 5 uint32_t words,
diff --git a/sha1.c b/sha1.c
index dc52be22..b7ab9412 100644
--- a/sha1.c
+++ b/sha1.c
@@ -76,14 +76,14 @@ sha1_init(struct sha1_ctx *ctx)
 
 void
 sha1_update(struct sha1_ctx *ctx,
-	    unsigned length, const uint8_t *data)
+	    size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, COMPRESS, MD_INCR(ctx));
 }
 	  
 void
 sha1_digest(struct sha1_ctx *ctx,
-	    unsigned length,
+	    size_t length,
 	    uint8_t *digest)
 {
   uint32_t high, low;
diff --git a/sha1.h b/sha1.h
index 5c90e542..9452f0aa 100644
--- a/sha1.h
+++ b/sha1.h
@@ -58,12 +58,12 @@ sha1_init(struct sha1_ctx *ctx);
 
 void
 sha1_update(struct sha1_ctx *ctx,
-	    unsigned length,
+	    size_t length,
 	    const uint8_t *data);
 
 void
 sha1_digest(struct sha1_ctx *ctx,
-	    unsigned length,
+	    size_t length,
 	    uint8_t *digest);
 
 /* Internal compression function. STATE points to 5 uint32_t words,
diff --git a/sha2.h b/sha2.h
index 738261e2..3a0b449a 100644
--- a/sha2.h
+++ b/sha2.h
@@ -65,12 +65,12 @@ sha256_init(struct sha256_ctx *ctx);
 
 void
 sha256_update(struct sha256_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      const uint8_t *data);
 
 void
 sha256_digest(struct sha256_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest);
 
 /* Internal compression function. STATE points to 8 uint32_t words,
@@ -93,7 +93,7 @@ sha224_init(struct sha256_ctx *ctx);
 
 void
 sha224_digest(struct sha256_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest);
 
 
@@ -118,12 +118,12 @@ sha512_init(struct sha512_ctx *ctx);
 
 void
 sha512_update(struct sha512_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      const uint8_t *data);
 
 void
 sha512_digest(struct sha512_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest);
 
 /* Internal compression function. STATE points to 8 uint64_t words,
@@ -146,7 +146,7 @@ sha384_init(struct sha512_ctx *ctx);
 
 void
 sha384_digest(struct sha512_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest);
 
 #ifdef __cplusplus
diff --git a/sha256.c b/sha256.c
index 47995979..5b77f9ce 100644
--- a/sha256.c
+++ b/sha256.c
@@ -87,14 +87,14 @@ sha256_init(struct sha256_ctx *ctx)
 
 void
 sha256_update(struct sha256_ctx *ctx,
-	      unsigned length, const uint8_t *data)
+	      size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, COMPRESS, MD_INCR(ctx));
 }
 
 static void
 sha256_write_digest(struct sha256_ctx *ctx,
-		    unsigned length,
+		    size_t length,
 		    uint8_t *digest)
 {
   uint32_t high, low;
@@ -119,7 +119,7 @@ sha256_write_digest(struct sha256_ctx *ctx,
 
 void
 sha256_digest(struct sha256_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest)
 {
   sha256_write_digest(ctx, length, digest);
@@ -149,7 +149,7 @@ sha224_init(struct sha256_ctx *ctx)
 
 void
 sha224_digest(struct sha256_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest)
 {
   sha256_write_digest(ctx, length, digest);
diff --git a/sha3-224.c b/sha3-224.c
index 81a4fbdf..2b9b2189 100644
--- a/sha3-224.c
+++ b/sha3-224.c
@@ -42,7 +42,7 @@ sha3_224_init (struct sha3_224_ctx *ctx)
 
 void
 sha3_224_update (struct sha3_224_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data)
 {
   ctx->index = _sha3_update (&ctx->state, SHA3_224_DATA_SIZE, ctx->block,
@@ -51,7 +51,7 @@ sha3_224_update (struct sha3_224_ctx *ctx,
 
 void
 sha3_224_digest(struct sha3_224_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest)
 {
   _sha3_pad (&ctx->state, SHA3_224_DATA_SIZE, ctx->block, ctx->index);
diff --git a/sha3-256.c b/sha3-256.c
index e5294818..64e3c0c2 100644
--- a/sha3-256.c
+++ b/sha3-256.c
@@ -42,7 +42,7 @@ sha3_256_init (struct sha3_256_ctx *ctx)
 
 void
 sha3_256_update (struct sha3_256_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data)
 {
   ctx->index = _sha3_update (&ctx->state, SHA3_256_DATA_SIZE, ctx->block,
@@ -51,7 +51,7 @@ sha3_256_update (struct sha3_256_ctx *ctx,
 
 void
 sha3_256_digest(struct sha3_256_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest)
 {
   _sha3_pad (&ctx->state, SHA3_256_DATA_SIZE, ctx->block, ctx->index);
diff --git a/sha3-384.c b/sha3-384.c
index 5a919807..1f2229c8 100644
--- a/sha3-384.c
+++ b/sha3-384.c
@@ -42,7 +42,7 @@ sha3_384_init (struct sha3_384_ctx *ctx)
 
 void
 sha3_384_update (struct sha3_384_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data)
 {
   ctx->index = _sha3_update (&ctx->state, SHA3_384_DATA_SIZE, ctx->block,
@@ -51,7 +51,7 @@ sha3_384_update (struct sha3_384_ctx *ctx,
 
 void
 sha3_384_digest(struct sha3_384_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest)
 {
   _sha3_pad (&ctx->state, SHA3_384_DATA_SIZE, ctx->block, ctx->index);
diff --git a/sha3-512.c b/sha3-512.c
index 53d3f3b6..c0ee2b29 100644
--- a/sha3-512.c
+++ b/sha3-512.c
@@ -42,7 +42,7 @@ sha3_512_init (struct sha3_512_ctx *ctx)
 
 void
 sha3_512_update (struct sha3_512_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data)
 {
   ctx->index = _sha3_update (&ctx->state, SHA3_512_DATA_SIZE, ctx->block,
@@ -51,7 +51,7 @@ sha3_512_update (struct sha3_512_ctx *ctx,
 
 void
 sha3_512_digest(struct sha3_512_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest)
 {
   _sha3_pad (&ctx->state, SHA3_512_DATA_SIZE, ctx->block, ctx->index);
diff --git a/sha3.c b/sha3.c
index c8381159..6f694c27 100644
--- a/sha3.c
+++ b/sha3.c
@@ -56,7 +56,7 @@ unsigned
 _sha3_update (struct sha3_state *state,
 	      unsigned block_size, uint8_t *block,
 	      unsigned pos,
-	      unsigned length, const uint8_t *data)
+	      size_t length, const uint8_t *data)
 {
   if (pos > 0)
     {
diff --git a/sha3.h b/sha3.h
index c6830b27..c81e46e9 100644
--- a/sha3.h
+++ b/sha3.h
@@ -67,7 +67,7 @@ unsigned
 _sha3_update (struct sha3_state *state,
 	      unsigned block_size, uint8_t *block,
 	      unsigned pos,
-	      unsigned length, const uint8_t *data);
+	      size_t length, const uint8_t *data);
 void
 _sha3_pad (struct sha3_state *state,
 	   unsigned block_size, uint8_t *block, unsigned pos);
@@ -101,12 +101,12 @@ sha3_224_init (struct sha3_224_ctx *ctx);
 
 void
 sha3_224_update (struct sha3_224_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data);
 
 void
 sha3_224_digest(struct sha3_224_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest);
 
 struct sha3_256_ctx
@@ -121,12 +121,12 @@ sha3_256_init (struct sha3_256_ctx *ctx);
 
 void
 sha3_256_update (struct sha3_256_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data);
 
 void
 sha3_256_digest(struct sha3_256_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest);
 
 struct sha3_384_ctx
@@ -141,12 +141,12 @@ sha3_384_init (struct sha3_384_ctx *ctx);
 
 void
 sha3_384_update (struct sha3_384_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data);
 
 void
 sha3_384_digest(struct sha3_384_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest);
 
 struct sha3_512_ctx
@@ -161,12 +161,12 @@ sha3_512_init (struct sha3_512_ctx *ctx);
 
 void
 sha3_512_update (struct sha3_512_ctx *ctx,
-		 unsigned length,
+		 size_t length,
 		 const uint8_t *data);
 
 void
 sha3_512_digest(struct sha3_512_ctx *ctx,
-		unsigned length,
+		size_t length,
 		uint8_t *digest);
 
 #ifdef __cplusplus
diff --git a/sha512.c b/sha512.c
index bf5de2fc..65297f33 100644
--- a/sha512.c
+++ b/sha512.c
@@ -137,14 +137,14 @@ sha512_init(struct sha512_ctx *ctx)
 
 void
 sha512_update(struct sha512_ctx *ctx,
-	      unsigned length, const uint8_t *data)
+	      size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, COMPRESS, MD_INCR(ctx));
 }
 
 static void
 sha512_write_digest(struct sha512_ctx *ctx,
-		    unsigned length,
+		    size_t length,
 		    uint8_t *digest)
 {
   uint64_t high, low;
@@ -188,7 +188,7 @@ sha512_write_digest(struct sha512_ctx *ctx,
 
 void
 sha512_digest(struct sha512_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest)
 {
   assert(length <= SHA512_DIGEST_SIZE);
@@ -229,7 +229,7 @@ sha384_init(struct sha512_ctx *ctx)
 
 void
 sha384_digest(struct sha512_ctx *ctx,
-	      unsigned length,
+	      size_t length,
 	      uint8_t *digest)
 {
   assert(length <= SHA384_DIGEST_SIZE);
diff --git a/umac.h b/umac.h
index 4fbd8e12..b6cec8aa 100644
--- a/umac.h
+++ b/umac.h
@@ -140,43 +140,43 @@ umac128_set_key (struct umac128_ctx *ctx, const uint8_t *key);
 /* Optional, if not used, messages get incrementing nonces starting from zero. */
 void
 umac32_set_nonce (struct umac32_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce);
+		  size_t nonce_length, const uint8_t *nonce);
 void
 umac64_set_nonce (struct umac64_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce);
+		  size_t nonce_length, const uint8_t *nonce);
 void
 umac96_set_nonce (struct umac96_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce);
+		  size_t nonce_length, const uint8_t *nonce);
 void
 umac128_set_nonce (struct umac128_ctx *ctx,
-		   unsigned nonce_length, const uint8_t *nonce);
+		   size_t nonce_length, const uint8_t *nonce);
 
 void
 umac32_update (struct umac32_ctx *ctx,
-	       unsigned length, const uint8_t *data);
+	       size_t length, const uint8_t *data);
 void
 umac64_update (struct umac64_ctx *ctx,
-	       unsigned length, const uint8_t *data);
+	       size_t length, const uint8_t *data);
 void
 umac96_update (struct umac96_ctx *ctx,
-	       unsigned length, const uint8_t *data);
+	       size_t length, const uint8_t *data);
 void
 umac128_update (struct umac128_ctx *ctx,
-		unsigned length, const uint8_t *data);
+		size_t length, const uint8_t *data);
 
 /* The _digest functions increment the nonce */
 void
 umac32_digest (struct umac32_ctx *ctx,
-	       unsigned length, uint8_t *digest);
+	       size_t length, uint8_t *digest);
 void
 umac64_digest (struct umac64_ctx *ctx,
-	       unsigned length, uint8_t *digest);
+	       size_t length, uint8_t *digest);
 void
 umac96_digest (struct umac96_ctx *ctx,
-	       unsigned length, uint8_t *digest);
+	       size_t length, uint8_t *digest);
 void
 umac128_digest (struct umac128_ctx *ctx,
-		unsigned length, uint8_t *digest);
+		size_t length, uint8_t *digest);
 
 
 /* Internal functions */
diff --git a/umac128.c b/umac128.c
index 95c90e5f..3ce0c05e 100644
--- a/umac128.c
+++ b/umac128.c
@@ -48,7 +48,7 @@ umac128_set_key (struct umac128_ctx *ctx, const uint8_t *key)
 
 void
 umac128_set_nonce (struct umac128_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce)
+		   size_t nonce_length, const uint8_t *nonce)
 {
   assert (nonce_length > 0);
   assert (nonce_length <= AES_BLOCK_SIZE);
@@ -71,7 +71,7 @@ umac128_set_nonce (struct umac128_ctx *ctx,
 
 void
 umac128_update (struct umac128_ctx *ctx,
-	       unsigned length, const uint8_t *data)
+		size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, UMAC128_BLOCK, (void)0);
 }
@@ -79,7 +79,7 @@ umac128_update (struct umac128_ctx *ctx,
 
 void
 umac128_digest (struct umac128_ctx *ctx,
-	       unsigned length, uint8_t *digest)
+		size_t length, uint8_t *digest)
 {
   uint32_t tag[4];
   unsigned i;
diff --git a/umac32.c b/umac32.c
index fd8a2819..c266a416 100644
--- a/umac32.c
+++ b/umac32.c
@@ -49,7 +49,7 @@ umac32_set_key (struct umac32_ctx *ctx, const uint8_t *key)
 
 void
 umac32_set_nonce (struct umac32_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce)
+		  size_t nonce_length, const uint8_t *nonce)
 {
   assert (nonce_length > 0);
   assert (nonce_length <= AES_BLOCK_SIZE);
@@ -71,7 +71,7 @@ umac32_set_nonce (struct umac32_ctx *ctx,
 
 void
 umac32_update (struct umac32_ctx *ctx,
-	       unsigned length, const uint8_t *data)
+	       size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, UMAC32_BLOCK, (void)0);
 }
@@ -79,7 +79,7 @@ umac32_update (struct umac32_ctx *ctx,
 
 void
 umac32_digest (struct umac32_ctx *ctx,
-	       unsigned length, uint8_t *digest)
+	       size_t length, uint8_t *digest)
 {
   uint32_t pad;
 
diff --git a/umac64.c b/umac64.c
index 3e05779a..133f2783 100644
--- a/umac64.c
+++ b/umac64.c
@@ -49,7 +49,7 @@ umac64_set_key (struct umac64_ctx *ctx, const uint8_t *key)
 
 void
 umac64_set_nonce (struct umac64_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce)
+		  size_t nonce_length, const uint8_t *nonce)
 {
   assert (nonce_length > 0);
   assert (nonce_length <= AES_BLOCK_SIZE);
@@ -72,7 +72,7 @@ umac64_set_nonce (struct umac64_ctx *ctx,
 
 void
 umac64_update (struct umac64_ctx *ctx,
-	       unsigned length, const uint8_t *data)
+	       size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, UMAC64_BLOCK, (void)0);
 }
@@ -80,7 +80,7 @@ umac64_update (struct umac64_ctx *ctx,
 
 void
 umac64_digest (struct umac64_ctx *ctx,
-	       unsigned length, uint8_t *digest)
+	       size_t length, uint8_t *digest)
 {
   uint32_t tag[2];
   uint32_t *pad;
diff --git a/umac96.c b/umac96.c
index 1c1840c9..3c7905a9 100644
--- a/umac96.c
+++ b/umac96.c
@@ -48,7 +48,7 @@ umac96_set_key (struct umac96_ctx *ctx, const uint8_t *key)
 
 void
 umac96_set_nonce (struct umac96_ctx *ctx,
-		  unsigned nonce_length, const uint8_t *nonce)
+		  size_t nonce_length, const uint8_t *nonce)
 {
   assert (nonce_length > 0);
   assert (nonce_length <= AES_BLOCK_SIZE);
@@ -70,7 +70,7 @@ umac96_set_nonce (struct umac96_ctx *ctx,
 
 void
 umac96_update (struct umac96_ctx *ctx,
-	       unsigned length, const uint8_t *data)
+	       size_t length, const uint8_t *data)
 {
   MD_UPDATE (ctx, length, data, UMAC96_BLOCK, (void)0);
 }
@@ -78,7 +78,7 @@ umac96_update (struct umac96_ctx *ctx,
 
 void
 umac96_digest (struct umac96_ctx *ctx,
-	       unsigned length, uint8_t *digest)
+	       size_t length, uint8_t *digest)
 {
   uint32_t tag[4];
   unsigned i;
-- 
GitLab