diff --git a/lib/libcrypto/include/crypto/base64.h b/lib/libcrypto/include/crypto/base64.h new file mode 100644 index 0000000..67c6ecd --- /dev/null +++ b/lib/libcrypto/include/crypto/base64.h @@ -0,0 +1,14 @@ +#pragma once +#include +#include + +namespace crypto +{ +namespace base64 +{ + size_t B64_GetEncodeLen(const uint8_t* src, size_t slen); + void B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen); + size_t B64_GetDecodeLen(const uint8_t* src, size_t slen); + void B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen); +} +} \ No newline at end of file diff --git a/lib/libcrypto/source/base64_wrapper.cpp b/lib/libcrypto/source/base64_wrapper.cpp new file mode 100644 index 0000000..1bc6f66 --- /dev/null +++ b/lib/libcrypto/source/base64_wrapper.cpp @@ -0,0 +1,30 @@ +#include +#include + +size_t crypto::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen) +{ + size_t dlen = 0; + + base64_encode(nullptr, &dlen, src, slen); + + return dlen; +} + +void crypto::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) +{ + base64_encode(dst, &dlen, src, slen); +} + +size_t crypto::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen) +{ + size_t dlen = 0; + + base64_decode(nullptr, &dlen, src, slen); + + return dlen; +} + +void crypto::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen) +{ + base64_decode(dst, &dlen, src, slen); +} \ No newline at end of file