Adding the ElGamal Classes

In this chapter, we’ll develop a full suite of classes to support ElGamal signatures and ciphers. The Jonathan provider will need to know about some of the implementation classes, namely:

oreilly.jonathan.crypto.ElGamalKeyPairGenerator
oreilly.jonathan.crypto.ElGamalSignature
oreilly.jonathan.crypto.ElGamalCipher

Thus, we just need to add the correct associations to our simple provider class. It’s a piece of cake:

package oreilly.jonathan.crypto;

import java.security.*;

public class Provider
    extends java.security.Provider {
  public Provider() {
    super ("Jonathan",
        1.2,
        "Jonathan's Cryptography Provider");
    
    put("KeyPairGenerator.ElGamal",
        "oreilly.jonathan.crypto.ElGamalKeyPairGenerator");
    put("Cipher.ElGamal", "oreilly.jonathan.crypto.ElGamalCipher");
    put("Signature.ElGamal", "oreilly.jonathan.crypto.ElGamalSignature");
    
    put("Cipher.DES/CBC/PKCS5Padding",
        "oreilly.jonathan.crypto.CBCWrapper");
    put("Cipher.DES/CFB/NoPadding", "oreilly.jonathan.crypto.CFBWrapper");
put("Alg.Alias.Cipher.DES/CFB8/NoPadding", "DES/CFB/NoPadding");
  }
}

The hard part is actually implementing the algorithms. We’ll spend the rest of the chapter doing just that.

Get Java Cryptography now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.