| 194 | |
| 195 | |
| 196 | word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain) |
| 197 | { |
| 198 | PK_Lengths lengths(key.GetModulus()); |
| 199 | |
| 200 | ByteBlock paddedBlock(BitsToBytes(lengths.PaddedBlockBitLength())); |
| 201 | Integer x = key.ApplyFunction(Integer(sig, |
| 202 | lengths.FixedCiphertextLength())); |
| 203 | if (x.ByteCount() > paddedBlock.size()) |
| 204 | x = Integer::Zero(); |
| 205 | x.Encode(paddedBlock.get_buffer(), paddedBlock.size()); |
| 206 | return RSA_BlockType1().UnPad(paddedBlock.get_buffer(), |
| 207 | lengths.PaddedBlockBitLength(), plain); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | } // namespace |
no test coverage detected