Skip to content
Snippets Groups Projects
Commit 55aa7d9d authored by Dan Egnor's avatar Dan Egnor Committed by Niels Möller
Browse files

Applied patch from Dan Egnor improving the base64 code.

* base64.h (BASE64_ENCODE_LENGTH): New macro.
(struct base64_ctx): New context struct, for decoding.
(BASE64_DECODE_LENGTH): New macro.
* base64.c (base64_decode_init): New function.
(base64_decode_update): New function, replacing base64_decode.
Takes a struct base64_ctx argument.
* nettle-meta.h: Updated nettle_armor, and related typedefs and
macros.
* testsuite/testutils.c (test_armor): Updated.
* configure.in: Use AC_PREREQ(2.50).

Rev: src/nettle/testsuite/testutils.c:1.9
parent fbcec4c2
No related branches found
No related tags found
No related merge requests found
...@@ -228,11 +228,12 @@ test_armor(const struct nettle_armor *armor, ...@@ -228,11 +228,12 @@ 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);
uint8_t *buffer = alloca(1 + strlen(ascii)); uint8_t *buffer = alloca(1 + strlen(ascii));
uint8_t *check = alloca(1 + data_length); uint8_t *check = alloca(1 + data_length);
memset(buffer, 0, 1 + strlen(ascii)); memset(buffer, 0x33, 1 + strlen(ascii));
memset(check, 0, 1 + data_length); memset(check, 0x55, 1 + data_length);
if (strlen(ascii) != armor->encode(buffer, data_length, data)) if (strlen(ascii) != armor->encode(buffer, data_length, data))
FAIL(); FAIL();
...@@ -240,16 +241,17 @@ test_armor(const struct nettle_armor *armor, ...@@ -240,16 +241,17 @@ test_armor(const struct nettle_armor *armor,
if (!MEMEQ(strlen(ascii), buffer, ascii)) if (!MEMEQ(strlen(ascii), buffer, ascii))
FAIL(); FAIL();
if (buffer[strlen(ascii)]) if (0x33 != buffer[strlen(ascii)])
FAIL(); FAIL();
if (data_length != armor->decode(check, strlen(ascii), buffer)) armor->decode_init(ctx);
if (data_length != armor->decode_update(ctx, check, strlen(ascii), buffer))
FAIL(); FAIL();
if (!MEMEQ(data_length, check, data)) if (!MEMEQ(data_length, check, data))
FAIL(); FAIL();
if (check[data_length]) if (0x55 != check[data_length])
FAIL(); FAIL();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment