aboutsummaryrefslogtreecommitdiff
path: root/tools/server/base64.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/server/base64.h')
-rw-r--r--tools/server/base64.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/server/base64.h b/tools/server/base64.h
index 88d88b3..2e77e2d 100644
--- a/tools/server/base64.h
+++ b/tools/server/base64.h
@@ -3,8 +3,18 @@
#include <stddef.h>
-/* Standard base64 (with '=' padding) of n bytes. Returns a NUL-terminated heap
- * string the caller frees; die-on-OOM, so it never returns NULL. */
+/* Standard base64 (with '=' padding). */
+
+/* Number of base64 characters for n input bytes, excluding any NUL. Aborts
+ * (die-on-OOM) if n is so large the length would overflow. */
+size_t base64_encoded_len(size_t n);
+
+/* Encode n bytes of src as base64 into dst, writing exactly base64_encoded_len(n)
+ * bytes and no NUL terminator; dst must have room for that many bytes. */
+void base64_encode_to(char *dst, const unsigned char *src, size_t n);
+
+/* Convenience wrapper: returns a NUL-terminated heap string the caller frees;
+ * die-on-OOM, so it never returns NULL. */
char *base64_encode(const unsigned char *src, size_t n);
#endif /* FFWD_BASE64_H */