diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-10-23 16:31:21 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-11-01 10:09:19 +0100 |
commit | fc609f75f9c89f098a772ed47184c3bdf086c19d (patch) | |
tree | 7b56a4452aebaa521848af79e7b392a20a5e9f74 /include/base64.h | |
parent | 066a6b11456547471e5b1f949b3e9ca0865d79f6 (diff) | |
download | barebox-fc609f75f9c89f098a772ed47184c3bdf086c19d.tar.gz barebox-fc609f75f9c89f098a772ed47184c3bdf086c19d.tar.xz |
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 <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20231023143122.1760217-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/base64.h')
-rw-r--r-- | include/base64.h | 1 |
1 files changed, 1 insertions, 0 deletions
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)) |