From 4cef4bd0423db2a407182d2f9e534ab77fb81e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sun, 6 Oct 2002 21:15:20 +0200 Subject: [PATCH] (base64_encode_group): New function, used by openpgp armoring code. Rev: src/nettle/base64.c:1.5 Rev: src/nettle/base64.h:1.7 --- base64.c | 9 +++++++++ base64.h | 4 ++++ 2 files changed, 13 insertions(+) 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 */ { -- GitLab