summaryrefslogtreecommitdiffstats
path: root/include/linux/base64.h
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2022-06-27 11:51:59 +0200
committerJens Axboe <axboe@kernel.dk>2022-08-02 17:14:47 -0600
commita116e1cdc64a743c36c40e6fa639dec991c157a3 (patch)
tree06203e96d2cf80d2dec7b2a72c1e83acd08cfce2 /include/linux/base64.h
parent9e2f284e149124aa9a6b963882d2b39ae1742196 (diff)
downloadlinux-a116e1cdc64a743c36c40e6fa639dec991c157a3.tar.gz
linux-a116e1cdc64a743c36c40e6fa639dec991c157a3.tar.bz2
linux-a116e1cdc64a743c36c40e6fa639dec991c157a3.zip
lib/base64: RFC4648-compliant base64 encoding
Add RFC4648-compliant base64 encoding and decoding routines, based on the base64url encoding in fs/crypto/fname.c. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Cc: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/base64.h')
-rw-r--r--include/linux/base64.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/base64.h b/include/linux/base64.h
new file mode 100644
index 000000000000..660d4cb1ef31
--- /dev/null
+++ b/include/linux/base64.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * base64 encoding, lifted from fs/crypto/fname.c.
+ */
+
+#ifndef _LINUX_BASE64_H
+#define _LINUX_BASE64_H
+
+#include <linux/types.h>
+
+#define BASE64_CHARS(nbytes) DIV_ROUND_UP((nbytes) * 4, 3)
+
+int base64_encode(const u8 *src, int len, char *dst);
+int base64_decode(const char *src, int len, u8 *dst);
+
+#endif /* _LINUX_BASE64_H */