aboutsummaryrefslogtreecommitdiff
path: root/src/base64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/base64.cpp')
-rw-r--r--src/base64.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/base64.cpp b/src/base64.cpp
index bf8492e..bbfb210 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "olm/base64.h"
#include "olm/base64.hh"
-
namespace {
static const std::uint8_t ENCODE_BASE64[64] = {
@@ -45,6 +45,12 @@ static const std::uint8_t DECODE_BASE64[128] = {
} // namespace
+std::size_t olm::encode_base64_length(
+ std::size_t input_length
+) {
+ return 4 * ((input_length + 2) / 3) + (input_length + 2) % 3 - 2;
+}
+
std::uint8_t * olm::encode_base64(
std::uint8_t const * input, std::size_t input_length,
std::uint8_t * output
@@ -128,3 +134,34 @@ std::uint8_t const * olm::decode_base64(
}
return input + input_length;
}
+
+
+// implementations of base64.h
+
+size_t _olm_encode_base64_length(
+ size_t input_length
+) {
+ return olm::encode_base64_length(input_length);
+}
+
+size_t _olm_encode_base64(
+ uint8_t const * input, size_t input_length,
+ uint8_t * output
+) {
+ uint8_t * r = olm::encode_base64(input, input_length, output);
+ return r - output;
+}
+
+size_t _olm_decode_base64_length(
+ size_t input_length
+) {
+ return olm::decode_base64_length(input_length);
+}
+
+size_t _olm_decode_base64(
+ uint8_t const * input, size_t input_length,
+ uint8_t * output
+) {
+ olm::decode_base64(input, input_length, output);
+ return olm::decode_base64_length(input_length);
+}