summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2013-05-02 09:43:27 +0200
committerNiels Möller <nisse@lysator.liu.se>2013-05-02 09:43:27 +0200
commit94bae3359eef6c9f8a396c896145b2430044f094 (patch)
tree234d60950a7fb1aa02ad90f6bb58ed67f2823fcf
parent47eae4be510778d8fe461d9f722a34adb596439c (diff)
downloadnettle-size_t-changes.tar.gz
Use size_t in testsuite.size_t-changes
-rw-r--r--testsuite/aes-test.c2
-rw-r--r--testsuite/arctwo-test.c2
-rw-r--r--testsuite/camellia-test.c2
-rw-r--r--testsuite/des-test.c2
-rw-r--r--testsuite/salsa20-test.c13
-rw-r--r--testsuite/serpent-test.c2
-rw-r--r--testsuite/testutils.c43
-rw-r--r--testsuite/testutils.h12
-rw-r--r--testsuite/umac-test.c14
9 files changed, 48 insertions, 44 deletions
diff --git a/testsuite/aes-test.c b/testsuite/aes-test.c
index ce5fc3ff..62936d1b 100644
--- a/testsuite/aes-test.c
+++ b/testsuite/aes-test.c
@@ -9,7 +9,7 @@ test_invert(const struct tstring *key,
struct aes_ctx encrypt;
struct aes_ctx decrypt;
uint8_t *data = xalloc(cleartext->length);
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
diff --git a/testsuite/arctwo-test.c b/testsuite/arctwo-test.c
index c75bb15e..73880bee 100644
--- a/testsuite/arctwo-test.c
+++ b/testsuite/arctwo-test.c
@@ -31,7 +31,7 @@ test_arctwo(unsigned ekb,
{
struct arctwo_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
diff --git a/testsuite/camellia-test.c b/testsuite/camellia-test.c
index b7d6eaf6..9a1cb8ca 100644
--- a/testsuite/camellia-test.c
+++ b/testsuite/camellia-test.c
@@ -9,7 +9,7 @@ test_invert(const struct tstring *key,
struct camellia_ctx encrypt;
struct camellia_ctx decrypt;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
diff --git a/testsuite/des-test.c b/testsuite/des-test.c
index 574193dc..a9c0eb93 100644
--- a/testsuite/des-test.c
+++ b/testsuite/des-test.c
@@ -9,7 +9,7 @@ test_des(const struct tstring *key, int expected_parity,
{
struct des_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
diff --git a/testsuite/salsa20-test.c b/testsuite/salsa20-test.c
index 4a10a892..3a1b8eab 100644
--- a/testsuite/salsa20-test.c
+++ b/testsuite/salsa20-test.c
@@ -28,7 +28,7 @@ test_salsa20_stream(const struct tstring *key,
uint8_t data[STREAM_LENGTH + 1];
uint8_t stream[STREAM_LENGTH + 1];
uint8_t xor[SALSA20_BLOCK_SIZE];
- unsigned j;
+ size_t j;
ASSERT (iv->length == SALSA20_IV_SIZE);
ASSERT (ciphertext->length == 4*SALSA20_BLOCK_SIZE);
@@ -97,7 +97,8 @@ test_salsa20_stream(const struct tstring *key,
if (!MEMEQ(j, data, stream))
{
- fprintf(stderr, "Encrypt failed for length %u:\n", j);
+ fprintf(stderr, "Encrypt failed for length %lu:\n",
+ (unsigned long) j);
fprintf(stderr, "\nOutput: ");
print_hex(j, data);
fprintf(stderr, "\nExpected:");
@@ -107,7 +108,8 @@ test_salsa20_stream(const struct tstring *key,
}
if (!memzero_p (data + j, STREAM_LENGTH + 1 - j))
{
- fprintf(stderr, "Encrypt failed for length %u, wrote too much:\n", j);
+ fprintf(stderr, "Encrypt failed for length %lu, wrote too much:\n",
+ (unsigned long) j);
fprintf(stderr, "\nOutput: ");
print_hex(STREAM_LENGTH + 1 - j, data + j);
fprintf(stderr, "\n");
@@ -128,7 +130,7 @@ _test_salsa20(salsa20_func *crypt,
{
struct salsa20_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -143,7 +145,8 @@ _test_salsa20(salsa20_func *crypt,
crypt(&ctx, length, data, cleartext->data);
if (data[length] != 17)
{
- fprintf(stderr, "Encrypt of %u bytes wrote too much!\nInput:", length);
+ fprintf(stderr, "Encrypt of %lu bytes wrote too much!\nInput:",
+ (unsigned long) length);
tstring_print_hex(cleartext);
fprintf(stderr, "\n");
FAIL();
diff --git a/testsuite/serpent-test.c b/testsuite/serpent-test.c
index 9f40c3fc..020fcbfd 100644
--- a/testsuite/serpent-test.c
+++ b/testsuite/serpent-test.c
@@ -6,7 +6,7 @@ tstring_hex_reverse (const char *hex)
{
struct tstring *s = tstring_hex (hex);
uint8_t *p;
- unsigned length, i;
+ size_t length, i;
length = s->length;
p = s->data;
diff --git a/testsuite/testutils.c b/testsuite/testutils.c
index c757c75d..6a512762 100644
--- a/testsuite/testutils.c
+++ b/testsuite/testutils.c
@@ -63,7 +63,7 @@ xalloc(size_t size)
static struct tstring *tstring_first = NULL;
struct tstring *
-tstring_alloc (unsigned length)
+tstring_alloc (size_t length)
{
struct tstring *s = xalloc(sizeof(struct tstring) + length - 1);
s->length = length;
@@ -84,19 +84,19 @@ tstring_clear(void)
}
struct tstring *
-tstring_data(unsigned length, const char *data)
+tstring_data(size_t length, const char *data)
{
struct tstring *s = tstring_alloc (length);
memcpy (s->data, data, length);
return s;
}
-static unsigned
+static size_t
decode_hex_length(const char *h)
{
const unsigned char *hex = (const unsigned char *) h;
- unsigned count;
- unsigned i;
+ size_t count;
+ size_t i;
for (count = i = 0; hex[i]; i++)
{
@@ -116,7 +116,7 @@ static void
decode_hex(uint8_t *dst, const char *h)
{
const unsigned char *hex = (const unsigned char *) h;
- unsigned i = 0;
+ size_t i = 0;
for (;;)
{
@@ -147,7 +147,7 @@ struct tstring *
tstring_hex(const char *hex)
{
struct tstring *s;
- unsigned length = decode_hex_length(hex);
+ size_t length = decode_hex_length(hex);
s = tstring_alloc(length);
@@ -162,9 +162,9 @@ tstring_print_hex(const struct tstring *s)
}
void
-print_hex(unsigned length, const uint8_t *data)
+print_hex(size_t length, const uint8_t *data)
{
- unsigned i;
+ size_t i;
for (i = 0; i < length; i++)
{
@@ -215,7 +215,7 @@ test_cipher(const struct nettle_cipher *cipher,
{
void *ctx = xalloc(cipher->context_size);
uint8_t *data = xalloc(cleartext->length);
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -262,7 +262,7 @@ test_cipher_cbc(const struct nettle_cipher *cipher,
void *ctx = xalloc(cipher->context_size);
uint8_t *data;
uint8_t *iv = xalloc(cipher->block_size);
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -323,8 +323,8 @@ test_cipher_ctr(const struct nettle_cipher *cipher,
uint8_t *data;
uint8_t *ctr = xalloc(cipher->block_size);
uint8_t *octr = xalloc(cipher->block_size);
- unsigned length;
- unsigned low, nblocks;
+ size_t length, nblocks;
+ unsigned low;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -397,11 +397,11 @@ test_cipher_stream(const struct nettle_cipher *cipher,
const struct tstring *cleartext,
const struct tstring *ciphertext)
{
- unsigned block;
+ size_t block;
void *ctx = xalloc(cipher->context_size);
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -410,7 +410,7 @@ test_cipher_stream(const struct nettle_cipher *cipher,
for (block = 1; block <= length; block++)
{
- unsigned i;
+ size_t i;
memset(data, 0x17, length + 1);
cipher->set_encrypt_key(ctx, key->length, key->data);
@@ -426,7 +426,8 @@ test_cipher_stream(const struct nettle_cipher *cipher,
if (!MEMEQ(length, data, ciphertext->data))
{
- fprintf(stderr, "Encrypt failed, block size %d\nInput:", block);
+ fprintf(stderr, "Encrypt failed, block size %lu\nInput:",
+ (unsigned long) block);
tstring_print_hex(cleartext);
fprintf(stderr, "\nOutput: ");
print_hex(length, data);
@@ -470,7 +471,7 @@ test_aead(const struct nettle_aead *aead,
void *ctx = xalloc(aead->context_size);
uint8_t *data;
uint8_t *buffer = xalloc(aead->block_size);
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
@@ -574,14 +575,14 @@ test_hash(const struct nettle_hash *hash,
void
test_hash_large(const struct nettle_hash *hash,
- unsigned count, unsigned length,
+ size_t count, size_t length,
uint8_t c,
const struct tstring *digest)
{
void *ctx = xalloc(hash->context_size);
uint8_t *buffer = xalloc(hash->digest_size);
uint8_t *data = xalloc(length);
- unsigned i;
+ size_t i;
ASSERT (digest->length == hash->digest_size);
@@ -603,7 +604,7 @@ test_hash_large(const struct nettle_hash *hash,
void
test_armor(const struct nettle_armor *armor,
- unsigned data_length,
+ size_t data_length,
const uint8_t *data,
const uint8_t *ascii)
{
diff --git a/testsuite/testutils.h b/testsuite/testutils.h
index 123bae2b..8440dbe5 100644
--- a/testsuite/testutils.h
+++ b/testsuite/testutils.h
@@ -43,18 +43,18 @@ xalloc(size_t size);
struct tstring {
struct tstring *next;
- unsigned length;
+ size_t length;
uint8_t data[1];
};
struct tstring *
-tstring_alloc (unsigned length);
+tstring_alloc (size_t length);
void
tstring_clear(void);
struct tstring *
-tstring_data(unsigned length, const char *data);
+tstring_data(size_t length, const char *data);
struct tstring *
tstring_hex(const char *hex);
@@ -65,7 +65,7 @@ tstring_print_hex(const struct tstring *s);
/* Decodes a NUL-terminated hex string. */
void
-print_hex(unsigned length, const uint8_t *data);
+print_hex(size_t length, const uint8_t *data);
/* The main program */
void
@@ -145,13 +145,13 @@ test_hash(const struct nettle_hash *hash,
void
test_hash_large(const struct nettle_hash *hash,
- unsigned count, unsigned length,
+ size_t count, size_t length,
uint8_t c,
const struct tstring *digest);
void
test_armor(const struct nettle_armor *armor,
- unsigned data_length,
+ size_t data_length,
const uint8_t *data,
const uint8_t *ascii);
diff --git a/testsuite/umac-test.c b/testsuite/umac-test.c
index 1e9a5580..0fb97cbc 100644
--- a/testsuite/umac-test.c
+++ b/testsuite/umac-test.c
@@ -9,7 +9,7 @@
static void
update (void *ctx, nettle_hash_update_func *f,
const struct tstring *msg,
- unsigned length)
+ size_t length)
{
for (; length > msg->length; length -= msg->length)
f(ctx, msg->length, msg->data);
@@ -18,8 +18,8 @@ update (void *ctx, nettle_hash_update_func *f,
static void
check_digest (const char *name, void *ctx, nettle_hash_digest_func *f,
- const struct tstring *msg, unsigned length,
- unsigned tag_length, const uint8_t *ref)
+ const struct tstring *msg, size_t length,
+ size_t tag_length, const uint8_t *ref)
{
uint8_t tag[16];
f(ctx, tag_length, tag);
@@ -27,7 +27,7 @@ check_digest (const char *name, void *ctx, nettle_hash_digest_func *f,
{
printf ("%s failed\n", name);
printf ("msg: "); print_hex (msg->length, msg->data);
- printf ("length: %u\n", length);
+ printf ("length: %lu\n", (unsigned long) length);
printf ("tag: "); print_hex (tag_length, tag);
printf ("ref: "); print_hex (tag_length, ref);
abort ();
@@ -39,7 +39,7 @@ static void
test_umac (const struct tstring *key,
const struct tstring *nonce,
const struct tstring *msg,
- unsigned length,
+ size_t length,
const struct tstring *ref32,
const struct tstring *ref64,
const struct tstring *ref128)
@@ -91,7 +91,7 @@ static void
test_align(const struct tstring *key,
const struct tstring *nonce,
const struct tstring *msg,
- unsigned length,
+ size_t length,
const struct tstring *ref32,
const struct tstring *ref64,
const struct tstring *ref128)
@@ -106,7 +106,7 @@ test_align(const struct tstring *key,
struct umac128_ctx ctx128;
uint8_t *input;
- unsigned i;
+ size_t i;
memset(buffer, 17, length + 16);
input = buffer + offset;