MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / Encrypt

Method Encrypt

src/cryptlib/elgamal.cpp:56–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void 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
73void ElGamalCryptoPublicKey::RawEncrypt(const Integer &k, const Integer &m, Integer &a, Integer &b) const
74{

Callers 1

ProcessBlockMethod · 0.80

Calls 3

IntegerClass · 0.70
GetBlockMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected