diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-27 14:00:22 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-27 14:00:22 +0100 |
commit | 5aec25ac0501352e4cb6645c86869dde6e91f0d0 (patch) | |
tree | ee9adfd55cddf25f098e5e028d585a72de7cd70c /libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java | |
parent | 8ca42b9bf953c6195ee0c17ef48a3154c126cc04 (diff) | |
download | open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.tar.gz open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.tar.bz2 open-keychain-5aec25ac0501352e4cb6645c86869dde6e91f0d0.zip |
Add spongy castle sources to libraries folder
Diffstat (limited to 'libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java')
-rw-r--r-- | libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java b/libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java new file mode 100644 index 000000000..2eceba4ce --- /dev/null +++ b/libraries/spongycastle/jce/src/main/java/javax/crypto/spec/DHParameterSpec.java @@ -0,0 +1,95 @@ +package javax.crypto.spec; + +import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; + +/** + * This class specifies the set of parameters used with the Diffie-Hellman + * algorithm, as specified in PKCS #3: <i>Diffie-Hellman Key-Agreement + * Standard</i>. + * <p> + * A central authority generates parameters and gives them to the two + * entities seeking to generate a secret key. The parameters are a prime + * <code>p</code>, a base <code>g</code>, and optionally the length + * in bits of the private value, <code>l</code>. + * <p> + * It is possible that more than one instance of parameters may be + * generated by a given central authority, and that there may be more than + * one central authority. Indeed, each individual may be its own central + * authority, with different entities having different parameters. + * + * @see javax.crypto.KeyAgreement + */ +public class DHParameterSpec + implements AlgorithmParameterSpec +{ + private BigInteger p; + private BigInteger g; + private int l; + + /** + * Constructs a parameter set for Diffie-Hellman, using a prime modulus + * <code>p</code> and a base generator <code>g</code>. + * + * @param p the prime modulus + * @param g the base generator + */ + public DHParameterSpec( + BigInteger p, + BigInteger g) + { + this.p = p; + this.g = g; + } + + /** + * Constructs a parameter set for Diffie-Hellman, using a prime modulus + * <code>p</code>, a base generator <code>g</code>, and the size in bits, + * <code>l</code>, of the random exponent (private value). + * + * @param p the prime modulus + * @param g the base generator + * @param l the size in bits of the random exponent (private value) + */ + public DHParameterSpec( + BigInteger p, + BigInteger g, + int l) + { + this.p = p; + this.g = g; + this.l = l; + } + + /** + * Returns the prime modulus <code>p</code>. + * + * @return the prime modulus <code>p</code> + */ + public BigInteger getP() + { + return p; + } + + /** + * Returns the base generator <code>g</code>. + * + * @return the base generator <code>g</code> + */ + public BigInteger getG() + { + return g; + } + + /** + * Returns the size in bits, <code>l</code>, of the random exponent + * (private value). + * + * @return the size in bits, <code>l</code>, of the random exponent + * (private value), or 0 if this size has not been set + */ + public int getL() + { + return l; + } +} |