blob: f2e84e44f36d53c2fe4c53b623df22e97230d263 [file] [log] [blame]
package org.bouncycastle.jce.provider.symmetric;
import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.CipherKeyGenerator;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.engines.AESFastEngine;
import org.bouncycastle.crypto.engines.AESWrapEngine;
// BEGIN android-removed
// import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
// END android-removed
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.modes.CFBBlockCipher;
import org.bouncycastle.crypto.modes.OFBBlockCipher;
import org.bouncycastle.jce.provider.JCEBlockCipher;
import org.bouncycastle.jce.provider.JCEKeyGenerator;
import org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator;
import org.bouncycastle.jce.provider.JDKAlgorithmParameters;
import org.bouncycastle.jce.provider.WrapCipherSpi;
import javax.crypto.spec.IvParameterSpec;
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
public final class AES
{
private AES()
{
}
public static class ECB
extends JCEBlockCipher
{
public ECB()
{
super(new AESFastEngine());
}
}
// BEGIN android-removed
// public static class CBC
// extends JCEBlockCipher
// {
// public CBC()
// {
// super(new CBCBlockCipher(new AESFastEngine()), 128);
// }
// }
//
// static public class CFB
// extends JCEBlockCipher
// {
// public CFB()
// {
// super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
// }
// }
//
// static public class OFB
// extends JCEBlockCipher
// {
// public OFB()
// {
// super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
// }
// }
// END android-removed
static public class Wrap
extends WrapCipherSpi
{
public Wrap()
{
super(new AESWrapEngine());
}
}
// BEGIN android-removed
// public static class RFC3211Wrap
// extends WrapCipherSpi
// {
// public RFC3211Wrap()
// {
// super(new RFC3211WrapEngine(new AESEngine()), 16);
// }
// }
// END android-removed
public static class KeyGen
extends JCEKeyGenerator
{
public KeyGen()
{
this(192);
}
public KeyGen(int keySize)
{
super("AES", keySize, new CipherKeyGenerator());
}
}
// BEGIN android-removed
// public static class KeyGen128
// extends KeyGen
// {
// public KeyGen128()
// {
// super(128);
// }
// }
//
// public static class KeyGen192
// extends KeyGen
// {
// public KeyGen192()
// {
// super(192);
// }
// }
//
// public static class KeyGen256
// extends KeyGen
// {
// public KeyGen256()
// {
// super(256);
// }
// }
//
// public static class AlgParamGen
// extends JDKAlgorithmParameterGenerator
// {
// protected void engineInit(
// AlgorithmParameterSpec genParamSpec,
// SecureRandom random)
// throws InvalidAlgorithmParameterException
// {
// throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation.");
// }
//
// protected AlgorithmParameters engineGenerateParameters()
// {
// byte[] iv = new byte[16];
//
// if (random == null)
// {
// random = new SecureRandom();
// }
//
// random.nextBytes(iv);
//
// AlgorithmParameters params;
//
// try
// {
// params = AlgorithmParameters.getInstance("AES", "BC");
// params.init(new IvParameterSpec(iv));
// }
// catch (Exception e)
// {
// throw new RuntimeException(e.getMessage());
// }
//
// return params;
// }
// }
// END android-removed
public static class AlgParams
extends JDKAlgorithmParameters.IVAlgorithmParameters
{
protected String engineToString()
{
return "AES IV";
}
}
}