]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(base64_encode_group): New function, used by openpgp
authorNiels Möller <nisse@lysator.liu.se>
Sun, 6 Oct 2002 19:15:20 +0000 (21:15 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 6 Oct 2002 19:15:20 +0000 (21:15 +0200)
armoring code.

Rev: src/nettle/base64.c:1.5
Rev: src/nettle/base64.h:1.7

base64.c
base64.h

index 566cd30b10e291610c001a39ad1aea786e127dfb..8de3b2e1d50d8a14a18830fdf3aa899f117fa74f 100644 (file)
--- 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,
index c91c5b33cac61df5301b00ff9e6ab06ed3e81e55..b45f9654d8024b91ca017933f833147a3e41154e 100644 (file)
--- 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 */
 {