{
String pad = Strings.toUpperCase(padding);
if (pad.equals("NOPADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new ElGamalEngine());
}
else if (pad.equals("PKCS1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new PKCS1Encoding(new ElGamalEngine()));
}
else if (pad.equals("OAEPPADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine()));
}
else if (pad.equals("ISO9796-1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new ISO9796d1Encoding(new ElGamalEngine()));
}
else if (pad.equals("OAEPWITHMD5ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new MD5Digest()));
}
else if (pad.equals("OAEPWITHSHA1ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA1Digest()));
}
else if (pad.equals("OAEPWITHSHA224ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA224Digest()));
}
else if (pad.equals("OAEPWITHSHA256ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA256Digest()));
}
else if (pad.equals("OAEPWITHSHA384ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA384Digest()));
}
else if (pad.equals("OAEPWITHSHA512ANDMGF1PADDING"))
{
cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA512Digest()));
}
else
{
throw new NoSuchPaddingException(padding + " unavailable with ElGamal.");
}