In this section, we demonstrate how to extend the .NET Framework by adding a new asymmetric encryption algorithm. We have selected the ElGamal algorithm, and we will implement the base classes and the core encryption functions. In the following chapters, we will extend our implementation to include support for digital signatures and padding schemes.
We have provided only a C# implementation of the ElGamal algorithm. 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.
Taher ElGamal published the ElGamal algorithm in 1985, and it has been widely adopted as an alternative to RSA, where licensing and patents have been an issue (the RSA algorithm was protected by a patent that has now expired, whereas no patents were obtained for ElGamal).
ElGamal relies on a different mathematical problem than the factoring of large numbers used by the RSA algorithm; this problem is finding the discrete logarithm of a large integer value. The ElGamal algorithm is as secure as RSA, but encrypts data slower; the algorithm is the basis for the Digital Signature Algorithm, which we discuss in the following chapter.
The key generation protocol for the ElGamal algorithm is as follows; we will select small values to demonstrate the key ...