From: Niels Möller Date: Sun, 6 Oct 2002 19:15:20 +0000 (+0200) Subject: (base64_encode_group): New function, used by openpgp X-Git-Tag: nettle_1.7_release_20030311~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cef4bd0423db2a407182d2f9e534ab77fb81e9b;p=thirdparty%2Fnettle.git (base64_encode_group): New function, used by openpgp armoring code. Rev: src/nettle/base64.c:1.5 Rev: src/nettle/base64.h:1.7 --- diff --git a/base64.c b/base64.c index 566cd30b..8de3b2e1 100644 --- a/base64.c +++ b/base64.c @@ -59,6 +59,15 @@ static const signed char decode_table[256] = #define ENCODE(x) (encode_table[0x3F & (x)]) +void +base64_encode_group(uint8_t *dst, uint32_t group) +{ + *dst++ = ENCODE(group >> 18); + *dst++ = ENCODE(group >> 12); + *dst++ = ENCODE(group >> 6); + *dst++ = ENCODE(group); +} + unsigned base64_encode(uint8_t *dst, unsigned src_length, diff --git a/base64.h b/base64.h index c91c5b33..b45f9654 100644 --- a/base64.h +++ b/base64.h @@ -46,6 +46,10 @@ base64_encode(uint8_t *dst, ((BASE64_BINARY_BLOCK_SIZE - 1 + (src_length)) \ / BASE64_BINARY_BLOCK_SIZE * BASE64_TEXT_BLOCK_SIZE) +/* Encode a single group */ +void +base64_encode_group(uint8_t *dst, uint32_t group); + /* FIXME: Perhaps rename to base64_decode_ctx? */ struct base64_ctx /* Internal, do not modify */ {