Commit 94bae335 authored by Niels Möller's avatar Niels Möller

Use size_t in testsuite.

parent 47eae4be
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
......
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