From fc609f75f9c89f098a772ed47184c3bdf086c19d Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 23 Oct 2023 16:31:21 +0200 Subject: lib: base64: add support for base64url base64url has some small differences to our current base64 implementation: - Instead of encoding to `+', `-' is used - Instead of encoding to `/', `_' is used - Padding with = to reach four byte boundary is optional - Invalid characters aren't silently skipped Everything else is the same though, so let's reuse the code and have an optional url bool parameter control whether to decode base64 or base64url. Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20231023143122.1760217-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- include/base64.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/base64.h') diff --git a/include/base64.h b/include/base64.h index 993a366b48..7da35e21ba 100644 --- a/include/base64.h +++ b/include/base64.h @@ -5,6 +5,7 @@ void uuencode(char *p, const char *src, int length); int decode_base64(char *dst, int dst_len, const char *src); +int decode_base64url(char *dst, int dst_len, const char *src); #define BASE64_LENGTH(len) (4 * (((len) + 2) / 3)) -- cgit v1.2.3