| 151 | } |
| 152 | |
| 153 | void TF_EncryptorBase::Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters) 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 | |
| 168 | NAMESPACE_END |
| 169 |
no test coverage detected