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

Method Encrypt

src/cryptopp/pubkey.cpp:153–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void TF_EncryptorBase::Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs &parameters) const
154{
155 if (plaintextLength > FixedMaxPlaintextLength())
156 {
157 if (FixedMaxPlaintextLength() < 1)
158 throw InvalidArgument(AlgorithmName() + ": this key is too short to encrypt any messages");
159 else
160 throw InvalidArgument(AlgorithmName() + ": message length of " + IntToString(plaintextLength) + " exceeds the maximum of " + IntToString(FixedMaxPlaintextLength()) + " for this public key");
161 }
162
163 SecByteBlock paddedBlock(PaddedBlockByteLength());
164 GetMessageEncodingInterface().Pad(rng, plaintext, plaintextLength, paddedBlock, PaddedBlockBitLength(), parameters);
165 GetTrapdoorFunctionInterface().ApplyRandomizedFunction(rng, Integer(paddedBlock, paddedBlock.size())).Encode(ciphertext, FixedCiphertextLength());
166}
167
168NAMESPACE_END
169

Callers 6

encryptMethod · 0.45
CryptoSystemValidateFunction · 0.45
ValidateRSAFunction · 0.45
Put2Method · 0.45
BenchMarkEncryptionFunction · 0.45
BenchMarkDecryptionFunction · 0.45

Calls 8

FixedMaxPlaintextLengthFunction · 0.85
IntToStringFunction · 0.85
FixedCiphertextLengthFunction · 0.85
AlgorithmNameFunction · 0.70
IntegerClass · 0.70
PadMethod · 0.45
EncodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected