| 54 | } |
| 55 | |
| 56 | void ElGamalCryptoPublicKey::Encrypt(RandomNumberGenerator &rng, const byte *plainText, unsigned int plainTextLength, byte *cipherText) |
| 57 | { |
| 58 | assert(plainTextLength <= MaxPlainTextLength()); |
| 59 | |
| 60 | SecByteBlock block(modulusLen-1); |
| 61 | rng.GetBlock(block, modulusLen-2-plainTextLength); |
| 62 | memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength); |
| 63 | block[modulusLen-2] = plainTextLength; |
| 64 | |
| 65 | Integer m(block, modulusLen-1); |
| 66 | Integer a,b; |
| 67 | RawEncrypt(Integer(rng, ExponentBitLength()), m, a, b); |
| 68 | |
| 69 | a.Encode(cipherText, modulusLen); |
| 70 | b.Encode(cipherText+modulusLen, modulusLen); |
| 71 | } |
| 72 | |
| 73 | void ElGamalCryptoPublicKey::RawEncrypt(const Integer &k, const Integer &m, Integer &a, Integer &b) const |
| 74 | { |
no test coverage detected