6 namespace swift::core::afv::crypto
24 msgpack::object_handle oh = msgpack::unpack(headerBuffer.
data(), headerBuffer.
size());
27 if (
m_header.
Mode == CryptoDtoMode::AEAD_ChaCha20Poly1305)
35 nonce.
fill(0, crypto_aead_chacha20poly1305_IETF_NPUBBYTES);
39 nonceBuffer.
write(
reinterpret_cast<const char *
>(&
id),
sizeof(
id));
44 unsigned long long mlen = 500;
45 decryptedPayload.
fill(0, mlen);
48 if (loopback) { key = channel.
getTransmitKey(CryptoDtoMode::AEAD_ChaCha20Poly1305); }
49 else { key = channel.
getReceiveKey(CryptoDtoMode::AEAD_ChaCha20Poly1305); }
50 Q_ASSERT_X(key.
size() == crypto_aead_chacha20poly1305_IETF_KEYBYTES, Q_FUNC_INFO,
"");
51 int result = crypto_aead_chacha20poly1305_ietf_decrypt(
52 reinterpret_cast<unsigned char *
>(decryptedPayload.
data()), &mlen,
nullptr,
53 reinterpret_cast<const unsigned char *
>(aePayloadBuffer.
constData()), aePayloadBuffer.
size(),
54 reinterpret_cast<const unsigned char *
>(adBuffer.
constData()), adBuffer.
size(),
55 reinterpret_cast<const unsigned char *
>(nonce.
constData()),
56 reinterpret_cast<const unsigned char *
>(key.
constData()));
60 decryptedPayload.
resize(mlen);
65 QBuffer decryptedPayloadBuffer(&decryptedPayload);
QByteArray getReceiveKey(CryptoDtoMode mode)
Receiver key.
QByteArray getTransmitKey(CryptoDtoMode mode)
Transmit key.
static Deserializer deserialize(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
Deserialize.
virtual void close() override
virtual bool open(QIODeviceBase::OpenMode flags) override
virtual qint64 size() const const override
const char * constData() const const
QByteArray & fill(char ch, qsizetype size)
QByteArray left(qsizetype len) &&
void resize(qsizetype newSize, char c)
qsizetype size() const const
QByteArray read(qint64 maxSize)
qint64 write(const QByteArray &data)
bool m_verified
is verified
QByteArray m_dataBuffer
Data.
quint16 m_headerLength
Header data.
Deserializer(CCryptoDtoChannel &channel, const QByteArray &bytes, bool loopback)
Ctor.
CryptoDtoHeaderDto m_header
Header data.
quint16 m_dataLength
Data.
QByteArray m_dtoNameBuffer
Name data.
quint16 m_dtoNameLength
Name data.