blob: 34e0e5ac85e5ee37b8eb952d3e66e3696ee1f972 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vadim Bendebury243c6142015-03-27 16:08:04 -07002
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 HAOUAS8250e2e2019-12-06 20:25:56 +010014 * Returns the size of the decoded data or zero if invalid characters were
Vadim Bendebury243c6142015-03-27 16:08:04 -070015 * encountered in the input buffer.
16 */
17size_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