| 175 | // Public Encrypt |
| 176 | template<class Pad> |
| 177 | void RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher, |
| 178 | RandomNumberGenerator& rng) |
| 179 | { |
| 180 | PK_Lengths lengths(key_.GetModulus()); |
| 181 | if (sz > lengths.FixedMaxPlaintextLength()) |
| 182 | return; |
| 183 | |
| 184 | ByteBlock paddedBlock(lengths.PaddedBlockByteLength()); |
| 185 | padding_.Pad(plain, sz, paddedBlock.get_buffer(), |
| 186 | lengths.PaddedBlockBitLength(), rng); |
| 187 | |
| 188 | key_.ApplyFunction(Integer(paddedBlock.get_buffer(), paddedBlock.size())). |
| 189 | Encode(cipher, lengths.FixedCiphertextLength()); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | // Private Decrypt |