2002/03/21 01:19:32
[org.ibex.core.git] / src / org / bouncycastle / crypto / params / ParametersWithRandom.java
diff --git a/src/org/bouncycastle/crypto/params/ParametersWithRandom.java b/src/org/bouncycastle/crypto/params/ParametersWithRandom.java
new file mode 100644 (file)
index 0000000..f8b7c82
--- /dev/null
@@ -0,0 +1,41 @@
+package org.bouncycastle.crypto.params;
+
+import java.security.SecureRandom;
+
+import org.bouncycastle.crypto.CipherParameters;
+
+public class ParametersWithRandom
+    implements CipherParameters
+{
+    private SecureRandom        random;
+    private CipherParameters    parameters;
+
+    public ParametersWithRandom(
+        CipherParameters    parameters,
+        SecureRandom        random)
+    {
+        this.random = random;
+        this.parameters = parameters;
+    }
+
+    public ParametersWithRandom(
+        CipherParameters    parameters)
+    {
+        this.random = null;
+        this.parameters = parameters;
+    }
+
+    public SecureRandom getRandom()
+    {
+        if (random == null)
+        {
+            random = new SecureRandom();
+        }
+        return random;
+    }
+
+    public CipherParameters getParameters()
+    {
+        return parameters;
+    }
+}