Commit 5216c63e authored by Niels Möller's avatar Niels Möller
Browse files

(test_armor): Updated to new armor

conventions.

Rev: src/nettle/testsuite/testutils.c:1.17
parent 59c4d3c3
...@@ -241,25 +241,35 @@ test_armor(const struct nettle_armor *armor, ...@@ -241,25 +241,35 @@ test_armor(const struct nettle_armor *armor,
const uint8_t *data, const uint8_t *data,
const uint8_t *ascii) const uint8_t *ascii)
{ {
void *ctx = alloca(armor->context_size); unsigned ascii_length = strlen(ascii);
uint8_t *buffer = alloca(1 + strlen(ascii)); uint8_t *buffer = alloca(1 + ascii_length);
uint8_t *check = alloca(1 + data_length); uint8_t *check = alloca(1 + data_length);
void *encode = alloca(armor->encode_context_size);
void *decode = alloca(armor->decode_context_size);
unsigned done;
memset(buffer, 0x33, 1 + strlen(ascii)); memset(buffer, 0x33, 1 + ascii_length);
memset(check, 0x55, 1 + data_length); memset(check, 0x55, 1 + data_length);
if (strlen(ascii) != armor->encode(buffer, data_length, data)) armor->encode_init(encode);
FAIL();
ASSERT(armor->encode_length(data_length) <= ascii_length);
done = armor->encode_update(encode, buffer, data_length, data);
done += armor->encode_final(encode, buffer + done);
ASSERT(done == ascii_length);
if (!MEMEQ(strlen(ascii), buffer, ascii)) if (!MEMEQ(ascii_length, buffer, ascii))
FAIL(); FAIL();
if (0x33 != buffer[strlen(ascii)]) if (0x33 != buffer[strlen(ascii)])
FAIL(); FAIL();
armor->decode_init(ctx); armor->decode_init(decode);
if (data_length != armor->decode_update(ctx, check, strlen(ascii), buffer)) ASSERT(data_length
FAIL(); == armor->decode_update(decode, check, ascii_length, buffer));
ASSERT(armor->decode_status(decode));
if (!MEMEQ(data_length, check, data)) if (!MEMEQ(data_length, check, data))
FAIL(); FAIL();
......
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