Commit fbcec4c2 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.
* configure.in: Use AC_PREREQ(2.50).

Rev: src/nettle/nettle-meta.h:1.4
parent 582374c2
...@@ -126,30 +126,37 @@ extern const struct nettle_hash nettle_sha256; ...@@ -126,30 +126,37 @@ extern const struct nettle_hash nettle_sha256;
/* ASCII armor codecs */ /* ASCII armor codecs */
typedef unsigned (*nettle_armor_func)(uint8_t *dst, typedef unsigned (*nettle_armor_encode_func)(uint8_t *dst,
unsigned src_length, unsigned src_length,
const uint8_t *src); const uint8_t *src);
typedef void (*nettle_armor_init_func)(void *ctx);
typedef unsigned (*nettle_armor_update_func)(void *ctx,
uint8_t *dst,
unsigned src_length,
const uint8_t *src);
struct nettle_armor struct nettle_armor
{ {
const char *name; const char *name;
unsigned context_size;
unsigned ascii_block_size; unsigned text_block_size;
unsigned raw_block_size; unsigned binary_block_size;
nettle_armor_encode_func encode;
nettle_armor_func encode; nettle_armor_init_func decode_init;
nettle_armor_func decode; nettle_armor_update_func decode_update;
}; };
#define _NETTLE_ARMOR(name, NAME) { \ #define _NETTLE_ARMOR(name, NAME) { \
#name, \ #name, \
NAME##_ASCII_BLOCK_SIZE, \ sizeof(struct name##_ctx), \
NAME##_RAW_BLOCK_SIZE, \ NAME##_TEXT_BLOCK_SIZE, \
name##_encode, \ NAME##_BINARY_BLOCK_SIZE, \
name##_decode \ (nettle_armor_encode_func) name##_encode, \
(nettle_armor_init_func) name##_decode_init, \
(nettle_armor_update_func) name##_decode_update \
} }
extern const struct nettle_armor nettle_base64; extern const struct nettle_armor nettle_base64;
extern const struct nettle_armor nettle_base16; /* extern const struct nettle_armor nettle_base16; */
#endif /* NETTLE_META_H_INCLUDED */ #endif /* NETTLE_META_H_INCLUDED */
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