Base64
Base64 Utilities. More...
Modules |
|
| Types | |
|
Base64 data types.
|
|
Functions |
|
| int32_t | gos_base64_encode (unsigned char *dst, uint32_t dlen, uint32_t *olen, const unsigned char *src, uint32_t slen) |
|
Encode a buffer into base64 format.
More...
|
|
| int32_t | gos_base64_decode (unsigned char *dst, uint32_t dlen, uint32_t *olen, const unsigned char *src, uint32_t slen) |
|
Decode a base64-formatted buffer.
More...
|
|
| gos_result_t | gos_base64_init_decode_context ( gos_base64_decode_context_t **context_ptr, void *user, uint32_t processing_buffer_size) |
|
Initialize
gos_base64_decode_context_t
.
More...
|
|
| gos_result_t | gos_base64_init_encode_context ( gos_base64_encode_context_t **context_ptr, void *user, uint32_t processing_buffer_size) |
|
Initialize
gos_base64_encode_context_t
.
More...
|
|
| gos_result_t | gos_base64_encode_with_writer ( gos_base64_encode_context_t *context, const void *data, uint32_t data_len, gos_base64_writer_t writer) |
|
Base64 encode binary data with writer callback.
More...
|
|
| gos_result_t | gos_base64_decode_with_reader ( gos_base64_decode_context_t *context, void *data, uint32_t data_len, gos_base64_reader_t reader) |
|
Base64 decode into binaryd data with reader callback.
More...
|
|
| void | gos_base64_destroy_context (void *context) |
|
Cleanup encode/decode context.
More...
|
|
Detailed Description
Base64 Utilities.
Function Documentation
◆ gos_base64_decode()
| int32_t gos_base64_decode | ( | unsigned char * |
dst,
|
| uint32_t |
dlen,
|
||
| uint32_t * |
olen,
|
||
| const unsigned char * |
src,
|
||
| uint32_t |
slen
|
||
| ) |
Decode a base64-formatted buffer.
- Parameters
-
dstdestination buffer dlensize of the destination buffer olennumber of bytes written srcsource buffer slenamount of data to be decoded
- Returns
- 0 if successful, MYKROSSL_ERR_BASE64_BUFFER_TOO_SMALL, or MYKROSSL_ERR_BASE64_INVALID_DATA if the input data is not correct. *dlen is always updated to reflect the amount of data that has (or would have) been written.
- Note
- Call this function with *dlen = 0 to obtain the required buffer size in *dlen
◆ gos_base64_decode_with_reader()
| gos_result_t gos_base64_decode_with_reader | ( | gos_base64_decode_context_t * |
context,
|
| void * |
data,
|
||
| uint32_t |
data_len,
|
||
| gos_base64_reader_t |
reader
|
||
| ) |
Base64 decode into binaryd data with reader callback.
Chunks of base64 encoded data are read using the supplied reader callback and decoded into the supplied buffer. This API is useful as it ensures each chunk of arbitrary length data is properly decoded without requiring base64 padding of the chunks.
- Note
- This API requires that the length of the non-base64 encoded data is known a priori. While this API may be called as many times as needed. The total sum of the supplied 'data_len' arguments must equal length of the non-base64 encoded binary data in bytes.
- Parameters
-
[in] contextDecoding context pre-initialized with gos_base64_init_decode_context() [in] dataBuffer to hold decoded binary data [in] data_lenLength of supplied data buffer [in] readerReader callback to read base64 encoded data
- Returns
- gos_result_t
◆ gos_base64_destroy_context()
| void gos_base64_destroy_context | ( | void * |
context
|
) |
Cleanup encode/decode context.
This cleans up (i.e de-allocates) a context allocated by gos_base64_init_encode_context() or gos_base64_init_decode_context()
- Parameters
-
[in] contextContext to be de-allocated
◆ gos_base64_encode()
| int32_t gos_base64_encode | ( | unsigned char * |
dst,
|
| uint32_t |
dlen,
|
||
| uint32_t * |
olen,
|
||
| const unsigned char * |
src,
|
||
| uint32_t |
slen
|
||
| ) |
Encode a buffer into base64 format.
- Parameters
-
dstdestination buffer dlensize of the buffer olennumber of bytes written srcsource buffer slenamount of data to be encoded
- Returns
- 0 if successful, or MYKROSSL_ERR_BASE64_BUFFER_TOO_SMALL. *dlen is always updated to reflect the amount of data that has (or would have) been written.
- Note
- Call this function with *dlen = 0 to obtain the required buffer size in *dlen
◆ gos_base64_encode_with_writer()
| gos_result_t gos_base64_encode_with_writer | ( | gos_base64_encode_context_t * |
context,
|
| const void * |
data,
|
||
| uint32_t |
data_len,
|
||
| gos_base64_writer_t |
writer
|
||
| ) |
Base64 encode binary data with writer callback.
Arbitrary chunks of binary data are base64 encoded and written using the supplied 'writer' callback. This API is useful as the supplied chunks may be any length. The API ensures the written data is properly base64 encoded as a continuous stream of data (i.e. it ensures no base64 encode padding is applied to the end of the data chunks).
- Note
-
To ensure proper base64 encode padding, once all data is written call this API a final time with a NULL data buffer, e.g.
gos_base64_encode_with_writer(context, NULL, 0, base64_writer_callback);
- Parameters
-
[in] contextEncoding context pre-initialized with gos_base64_init_encode_context() [in] dataBinary data to base64 encode [in] data_lenLength of supplied data buffer [in] writerWriter callback to write base64 encoded data
- Returns
- gos_result_t
◆ gos_base64_init_decode_context()
| gos_result_t gos_base64_init_decode_context | ( | gos_base64_decode_context_t ** |
context_ptr,
|
| void * |
user,
|
||
| uint32_t |
processing_buffer_size
|
||
| ) |
Initialize gos_base64_decode_context_t .
This must be called before gos_base64_decode_with_reader()
Use gos_base64_destroy_context() to cleanup the context.
- Parameters
-
[out] context_ptrPointer to hold allocated gos_base64_decode_context_t [in] userUser specificied argument passed to gos_base64_reader_t [in] processing_buffer_sizesize of decode processing buffer. A larger buffer typically means faster decoding. Typical value is 1024.
◆ gos_base64_init_encode_context()
| gos_result_t gos_base64_init_encode_context | ( | gos_base64_encode_context_t ** |
context_ptr,
|
| void * |
user,
|
||
| uint32_t |
processing_buffer_size
|
||
| ) |
Initialize gos_base64_encode_context_t .
Use gos_base64_destroy_context() to cleanup the context.
- Parameters
-
[out] context_ptrPointer to hold allocated gos_base64_encode_context_t [in] userUser specificied argument passed to gos_base64_writer_t [in] processing_buffer_sizesize of encoding processing buffer. A larger buffer typically means faster encoding. Typical value is 1024.