diff options
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/crypto/params')
39 files changed, 0 insertions, 2117 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CCMParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CCMParameters.java deleted file mode 100644 index 4924dcc..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CCMParameters.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.bouncycastle.crypto.params; - -/** - * @deprecated use AEADParameters - */ -public class CCMParameters - extends AEADParameters -{ - /** - * Base constructor. - * - * @param key key to be used by underlying cipher - * @param macSize macSize in bits - * @param nonce nonce to be used - * @param associatedText associated text, if any - */ - public CCMParameters(KeyParameter key, int macSize, byte[] nonce, byte[] associatedText) - { - super(key, macSize, nonce, associatedText); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyGenerationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyGenerationParameters.java deleted file mode 100644 index 001cd59..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyGenerationParameters.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.security.SecureRandom; - -import org.bouncycastle.crypto.KeyGenerationParameters; - -public class CramerShoupKeyGenerationParameters - extends KeyGenerationParameters -{ - - private CramerShoupParameters params; - - public CramerShoupKeyGenerationParameters(SecureRandom random, CramerShoupParameters params) - { - super(random, getStrength(params)); - - this.params = params; - } - - public CramerShoupParameters getParameters() - { - return params; - } - - static int getStrength(CramerShoupParameters params) - { - return params.getP().bitLength(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyParameters.java deleted file mode 100644 index 9e4219c..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupKeyParameters.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.bouncycastle.crypto.params; - -public class CramerShoupKeyParameters extends AsymmetricKeyParameter { - - private CramerShoupParameters params; - - protected CramerShoupKeyParameters(boolean isPrivate, CramerShoupParameters params) { - super(isPrivate); - - this.params = params; - } - - public CramerShoupParameters getParameters() { - return params; - } - - public boolean equals(Object obj) { - if (!(obj instanceof CramerShoupKeyParameters)) { - return false; - } - - CramerShoupKeyParameters csKey = (CramerShoupKeyParameters) obj; - - if (params == null) { - return csKey.getParameters() == null; - } else { - return params.equals(csKey.getParameters()); - } - } - - public int hashCode() { - int code = isPrivate() ? 0 : 1; - - if (params != null) { - code ^= params.hashCode(); - } - - return code; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupParameters.java deleted file mode 100644 index 24264b6..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupParameters.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -import org.bouncycastle.crypto.CipherParameters; -import org.bouncycastle.crypto.Digest; - -public class CramerShoupParameters implements CipherParameters { - - private BigInteger p; // prime order of G - private BigInteger g1, g2; // generate G - - private Digest H; // hash function - - public CramerShoupParameters(BigInteger p, BigInteger g1, BigInteger g2, Digest H) { - this.p = p; - this.g1 = g1; - this.g2 = g2; - this.H = H; - } - - public boolean equals(Object obj) { - if (!(obj instanceof DSAParameters)) { - return false; - } - - CramerShoupParameters pm = (CramerShoupParameters) obj; - - return (pm.getP().equals(p) && pm.getG1().equals(g1) && pm.getG2().equals(g2)); - } - - public int hashCode() { - return getP().hashCode() ^ getG1().hashCode() ^ getG2().hashCode(); - } - - public BigInteger getG1() { - return g1; - } - - public BigInteger getG2() { - return g2; - } - - public BigInteger getP() { - return p; - } - - public Digest getH() { - H.reset(); - return H; - } - -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPrivateKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPrivateKeyParameters.java deleted file mode 100644 index 79de46a..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPrivateKeyParameters.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class CramerShoupPrivateKeyParameters extends CramerShoupKeyParameters { - - private BigInteger x1, x2, y1, y2, z; // Z_p - private CramerShoupPublicKeyParameters pk; // public key - - public CramerShoupPrivateKeyParameters(CramerShoupParameters params, BigInteger x1, BigInteger x2, BigInteger y1, BigInteger y2, BigInteger z) { - super(true, params); - - this.x1 = x1; - this.x2 = x2; - this.y1 = y1; - this.y2 = y2; - this.z = z; - } - - public BigInteger getX1() { - return x1; - } - - public BigInteger getX2() { - return x2; - } - - public BigInteger getY1() { - return y1; - } - - public BigInteger getY2() { - return y2; - } - - public BigInteger getZ() { - return z; - } - - public void setPk(CramerShoupPublicKeyParameters pk) { - this.pk = pk; - } - - public CramerShoupPublicKeyParameters getPk() { - return pk; - } - - public int hashCode() { - return x1.hashCode() ^ x2.hashCode() ^ y1.hashCode() ^ y2.hashCode() ^ z.hashCode() ^ super.hashCode(); - } - - public boolean equals(Object obj) { - if (!(obj instanceof CramerShoupPrivateKeyParameters)) { - return false; - } - - CramerShoupPrivateKeyParameters other = (CramerShoupPrivateKeyParameters) obj; - - return other.getX1().equals(this.x1) && other.getX2().equals(this.x2) && other.getY1().equals(this.y1) && other.getY2().equals(this.y2) && other.getZ().equals(this.z) && super.equals(obj); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPublicKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPublicKeyParameters.java deleted file mode 100644 index 341149c..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/CramerShoupPublicKeyParameters.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class CramerShoupPublicKeyParameters extends CramerShoupKeyParameters { - - private BigInteger c, d, h; // public key group elements - - public CramerShoupPublicKeyParameters(CramerShoupParameters params, BigInteger c, BigInteger d, BigInteger h) { - super(false, params); - - this.c = c; - this.d = d; - this.h = h; - } - - public BigInteger getC() { - return c; - } - - public BigInteger getD() { - return d; - } - - public BigInteger getH() { - return h; - } - - public int hashCode() { - return c.hashCode() ^ d.hashCode() ^ h.hashCode() ^ super.hashCode(); - } - - public boolean equals(Object obj) { - if (!(obj instanceof CramerShoupPublicKeyParameters)) { - return false; - } - - CramerShoupPublicKeyParameters other = (CramerShoupPublicKeyParameters) obj; - - return other.getC().equals(c) && other.getD().equals(d) && other.getH().equals(h) && super.equals(obj); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyGenerationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyGenerationParameters.java deleted file mode 100644 index f5fbabd..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyGenerationParameters.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.security.SecureRandom; - -import org.bouncycastle.crypto.KeyGenerationParameters; - -public class ElGamalKeyGenerationParameters - extends KeyGenerationParameters -{ - private ElGamalParameters params; - - public ElGamalKeyGenerationParameters( - SecureRandom random, - ElGamalParameters params) - { - super(random, getStrength(params)); - - this.params = params; - } - - public ElGamalParameters getParameters() - { - return params; - } - - static int getStrength(ElGamalParameters params) - { - return params.getL() != 0 ? params.getL() : params.getP().bitLength(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyParameters.java deleted file mode 100644 index 7250693..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalKeyParameters.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.bouncycastle.crypto.params; - - -public class ElGamalKeyParameters - extends AsymmetricKeyParameter -{ - private ElGamalParameters params; - - protected ElGamalKeyParameters( - boolean isPrivate, - ElGamalParameters params) - { - super(isPrivate); - - this.params = params; - } - - public ElGamalParameters getParameters() - { - return params; - } - - public int hashCode() - { - return (params != null) ? params.hashCode() : 0; - } - - public boolean equals( - Object obj) - { - if (!(obj instanceof ElGamalKeyParameters)) - { - return false; - } - - ElGamalKeyParameters dhKey = (ElGamalKeyParameters)obj; - - if (params == null) - { - return dhKey.getParameters() == null; - } - else - { - return params.equals(dhKey.getParameters()); - } - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalParameters.java deleted file mode 100644 index 166eff3..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalParameters.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -import org.bouncycastle.crypto.CipherParameters; - -public class ElGamalParameters - implements CipherParameters -{ - private BigInteger g; - private BigInteger p; - private int l; - - public ElGamalParameters( - BigInteger p, - BigInteger g) - { - this(p, g, 0); - } - - public ElGamalParameters( - BigInteger p, - BigInteger g, - int l) - { - this.g = g; - this.p = p; - this.l = l; - } - - public BigInteger getP() - { - return p; - } - - /** - * return the generator - g - */ - public BigInteger getG() - { - return g; - } - - /** - * return private value limit - l - */ - public int getL() - { - return l; - } - - public boolean equals( - Object obj) - { - if (!(obj instanceof ElGamalParameters)) - { - return false; - } - - ElGamalParameters pm = (ElGamalParameters)obj; - - return pm.getP().equals(p) && pm.getG().equals(g) && pm.getL() == l; - } - - public int hashCode() - { - return (getP().hashCode() ^ getG().hashCode()) + l; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPrivateKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPrivateKeyParameters.java deleted file mode 100644 index b8fb529..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPrivateKeyParameters.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class ElGamalPrivateKeyParameters - extends ElGamalKeyParameters -{ - private BigInteger x; - - public ElGamalPrivateKeyParameters( - BigInteger x, - ElGamalParameters params) - { - super(true, params); - - this.x = x; - } - - public BigInteger getX() - { - return x; - } - - public boolean equals( - Object obj) - { - if (!(obj instanceof ElGamalPrivateKeyParameters)) - { - return false; - } - - ElGamalPrivateKeyParameters pKey = (ElGamalPrivateKeyParameters)obj; - - if (!pKey.getX().equals(x)) - { - return false; - } - - return super.equals(obj); - } - - public int hashCode() - { - return getX().hashCode(); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPublicKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPublicKeyParameters.java deleted file mode 100644 index d7da7a9..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ElGamalPublicKeyParameters.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class ElGamalPublicKeyParameters - extends ElGamalKeyParameters -{ - private BigInteger y; - - public ElGamalPublicKeyParameters( - BigInteger y, - ElGamalParameters params) - { - super(false, params); - - this.y = y; - } - - public BigInteger getY() - { - return y; - } - - public int hashCode() - { - return y.hashCode() ^ super.hashCode(); - } - - public boolean equals( - Object obj) - { - if (!(obj instanceof ElGamalPublicKeyParameters)) - { - return false; - } - - ElGamalPublicKeyParameters other = (ElGamalPublicKeyParameters)obj; - - return other.getY().equals(y) && super.equals(obj); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyGenerationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyGenerationParameters.java deleted file mode 100644 index 74e05a9..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyGenerationParameters.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.KeyGenerationParameters; - -import java.security.SecureRandom; - -public class GOST3410KeyGenerationParameters - extends KeyGenerationParameters -{ - private GOST3410Parameters params; - - public GOST3410KeyGenerationParameters( - SecureRandom random, - GOST3410Parameters params) - { - super(random, params.getP().bitLength() - 1); - - this.params = params; - } - - public GOST3410Parameters getParameters() - { - return params; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyParameters.java deleted file mode 100644 index 6716924..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410KeyParameters.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.bouncycastle.crypto.params; - -public class GOST3410KeyParameters - extends AsymmetricKeyParameter -{ - private GOST3410Parameters params; - - public GOST3410KeyParameters( - boolean isPrivate, - GOST3410Parameters params) - { - super(isPrivate); - - this.params = params; - } - - public GOST3410Parameters getParameters() - { - return params; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410Parameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410Parameters.java deleted file mode 100644 index 07450f6..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410Parameters.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -import java.math.BigInteger; - -public class GOST3410Parameters - implements CipherParameters -{ - private BigInteger p; - private BigInteger q; - private BigInteger a; - private GOST3410ValidationParameters validation; - - public GOST3410Parameters( - BigInteger p, - BigInteger q, - BigInteger a) - { - this.p = p; - this.q = q; - this.a = a; - } - - public GOST3410Parameters( - BigInteger p, - BigInteger q, - BigInteger a, - GOST3410ValidationParameters params) - { - this.a = a; - this.p = p; - this.q = q; - this.validation = params; - } - - public BigInteger getP() - { - return p; - } - - public BigInteger getQ() - { - return q; - } - - public BigInteger getA() - { - return a; - } - - public GOST3410ValidationParameters getValidationParameters() - { - return validation; - } - - public int hashCode() - { - return p.hashCode() ^ q.hashCode() ^ a.hashCode(); - } - - public boolean equals( - Object obj) - { - if (!(obj instanceof GOST3410Parameters)) - { - return false; - } - - GOST3410Parameters pm = (GOST3410Parameters)obj; - - return (pm.getP().equals(p) && pm.getQ().equals(q) && pm.getA().equals(a)); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PrivateKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PrivateKeyParameters.java deleted file mode 100644 index 408e065..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PrivateKeyParameters.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class GOST3410PrivateKeyParameters - extends GOST3410KeyParameters -{ - private BigInteger x; - - public GOST3410PrivateKeyParameters( - BigInteger x, - GOST3410Parameters params) - { - super(true, params); - - this.x = x; - } - - public BigInteger getX() - { - return x; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PublicKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PublicKeyParameters.java deleted file mode 100644 index 9dfd2d9..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410PublicKeyParameters.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class GOST3410PublicKeyParameters - extends GOST3410KeyParameters -{ - private BigInteger y; - - public GOST3410PublicKeyParameters( - BigInteger y, - GOST3410Parameters params) - { - super(false, params); - - this.y = y; - } - - public BigInteger getY() - { - return y; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410ValidationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410ValidationParameters.java deleted file mode 100644 index c2a4fb5..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/GOST3410ValidationParameters.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.bouncycastle.crypto.params; - -public class GOST3410ValidationParameters -{ - private int x0; - private int c; - private long x0L; - private long cL; - - - public GOST3410ValidationParameters( - int x0, - int c) - { - this.x0 = x0; - this.c = c; - } - - public GOST3410ValidationParameters( - long x0L, - long cL) - { - this.x0L = x0L; - this.cL = cL; - } - - public int getC() - { - return c; - } - - public int getX0() - { - return x0; - } - - public long getCL() - { - return cL; - } - - public long getX0L() - { - return x0L; - } - - public boolean equals( - Object o) - { - if (!(o instanceof GOST3410ValidationParameters)) - { - return false; - } - - GOST3410ValidationParameters other = (GOST3410ValidationParameters)o; - - if (other.c != this.c) - { - return false; - } - - if (other.x0 != this.x0) - { - return false; - } - - if (other.cL != this.cL) - { - return false; - } - - if (other.x0L != this.x0L) - { - return false; - } - - return true; - } - - public int hashCode() - { - return x0 ^ c ^ (int) x0L ^ (int)(x0L >> 32) ^ (int) cL ^ (int)(cL >> 32); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/HKDFParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/HKDFParameters.java deleted file mode 100644 index 2db3ce6..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/HKDFParameters.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; -import org.bouncycastle.util.Arrays; - -/** - * Parameter class for the HKDFBytesGenerator class. - */ -public class HKDFParameters - implements DerivationParameters -{ - private final byte[] ikm; - private final boolean skipExpand; - private final byte[] salt; - private final byte[] info; - - private HKDFParameters(final byte[] ikm, final boolean skip, - final byte[] salt, final byte[] info) - { - if (ikm == null) - { - throw new IllegalArgumentException( - "IKM (input keying material) should not be null"); - } - - this.ikm = Arrays.clone(ikm); - - this.skipExpand = skip; - - if (salt == null || salt.length == 0) - { - this.salt = null; - } - else - { - this.salt = Arrays.clone(salt); - } - - if (info == null) - { - this.info = new byte[0]; - } - else - { - this.info = Arrays.clone(info); - } - } - - /** - * Generates parameters for HKDF, specifying both the optional salt and - * optional info. Step 1: Extract won't be skipped. - * - * @param ikm the input keying material or seed - * @param salt the salt to use, may be null for a salt for hashLen zeros - * @param info the info to use, may be null for an info field of zero bytes - */ - public HKDFParameters(final byte[] ikm, final byte[] salt, final byte[] info) - { - this(ikm, false, salt, info); - } - - /** - * Factory method that makes the HKDF skip the extract part of the key - * derivation function. - * - * @param ikm the input keying material or seed, directly used for step 2: - * Expand - * @param info the info to use, may be null for an info field of zero bytes - * @return HKDFParameters that makes the implementation skip step 1 - */ - public static HKDFParameters skipExtractParameters(final byte[] ikm, - final byte[] info) - { - - return new HKDFParameters(ikm, true, null, info); - } - - public static HKDFParameters defaultParameters(final byte[] ikm) - { - return new HKDFParameters(ikm, false, null, null); - } - - /** - * Returns the input keying material or seed. - * - * @return the keying material - */ - public byte[] getIKM() - { - return Arrays.clone(ikm); - } - - /** - * Returns if step 1: extract has to be skipped or not - * - * @return true for skipping, false for no skipping of step 1 - */ - public boolean skipExtract() - { - return skipExpand; - } - - /** - * Returns the salt, or null if the salt should be generated as a byte array - * of HashLen zeros. - * - * @return the salt, or null - */ - public byte[] getSalt() - { - return Arrays.clone(salt); - } - - /** - * Returns the info field, which may be empty (null is converted to empty). - * - * @return the info field, never null - */ - public byte[] getInfo() - { - return Arrays.clone(info); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/IESParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/IESParameters.java deleted file mode 100644 index 0600b34..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/IESParameters.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -/** - * parameters for using an integrated cipher in stream mode. - */ -public class IESParameters - implements CipherParameters -{ - private byte[] derivation; - private byte[] encoding; - private int macKeySize; - - /** - * @param derivation the derivation parameter for the KDF function. - * @param encoding the encoding parameter for the KDF function. - * @param macKeySize the size of the MAC key (in bits). - */ - public IESParameters( - byte[] derivation, - byte[] encoding, - int macKeySize) - { - this.derivation = derivation; - this.encoding = encoding; - this.macKeySize = macKeySize; - } - - public byte[] getDerivationV() - { - return derivation; - } - - public byte[] getEncodingV() - { - return encoding; - } - - public int getMacKeySize() - { - return macKeySize; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/IESWithCipherParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/IESWithCipherParameters.java deleted file mode 100644 index ef61b2c..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/IESWithCipherParameters.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.bouncycastle.crypto.params; - - -public class IESWithCipherParameters - extends IESParameters -{ - private int cipherKeySize; - - /** - * @param derivation the derivation parameter for the KDF function. - * @param encoding the encoding parameter for the KDF function. - * @param macKeySize the size of the MAC key (in bits). - * @param cipherKeySize the size of the associated Cipher key (in bits). - */ - public IESWithCipherParameters( - byte[] derivation, - byte[] encoding, - int macKeySize, - int cipherKeySize) - { - super(derivation, encoding, macKeySize); - - this.cipherKeySize = cipherKeySize; - } - - public int getCipherKeySize() - { - return cipherKeySize; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ISO18033KDFParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ISO18033KDFParameters.java deleted file mode 100644 index 8dffe2e..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ISO18033KDFParameters.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; - -/** - * parameters for Key derivation functions for ISO-18033 - */ -public class ISO18033KDFParameters - implements DerivationParameters -{ - byte[] seed; - - public ISO18033KDFParameters( - byte[] seed) - { - this.seed = seed; - } - - public byte[] getSeed() - { - return seed; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFCounterParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFCounterParameters.java deleted file mode 100644 index 29d8b36..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFCounterParameters.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; -import org.bouncycastle.util.Arrays; - -/** - * This KDF has been defined by the publicly available NIST SP 800-108 specification. - * NIST SP800-108 allows for alternative orderings of the input fields, meaning that the input can be formated in multiple ways. - * There are 3 supported formats: - Below [i]_2 is a counter of r-bits length concatenated to the fixedInputData. - * <ul> - * <li>1: K(i) := PRF( KI, [i]_2 || Label || 0x00 || Context || [L]_2 ) with the counter at the very beginning of the fixedInputData (The default implementation has this format)</li> - * <li>2: K(i) := PRF( KI, Label || 0x00 || Context || [L]_2 || [i]_2 ) with the counter at the very end of the fixedInputData</li> - * <li>3a: K(i) := PRF( KI, Label || 0x00 || [i]_2 || Context || [L]_2 ) OR:</li> - * <li>3b: K(i) := PRF( KI, Label || 0x00 || [i]_2 || [L]_2 || Context ) OR:</li> - * <li>3c: K(i) := PRF( KI, Label || [i]_2 || 0x00 || Context || [L]_2 ) etc... with the counter somewhere in the 'middle' of the fixedInputData.</li> - * </ul> - * <p> - * This function must be called with the following KDFCounterParameters(): - * - KI <br/> - * - The part of the fixedInputData that comes BEFORE the counter OR null <br/> - * - the part of the fixedInputData that comes AFTER the counter OR null <br/> - * - the length of the counter in bits (not bytes) <br/> - * </p> - * Resulting function calls assuming an 8 bit counter. - * <ul> - * <li>1. KDFCounterParameters(ki, null, "Label || 0x00 || Context || [L]_2]", 8); </li> - * <li>2. KDFCounterParameters(ki, "Label || 0x00 || Context || [L]_2]", null, 8); </li> - * <li>3a. KDFCounterParameters(ki, "Label || 0x00", "Context || [L]_2]", 8); </li> - * <li>3b. KDFCounterParameters(ki, "Label || 0x00", "[L]_2] || Context", 8);</li> - * <li>3c. KDFCounterParameters(ki, "Label", "0x00 || Context || [L]_2]", 8); </li> - * </ul> - */ -public final class KDFCounterParameters - implements DerivationParameters -{ - - private byte[] ki; - private byte[] fixedInputDataCounterPrefix; - private byte[] fixedInputDataCounterSuffix; - private int r; - - /** - * Base constructor - suffix fixed input data only. - * - * @param ki the KDF seed - * @param fixedInputDataCounterSuffix fixed input data to follow counter. - * @param r length of the counter in bits. - */ - public KDFCounterParameters(byte[] ki, byte[] fixedInputDataCounterSuffix, int r) - { - this(ki, null, fixedInputDataCounterSuffix, r); - } - - /** - * Base constructor - prefix and suffix fixed input data. - * - * @param ki the KDF seed - * @param fixedInputDataCounterPrefix fixed input data to precede counter - * @param fixedInputDataCounterSuffix fixed input data to follow counter. - * @param r length of the counter in bits. - */ - public KDFCounterParameters(byte[] ki, byte[] fixedInputDataCounterPrefix, byte[] fixedInputDataCounterSuffix, int r) - { - if (ki == null) - { - throw new IllegalArgumentException("A KDF requires Ki (a seed) as input"); - } - this.ki = Arrays.clone(ki); - - if (fixedInputDataCounterPrefix == null) - { - this.fixedInputDataCounterPrefix = new byte[0]; - } - else - { - this.fixedInputDataCounterPrefix = Arrays.clone(fixedInputDataCounterPrefix); - } - - if (fixedInputDataCounterSuffix == null) - { - this.fixedInputDataCounterSuffix = new byte[0]; - } - else - { - this.fixedInputDataCounterSuffix = Arrays.clone(fixedInputDataCounterSuffix); - } - - if (r != 8 && r != 16 && r != 24 && r != 32) - { - throw new IllegalArgumentException("Length of counter should be 8, 16, 24 or 32"); - } - this.r = r; - } - - public byte[] getKI() - { - return ki; - } - - public byte[] getFixedInputData() - { - //Retained for backwards compatibility - return Arrays.clone(fixedInputDataCounterSuffix); - } - - public byte[] getFixedInputDataCounterPrefix() - { - return Arrays.clone(fixedInputDataCounterPrefix); - } - - public byte[] getFixedInputDataCounterSuffix() - { - return Arrays.clone(fixedInputDataCounterSuffix); - } - - public int getR() - { - return r; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFDoublePipelineIterationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFDoublePipelineIterationParameters.java deleted file mode 100644 index 383678a..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFDoublePipelineIterationParameters.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; -import org.bouncycastle.util.Arrays; - -/** - * Note that counter is only supported at the location presented in the - * NIST SP 800-108 specification, not in the additional locations present - * in the CAVP test vectors. - */ -public final class KDFDoublePipelineIterationParameters - implements DerivationParameters -{ - - // could be any valid value, using 32, don't know why - private static final int UNUSED_R = 32; - - private final byte[] ki; - private final boolean useCounter; - private final int r; - private final byte[] fixedInputData; - - private KDFDoublePipelineIterationParameters(byte[] ki, byte[] fixedInputData, int r, boolean useCounter) - { - if (ki == null) - { - throw new IllegalArgumentException("A KDF requires Ki (a seed) as input"); - } - this.ki = Arrays.clone(ki); - - if (fixedInputData == null) - { - this.fixedInputData = new byte[0]; - } - else - { - this.fixedInputData = Arrays.clone(fixedInputData); - } - - if (r != 8 && r != 16 && r != 24 && r != 32) - { - throw new IllegalArgumentException("Length of counter should be 8, 16, 24 or 32"); - } - this.r = r; - - this.useCounter = useCounter; - } - - public static KDFDoublePipelineIterationParameters createWithCounter( - byte[] ki, byte[] fixedInputData, int r) - { - return new KDFDoublePipelineIterationParameters(ki, fixedInputData, r, true); - } - - public static KDFDoublePipelineIterationParameters createWithoutCounter( - byte[] ki, byte[] fixedInputData) - { - return new KDFDoublePipelineIterationParameters(ki, fixedInputData, UNUSED_R, false); - } - - public byte[] getKI() - { - return ki; - } - - public boolean useCounter() - { - return useCounter; - } - - public int getR() - { - return r; - } - - public byte[] getFixedInputData() - { - return Arrays.clone(fixedInputData); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFFeedbackParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFFeedbackParameters.java deleted file mode 100644 index 8a6e7f5..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFFeedbackParameters.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; -import org.bouncycastle.util.Arrays; - -/** - * Note that counter is only supported at the location presented in the - * NIST SP 800-108 specification, not in the additional locations present - * in the CAVP test vectors. - */ -public final class KDFFeedbackParameters - implements DerivationParameters -{ - - // could be any valid value, using 32, don't know why - private static final int UNUSED_R = -1; - - private final byte[] ki; - private final byte[] iv; - private final boolean useCounter; - private final int r; - private final byte[] fixedInputData; - - private KDFFeedbackParameters(byte[] ki, byte[] iv, byte[] fixedInputData, int r, boolean useCounter) - { - if (ki == null) - { - throw new IllegalArgumentException("A KDF requires Ki (a seed) as input"); - } - this.ki = Arrays.clone(ki); - - if (fixedInputData == null) - { - this.fixedInputData = new byte[0]; - } - else - { - this.fixedInputData = Arrays.clone(fixedInputData); - } - - this.r = r; - - if (iv == null) - { - this.iv = new byte[0]; - } - else - { - this.iv = Arrays.clone(iv); - } - - this.useCounter = useCounter; - } - - public static KDFFeedbackParameters createWithCounter( - byte[] ki, final byte[] iv, byte[] fixedInputData, int r) - { - if (r != 8 && r != 16 && r != 24 && r != 32) - { - throw new IllegalArgumentException("Length of counter should be 8, 16, 24 or 32"); - } - - return new KDFFeedbackParameters(ki, iv, fixedInputData, r, true); - } - - public static KDFFeedbackParameters createWithoutCounter( - byte[] ki, final byte[] iv, byte[] fixedInputData) - { - return new KDFFeedbackParameters(ki, iv, fixedInputData, UNUSED_R, false); - } - - public byte[] getKI() - { - return ki; - } - - public byte[] getIV() - { - return iv; - } - - public boolean useCounter() - { - return useCounter; - } - - public int getR() - { - return r; - } - - public byte[] getFixedInputData() - { - return Arrays.clone(fixedInputData); - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFParameters.java deleted file mode 100644 index f3bac64..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/KDFParameters.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; - -/** - * parameters for Key derivation functions for IEEE P1363a - */ -public class KDFParameters - implements DerivationParameters -{ - byte[] iv; - byte[] shared; - - public KDFParameters( - byte[] shared, - byte[] iv) - { - this.shared = shared; - this.iv = iv; - } - - public byte[] getSharedSecret() - { - return shared; - } - - public byte[] getIV() - { - return iv; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/MGFParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/MGFParameters.java deleted file mode 100644 index 847bd98..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/MGFParameters.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.DerivationParameters; - -/** - * parameters for mask derivation functions. - */ -public class MGFParameters - implements DerivationParameters -{ - byte[] seed; - - public MGFParameters( - byte[] seed) - { - this(seed, 0, seed.length); - } - - public MGFParameters( - byte[] seed, - int off, - int len) - { - this.seed = new byte[len]; - System.arraycopy(seed, off, this.seed, 0, len); - } - - public byte[] getSeed() - { - return seed; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPrivateParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPrivateParameters.java deleted file mode 100644 index 832c07f..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPrivateParameters.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -public class MQVPrivateParameters - implements CipherParameters -{ - private ECPrivateKeyParameters staticPrivateKey; - private ECPrivateKeyParameters ephemeralPrivateKey; - private ECPublicKeyParameters ephemeralPublicKey; - - public MQVPrivateParameters( - ECPrivateKeyParameters staticPrivateKey, - ECPrivateKeyParameters ephemeralPrivateKey) - { - this(staticPrivateKey, ephemeralPrivateKey, null); - } - - public MQVPrivateParameters( - ECPrivateKeyParameters staticPrivateKey, - ECPrivateKeyParameters ephemeralPrivateKey, - ECPublicKeyParameters ephemeralPublicKey) - { - this.staticPrivateKey = staticPrivateKey; - this.ephemeralPrivateKey = ephemeralPrivateKey; - this.ephemeralPublicKey = ephemeralPublicKey; - } - - public ECPrivateKeyParameters getStaticPrivateKey() - { - return staticPrivateKey; - } - - public ECPrivateKeyParameters getEphemeralPrivateKey() - { - return ephemeralPrivateKey; - } - - public ECPublicKeyParameters getEphemeralPublicKey() - { - return ephemeralPublicKey; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPublicParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPublicParameters.java deleted file mode 100644 index b3b2467..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/MQVPublicParameters.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -public class MQVPublicParameters - implements CipherParameters -{ - private ECPublicKeyParameters staticPublicKey; - private ECPublicKeyParameters ephemeralPublicKey; - - public MQVPublicParameters( - ECPublicKeyParameters staticPublicKey, - ECPublicKeyParameters ephemeralPublicKey) - { - this.staticPublicKey = staticPublicKey; - this.ephemeralPublicKey = ephemeralPublicKey; - } - - public ECPublicKeyParameters getStaticPublicKey() - { - return staticPublicKey; - } - - public ECPublicKeyParameters getEphemeralPublicKey() - { - return ephemeralPublicKey; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyGenerationParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyGenerationParameters.java deleted file mode 100644 index 758fcd7..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyGenerationParameters.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.security.SecureRandom; - -import org.bouncycastle.crypto.KeyGenerationParameters; - -/** - * Parameters for NaccacheStern public private key generation. For details on - * this cipher, please see - * - * http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf - */ -public class NaccacheSternKeyGenerationParameters extends KeyGenerationParameters -{ - - // private BigInteger publicExponent; - private int certainty; - - private int cntSmallPrimes; - - private boolean debug = false; - - /** - * Parameters for generating a NaccacheStern KeyPair. - * - * @param random - * The source of randomness - * @param strength - * The desired strength of the Key in Bits - * @param certainty - * the probability that the generated primes are not really prime - * as integer: 2^(-certainty) is then the probability - * @param cntSmallPrimes - * How many small key factors are desired - */ - public NaccacheSternKeyGenerationParameters(SecureRandom random, int strength, int certainty, int cntSmallPrimes) - { - this(random, strength, certainty, cntSmallPrimes, false); - } - - /** - * Parameters for a NaccacheStern KeyPair. - * - * @param random - * The source of randomness - * @param strength - * The desired strength of the Key in Bits - * @param certainty - * the probability that the generated primes are not really prime - * as integer: 2^(-certainty) is then the probability - * @param cntSmallPrimes - * How many small key factors are desired - * @param debug - * Turn debugging on or off (reveals secret information, use with - * caution) - */ - public NaccacheSternKeyGenerationParameters(SecureRandom random, - int strength, int certainty, int cntSmallPrimes, boolean debug) - { - super(random, strength); - - this.certainty = certainty; - if (cntSmallPrimes % 2 == 1) - { - throw new IllegalArgumentException("cntSmallPrimes must be a multiple of 2"); - } - if (cntSmallPrimes < 30) - { - throw new IllegalArgumentException("cntSmallPrimes must be >= 30 for security reasons"); - } - this.cntSmallPrimes = cntSmallPrimes; - - this.debug = debug; - } - - /** - * @return Returns the certainty. - */ - public int getCertainty() - { - return certainty; - } - - /** - * @return Returns the cntSmallPrimes. - */ - public int getCntSmallPrimes() - { - return cntSmallPrimes; - } - - public boolean isDebug() - { - return debug; - } - -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyParameters.java deleted file mode 100644 index 21b6a28..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternKeyParameters.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -/** - * Public key parameters for NaccacheStern cipher. For details on this cipher, - * please see - * - * http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf - */ -public class NaccacheSternKeyParameters extends AsymmetricKeyParameter -{ - - private BigInteger g, n; - - int lowerSigmaBound; - - /** - * @param privateKey - */ - public NaccacheSternKeyParameters(boolean privateKey, BigInteger g, BigInteger n, int lowerSigmaBound) - { - super(privateKey); - this.g = g; - this.n = n; - this.lowerSigmaBound = lowerSigmaBound; - } - - /** - * @return Returns the g. - */ - public BigInteger getG() - { - return g; - } - - /** - * @return Returns the lowerSigmaBound. - */ - public int getLowerSigmaBound() - { - return lowerSigmaBound; - } - - /** - * @return Returns the n. - */ - public BigInteger getModulus() - { - return n; - } - -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternPrivateKeyParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternPrivateKeyParameters.java deleted file mode 100644 index 6d0ec48..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/NaccacheSternPrivateKeyParameters.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; -import java.util.Vector; - -/** - * Private key parameters for NaccacheStern cipher. For details on this cipher, - * please see - * - * http://www.gemplus.com/smart/rd/publications/pdf/NS98pkcs.pdf - */ -public class NaccacheSternPrivateKeyParameters extends NaccacheSternKeyParameters -{ - private BigInteger phi_n; - private Vector smallPrimes; - - /** - * Constructs a NaccacheSternPrivateKey - * - * @param g - * the public enryption parameter g - * @param n - * the public modulus n = p*q - * @param lowerSigmaBound - * the public lower sigma bound up to which data can be encrypted - * @param smallPrimes - * the small primes, of which sigma is constructed in the right - * order - * @param phi_n - * the private modulus phi(n) = (p-1)(q-1) - */ - public NaccacheSternPrivateKeyParameters(BigInteger g, BigInteger n, - int lowerSigmaBound, Vector smallPrimes, - BigInteger phi_n) - { - super(true, g, n, lowerSigmaBound); - this.smallPrimes = smallPrimes; - this.phi_n = phi_n; - } - - public BigInteger getPhi_n() - { - return phi_n; - } - - public Vector getSmallPrimes() - { - return smallPrimes; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSBox.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSBox.java deleted file mode 100644 index b226a9d..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSBox.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -public class ParametersWithSBox - implements CipherParameters -{ - private CipherParameters parameters; - private byte[] sBox; - - public ParametersWithSBox( - CipherParameters parameters, - byte[] sBox) - { - this.parameters = parameters; - this.sBox = sBox; - } - - public byte[] getSBox() - { - return sBox; - } - - public CipherParameters getParameters() - { - return parameters; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSalt.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSalt.java deleted file mode 100644 index 73765dd..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/ParametersWithSalt.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -/** - * Cipher parameters with a fixed salt value associated with them. - */ -public class ParametersWithSalt - implements CipherParameters -{ - private byte[] salt; - private CipherParameters parameters; - - public ParametersWithSalt( - CipherParameters parameters, - byte[] salt) - { - this(parameters, salt, 0, salt.length); - } - - public ParametersWithSalt( - CipherParameters parameters, - byte[] salt, - int saltOff, - int saltLen) - { - this.salt = new byte[saltLen]; - this.parameters = parameters; - - System.arraycopy(salt, saltOff, this.salt, 0, saltLen); - } - - public byte[] getSalt() - { - return salt; - } - - public CipherParameters getParameters() - { - return parameters; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/RC5Parameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/RC5Parameters.java deleted file mode 100644 index 6cbd57f..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/RC5Parameters.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -public class RC5Parameters - implements CipherParameters -{ - private byte[] key; - private int rounds; - - public RC5Parameters( - byte[] key, - int rounds) - { - if (key.length > 255) - { - throw new IllegalArgumentException("RC5 key length can be no greater than 255"); - } - - this.key = new byte[key.length]; - this.rounds = rounds; - - System.arraycopy(key, 0, this.key, 0, key.length); - } - - public byte[] getKey() - { - return key; - } - - public int getRounds() - { - return rounds; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/RSABlindingParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/RSABlindingParameters.java deleted file mode 100644 index c7fa6ba..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/RSABlindingParameters.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; - -import java.math.BigInteger; - -public class RSABlindingParameters - implements CipherParameters -{ - private RSAKeyParameters publicKey; - private BigInteger blindingFactor; - - public RSABlindingParameters( - RSAKeyParameters publicKey, - BigInteger blindingFactor) - { - if (publicKey instanceof RSAPrivateCrtKeyParameters) - { - throw new IllegalArgumentException("RSA parameters should be for a public key"); - } - - this.publicKey = publicKey; - this.blindingFactor = blindingFactor; - } - - public RSAKeyParameters getPublicKey() - { - return publicKey; - } - - public BigInteger getBlindingFactor() - { - return blindingFactor; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/SRP6GroupParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/SRP6GroupParameters.java deleted file mode 100644 index 506560e..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/SRP6GroupParameters.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.math.BigInteger; - -public class SRP6GroupParameters -{ - private BigInteger N, g; - - public SRP6GroupParameters(BigInteger N, BigInteger g) - { - this.N = N; - this.g = g; - } - - public BigInteger getG() - { - return g; - } - - public BigInteger getN() - { - return N; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/SkeinParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/SkeinParameters.java deleted file mode 100644 index 326e106..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/SkeinParameters.java +++ /dev/null @@ -1,329 +0,0 @@ -package org.bouncycastle.crypto.params; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Locale; - -import org.bouncycastle.crypto.CipherParameters; -import org.bouncycastle.crypto.digests.SkeinDigest; -import org.bouncycastle.crypto.digests.SkeinEngine; -import org.bouncycastle.crypto.macs.SkeinMac; -import org.bouncycastle.util.Integers; - -/** - * Parameters for the Skein hash function - a series of byte[] strings identified by integer tags. - * <p> - * Parameterised Skein can be used for: - * <ul> - * <li>MAC generation, by providing a {@link SkeinParameters.Builder#setKey(byte[]) key}.</li> - * <li>Randomised hashing, by providing a {@link SkeinParameters.Builder#setNonce(byte[]) nonce}.</li> - * <li>A hash function for digital signatures, associating a - * {@link SkeinParameters.Builder#setPublicKey(byte[]) public key} with the message digest.</li> - * <li>A key derivation function, by providing a - * {@link SkeinParameters.Builder#setKeyIdentifier(byte[]) key identifier}.</li> - * <li>Personalised hashing, by providing a - * {@link SkeinParameters.Builder#setPersonalisation(Date, String, String) recommended format} or - * {@link SkeinParameters.Builder#setPersonalisation(byte[]) arbitrary} personalisation string.</li> - * </ul> - * - * @see SkeinEngine - * @see SkeinDigest - * @see SkeinMac - */ -public class SkeinParameters - implements CipherParameters -{ - /** - * The parameter type for a secret key, supporting MAC or KDF functions: {@value - * #PARAM_TYPE_KEY}. - */ - public static final int PARAM_TYPE_KEY = 0; - - /** - * The parameter type for the Skein configuration block: {@value #PARAM_TYPE_CONFIG}. - */ - public static final int PARAM_TYPE_CONFIG = 4; - - /** - * The parameter type for a personalisation string: {@value #PARAM_TYPE_PERSONALISATION}. - */ - public static final int PARAM_TYPE_PERSONALISATION = 8; - - /** - * The parameter type for a public key: {@value #PARAM_TYPE_PUBLIC_KEY}. - */ - public static final int PARAM_TYPE_PUBLIC_KEY = 12; - - /** - * The parameter type for a key identifier string: {@value #PARAM_TYPE_KEY_IDENTIFIER}. - */ - public static final int PARAM_TYPE_KEY_IDENTIFIER = 16; - - /** - * The parameter type for a nonce: {@value #PARAM_TYPE_NONCE}. - */ - public static final int PARAM_TYPE_NONCE = 20; - - /** - * The parameter type for the message: {@value #PARAM_TYPE_MESSAGE}. - */ - public static final int PARAM_TYPE_MESSAGE = 48; - - /** - * The parameter type for the output transformation: {@value #PARAM_TYPE_OUTPUT}. - */ - public static final int PARAM_TYPE_OUTPUT = 63; - - private Hashtable parameters; - - public SkeinParameters() - { - this(new Hashtable()); - } - - private SkeinParameters(final Hashtable parameters) - { - this.parameters = parameters; - } - - /** - * Obtains a map of type (Integer) to value (byte[]) for the parameters tracked in this object. - */ - public Hashtable getParameters() - { - return parameters; - } - - /** - * Obtains the value of the {@link #PARAM_TYPE_KEY key parameter}, or <code>null</code> if not - * set. - */ - public byte[] getKey() - { - return (byte[])parameters.get(Integers.valueOf(PARAM_TYPE_KEY)); - } - - /** - * Obtains the value of the {@link #PARAM_TYPE_PERSONALISATION personalisation parameter}, or - * <code>null</code> if not set. - */ - public byte[] getPersonalisation() - { - return (byte[])parameters.get(Integers.valueOf(PARAM_TYPE_PERSONALISATION)); - } - - /** - * Obtains the value of the {@link #PARAM_TYPE_PUBLIC_KEY public key parameter}, or - * <code>null</code> if not set. - */ - public byte[] getPublicKey() - { - return (byte[])parameters.get(Integers.valueOf(PARAM_TYPE_PUBLIC_KEY)); - } - - /** - * Obtains the value of the {@link #PARAM_TYPE_KEY_IDENTIFIER key identifier parameter}, or - * <code>null</code> if not set. - */ - public byte[] getKeyIdentifier() - { - return (byte[])parameters.get(Integers.valueOf(PARAM_TYPE_KEY_IDENTIFIER)); - } - - /** - * Obtains the value of the {@link #PARAM_TYPE_NONCE nonce parameter}, or <code>null</code> if - * not set. - */ - public byte[] getNonce() - { - return (byte[])parameters.get(Integers.valueOf(PARAM_TYPE_NONCE)); - } - - /** - * A builder for {@link SkeinParameters}. - */ - public static class Builder - { - private Hashtable parameters = new Hashtable(); - - public Builder() - { - } - - public Builder(Hashtable paramsMap) - { - Enumeration keys = paramsMap.keys(); - while (keys.hasMoreElements()) - { - Integer key = (Integer)keys.nextElement(); - parameters.put(key, paramsMap.get(key)); - } - } - - public Builder(SkeinParameters params) - { - Enumeration keys = params.parameters.keys(); - while (keys.hasMoreElements()) - { - Integer key = (Integer)keys.nextElement(); - parameters.put(key, params.parameters.get(key)); - } - } - - /** - * Sets a parameters to apply to the Skein hash function.<br> - * Parameter types must be in the range 0,5..62, and cannot use the value {@value - * SkeinParameters#PARAM_TYPE_MESSAGE} (reserved for message body). - * <p> - * Parameters with type < {@value SkeinParameters#PARAM_TYPE_MESSAGE} are processed before - * the message content, parameters with type > {@value SkeinParameters#PARAM_TYPE_MESSAGE} - * are processed after the message and prior to output. - * - * @param type the type of the parameter, in the range 5..62. - * @param value the byte sequence of the parameter. - * @return - */ - public Builder set(int type, byte[] value) - { - if (value == null) - { - throw new IllegalArgumentException("Parameter value must not be null."); - } - if ((type != PARAM_TYPE_KEY) - && (type <= PARAM_TYPE_CONFIG || type >= PARAM_TYPE_OUTPUT || type == PARAM_TYPE_MESSAGE)) - { - throw new IllegalArgumentException("Parameter types must be in the range 0,5..47,49..62."); - } - if (type == PARAM_TYPE_CONFIG) - { - throw new IllegalArgumentException("Parameter type " + PARAM_TYPE_CONFIG - + " is reserved for internal use."); - } - this.parameters.put(Integers.valueOf(type), value); - return this; - } - - /** - * Sets the {@link SkeinParameters#PARAM_TYPE_KEY} parameter. - */ - public Builder setKey(byte[] key) - { - return set(PARAM_TYPE_KEY, key); - } - - /** - * Sets the {@link SkeinParameters#PARAM_TYPE_PERSONALISATION} parameter. - */ - public Builder setPersonalisation(byte[] personalisation) - { - return set(PARAM_TYPE_PERSONALISATION, personalisation); - } - - /** - * Implements the recommended personalisation format for Skein defined in Section 4.11 of - * the Skein 1.3 specification. - * <p> - * The format is <code>YYYYMMDD email@address distinguisher</code>, encoded to a byte - * sequence using UTF-8 encoding. - * - * @param date the date the personalised application of the Skein was defined. - * @param emailAddress the email address of the creation of the personalised application. - * @param distinguisher an arbitrary personalisation string distinguishing the application. - * @return the current builder. - */ - public Builder setPersonalisation(Date date, String emailAddress, String distinguisher) - { - try - { - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - final OutputStreamWriter out = new OutputStreamWriter(bout, "UTF-8"); - final DateFormat format = new SimpleDateFormat("YYYYMMDD"); - out.write(format.format(date)); - out.write(" "); - out.write(emailAddress); - out.write(" "); - out.write(distinguisher); - out.close(); - return set(PARAM_TYPE_PERSONALISATION, bout.toByteArray()); - } - catch (IOException e) - { - throw new IllegalStateException("Byte I/O failed: " + e); - } - } - - /** - * Implements the recommended personalisation format for Skein defined in Section 4.11 of - * the Skein 1.3 specification. You may need to use this method if the default locale - * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible implementations. - * <p> - * The format is <code>YYYYMMDD email@address distinguisher</code>, encoded to a byte - * sequence using UTF-8 encoding. - * - * @param date the date the personalised application of the Skein was defined. - * @param dateLocale locale to be used for date interpretation. - * @param emailAddress the email address of the creation of the personalised application. - * @param distinguisher an arbitrary personalisation string distinguishing the application. - * @return the current builder. - */ - public Builder setPersonalisation(Date date, Locale dateLocale, String emailAddress, String distinguisher) - { - try - { - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - final OutputStreamWriter out = new OutputStreamWriter(bout, "UTF-8"); - final DateFormat format = new SimpleDateFormat("YYYYMMDD", dateLocale); - out.write(format.format(date)); - out.write(" "); - out.write(emailAddress); - out.write(" "); - out.write(distinguisher); - out.close(); - return set(PARAM_TYPE_PERSONALISATION, bout.toByteArray()); - } - catch (IOException e) - { - throw new IllegalStateException("Byte I/O failed: " + e); - } - } - - /** - * Sets the {@link SkeinParameters#PARAM_TYPE_KEY_IDENTIFIER} parameter. - */ - public Builder setPublicKey(byte[] publicKey) - { - return set(PARAM_TYPE_PUBLIC_KEY, publicKey); - } - - /** - * Sets the {@link SkeinParameters#PARAM_TYPE_KEY_IDENTIFIER} parameter. - */ - public Builder setKeyIdentifier(byte[] keyIdentifier) - { - return set(PARAM_TYPE_KEY_IDENTIFIER, keyIdentifier); - } - - /** - * Sets the {@link SkeinParameters#PARAM_TYPE_NONCE} parameter. - */ - public Builder setNonce(byte[] nonce) - { - return set(PARAM_TYPE_NONCE, nonce); - } - - /** - * Constructs a new {@link SkeinParameters} instance with the parameters provided to this - * builder. - */ - public SkeinParameters build() - { - return new SkeinParameters(parameters); - } - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/TweakableBlockCipherParameters.java b/bcprov/src/main/java/org/bouncycastle/crypto/params/TweakableBlockCipherParameters.java deleted file mode 100644 index fa16fac..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/TweakableBlockCipherParameters.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.bouncycastle.crypto.params; - -import org.bouncycastle.crypto.CipherParameters; -import org.bouncycastle.util.Arrays; - -/** - * Parameters for tweakable block ciphers. - */ -public class TweakableBlockCipherParameters - implements CipherParameters -{ - private final byte[] tweak; - private final KeyParameter key; - - public TweakableBlockCipherParameters(final KeyParameter key, final byte[] tweak) - { - this.key = key; - this.tweak = Arrays.clone(tweak); - } - - /** - * Gets the key. - * - * @return the key to use, or <code>null</code> to use the current key. - */ - public KeyParameter getKey() - { - return key; - } - - /** - * Gets the tweak value. - * - * @return the tweak to use, or <code>null</code> to use the current tweak. - */ - public byte[] getTweak() - { - return tweak; - } -} diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/params/package.html b/bcprov/src/main/java/org/bouncycastle/crypto/params/package.html deleted file mode 100644 index 4e00a75..0000000 --- a/bcprov/src/main/java/org/bouncycastle/crypto/params/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body bgcolor="#ffffff"> -Classes for parameter objects for ciphers and generators. -</body> -</html> |