Base64URL
Public API for decoding
-
bde_error_t bde_base64url_decode_length(const size_t encoded_len, size_t *const decoded_len)
Obtains the length of the decoded data from the length of the Base64URL encoded string.
- Parameters:
encoded_len – [in] Length of the Base64URL encoded string, not including the
NULL
terminator.decoded_len – [out] Length of the decoded data.
- Return values:
bde_error_ok – Success.
bde_error_args – Invalid arguments.
bde_error_encoded_string – The Base64URL encoded string has an invalid form.
-
bde_error_t bde_base64url_decode(const bde_enc_t *encoded, const size_t encoded_len, const size_t decoded_max_len, bde_dec_t *const decoded, size_t *const decoded_len)
Obtains the decoded data from the Base64URL encoded string.
This function can decode inplace, it is possible to use the same buffer for the encoded and decoded data.
- Parameters:
encoded – [in] Base64URL encoded string.
encoded_len – [in] Length of
encoded
, not including theNULL
terminator.decoded_max_len – [in] Length of
decoded
.decoded – [out] Buffer where the decoded data will be written.
decoded_len – [out] Amount of data written to
decoded
, can beNULL
if not required by caller.
- Return values:
bde_error_ok – Success.
bde_error_args – Invalid arguments.
bde_error_encoded_string – The Base64URL encoded string given is not valid.
Public API for encoding
-
bde_error_t bde_base64url_encode_length(const size_t decoded_len, size_t *const encoded_len)
Obtains the length of the Base64URL encoded string from the length of the decoded data.
- Parameters:
decoded_len – [in] Length of the decoded data.
encoded_len – [out] Length of the Base64URL encoded string, not including the
NULL
terminator.
- Return values:
bde_error_ok – Success.
bde_error_args – Invalid arguments.
-
bde_error_t bde_base64url_encode(const bde_dec_t *const decoded, const size_t decoded_len, const size_t encoded_max_len, bde_enc_t *const encoded, size_t *const encoded_len)
Obtains the Base64URL encoded string from the decoded data.
This function can encode inplace, it is possible to use the same buffer for the encoded and decoded data.
- Parameters:
decoded – [in] Decoded data.
decoded_len – [in] Length of
decoded
.encoded_max_len – [in] Length of
encoded
.encoded – [out] Buffer where the Base64URL encoded string and the
NULL
terminator will be written.encoded_len – [out] Amount of data written to
encoded
, not including theNULL
terminator, can beNULL
if not required by caller.
- Return values:
bde_error_ok – Success.
bde_error_args – Invalid arguments.