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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.