[*] TLS Stack: use new AuByteBuffer apis
This commit is contained in:
parent
d68fc7fc91
commit
2b72228b9e
@ -10,6 +10,8 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include <Aurora/IO/TLS/TLS.hpp>
|
||||
|
||||
#include <mbedtls/entropy.h>
|
||||
#include <mbedtls/ctr_drbg.h>
|
||||
#include <mbedtls/ssl.h>
|
||||
#include <mbedtls/x509.h>
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace Aurora::IO::TLS
|
||||
keyPair.privateKey.RemainingBytes(),
|
||||
keyPair.sPassword.size() ? (const unsigned char *)keyPair.sPassword.c_str() : nullptr,
|
||||
keyPair.sPassword.size(),
|
||||
gEntropy,
|
||||
mbedtls_ctr_drbg_random,
|
||||
&gCtrDrbg);
|
||||
if (iRet != 0)
|
||||
{
|
||||
|
@ -117,42 +117,11 @@ namespace Aurora::IO::TLS
|
||||
|
||||
bool TLSProtocolRecv::DoOneTick(const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer)
|
||||
{
|
||||
AuUInt8 *pBase {};
|
||||
AuUInt uCount {};
|
||||
|
||||
while (true)
|
||||
{
|
||||
// sanitize end index as index zero
|
||||
if (pWriteOutByteBuffer->flagCircular &&
|
||||
pWriteOutByteBuffer->writePtr == pWriteOutByteBuffer->base + pWriteOutByteBuffer->length)
|
||||
{
|
||||
pWriteOutByteBuffer->writePtr = pWriteOutByteBuffer->base;
|
||||
|
||||
if (pWriteOutByteBuffer->readPtr == pWriteOutByteBuffer->writePtr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// fetch linear bytes, readable
|
||||
// i do not care what anybody says. you do not touch this EVER.
|
||||
// this is the most correct linear-access in unsanitized state to-date.
|
||||
// no concept in the bytebuffer exists yet.
|
||||
if (pWriteOutByteBuffer->flagCircular && pWriteOutByteBuffer->readPtr > pWriteOutByteBuffer->writePtr)
|
||||
{
|
||||
uCount = pWriteOutByteBuffer->writePtr - pWriteOutByteBuffer->readPtr;
|
||||
pBase = pWriteOutByteBuffer->writePtr;
|
||||
}
|
||||
else if (pWriteOutByteBuffer->readPtr == pWriteOutByteBuffer->writePtr)
|
||||
{
|
||||
uCount = (pWriteOutByteBuffer->base + pWriteOutByteBuffer->length) - pWriteOutByteBuffer->writePtr;
|
||||
pBase = pWriteOutByteBuffer->writePtr;
|
||||
}
|
||||
else if (pWriteOutByteBuffer->flagCircular)
|
||||
{
|
||||
uCount = (pWriteOutByteBuffer->base + pWriteOutByteBuffer->length) - pWriteOutByteBuffer->writePtr;
|
||||
pBase = pWriteOutByteBuffer->writePtr;
|
||||
}
|
||||
auto pDest = pWriteOutByteBuffer->GetNextLinearWrite();
|
||||
AuUInt8 *pBase { pDest.ToPointer() };
|
||||
AuUInt uCount { pDest.length };
|
||||
|
||||
// ...
|
||||
if (!uCount)
|
||||
|
@ -30,24 +30,9 @@ namespace Aurora::IO::TLS
|
||||
|
||||
while (pReadInByteBuffer->writePtr != pReadInByteBuffer->readPtr)
|
||||
{
|
||||
AuUInt8 *pBase {};
|
||||
AuUInt uCount {};
|
||||
|
||||
if (pReadInByteBuffer->base + pReadInByteBuffer->length == pReadInByteBuffer->readPtr)
|
||||
{
|
||||
pReadInByteBuffer->readPtr = pReadInByteBuffer->base;
|
||||
}
|
||||
|
||||
if (pReadInByteBuffer->writePtr >= pReadInByteBuffer->readPtr)
|
||||
{
|
||||
uCount = pReadInByteBuffer->writePtr - pReadInByteBuffer->readPtr;
|
||||
pBase = pReadInByteBuffer->readPtr;
|
||||
}
|
||||
else if (pReadInByteBuffer->flagCircular)
|
||||
{
|
||||
uCount = (pReadInByteBuffer->base + pReadInByteBuffer->length) - pReadInByteBuffer->readPtr;
|
||||
pBase = pReadInByteBuffer->readPtr;
|
||||
}
|
||||
auto pDest = pReadInByteBuffer->GetNextLinearRead();
|
||||
const AuUInt8 *pBase { pDest.ToPointer() };
|
||||
AuUInt uCount { pDest.length };
|
||||
|
||||
if (!uCount)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user