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;
{
struct arctwo_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
struct camellia_ctx encrypt;
struct camellia_ctx decrypt;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
{
struct des_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
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);
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:");
}
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");
{
struct salsa20_ctx ctx;
uint8_t *data;
- unsigned length;
+ size_t length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
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();
{
struct tstring *s = tstring_hex (hex);
uint8_t *p;
- unsigned length, i;
+ size_t length, i;
length = s->length;
p = s->data;
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;
}
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++)
{
decode_hex(uint8_t *dst, const char *h)
{
const unsigned char *hex = (const unsigned char *) h;
- unsigned i = 0;
+ size_t i = 0;
for (;;)
{
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);
}
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++)
{
{
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;
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;
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;
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;
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);
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);
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;
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);
void
test_armor(const struct nettle_armor *armor,
- unsigned data_length,
+ size_t data_length,
const uint8_t *data,
const uint8_t *ascii)
{
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);
/* 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
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);
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);
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);
{
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 ();
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)
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)
struct umac128_ctx ctx128;
uint8_t *input;
- unsigned i;
+ size_t i;
memset(buffer, 17, length + 16);
input = buffer + offset;