aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java')
-rw-r--r--libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java
new file mode 100644
index 000000000..048108490
--- /dev/null
+++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/AlgorithmParameterGenerator.java
@@ -0,0 +1,96 @@
+package java.security;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+public class AlgorithmParameterGenerator
+{
+ AlgorithmParameterGeneratorSpi spi;
+ Provider provider;
+ String algorithm;
+
+ protected AlgorithmParameterGenerator(
+ AlgorithmParameterGeneratorSpi paramGenSpi,
+ Provider provider,
+ String algorithm)
+ {
+ this.spi = paramGenSpi;
+ this.provider = provider;
+ this.algorithm = algorithm;
+ }
+
+ public final AlgorithmParameters generateParameters()
+ {
+ return spi.engineGenerateParameters();
+ }
+
+ public final String getAlgorithm()
+ {
+ return algorithm;
+ }
+
+ public static AlgorithmParameterGenerator getInstance(String algorithm)
+ throws NoSuchAlgorithmException
+ {
+ try
+ {
+ SecurityUtil.Implementation imp = SecurityUtil.getImplementation("AlgorithmParameterGenerator", algorithm, null);
+
+ if (imp != null)
+ {
+ return new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi)imp.getEngine(), imp.getProvider(), algorithm);
+ }
+
+ throw new NoSuchAlgorithmException("can't find algorithm " + algorithm);
+ }
+ catch (NoSuchProviderException e)
+ {
+ throw new NoSuchAlgorithmException(algorithm + " not found");
+ }
+ }
+
+ public static AlgorithmParameterGenerator getInstance(String algorithm, String provider)
+ throws NoSuchAlgorithmException, NoSuchProviderException
+ {
+ SecurityUtil.Implementation imp = SecurityUtil.getImplementation("AlgorithmParameterGenerator", algorithm, provider);
+
+ if (imp != null)
+ {
+ return new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi)imp.getEngine(), imp.getProvider(), algorithm);
+ }
+
+ throw new NoSuchAlgorithmException("can't find algorithm " + algorithm);
+ }
+
+ public final Provider getProvider()
+ {
+ return provider;
+ }
+
+ public final void init(
+ AlgorithmParameterSpec genParamSpec)
+ throws InvalidAlgorithmParameterException
+ {
+ spi.engineInit(genParamSpec, new SecureRandom());
+ }
+
+ public final void init(
+ AlgorithmParameterSpec genParamSpec,
+ SecureRandom random)
+ throws InvalidAlgorithmParameterException
+ {
+ spi.engineInit(genParamSpec, random);
+ }
+
+ public final void init(
+ int size)
+ {
+ spi.engineInit(size, new SecureRandom());
+ }
+
+ public final void init(
+ int size,
+ SecureRandom random)
+ {
+ spi.engineInit(size, random);
+ }
+}