MCPcopy Create free account
hub / github.com/LUX-Core/lux / SymmetricDecrypt

Method SymmetricDecrypt

src/cryptopp/gfpcrypt.h:839–873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837 mac.Final(ciphertext + plaintextLength);
838 }
839 DecodingResult SymmetricDecrypt(const byte *key, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs &parameters) const
840 {
841 size_t plaintextLength = GetMaxSymmetricPlaintextLength(ciphertextLength);
842 const byte *cipherKey, *macKey;
843 if (DHAES_MODE)
844 {
845 macKey = key;
846 cipherKey = key + MAC::DEFAULT_KEYLENGTH;
847 }
848 else
849 {
850 cipherKey = key;
851 macKey = key + plaintextLength;
852 }
853
854 ConstByteArrayParameter encodingParameters;
855 parameters.GetValue(Name::EncodingParameters(), encodingParameters);
856
857 MAC mac(macKey);
858 mac.Update(ciphertext, plaintextLength);
859 mac.Update(encodingParameters.begin(), encodingParameters.size());
860 if (DHAES_MODE)
861 {
862 byte L[8];
863 PutWord(false, BIG_ENDIAN_ORDER, L, (LABEL_OCTETS ? word64(encodingParameters.size()) : 8 * word64(encodingParameters.size())));
864 mac.Update(L, 8);
865 }
866 if (!mac.Verify(ciphertext + plaintextLength))
867 return DecodingResult();
868
869 if (plaintextLength) // Coverity finding
870 xorbuf(plaintext, ciphertext, cipherKey, plaintextLength);
871
872 return DecodingResult(plaintextLength);
873 }
874};
875
876//! _

Callers 1

DecryptFunction · 0.80

Calls 8

PutWordFunction · 0.85
DecodingResultFunction · 0.85
xorbufFunction · 0.85
GetValueMethod · 0.80
UpdateMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
VerifyMethod · 0.45

Tested by

no test coverage detected