38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
#ifndef _OSAUTH2LIB_BASE64_
|
|
#define _OSAUTH2LIB_BASE64_
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
/**
|
|
* base64_encode - Base64 encode
|
|
* @src: Data to be encoded
|
|
* @len: Length of the data to be encoded
|
|
* @out_len: Pointer to output length variable, or %NULL if not used
|
|
* Returns: Allocated buffer of out_len bytes of encoded data,
|
|
* or %NULL on failure
|
|
*
|
|
* Caller is responsible for freeing the returned buffer. Returned buffer is
|
|
* nul terminated to make it easier to use as a C string. The nul terminator is
|
|
* not included in out_len.
|
|
*/
|
|
char *base64_encode(const uint8_t* src, size_t len, size_t* out_len);
|
|
|
|
/**
|
|
* base64_decode - Base64 decode
|
|
* @src: Data to be decoded
|
|
* @len: Length of the data to be decoded
|
|
* @out_len: Pointer to output length variable
|
|
* Returns: Allocated buffer of out_len bytes of decoded data,
|
|
* or %NULL on failure
|
|
*
|
|
* Caller is responsible for freeing the returned buffer.
|
|
*/
|
|
uint8_t *base64_decode(const char* src, size_t len, size_t* out_len);
|
|
|
|
|
|
char *base64url_encode(const uint8_t* src, size_t len, size_t* out_len);
|
|
uint8_t *base64url_decode(const char* src, size_t len, size_t* out_len);
|
|
|
|
#endif //_OSAUTH2LIB_BASE64_
|