#include <stdlib.h>
#include <stdint.h>
#include "core.h"
Go to the source code of this file.
|
size_t | lacf_base64_encode (const uint8_t *raw, size_t raw_size, uint8_t *encoded) |
|
size_t | lacf_base64_encode2 (const uint8_t *raw, size_t raw_size, uint8_t *encoded, int mod) |
|
ssize_t | lacf_base64_decode (const uint8_t *encoded, size_t encoded_size, uint8_t *raw) |
|
ssize_t | lacf_base64_decode2 (const uint8_t *encoded, size_t encoded_size, uint8_t *raw, int mod) |
|
◆ BASE64_DEC_SIZE
#define BASE64_DEC_SIZE |
( |
|
__enc_size__ | ) |
(((__enc_size__) / 4) * 3) |
Provides an estimate of how much raw data results from decoding of enc_size many base-64 encoded bytes. Unlike the macro above, this macro may slightly (by up to 2 bytes) overestimate the actual size of the decoded data, so be sure to always check the return value of base64_decode to avoid accessing uninitialized data.
Definition at line 41 of file base64.h.
◆ BASE64_ENC_SIZE
#define BASE64_ENC_SIZE |
( |
|
__raw_size__ | ) |
((((__raw_size__) + 2) / 3) * 4) |
Provides a precise computation of how much base64 data will be generated when raw_size many binary bytes a base64-encoded.
Definition at line 32 of file base64.h.
◆ lacf_base64_decode()
ssize_t lacf_base64_decode |
( |
const uint8_t * |
encoded, |
|
|
size_t |
encoded_size, |
|
|
uint8_t * |
raw |
|
) |
| |
Front-end to base64_decode2 with mod set to zero.
Definition at line 182 of file base64.c.
◆ lacf_base64_decode2()
ssize_t lacf_base64_decode2 |
( |
const uint8_t * |
encoded, |
|
|
size_t |
encoded_size, |
|
|
uint8_t * |
raw, |
|
|
int |
mod |
|
) |
| |
Decodes a Base64 encoded string, previously encoded with base64_encode.
- Parameters
-
encoded | The encoded Base64 bytes. |
encoded_size | Number of bytes in ‘encoded’. |
raw | Output buffer to be filled with decoded bytes. This buffer must contain at least BASE64_DEC_SIZE(encoded_size) bytes. |
- Returns
- The number of actual message that were encoded in the Base64 buffer, or -1 if the input was malformed.
Definition at line 199 of file base64.c.
◆ lacf_base64_encode()
size_t lacf_base64_encode |
( |
const uint8_t * |
raw, |
|
|
size_t |
raw_size, |
|
|
uint8_t * |
encoded |
|
) |
| |
Front-end to base64_encode2 with mod set to zero.
Definition at line 93 of file base64.c.
◆ lacf_base64_encode2()
size_t lacf_base64_encode2 |
( |
const uint8_t * |
raw, |
|
|
size_t |
raw_size, |
|
|
uint8_t * |
encoded, |
|
|
int |
mod |
|
) |
| |
Encodes a string of bytes into a Base64 encoding.
- Parameters
-
raw | The input buffer of raw bytes. |
raw_size | Number of bytes in ‘raw’. |
encoded | Buffer where the encoded Base64 bytes will be written. This buffer must contain at least BASE64_ENC_SIZE(raw_size) bytes. |
- Returns
- Number of bytes written to ‘encoded’. This is always equal to BASE64_ENC_SIZE(raw_size).
Definition at line 111 of file base64.c.