summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/base64.h
blob: 129594154347eeaae9393befe58e63b7d16095f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _IPXE_BASE64_H
#define _IPXE_BASE64_H

/** @file
 *
 * Base64 encoding
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

#include <stdint.h>

/**
 * Calculate length of base64-encoded string
 *
 * @v raw_len		Raw string length (excluding NUL)
 * @ret encoded_len	Encoded string length (excluding NUL)
 */
static inline size_t base64_encoded_len ( size_t raw_len ) {
	return ( ( ( raw_len + 3 - 1 ) / 3 ) * 4 );
}

extern void base64_encode ( const char *raw, char *encoded );

#endif /* _IPXE_BASE64_H */