Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Vadim Bendebury | 243c614 | 2015-03-27 16:08:04 -0700 | [diff] [blame] | 2 | |
| 3 | #ifndef __INCLUDE_B64_DECODE_H__ |
| 4 | #define __INCLUDE_B64_DECODE_H__ |
| 5 | |
| 6 | #include <stddef.h> |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | /* |
| 10 | * A function to convert a buffer of base64 format data into its source. |
| 11 | * |
| 12 | * The user provides output buffer of the size guaranteed to fit the result. |
| 13 | * |
Elyes HAOUAS | 8250e2e | 2019-12-06 20:25:56 +0100 | [diff] [blame] | 14 | * Returns the size of the decoded data or zero if invalid characters were |
Vadim Bendebury | 243c614 | 2015-03-27 16:08:04 -0700 | [diff] [blame] | 15 | * encountered in the input buffer. |
| 16 | */ |
| 17 | size_t b64_decode(const uint8_t *input_data, |
| 18 | size_t input_length, |
| 19 | uint8_t *output_data); |
| 20 | |
| 21 | /* A macro to derive decoded size of a base64 encoded blob. */ |
| 22 | #define B64_DECODED_SIZE(encoded_size) (((encoded_size) * 3)/4) |
| 23 | |
| 24 | #endif |