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/core/src/main/jdk1.1/java/security/spec | |
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/core/src/main/jdk1.1/java/security/spec')
17 files changed, 656 insertions, 0 deletions
diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/AlgorithmParameterSpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/AlgorithmParameterSpec.java new file mode 100644 index 000000000..37a03e9b2 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/AlgorithmParameterSpec.java @@ -0,0 +1,6 @@ + +package java.security.spec; + +public interface AlgorithmParameterSpec +{ +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAParameterSpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAParameterSpec.java new file mode 100644 index 000000000..a3897f8a6 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAParameterSpec.java @@ -0,0 +1,34 @@ + +package java.security.spec; + +import java.math.BigInteger; +import java.security.interfaces.DSAParams; + +public class DSAParameterSpec implements AlgorithmParameterSpec, DSAParams +{ + private BigInteger p; + private BigInteger q; + private BigInteger g; + + public DSAParameterSpec(BigInteger p, BigInteger q, BigInteger g) + { + this.p = p; + this.q = q; + this.g = g; + } + + public BigInteger getG() + { + return g; + } + + public BigInteger getP() + { + return p; + } + + public BigInteger getQ() + { + return q; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPrivateKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPrivateKeySpec.java new file mode 100644 index 000000000..ff5febef6 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPrivateKeySpec.java @@ -0,0 +1,40 @@ + +package java.security.spec; + +import java.math.BigInteger; + +public class DSAPrivateKeySpec implements KeySpec +{ + private BigInteger x; + private BigInteger p; + private BigInteger q; + private BigInteger g; + + public DSAPrivateKeySpec(BigInteger x, BigInteger p, BigInteger q, BigInteger g) + { + this.x = x; + this.p = p; + this.q = q; + this.g = g; + } + + public BigInteger getG() + { + return g; + } + + public BigInteger getP() + { + return p; + } + + public BigInteger getQ() + { + return q; + } + + public BigInteger getX() + { + return x; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPublicKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPublicKeySpec.java new file mode 100644 index 000000000..f8ca36792 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/DSAPublicKeySpec.java @@ -0,0 +1,40 @@ + +package java.security.spec; + +import java.math.BigInteger; + +public class DSAPublicKeySpec implements KeySpec +{ + private BigInteger y; + private BigInteger p; + private BigInteger q; + private BigInteger g; + + public DSAPublicKeySpec(BigInteger y, BigInteger p, BigInteger q, BigInteger g) + { + this.y = y; + this.p = p; + this.q = q; + this.g = g; + } + + public BigInteger getG() + { + return g; + } + + public BigInteger getP() + { + return p; + } + + public BigInteger getQ() + { + return q; + } + + public BigInteger getY() + { + return y; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/EncodedKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/EncodedKeySpec.java new file mode 100644 index 000000000..7295460f0 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/EncodedKeySpec.java @@ -0,0 +1,19 @@ + +package java.security.spec; + +public abstract class EncodedKeySpec implements KeySpec +{ + private byte[] encodedKey; + + public EncodedKeySpec(byte[] encodedKey) + { + this.encodedKey = (byte[])encodedKey.clone(); + } + + public byte[] getEncoded() + { + return (byte[])encodedKey.clone(); + } + + public abstract String getFormat(); +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidKeySpecException.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidKeySpecException.java new file mode 100644 index 000000000..cb29aee38 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidKeySpecException.java @@ -0,0 +1,16 @@ + +package java.security.spec; + +import java.security.GeneralSecurityException; + +public class InvalidKeySpecException extends GeneralSecurityException +{ + public InvalidKeySpecException() + { + } + + public InvalidKeySpecException(String msg) + { + super(msg); + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidParameterSpecException.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidParameterSpecException.java new file mode 100644 index 000000000..c8303edda --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/InvalidParameterSpecException.java @@ -0,0 +1,16 @@ + +package java.security.spec; + +import java.security.GeneralSecurityException; + +public class InvalidParameterSpecException extends GeneralSecurityException +{ + public InvalidParameterSpecException() + { + } + + public InvalidParameterSpecException(String msg) + { + super(msg); + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/KeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/KeySpec.java new file mode 100644 index 000000000..cfa7cb92f --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/KeySpec.java @@ -0,0 +1,6 @@ + +package java.security.spec; + +public interface KeySpec +{ +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PKCS8EncodedKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PKCS8EncodedKeySpec.java new file mode 100644 index 000000000..10c5f66c2 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PKCS8EncodedKeySpec.java @@ -0,0 +1,20 @@ + +package java.security.spec; + +public class PKCS8EncodedKeySpec extends EncodedKeySpec +{ + public PKCS8EncodedKeySpec(byte[] encodedKey) + { + super(encodedKey); + } + + public byte[] getEncoded() + { + return super.getEncoded(); + } + + public final String getFormat() + { + return "PKCS#8"; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PSSParameterSpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PSSParameterSpec.java new file mode 100644 index 000000000..c4b4989cd --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/PSSParameterSpec.java @@ -0,0 +1,45 @@ + +package java.security.spec; + +/** + * This class specifies a parameter spec for RSA PSS encoding scheme, + * as defined in the PKCS#1 v2.1. + * + * @since 1.4 + * @see AlgorithmParameterSpec, Signature + */ +public class PSSParameterSpec + extends Object + implements AlgorithmParameterSpec +{ + private int saltLen; + + /** + * Creates a new PSSParameterSpec given the salt length as defined + * in PKCS#1. + * + * @param saltLen - the length of salt in bits to be used in PKCS#1 + * PSS encoding. + * @throws IllegalArgumentException - if saltLen is less than 0. + */ + public PSSParameterSpec(int saltLen) + { + if ( saltLen < 0 ) + { + throw new IllegalArgumentException("Salt length must be >= 0"); + } + + this.saltLen = saltLen; + } + + /** + * Returns the salt length in bits. + * + * @returns the salt length. + */ + public int getSaltLength() + { + return saltLen; + } +} + diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAKeyGenParameterSpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAKeyGenParameterSpec.java new file mode 100644 index 000000000..756c6c0fd --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAKeyGenParameterSpec.java @@ -0,0 +1,35 @@ +package java.security.spec; + +import java.math.BigInteger; + +/** + * specifies parameters to be used for the generation of + * a RSA key pair. + */ +public class RSAKeyGenParameterSpec + implements AlgorithmParameterSpec +{ + static BigInteger F0 = BigInteger.valueOf(3); + static BigInteger F4 = BigInteger.valueOf(65537); + + private int keysize; + private BigInteger publicExponent; + + public RSAKeyGenParameterSpec( + int keysize, + BigInteger publicExponent) + { + this.keysize = keysize; + this.publicExponent = publicExponent; + } + + public int getKeysize() + { + return keysize; + } + + public BigInteger getPublicExponent() + { + return publicExponent; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java new file mode 100644 index 000000000..53c3a8a51 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java @@ -0,0 +1,159 @@ + +package java.security.spec; + +import java.math.BigInteger; + +/** + * This class specifies an RSA multi-prime private key, as defined in + * the PKCS#1 v2.1, using the Chinese Remainder Theorem (CRT) information + * values for efficiency. + * + * @since 1.4 + * @see Key, KeyFactory, KeySpec, PKCS8EncodedKeySpec, RSAPrivateKeySpec, + * RSAPublicKeySpec, RSAOtherPrimeInfo + */ +public class RSAMultiPrimePrivateCrtKeySpec + extends RSAPrivateKeySpec +{ + private BigInteger publicExponent; + private BigInteger privateExponent; + private BigInteger primeP; + private BigInteger primeQ; + private BigInteger primeExponentP; + private BigInteger primeExponentQ; + private BigInteger crtCoefficient; + private RSAOtherPrimeInfo[] otherPrimeInfo; + + /** + * Creates a new RSAMultiPrimePrivateCrtKeySpec given the modulus, + * publicExponent, privateExponent, primeP, primeQ, primeExponentP, + * primeExponentQ, crtCoefficient, and otherPrimeInfo as defined in + * PKCS#1 v2.1. + * + * Note that otherPrimeInfo is cloned when constructing this object. + * + * @param modulus - the modulus n. + * @param publicExponent - the public exponent e. + * @param privateExponent - the private exponent d. + * @param primeP - the prime factor p of n. + * @param primeQ - the prime factor q of n. + * @param primeExponentP - this is d mod (p-1). + * @param primeExponentQ - this is d mod (q-1). + * @param crtCoefficient - the Chinese Remainder Theorem coefficient q-1 + * mod p. + * @param otherPrimeInfo - triplets of the rest of primes, null can be + * specified if there are only two prime factors (p and q). + * @throws NullPointerException - if any of the parameters, i.e. modulus, + * publicExponent, privateExponent, primeP, primeQ, primeExponentP, + * primeExponentQ, crtCoefficient, is null. + * @throws IllegalArgumentException - if an empty, i.e. 0-length, + * otherPrimeInfo is specified. + */ + public RSAMultiPrimePrivateCrtKeySpec( + BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient, + RSAOtherPrimeInfo[] otherPrimeInfo) + { + super(modulus, privateExponent); + + if ( publicExponent == null || primeP == null || primeQ == null + || primeExponentP == null || primeExponentQ == null + || crtCoefficient == null ) + { + throw new NullPointerException("Invalid null argument"); + } + + if ( otherPrimeInfo != null ) + { + if ( otherPrimeInfo.length == 0 ) + { + throw new IllegalArgumentException("Invalid length for otherPrimeInfo"); + } + + this.otherPrimeInfo = (RSAOtherPrimeInfo[])otherPrimeInfo.clone(); + } + } + + /** + * Returns the public exponent. + * + * @returns the public exponent. + */ + public BigInteger getPublicExponent() + { + return publicExponent; + } + + /** + * Returns the primeP. + * + * @returns the primeP. + */ + public BigInteger getPrimeP() + { + return primeP; + } + + /** + * Returns the primeQ. + * + * @returns the primeQ. + */ + public BigInteger getPrimeQ() + { + return primeQ; + } + + /** + * Returns the primeExponentP. + * + * @returns the primeExponentP. + */ + public BigInteger getPrimeExponentP() + { + return primeExponentP; + } + + /** + * Returns the primeExponentQ. + * + * @returns the primeExponentQ. + */ + public BigInteger getPrimeExponentQ() + { + return primeExponentQ; + } + + /** + * Returns the crtCofficient. + * + * @returns the crtCofficient. + */ + public BigInteger getCrtCoefficient() + { + return crtCoefficient; + } + + /** + * Returns a copy of the otherPrimeInfo or null if there are only + * two prime factors (p and q). + * + * @returns the otherPrimeInfo. + */ + public RSAOtherPrimeInfo[] getOtherPrimeInfo() + { + if ( otherPrimeInfo != null ) + { + return (RSAOtherPrimeInfo[])otherPrimeInfo.clone(); + } + + return null; + } +} + diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAOtherPrimeInfo.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAOtherPrimeInfo.java new file mode 100644 index 000000000..4d0e1468e --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAOtherPrimeInfo.java @@ -0,0 +1,80 @@ + +package java.security.spec; + +import java.math.BigInteger; + +/** + * This class represents the triplet (prime, exponent, and coefficient) + * inside RSA's OtherPrimeInfo structure, as defined in the PKCS#1 v2.1. + * The ASN.1 syntax of RSA's OtherPrimeInfo is as follows: + * + * <pre> + * OtherPrimeInfo ::= SEQUENCE { + * prime INTEGER, + * exponent INTEGER, + * coefficient INTEGER + * } + * </pre> + */ +public class RSAOtherPrimeInfo +extends Object +{ + private BigInteger prime; + private BigInteger primeExponent; + private BigInteger crtCoefficient; + + /** + * Creates a new RSAOtherPrimeInfo given the prime, primeExponent, + * and crtCoefficient as defined in PKCS#1. + * + * @param prime - the prime factor of n. + * @param primeExponent - the exponent. + * @param crtCoefficient - the Chinese Remainder Theorem coefficient. + * @throws NullPointerException - if any of the parameters, i.e. prime, + * primeExponent, crtCoefficient, is null. + */ + public RSAOtherPrimeInfo( + BigInteger prime, + BigInteger primeExponent, + BigInteger crtCoefficient) + { + if ( prime == null || primeExponent == null || crtCoefficient == null ) + { + throw new NullPointerException("Null parameter"); + } + + this.prime = prime; + this.primeExponent = primeExponent; + this.crtCoefficient = crtCoefficient; + } + + /** + * Returns the prime. + * + * @returns the prime. + */ + public final BigInteger getPrime() + { + return prime; + } + + /** + * Returns the prime's exponent. + * + * @returns the primeExponent. + */ + public final BigInteger getExponent() + { + return primeExponent; + } + + /** + * Returns the prime's crtCoefficient. + * + * @returns the crtCoefficient. + */ + public final BigInteger getCrtCoefficient() + { + return crtCoefficient; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateCrtKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateCrtKeySpec.java new file mode 100644 index 000000000..b9d450ad7 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateCrtKeySpec.java @@ -0,0 +1,64 @@ + +package java.security.spec; + +import java.math.BigInteger; + +public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec +{ + private BigInteger publicExponent; + private BigInteger primeP; + private BigInteger primeQ; + private BigInteger primeExponentP; + private BigInteger primeExponentQ; + private BigInteger crtCoefficient; + + public RSAPrivateCrtKeySpec( + BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient) + { + super(modulus, privateExponent); + + this.publicExponent = publicExponent; + this.primeP = primeP; + this.primeQ = primeQ; + this.primeExponentP = primeExponentP; + this.primeExponentQ = primeExponentQ; + this.crtCoefficient = crtCoefficient; + } + + public BigInteger getCrtCoefficient() + { + return crtCoefficient; + } + + public BigInteger getPrimeExponentP() + { + return primeExponentP; + } + + public BigInteger getPrimeExponentQ() + { + return primeExponentQ; + } + + public BigInteger getPrimeP() + { + return primeP; + } + + public BigInteger getPrimeQ() + { + return primeQ; + } + + public BigInteger getPublicExponent() + { + return publicExponent; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateKeySpec.java new file mode 100644 index 000000000..88dc4c159 --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPrivateKeySpec.java @@ -0,0 +1,28 @@ + +package java.security.spec; + +import java.math.BigInteger; + +public class RSAPrivateKeySpec extends Object implements KeySpec +{ + private BigInteger modulus; + private BigInteger privateExponent; + + public RSAPrivateKeySpec( + BigInteger modulus, + BigInteger privateExponent) + { + this.modulus = modulus; + this.privateExponent = privateExponent; + } + + public BigInteger getModulus() + { + return modulus; + } + + public BigInteger getPrivateExponent() + { + return privateExponent; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPublicKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPublicKeySpec.java new file mode 100644 index 000000000..b3a367e7e --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/RSAPublicKeySpec.java @@ -0,0 +1,28 @@ + +package java.security.spec; + +import java.math.BigInteger; + +public class RSAPublicKeySpec extends Object implements KeySpec +{ + private BigInteger modulus; + private BigInteger publicExponent; + + public RSAPublicKeySpec( + BigInteger modulus, + BigInteger publicExponent) + { + this.modulus = modulus; + this.publicExponent = publicExponent; + } + + public BigInteger getModulus() + { + return modulus; + } + + public BigInteger getPublicExponent() + { + return publicExponent; + } +} diff --git a/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/X509EncodedKeySpec.java b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/X509EncodedKeySpec.java new file mode 100644 index 000000000..1d095b11d --- /dev/null +++ b/libraries/spongycastle/core/src/main/jdk1.1/java/security/spec/X509EncodedKeySpec.java @@ -0,0 +1,20 @@ + +package java.security.spec; + +public class X509EncodedKeySpec extends EncodedKeySpec +{ + public X509EncodedKeySpec(byte[] encodedKey) + { + super(encodedKey); + } + + public byte[] getEncoded() + { + return super.getEncoded(); + } + + public final String getFormat() + { + return "X.509"; + } +} |