• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
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  *
14  * Returns the size of the decoded data or zero if invalid characters were
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
25