MCPcopy Create free account
hub / github.com/blizzard4591/openMittsu / encrypt

Method encrypt

src/crypto/BasicCryptoBox.cpp:22–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 }
21
22 std::pair<openmittsu::crypto::Nonce, QByteArray> BasicCryptoBox::encrypt(QByteArray const& data, openmittsu::crypto::PublicKey const& targetIdentityPublicKey) {
23 openmittsu::crypto::Nonce nonce;
24 QByteArray encryptedData(data.size() + crypto_box_MACBYTES, 0x00);
25 if (crypto_box_easy(reinterpret_cast<unsigned char*>(encryptedData.data()), reinterpret_cast<unsigned char const*>(data.data()), data.size(), nonce.getNonceAsCharPtr(), reinterpret_cast<unsigned char const*>(targetIdentityPublicKey.getPublicKey().data()), reinterpret_cast<unsigned char const*>(m_clientLongTermKey.getPrivateKey().data())) != 0) {
26 throw openmittsu::exceptions::CryptoException() << "Failed to encrypt data.";
27 }
28
29 return std::make_pair(nonce, encryptedData);
30 }
31
32 QByteArray BasicCryptoBox::encryptForFixedNonce(QByteArray const& data, openmittsu::crypto::EncryptionKey const& encryptionKey, openmittsu::crypto::Nonce const& fixedNonce) {
33 QByteArray encryptedData(data.size() + crypto_secretbox_MACBYTES, 0x00);

Callers

nothing calls this directly

Calls 4

dataMethod · 0.80
getNonceAsCharPtrMethod · 0.80
getPublicKeyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected