[OpenWrt-Devel] [PATCH] [libubox][v2] b64: add base64 support

Felix Fietkau nbd at openwrt.org
Sun Apr 12 03:32:20 EDT 2015

On 2015-04-12 03:31, Luka Perkov wrote:
> The base code has been taken from zstream project which was
> written by Steven Barth.
> Signed-off-by: Luka Perkov <luka at openwrt.org>
> CC: Steven Barth <steven at midlink.org>
Your v2 patch did not properly consider my comments on v1. I'll repeat
them with some added clarifications.

I think output *buffers* (not just pointers to output buffer pointers)
should be passed in by the caller, and the functions should return
size_t. Your functions should not do any memory allocation at all!

You could then add an inline function that returns the maximum output
buffer size for encode/decode.


size_t b64decode(void *out, const void *in, size_t len);
size_t b64encode(void *out, const void *in, size_t len);

static inline int b64_decode_size(size_t in);
static inline int b64_encode_size(size_t in);

b64decode() should also be able to handle in == out, i.e. working within
the same buffer.

- Felix
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list