[*] transition parse apis that use the old bytebuffer write-into semantics
This commit is contained in:
parent
a7bb5507bb
commit
50a3ee76f6
@ -14,20 +14,19 @@ namespace Aurora::Parse
|
||||
AUKN_SYM bool Base32Decode(const AuString &in, AuByteBuffer &decoded)
|
||||
{
|
||||
unsigned long length = in.size();
|
||||
|
||||
if (!AuTryResize(decoded, length))
|
||||
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(length);
|
||||
if (!writeView)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto status = base32_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length, BASE32_RFC4648);
|
||||
if (!AuTryResize(decoded, length))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto status = ::base32_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length, BASE32_RFC4648);
|
||||
decoded.writePtr += length;
|
||||
return status == CRYPT_OK;
|
||||
}
|
||||
|
||||
@ -41,7 +40,11 @@ namespace Aurora::Parse
|
||||
return false;
|
||||
}
|
||||
|
||||
auto status = base32_encode(reinterpret_cast<const unsigned char *>(buffer), (unsigned long)length, &encoded[0], &outLength, BASE32_RFC4648);
|
||||
auto status = ::base32_encode(AuReinterpretCast<const unsigned char *>(buffer),
|
||||
(unsigned long)length,
|
||||
&encoded[0],
|
||||
&outLength,
|
||||
BASE32_RFC4648);
|
||||
if (!AuTryResize(encoded, length))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
|
@ -15,28 +15,30 @@ namespace Aurora::Parse
|
||||
{
|
||||
unsigned long length = (unsigned long)in.size();
|
||||
|
||||
if (!AuTryResize(decoded, length))
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(length);
|
||||
if (!writeView)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
|
||||
int status;
|
||||
if (url)
|
||||
{
|
||||
status = base64url_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
|
||||
status = ::base64url_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = base64_decode(in.data(), (unsigned long)in.size(), reinterpret_cast<unsigned char *>(&decoded[0]), &length);
|
||||
}
|
||||
|
||||
if (!AuTryResize(decoded, length))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
status = ::base64_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length);
|
||||
}
|
||||
|
||||
decoded.writePtr += length;
|
||||
return status == CRYPT_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user