summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2020-02-23 10:01:33 +0000
committerVincent Sanders <vince@kyllikki.org>2020-02-23 10:01:33 +0000
commit09f95e2c5f705a6a78a70ab8be1e9a9b7283aa87 (patch)
tree668a2c9b64882fb1d2121e639456c7cef14e522b /include
parentb7199a77aca01f85a3359737cd4e6c73c29bd82a (diff)
downloadlibnsutils-09f95e2c5f705a6a78a70ab8be1e9a9b7283aa87.tar.gz
libnsutils-09f95e2c5f705a6a78a70ab8be1e9a9b7283aa87.tar.bz2
add non allocating base64 encoding API
Diffstat (limited to 'include')
-rw-r--r--include/nsutils/base64.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/include/nsutils/base64.h b/include/nsutils/base64.h
index 6dba643..fb26426 100644
--- a/include/nsutils/base64.h
+++ b/include/nsutils/base64.h
@@ -28,7 +28,7 @@
* \param input_length The length of the source data.
* \param output The buffer to recive data into, the caller must free.
* \param output_length The length of data placed in \a output
- * \return NSERROR_OK on success and \a output updated else error code.
+ * \return NSUERROR_OK on success and \a output updated else error code.
*/
nsuerror nsu_base64_encode_alloc(const uint8_t *input,
size_t input_length,
@@ -38,6 +38,22 @@ nsuerror nsu_base64_encode_alloc(const uint8_t *input,
/**
* Base 64 encode data.
*
+ * encode source data into buffer it using the Base64 encoding.
+ *
+ * \param input The source data to encode.
+ * \param input_length The length of the source data.
+ * \param output The output buffer
+ * \param output_length The size of the \a output buffer on entry updated with length written on exit.
+ * \return NSUERROR_OK on success and \a output_length updated else error code.
+ */
+nsuerror nsu_base64_encode(const uint8_t *input,
+ size_t input_length,
+ uint8_t *output,
+ size_t *output_length);
+
+/**
+ * Base 64 encode data.
+ *
* allocate a buffer and encode source data into it using the base64 URL safe
* encoding.
*
@@ -52,6 +68,23 @@ nsuerror nsu_base64_encode_alloc_url(const uint8_t *input,
uint8_t **output,
size_t *output_length);
+
+/**
+ * Base 64 encode data.
+ *
+ * encode source data into buffer using the Base64 URL safe encoding.
+ *
+ * \param input The source data to encode.
+ * \param input_length The length of the source data.
+ * \param output The output buffer
+ * \param output_length The size of the \a output buffer on entry updated with length written on exit.
+ * \return NSUERROR_OK on success and \a output_length updated else error code.
+ */
+nsuerror nsu_base64_encode_url(const uint8_t *input,
+ size_t input_length,
+ uint8_t *output,
+ size_t *output_length);
+
/**
* Base 64 decode data.
*