O'Reilly logo

Programming .NET Security by Allen Jones, Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending the .NET Framework

In Chapter 15, we extended the .NET Framework by creating an implementation of the ElGamal algorithm that supported encryption. In this section, we extend our implementation to include support for creating and verifying digital signatures.

We have provided a C# implementation of the ElGamal algorithm only. 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.

The ElGamal Signature Functions Explained

The ElGamal algorithm supports encryption and digital signatures using the same key pair. Keys created by following the key generation protocol (discussed in Chapter 15) can be used to create and verify digital signatures using the functions that we explain in this section. As a reminder, the parameters p, g, and y form the public key, and the parameter x is the private key.

The basic protocol for creating an ElGamal signature is:

  1. Choose a random number, k, that is relatively prime to (p -1).

  2. Compute the signature element, a, as follows:

    a = gk modp

  3. Compute the signature element, b, as follows (m is the data to sign):

    image with no caption

  4. Concatenate a and b to form the signature.

To verify an ElGamal signature, we follow the following protocol:

  1. Split the digital signature to form the signature elements, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required