In the following sections, we complete our implementation of the ElGamal algorithm by creating the key exchange formatter and deformatter classes. We have only provided a C# implementation of the ElGamal key exchange formatters. Like almost all encryption algorithms, ElGamal relies on mathematical operations that are not possible in Visual Basic .NET without creating additional support functions to compensate for the limited numeric support the language provides.
Our implementation of the ElGamal encryption
functions exposes the
"raw" algorithm; that is, unlike
the Microsoft RSA implementation, our
ElGamalManaged class does not format data prior to
To provide support for session key exchange, we must provide classes
that extend the
AsymmetricExchangeDeformatter classes that we
discussed in the previous section. We have selected the OAEP
formatting scheme for our key exchange; we have listed the complete
code for our formatting classes, which naturally includes the details
of the OAEP scheme. We do not discuss the details of OAEP, and you
should refer to the PKCS #1 standard (which defines both the OAEP and
PKCS #1 v1.5 formatting schemes) for details.
We begin by
ElGamalOAEPKeyExchangeFormatter, which is our
formatter class, extending the
AsymmetricKeyExchangeFormatter class that we
discussed in the previous section:
using System; using ...