Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge base64url #2341

Merged
merged 3 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features Added

[[#2329](https://github.com/Azure/azure-sdk-for-c/pull/2329)] Add Base64 URL decoder.

### Breaking Changes

### Bugs Fixed
Expand Down
35 changes: 35 additions & 0 deletions sdk/inc/azure/core/az_base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,41 @@ az_base64_decode(az_span destination_bytes, az_span source_base64_text, int32_t*
*/
AZ_NODISCARD int32_t az_base64_get_max_decoded_size(int32_t source_base64_text_size);

/**
* @brief Decodes the span of UTF-8 encoded text represented as base 64 url into binary data.
*
* @param destination_bytes The output #az_span where the decoded binary data should be copied to as
* a result of the operation.
* @param[in] source_base64_url_text The input #az_span that contains the base 64 text to be
* decoded.
* @param[out] out_written A pointer to an `int32_t` that receives the number of bytes written into
* the destination #az_span. This can be used to slice the output for subsequent calls, if
* necessary.
*
* @return An #az_result value indicating the result of the operation.
* @retval #AZ_OK Success.
* @retval #AZ_ERROR_NOT_ENOUGH_SPACE The \p destination_bytes is not large enough to contain
* the decoded text.
* @retval #AZ_ERROR_UNEXPECTED_CHAR The input \p source_base64_url_text contains characters outside
* of the expected base 64 range or is incomplete (that is, has length % 4 == 1 characters).
* @retval #AZ_ERROR_UNEXPECTED_END The input \p source_base64_url_text is incomplete (that is, it
* is of a size which is length % 4 == 1 characters).
*/
AZ_NODISCARD az_result az_base64_url_decode(
az_span destination_bytes,
az_span source_base64_url_text,
int32_t* out_written);

/**
* @brief Returns the maximum length of the result if you were to decode an #az_span of the
* specified length which contained base 64 url encoded text.
*
* @param source_base64_url_text_size The size of the span containing base 64 encoded text.
*
* @return The maximum length of the result.
*/
AZ_NODISCARD int32_t az_base64_url_get_max_decoded_size(int32_t source_base64_url_text_size);

#include <azure/core/_az_cfg_suffix.h>

#endif // _az_BASE64_H
Loading