[*] API design change, MemoryViews must be passed by reference such that a pointer to an object that may be the superclass of the actual RAII owner of the memory is passed
This commit is contained in:
parent
2c68cf529a
commit
412d798994
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace Aurora::Crypto::AES
|
namespace Aurora::Crypto::AES
|
||||||
{
|
{
|
||||||
AUKN_SYM AuUInt GetSafeCipherPadding(Memory::MemoryViewRead plainText);
|
AUKN_SYM AuUInt GetSafeCipherPadding(const Memory::MemoryViewRead & plainText);
|
||||||
|
|
||||||
// Remember: AES works in chunks of 128 bits
|
// Remember: AES works in chunks of 128 bits
|
||||||
// IVS are 16 bytes long
|
// IVS are 16 bytes long
|
||||||
@ -20,17 +20,17 @@ namespace Aurora::Crypto::AES
|
|||||||
// It is not the end of the world if an IV is made public by design
|
// It is not the end of the world if an IV is made public by design
|
||||||
// Keys must be random
|
// Keys must be random
|
||||||
// Initialization vectors could be derived from SHA1, Tiger, or SHA2 digests
|
// Initialization vectors could be derived from SHA1, Tiger, or SHA2 digests
|
||||||
AUKN_SYM bool Encrypt(Memory::MemoryViewRead plainText,
|
AUKN_SYM bool Encrypt(const Memory::MemoryViewRead & plainText,
|
||||||
Memory::MemoryViewRead inIv,
|
const Memory::MemoryViewRead & inIv,
|
||||||
Memory::MemoryViewWrite outIv,
|
const Memory::MemoryViewWrite & outIv,
|
||||||
Memory::MemoryViewRead inKey,
|
const Memory::MemoryViewRead & inKey,
|
||||||
AuList<AuUInt8> &out,
|
AuList<AuUInt8> &out,
|
||||||
bool auCoolCodePadding);
|
bool auCoolCodePadding);
|
||||||
|
|
||||||
AUKN_SYM bool Decrypt(Memory::MemoryViewRead cipherText,
|
AUKN_SYM bool Decrypt(const Memory::MemoryViewRead & cipherText,
|
||||||
Memory::MemoryViewRead inIv,
|
const Memory::MemoryViewRead & inIv,
|
||||||
Memory::MemoryViewWrite outIv,
|
const Memory::MemoryViewWrite & outIv,
|
||||||
Memory::MemoryViewRead inKey,
|
const Memory::MemoryViewRead & inKey,
|
||||||
AuList<AuUInt8>& plainText,
|
AuList<AuUInt8>& plainText,
|
||||||
bool auCoolCodePadding);
|
bool auCoolCodePadding);
|
||||||
}
|
}
|
@ -9,46 +9,42 @@
|
|||||||
|
|
||||||
namespace Aurora::Crypto::ECC
|
namespace Aurora::Crypto::ECC
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
class IECCPublic
|
class IECCPublic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual bool Verify(const Memory::MemoryViewRead &payload,
|
||||||
virtual bool Verify(const void *hash, AuUInt hashLength,
|
const Memory::MemoryViewRead &signature) = 0;
|
||||||
const void *sigBuffer, AuUInt sigLength) = 0;
|
|
||||||
|
|
||||||
virtual bool Verify(const void *buffer, AuUInt length,
|
|
||||||
const void *sigBuffer, AuUInt sigLength,
|
|
||||||
EHashType method) = 0;
|
|
||||||
|
|
||||||
virtual bool Verify(const AuList<AuUInt8> &buffer, const AuList<AuUInt8> &sig,
|
|
||||||
EHashType method) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool AsPublicECC(PublicECCKey &out) = 0;
|
virtual bool AsPublicECC(AuList<AuUInt8> &out) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IECCPrivate
|
class IECCPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool Sign(const void *buffer, AuUInt length,
|
virtual bool Sign(const Memory::MemoryViewRead &payload,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
AuList<AuUInt8> &out) = 0;
|
AuList<AuUInt8> &out) = 0;
|
||||||
|
|
||||||
virtual bool Sign(const AuList<AuUInt8> &in,
|
virtual bool ECDH(const AuSPtr<IECCPublic> &partnerPublic,
|
||||||
EHashType method,
|
AuList<AuUInt8> &sharedKey) = 0;
|
||||||
AuList<AuUInt8> &out) = 0;
|
|
||||||
|
|
||||||
|
virtual bool AsPublicECC(AuList<AuUInt8> &out) = 0;
|
||||||
virtual bool Sign(const void *hash, AuUInt hashLength, AuList<AuUInt8> &out) = 0;
|
virtual bool AsPrivateECC(AuList<AuUInt8> &out) = 0;
|
||||||
|
|
||||||
virtual bool ECDH(IECCPublic *partnerPublic, AuList<AuUInt8> &sharedKey) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool AsPublicECC(PublicECCKey &out) = 0;
|
|
||||||
virtual bool AsPrivateECC(PrivateECCKey &out) = 0;
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
enum EECCCurve
|
||||||
|
{
|
||||||
|
eCurve256,
|
||||||
|
eCurve384,
|
||||||
|
eCurveX25519,
|
||||||
|
eCurveEd25519
|
||||||
|
};
|
||||||
|
|
||||||
|
AUKN_SHARED_API(NewECC, IECCPrivate, EECCCurve curve);
|
||||||
|
AUKN_SHARED_API(OpenPrivateECC, IECCPrivate, EECCCurve curve, const Memory::MemoryViewRead &pk);
|
||||||
|
AUKN_SHARED_API(OpenPublicECC, IECCPublic, EECCCurve curve, const Memory::MemoryViewRead &pk);
|
||||||
|
AUKN_SHARED_API(OpenPublicECCFromCert, IECCPublic, EECCCurve curve, const Memory::MemoryViewRead &certificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "25519/25519.hpp"
|
#include "25519/25519.hpp"
|
||||||
|
@ -13,12 +13,12 @@ namespace Aurora::Crypto::RSA
|
|||||||
class IRSAPrivate
|
class IRSAPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool Sign(Memory::MemoryViewRead payload,
|
virtual bool Sign(const Memory::MemoryViewRead & payload,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) = 0;
|
AuList<AuUInt8> &out) = 0;
|
||||||
|
|
||||||
virtual bool Decrypt(Memory::MemoryViewRead payload,
|
virtual bool Decrypt(const Memory::MemoryViewRead & payload,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) = 0;
|
AuList<AuUInt8> &out) = 0;
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ namespace Aurora::Crypto::RSA
|
|||||||
class IRSAPublic
|
class IRSAPublic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool Verify(Memory::MemoryViewRead payload,
|
virtual bool Verify(const Memory::MemoryViewRead & payload,
|
||||||
Memory::MemoryViewRead signature,
|
const Memory::MemoryViewRead & signature,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type) = 0;
|
EPaddingType type) = 0;
|
||||||
|
|
||||||
virtual bool Encrypt(Memory::MemoryViewRead plainText,
|
virtual bool Encrypt(const Memory::MemoryViewRead & plainText,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) = 0;
|
AuList<AuUInt8> &out) = 0;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace Aurora::IO::Buffered
|
|||||||
return EStreamError::eErrorNone;
|
return EStreamError::eErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError ArbitraryRead(AuUInt32 offset, Memory::MemoryViewStreamWrite paramters) override
|
virtual EStreamError ArbitraryRead(AuUInt32 offset, const Memory::MemoryViewStreamWrite ¶mters) override
|
||||||
{
|
{
|
||||||
if (buffer_.empty()) return EStreamError::eErrorEndOfStream;
|
if (buffer_.empty()) return EStreamError::eErrorEndOfStream;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace Aurora::IO::Buffered
|
|||||||
return EStreamError::eErrorNone;
|
return EStreamError::eErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError Read(Memory::MemoryViewStreamWrite paramters) override
|
virtual EStreamError Read(const Memory::MemoryViewStreamWrite ¶mters) override
|
||||||
{
|
{
|
||||||
auto realEndOffset = std::min(buffer_.size() - offset_, paramters.length);
|
auto realEndOffset = std::min(buffer_.size() - offset_, paramters.length);
|
||||||
if (realEndOffset == 0) return EStreamError::eErrorEndOfStream;
|
if (realEndOffset == 0) return EStreamError::eErrorEndOfStream;
|
||||||
|
@ -22,7 +22,7 @@ namespace Aurora::IO::Buffered
|
|||||||
return EStreamError::eErrorNone;
|
return EStreamError::eErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError Write(Memory::MemoryViewStreamRead parameters) override
|
virtual EStreamError Write(const Memory::MemoryViewStreamRead & parameters) override
|
||||||
{
|
{
|
||||||
auto idx = buffer_.size();
|
auto idx = buffer_.size();
|
||||||
buffer_.resize(idx + parameters.length);
|
buffer_.resize(idx + parameters.length);
|
||||||
|
@ -29,7 +29,7 @@ namespace Aurora::IO::FS
|
|||||||
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError ArbitraryRead(AuUInt32 offset, Memory::MemoryViewStreamWrite paramters) override
|
virtual EStreamError ArbitraryRead(AuUInt32 offset, const Memory::MemoryViewStreamWrite ¶mters) override
|
||||||
{
|
{
|
||||||
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
||||||
if (!stream_->SetOffset(offset)) return EStreamError::eErrorEndOfStream;
|
if (!stream_->SetOffset(offset)) return EStreamError::eErrorEndOfStream;
|
||||||
|
@ -29,7 +29,7 @@ namespace Aurora::IO::FS
|
|||||||
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError Read(Memory::MemoryViewStreamWrite paramters) override
|
virtual EStreamError Read(const Memory::MemoryViewStreamWrite ¶mters) override
|
||||||
{
|
{
|
||||||
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
||||||
if (!stream_->Read(paramters)) return EStreamError::eErrorStreamInterrupted;
|
if (!stream_->Read(paramters)) return EStreamError::eErrorStreamInterrupted;
|
||||||
|
@ -15,8 +15,8 @@ namespace Aurora::IO::FS
|
|||||||
virtual AuUInt64 GetOffset() = 0;
|
virtual AuUInt64 GetOffset() = 0;
|
||||||
virtual bool SetOffset(AuUInt64 offset) = 0;
|
virtual bool SetOffset(AuUInt64 offset) = 0;
|
||||||
virtual AuUInt64 GetLength() = 0;
|
virtual AuUInt64 GetLength() = 0;
|
||||||
virtual bool Read(Memory::MemoryViewStreamWrite parameters) = 0;
|
virtual bool Read(const Memory::MemoryViewStreamWrite ¶meters) = 0;
|
||||||
virtual bool Write(Memory::MemoryViewStreamRead parameters) = 0;
|
virtual bool Write(const Memory::MemoryViewStreamRead ¶meters) = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ namespace Aurora::IO::FS
|
|||||||
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
return stream_ ? EStreamError::eErrorNone : EStreamError::eErrorStreamInterrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EStreamError Write(Memory::MemoryViewStreamRead parameters) override
|
virtual EStreamError Write(const Memory::MemoryViewStreamRead & parameters) override
|
||||||
{
|
{
|
||||||
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
if (!stream_) return EStreamError::eErrorStreamNotOpen;
|
||||||
if (!stream_->Write(parameters)) return EStreamError::eErrorStreamInterrupted;
|
if (!stream_->Write(parameters)) return EStreamError::eErrorStreamInterrupted;
|
||||||
|
@ -13,7 +13,7 @@ namespace Aurora::IO
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual EStreamError Open() = 0;
|
virtual EStreamError Open() = 0;
|
||||||
virtual EStreamError ArbitraryRead(AuUInt32 offset, Memory::MemoryViewStreamWrite paramters) = 0;
|
virtual EStreamError ArbitraryRead(AuUInt32 offset, const Memory::MemoryViewStreamWrite ¶mters) = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ namespace Aurora::IO
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual EStreamError Open() = 0;
|
virtual EStreamError Open() = 0;
|
||||||
virtual EStreamError Read(Memory::MemoryViewStreamWrite paramters) = 0;
|
virtual EStreamError Read(const Memory::MemoryViewStreamWrite ¶mters) = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
|
|
||||||
EStreamError ReadAll(AuList<AuUInt8> &buffer)
|
EStreamError ReadAll(AuList<AuUInt8> &buffer)
|
||||||
|
@ -13,7 +13,7 @@ namespace Aurora::IO
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual EStreamError Open() = 0;
|
virtual EStreamError Open() = 0;
|
||||||
virtual EStreamError Write(Memory::MemoryViewStreamRead parameters) = 0;
|
virtual EStreamError Write(const Memory::MemoryViewStreamRead & parameters) = 0;
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
namespace Aurora::Locale::Encoding
|
namespace Aurora::Locale::Encoding
|
||||||
{
|
{
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t EncodeUTF8(Aurora::Memory::MemoryViewRead utf8, Aurora::Memory::MemoryViewWrite binary, ECodePage page = ECodePage::eUnsupported);
|
AUKN_SYM AuStreamReadWrittenPair_t EncodeUTF8(const Aurora::Memory::MemoryViewRead & utf8, const Aurora::Memory::MemoryViewWrite & binary, ECodePage page = ECodePage::eUnsupported);
|
||||||
static inline AuStreamReadWrittenPair_t EncodeUTF8(const AuString &utf8, Aurora::Memory::MemoryViewWrite binary, ECodePage page = ECodePage::eUnsupported)
|
static inline AuStreamReadWrittenPair_t EncodeUTF8(const AuString &utf8, const Aurora::Memory::MemoryViewWrite & binary, ECodePage page = ECodePage::eUnsupported)
|
||||||
{
|
{
|
||||||
return EncodeUTF8(Aurora::Memory::MemoryViewRead(utf8), binary, page);
|
return EncodeUTF8(Aurora::Memory::MemoryViewRead(utf8), binary, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM std::optional<AuPair<ECodePage, AuUInt8>> DecodeBOM(Aurora::Memory::MemoryViewRead binary);
|
AUKN_SYM std::optional<AuPair<ECodePage, AuUInt8>> DecodeBOM(const Aurora::Memory::MemoryViewRead & binary);
|
||||||
|
|
||||||
/// Translates a buffer, possibly a slice of a stream, to UTF-8
|
/// Translates a buffer, possibly a slice of a stream, to UTF-8
|
||||||
/// Returns a pair; bytes consumed, bytes written
|
/// Returns a pair; bytes consumed, bytes written
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(Aurora::Memory::MemoryViewRead binary, Aurora::Memory::MemoryViewWrite utf8, ECodePage page = ECodePage::eUnsupported);
|
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(const Aurora::Memory::MemoryViewRead & binary, const Aurora::Memory::MemoryViewWrite & utf8, ECodePage page = ECodePage::eUnsupported);
|
||||||
|
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(Aurora::Memory::MemoryViewRead binary, AuString &out, ECodePage page = ECodePage::eUnsupported);
|
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(const Aurora::Memory::MemoryViewRead & binary, AuString &out, ECodePage page = ECodePage::eUnsupported);
|
||||||
}
|
}
|
@ -158,6 +158,7 @@ namespace Aurora::Memory
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuUInt &outVariable;
|
AuUInt &outVariable;
|
||||||
|
private:
|
||||||
AuUInt unused;
|
AuUInt unused;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,7 +104,6 @@ namespace Aurora::Console::ConsoleFIO
|
|||||||
|
|
||||||
if (gFileHandle)
|
if (gFileHandle)
|
||||||
{
|
{
|
||||||
AuUInt idc;
|
|
||||||
gFileHandle->Write(Aurora::Memory::MemoryViewStreamRead(gLogBuffer));
|
gFileHandle->Write(Aurora::Memory::MemoryViewStreamRead(gLogBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace Aurora::Crypto::AES
|
namespace Aurora::Crypto::AES
|
||||||
{
|
{
|
||||||
AUKN_SYM AuUInt GetSafeCipherPadding(Memory::MemoryViewRead parameters)
|
AUKN_SYM AuUInt GetSafeCipherPadding(const Memory::MemoryViewRead & parameters)
|
||||||
{
|
{
|
||||||
auto tptr = reinterpret_cast<const unsigned char *>(parameters.ptr);
|
auto tptr = reinterpret_cast<const unsigned char *>(parameters.ptr);
|
||||||
|
|
||||||
@ -139,10 +139,10 @@ namespace Aurora::Crypto::AES
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM bool Encrypt(Memory::MemoryViewRead plainText,
|
AUKN_SYM bool Encrypt(const Memory::MemoryViewRead & plainText,
|
||||||
Memory::MemoryViewRead inIv,
|
const Memory::MemoryViewRead & inIv,
|
||||||
Memory::MemoryViewWrite outIv,
|
const Memory::MemoryViewWrite & outIv,
|
||||||
Memory::MemoryViewRead inKey,
|
const Memory::MemoryViewRead & inKey,
|
||||||
AuList<AuUInt8> &out,
|
AuList<AuUInt8> &out,
|
||||||
bool auCoolCodePadding)
|
bool auCoolCodePadding)
|
||||||
{
|
{
|
||||||
@ -254,10 +254,10 @@ namespace Aurora::Crypto::AES
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AUKN_SYM bool Decrypt(Memory::MemoryViewRead cipherText,
|
AUKN_SYM bool Decrypt(const Memory::MemoryViewRead & cipherText,
|
||||||
Memory::MemoryViewRead inIv,
|
const Memory::MemoryViewRead & inIv,
|
||||||
Memory::MemoryViewWrite outIv,
|
const Memory::MemoryViewWrite & outIv,
|
||||||
Memory::MemoryViewRead inKey,
|
const Memory::MemoryViewRead & inKey,
|
||||||
AuList<AuUInt8> &plainText,
|
AuList<AuUInt8> &plainText,
|
||||||
bool safe)
|
bool safe)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ namespace Aurora::Crypto::RSA
|
|||||||
rsa_free(&key_);
|
rsa_free(&key_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrivateRSA::Sign(Memory::MemoryViewRead payload,
|
bool PrivateRSA::Sign(const Memory::MemoryViewRead & payload,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out)
|
AuList<AuUInt8> &out)
|
||||||
@ -88,7 +88,7 @@ namespace Aurora::Crypto::RSA
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrivateRSA::Decrypt(Memory::MemoryViewRead payload,
|
bool PrivateRSA::Decrypt(const Memory::MemoryViewRead & payload,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out)
|
AuList<AuUInt8> &out)
|
||||||
{
|
{
|
||||||
|
@ -15,12 +15,12 @@ namespace Aurora::Crypto::RSA
|
|||||||
PrivateRSA(rsa_key &key);
|
PrivateRSA(rsa_key &key);
|
||||||
~PrivateRSA();
|
~PrivateRSA();
|
||||||
|
|
||||||
bool Sign(Memory::MemoryViewRead payload,
|
bool Sign(const Memory::MemoryViewRead & payload,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) override;
|
AuList<AuUInt8> &out) override;
|
||||||
|
|
||||||
bool Decrypt(Memory::MemoryViewRead payload,
|
bool Decrypt(const Memory::MemoryViewRead & payload,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) override;
|
AuList<AuUInt8> &out) override;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ namespace Aurora::Crypto::RSA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PublicRSA::Verify(Memory::MemoryViewRead payload,
|
bool PublicRSA::Verify(const Memory::MemoryViewRead & payload,
|
||||||
Memory::MemoryViewRead signature,
|
const Memory::MemoryViewRead & signature,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type)
|
EPaddingType type)
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ namespace Aurora::Crypto::RSA
|
|||||||
return ok == 1;
|
return ok == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PublicRSA::Encrypt(Memory::MemoryViewRead plainText,
|
bool PublicRSA::Encrypt(const Memory::MemoryViewRead & plainText,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out)
|
AuList<AuUInt8> &out)
|
||||||
{
|
{
|
||||||
|
@ -16,12 +16,12 @@ namespace Aurora::Crypto::RSA
|
|||||||
PublicRSA(rsa_key &key, bool owned = true);
|
PublicRSA(rsa_key &key, bool owned = true);
|
||||||
~PublicRSA();
|
~PublicRSA();
|
||||||
|
|
||||||
bool Verify(Memory::MemoryViewRead payload,
|
bool Verify(const Memory::MemoryViewRead & payload,
|
||||||
Memory::MemoryViewRead signature,
|
const Memory::MemoryViewRead & signature,
|
||||||
EHashType method,
|
EHashType method,
|
||||||
EPaddingType type) override;
|
EPaddingType type) override;
|
||||||
|
|
||||||
bool Encrypt(Memory::MemoryViewRead plainText,
|
bool Encrypt(const Memory::MemoryViewRead & plainText,
|
||||||
EPaddingType type,
|
EPaddingType type,
|
||||||
AuList<AuUInt8> &out) override;
|
AuList<AuUInt8> &out) override;
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ namespace Aurora::IO::FS
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ok {};
|
bool ok {};
|
||||||
ok = stream->Write(Memory::MemoryViewStreamRead{bom});
|
ok = stream->Write(const Memory::MemoryViewStreamRead &{bom});
|
||||||
ok &= stream->Write(Memory::MemoryViewStreamRead{str});
|
ok &= stream->Write(const Memory::MemoryViewStreamRead &{str});
|
||||||
stream->Flush();
|
stream->Flush();
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -100,7 +100,7 @@ namespace Aurora::IO::FS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Read(Memory::MemoryViewStreamWrite parameters) override
|
bool Read(const Memory::MemoryViewStreamWrite ¶meters) override
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ namespace Aurora::IO::FS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Write(Memory::MemoryViewStreamRead parameters) override
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -134,12 +134,12 @@ namespace Aurora::IO::FS
|
|||||||
offset_ = stream_.tellp();
|
offset_ = stream_.tellp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Read(Memory::MemoryViewStreamWrite parameters) override
|
bool Read(const Memory::MemoryViewStreamWrite ¶meters) override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Write(Memory::MemoryViewStreamRead parameters) override
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace Aurora::IO::FS
|
|||||||
return length.QuadPart;
|
return length.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinFileStream::Read(Memory::MemoryViewStreamWrite parameters)
|
bool WinFileStream::Read(const Memory::MemoryViewStreamWrite ¶meters)
|
||||||
{
|
{
|
||||||
if (handle_ == INVALID_HANDLE_VALUE)
|
if (handle_ == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ namespace Aurora::IO::FS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinFileStream::Write(Memory::MemoryViewStreamRead parameters)
|
bool WinFileStream::Write(const Memory::MemoryViewStreamRead & parameters)
|
||||||
{
|
{
|
||||||
if (handle_ == INVALID_HANDLE_VALUE)
|
if (handle_ == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -21,8 +21,8 @@ namespace Aurora::IO::FS
|
|||||||
AuUInt64 GetOffset() override;
|
AuUInt64 GetOffset() override;
|
||||||
bool SetOffset(AuUInt64 offset) override;
|
bool SetOffset(AuUInt64 offset) override;
|
||||||
AuUInt64 GetLength() override;
|
AuUInt64 GetLength() override;
|
||||||
bool Read(Memory::MemoryViewStreamWrite parameters) override;
|
bool Read(const Memory::MemoryViewStreamWrite ¶meters) override;
|
||||||
bool Write(Memory::MemoryViewStreamRead parameters) override;
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override;
|
||||||
void Close() override;
|
void Close() override;
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ namespace Aurora::IO::FS
|
|||||||
return PosixGetLength(handle_);
|
return PosixGetLength(handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PosixFileStream::Read(Memory::MemoryViewStreamWrite parameters)
|
bool PosixFileStream::Read(const Memory::MemoryViewStreamWrite ¶meters)
|
||||||
{
|
{
|
||||||
if (handle_ == -1)
|
if (handle_ == -1)
|
||||||
{
|
{
|
||||||
@ -201,7 +201,7 @@ namespace Aurora::IO::FS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PosixFileStream::Write(Memory::MemoryViewStreamRead parameters)
|
bool PosixFileStream::Write(const Memory::MemoryViewStreamRead ¶meters)
|
||||||
{
|
{
|
||||||
if (handle_ == -1)
|
if (handle_ == -1)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Aurora::Locale::Encoding
|
namespace Aurora::Locale::Encoding
|
||||||
{
|
{
|
||||||
AUKN_SYM AuOptional<AuPair<ECodePage, AuUInt8>> DecodeBOM(Aurora::Memory::MemoryViewRead binary)
|
AUKN_SYM AuOptional<AuPair<ECodePage, AuUInt8>> DecodeBOM(const Aurora::Memory::MemoryViewRead & binary)
|
||||||
{
|
{
|
||||||
#define ADD_PATTERN(str, code) {str, AuArraySize(str) - 1, ECodePage::code}
|
#define ADD_PATTERN(str, code) {str, AuArraySize(str) - 1, ECodePage::code}
|
||||||
AuList<std::tuple<const char *, int, ECodePage>> bows =
|
AuList<std::tuple<const char *, int, ECodePage>> bows =
|
||||||
@ -41,19 +41,19 @@ namespace Aurora::Locale::Encoding
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t EncodeUTF8(Aurora::Memory::MemoryViewRead utf8, Aurora::Memory::MemoryViewWrite binary, ECodePage page)
|
AUKN_SYM AuStreamReadWrittenPair_t EncodeUTF8(const Aurora::Memory::MemoryViewRead & utf8, const Aurora::Memory::MemoryViewWrite & binary, ECodePage page)
|
||||||
{
|
{
|
||||||
TextStreamEncoder re(page);
|
TextStreamEncoder re(page);
|
||||||
return re.DecodeUTF8(utf8.ptr, utf8.length, binary.ptr, binary.length);
|
return re.DecodeUTF8(utf8.ptr, utf8.length, binary.ptr, binary.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(Aurora::Memory::MemoryViewRead binary, Aurora::Memory::MemoryViewWrite utf8, ECodePage page)
|
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(const Aurora::Memory::MemoryViewRead & binary, const Aurora::Memory::MemoryViewWrite & utf8, ECodePage page)
|
||||||
{
|
{
|
||||||
TextStreamProcessor re(page);
|
TextStreamProcessor re(page);
|
||||||
return re.EncodeUTF8(binary.ptr, binary.length, utf8.ptr, utf8.length);
|
return re.EncodeUTF8(binary.ptr, binary.length, utf8.ptr, utf8.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(Aurora::Memory::MemoryViewRead binary, AuString &out, ECodePage page)
|
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(const Aurora::Memory::MemoryViewRead & binary, AuString &out, ECodePage page)
|
||||||
{
|
{
|
||||||
auto aaa = DecodeUTF8(binary, {}, page);
|
auto aaa = DecodeUTF8(binary, {}, page);
|
||||||
out.resize(aaa.second);
|
out.resize(aaa.second);
|
||||||
|
Loading…
Reference in New Issue
Block a user