mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-23 03:05:27 +00:00
[crypto] Add base64 wrapper.
This commit is contained in:
parent
38eb0391b3
commit
4cdb213f8d
14
lib/libcrypto/include/crypto/base64.h
Normal file
14
lib/libcrypto/include/crypto/base64.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
30
lib/libcrypto/source/base64_wrapper.cpp
Normal file
30
lib/libcrypto/source/base64_wrapper.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <crypto/base64.h>
|
||||
#include <polarssl/base64.h>
|
||||
|
||||
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);
|
||||
}
|
Loading…
Reference in a new issue