Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider')
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/dsa/DSASigner.java280
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/ecgost/SignatureSpi.java221
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/gost/SignatureSpi.java230
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java368
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/ISOSignatureSpi.java143
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/util/DSABase.java129
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/CertificateFactory.java397
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java379
-rw-r--r--prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/SignatureUtil.java107
9 files changed, 0 insertions, 2254 deletions
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/dsa/DSASigner.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/dsa/DSASigner.java
deleted file mode 100644
index 381511f9..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/dsa/DSASigner.java
+++ /dev/null
@@ -1,280 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.dsa;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.SignatureException;
-import java.security.Signature;
-import java.security.interfaces.DSAKey;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.asn1.ASN1Encoding;
-import org.bouncycastle.asn1.ASN1Integer;
-import org.bouncycastle.asn1.ASN1Primitive;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DERSequence;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
-import org.bouncycastle.crypto.CipherParameters;
-import org.bouncycastle.crypto.DSA;
-import org.bouncycastle.crypto.Digest;
-import org.bouncycastle.crypto.digests.NullDigest;
-import org.bouncycastle.crypto.digests.SHA1Digest;
-import org.bouncycastle.crypto.digests.SHA224Digest;
-import org.bouncycastle.crypto.digests.SHA256Digest;
-import org.bouncycastle.crypto.digests.SHA384Digest;
-import org.bouncycastle.crypto.digests.SHA512Digest;
-import org.bouncycastle.crypto.params.ParametersWithRandom;
-
-public class DSASigner
- extends Signature
- implements PKCSObjectIdentifiers, X509ObjectIdentifiers
-{
- private Digest digest;
- private DSA signer;
- private SecureRandom random;
-
- protected DSASigner(
- Digest digest,
- DSA signer)
- {
- super("DSA");
- this.digest = digest;
- this.signer = signer;
- }
-
- protected void engineInitVerify(
- PublicKey publicKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
-// if (publicKey instanceof GOST3410Key)
-// {
-// param = GOST3410Util.generatePublicKeyParameter(publicKey);
-// }
-// else if (publicKey instanceof DSAKey)
- if (publicKey instanceof DSAKey)
- {
- param = DSAUtil.generatePublicKeyParameter(publicKey);
- }
- else
- {
- try
- {
- byte[] bytes = publicKey.getEncoded();
-
- publicKey = new BCDSAPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
-
- if (publicKey instanceof DSAKey)
- {
- param = DSAUtil.generatePublicKeyParameter(publicKey);
- }
- else
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
- catch (Exception e)
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
-
- digest.reset();
- signer.init(false, param);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey,
- SecureRandom random)
- throws InvalidKeyException
- {
- this.random = random;
- engineInitSign(privateKey);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
-// if (privateKey instanceof GOST3410Key)
-// {
-// param = GOST3410Util.generatePrivateKeyParameter(privateKey);
-// }
-// else
-// {
- param = DSAUtil.generatePrivateKeyParameter(privateKey);
-// }
-
- if (random != null)
- {
- param = new ParametersWithRandom(param, random);
- }
-
- digest.reset();
- signer.init(true, param);
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- digest.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- digest.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- try
- {
- BigInteger[] sig = signer.generateSignature(hash);
-
- return derEncode(sig[0], sig[1]);
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- BigInteger[] sig;
-
- try
- {
- sig = derDecode(sigBytes);
- }
- catch (Exception e)
- {
- throw new SignatureException("error decoding signature bytes.");
- }
-
- return signer.verifySignature(hash, sig[0], sig[1]);
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- private byte[] derEncode(
- BigInteger r,
- BigInteger s)
- throws IOException
- {
- ASN1Integer[] rs = new ASN1Integer[]{ new ASN1Integer(r), new ASN1Integer(s) };
- return new DERSequence(rs).getEncoded(ASN1Encoding.DER);
- }
-
- private BigInteger[] derDecode(
- byte[] encoding)
- throws IOException
- {
- ASN1Sequence s = (ASN1Sequence)ASN1Primitive.fromByteArray(encoding);
- return new BigInteger[]{
- ((ASN1Integer)s.getObjectAt(0)).getValue(),
- ((ASN1Integer)s.getObjectAt(1)).getValue()
- };
- }
-
- static public class stdDSA
- extends DSASigner
- {
- public stdDSA()
- {
- super(new SHA1Digest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-
- static public class dsa224
- extends DSASigner
- {
- public dsa224()
- {
- super(new SHA224Digest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-
- static public class dsa256
- extends DSASigner
- {
- public dsa256()
- {
- super(new SHA256Digest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-
- static public class dsa384
- extends DSASigner
- {
- public dsa384()
- {
- super(new SHA384Digest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-
- static public class dsa512
- extends DSASigner
- {
- public dsa512()
- {
- super(new SHA512Digest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-
- static public class noneDSA
- extends DSASigner
- {
- public noneDSA()
- {
- super(new NullDigest(), new org.bouncycastle.crypto.signers.DSASigner());
- }
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/ecgost/SignatureSpi.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/ecgost/SignatureSpi.java
deleted file mode 100644
index 65fa03eb..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/ecgost/SignatureSpi.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.ecgost;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.SignatureException;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
-import org.bouncycastle.crypto.CipherParameters;
-import org.bouncycastle.crypto.DSA;
-import org.bouncycastle.crypto.Digest;
-import org.bouncycastle.crypto.digests.GOST3411Digest;
-import org.bouncycastle.crypto.params.ParametersWithRandom;
-import org.bouncycastle.crypto.signers.ECGOST3410Signer;
-import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil;
-import org.bouncycastle.jce.interfaces.ECKey;
-import org.bouncycastle.jce.interfaces.ECPublicKey;
-import org.bouncycastle.jce.interfaces.GOST3410Key;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.jcajce.provider.asymmetric.util.GOST3410Util;
-
-public class SignatureSpi
- extends java.security.Signature
- implements PKCSObjectIdentifiers, X509ObjectIdentifiers
-{
- private Digest digest;
- private DSA signer;
- private SecureRandom appRandom;
-
- public SignatureSpi()
- {
- super("ECGOST3410");
- this.digest = new GOST3411Digest();
- this.signer = new ECGOST3410Signer();
- }
-
- protected void engineInitVerify(
- PublicKey publicKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
- if (publicKey instanceof ECPublicKey)
- {
- param = ECUtil.generatePublicKeyParameter(publicKey);
- }
- else if (publicKey instanceof GOST3410Key)
- {
- param = GOST3410Util.generatePublicKeyParameter(publicKey);
- }
- else
- {
- try
- {
- byte[] bytes = publicKey.getEncoded();
-
- publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
-
- if (publicKey instanceof ECPublicKey)
- {
- param = ECUtil.generatePublicKeyParameter(publicKey);
- }
- else
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
- catch (Exception e)
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
-
- digest.reset();
- signer.init(false, param);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
- if (privateKey instanceof ECKey)
- {
- param = ECUtil.generatePrivateKeyParameter(privateKey);
- }
- else
- {
- param = GOST3410Util.generatePrivateKeyParameter(privateKey);
- }
-
- digest.reset();
-
- if (appRandom != null)
- {
- signer.init(true, new ParametersWithRandom(param, appRandom));
- }
- else
- {
- signer.init(true, param);
- }
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- digest.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- digest.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- try
- {
- byte[] sigBytes = new byte[64];
- BigInteger[] sig = signer.generateSignature(hash);
- byte[] r = sig[0].toByteArray();
- byte[] s = sig[1].toByteArray();
-
- if (s[0] != 0)
- {
- System.arraycopy(s, 0, sigBytes, 32 - s.length, s.length);
- }
- else
- {
- System.arraycopy(s, 1, sigBytes, 32 - (s.length - 1), s.length - 1);
- }
-
- if (r[0] != 0)
- {
- System.arraycopy(r, 0, sigBytes, 64 - r.length, r.length);
- }
- else
- {
- System.arraycopy(r, 1, sigBytes, 64 - (r.length - 1), r.length - 1);
- }
-
- return sigBytes;
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- BigInteger[] sig;
-
- try
- {
- byte[] r = new byte[32];
- byte[] s = new byte[32];
-
- System.arraycopy(sigBytes, 0, s, 0, 32);
-
- System.arraycopy(sigBytes, 32, r, 0, 32);
-
- sig = new BigInteger[2];
- sig[0] = new BigInteger(1, r);
- sig[1] = new BigInteger(1, s);
- }
- catch (Exception e)
- {
- throw new SignatureException("error decoding signature bytes.");
- }
-
- return signer.verifySignature(hash, sig[0], sig[1]);
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/gost/SignatureSpi.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/gost/SignatureSpi.java
deleted file mode 100644
index 22aaa82f..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/gost/SignatureSpi.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.gost;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.SignatureException;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
-import org.bouncycastle.crypto.CipherParameters;
-import org.bouncycastle.crypto.DSA;
-import org.bouncycastle.crypto.Digest;
-import org.bouncycastle.crypto.digests.GOST3411Digest;
-import org.bouncycastle.crypto.params.ParametersWithRandom;
-import org.bouncycastle.crypto.signers.GOST3410Signer;
-import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil;
-import org.bouncycastle.jce.interfaces.ECKey;
-import org.bouncycastle.jce.interfaces.ECPublicKey;
-import org.bouncycastle.jce.interfaces.GOST3410Key;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.jcajce.provider.asymmetric.util.GOST3410Util;
-
-public class SignatureSpi
- extends java.security.Signature
- implements PKCSObjectIdentifiers, X509ObjectIdentifiers
-{
- private Digest digest;
- private DSA signer;
- private SecureRandom random;
-
- public SignatureSpi()
- {
- super("GOST3410");
- this.digest = new GOST3411Digest();
- this.signer = new GOST3410Signer();
- }
-
- protected void engineInitVerify(
- PublicKey publicKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
- if (publicKey instanceof ECPublicKey)
- {
- param = ECUtil.generatePublicKeyParameter(publicKey);
- }
- else if (publicKey instanceof GOST3410Key)
- {
- param = GOST3410Util.generatePublicKeyParameter(publicKey);
- }
- else
- {
- try
- {
- byte[] bytes = publicKey.getEncoded();
-
- publicKey = BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo.getInstance(bytes));
-
- if (publicKey instanceof ECPublicKey)
- {
- param = ECUtil.generatePublicKeyParameter(publicKey);
- }
- else
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
- catch (Exception e)
- {
- throw new InvalidKeyException("can't recognise key type in DSA based signer");
- }
- }
-
- digest.reset();
- signer.init(false, param);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey,
- SecureRandom random)
- throws InvalidKeyException
- {
- this.random = random;
- engineInitSign(privateKey);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- CipherParameters param;
-
- if (privateKey instanceof ECKey)
- {
- param = ECUtil.generatePrivateKeyParameter(privateKey);
- }
- else
- {
- param = GOST3410Util.generatePrivateKeyParameter(privateKey);
- }
-
- digest.reset();
-
- if (random != null)
- {
- signer.init(true, new ParametersWithRandom(param, random));
- }
- else
- {
- signer.init(true, param);
- }
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- digest.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- digest.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- try
- {
- byte[] sigBytes = new byte[64];
- BigInteger[] sig = signer.generateSignature(hash);
- byte[] r = sig[0].toByteArray();
- byte[] s = sig[1].toByteArray();
-
- if (s[0] != 0)
- {
- System.arraycopy(s, 0, sigBytes, 32 - s.length, s.length);
- }
- else
- {
- System.arraycopy(s, 1, sigBytes, 32 - (s.length - 1), s.length - 1);
- }
-
- if (r[0] != 0)
- {
- System.arraycopy(r, 0, sigBytes, 64 - r.length, r.length);
- }
- else
- {
- System.arraycopy(r, 1, sigBytes, 64 - (r.length - 1), r.length - 1);
- }
-
- return sigBytes;
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- BigInteger[] sig;
-
- try
- {
- byte[] r = new byte[32];
- byte[] s = new byte[32];
-
- System.arraycopy(sigBytes, 0, s, 0, 32);
-
- System.arraycopy(sigBytes, 32, r, 0, 32);
-
- sig = new BigInteger[2];
- sig[0] = new BigInteger(1, r);
- sig[1] = new BigInteger(1, s);
- }
- catch (Exception e)
- {
- throw new SignatureException("error decoding signature bytes.");
- }
-
- return signer.verifySignature(hash, sig[0], sig[1]);
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java
deleted file mode 100644
index d909f94a..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/DigestSignatureSpi.java
+++ /dev/null
@@ -1,368 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.rsa;
-
-import java.io.IOException;
-import java.security.AlgorithmParameters;
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.Signature;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.asn1.ASN1Encoding;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.DERNull;
-import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
-import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x509.DigestInfo;
-import org.bouncycastle.crypto.AsymmetricBlockCipher;
-import org.bouncycastle.crypto.CipherParameters;
-import org.bouncycastle.crypto.Digest;
-import org.bouncycastle.crypto.digests.MD2Digest;
-import org.bouncycastle.crypto.digests.MD4Digest;
-import org.bouncycastle.crypto.digests.MD5Digest;
-import org.bouncycastle.crypto.digests.NullDigest;
-import org.bouncycastle.crypto.digests.RIPEMD128Digest;
-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
-import org.bouncycastle.crypto.digests.RIPEMD256Digest;
-import org.bouncycastle.crypto.digests.SHA1Digest;
-import org.bouncycastle.crypto.digests.SHA224Digest;
-import org.bouncycastle.crypto.digests.SHA256Digest;
-import org.bouncycastle.crypto.digests.SHA384Digest;
-import org.bouncycastle.crypto.digests.SHA512Digest;
-import org.bouncycastle.crypto.encodings.PKCS1Encoding;
-import org.bouncycastle.crypto.engines.RSABlindedEngine;
-
-public class DigestSignatureSpi
- extends Signature
-{
- private Digest digest;
- private AsymmetricBlockCipher cipher;
- private AlgorithmIdentifier algId;
-
- // care - this constructor is actually used by outside organisations
- protected DigestSignatureSpi(
- Digest digest,
- AsymmetricBlockCipher cipher)
- {
- super(digest.getAlgorithmName() + "withRSA");
- this.digest = digest;
- this.cipher = cipher;
- this.algId = null;
- }
-
- // care - this constructor is actually used by outside organisations
- protected DigestSignatureSpi(
- ASN1ObjectIdentifier objId,
- Digest digest,
- AsymmetricBlockCipher cipher)
- {
- super(digest.getAlgorithmName() + "withRSA");
- this.digest = digest;
- this.cipher = cipher;
- this.algId = new AlgorithmIdentifier(objId, DERNull.INSTANCE);
- }
-
- protected void engineInitVerify(
- PublicKey publicKey)
- throws InvalidKeyException
- {
- if (!(publicKey instanceof RSAPublicKey))
- {
- throw new InvalidKeyException("Supplied key (" + getType(publicKey) + ") is not a RSAPublicKey instance");
- }
-
- CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey);
-
- digest.reset();
- cipher.init(false, param);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- if (!(privateKey instanceof RSAPrivateKey))
- {
- throw new InvalidKeyException("Supplied key (" + getType(privateKey) + ") is not a RSAPrivateKey instance");
- }
-
- CipherParameters param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey);
-
- digest.reset();
-
- cipher.init(true, param);
- }
-
- private String getType(
- Object o)
- {
- if (o == null)
- {
- return null;
- }
-
- return o.getClass().getName();
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- digest.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- digest.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- try
- {
- byte[] bytes = derEncode(hash);
-
- return cipher.processBlock(bytes, 0, bytes.length);
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- throw new SignatureException("key too small for signature type");
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- byte[] sig;
- byte[] expected;
-
- try
- {
- sig = cipher.processBlock(sigBytes, 0, sigBytes.length);
-
- expected = derEncode(hash);
- }
- catch (Exception e)
- {
- return false;
- }
-
- if (sig.length == expected.length)
- {
- for (int i = 0; i < sig.length; i++)
- {
- if (sig[i] != expected[i])
- {
- return false;
- }
- }
- }
- else if (sig.length == expected.length - 2) // NULL left out
- {
- int sigOffset = sig.length - hash.length - 2;
- int expectedOffset = expected.length - hash.length - 2;
-
- expected[1] -= 2; // adjust lengths
- expected[3] -= 2;
-
- for (int i = 0; i < hash.length; i++)
- {
- if (sig[sigOffset + i] != expected[expectedOffset + i]) // check hash
- {
- return false;
- }
- }
-
- for (int i = 0; i < sigOffset; i++)
- {
- if (sig[i] != expected[i]) // check header less NULL
- {
- return false;
- }
- }
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- return null;
- }
-
- protected AlgorithmParameters engineGetParameters()
- {
- return null;
- }
-
- private byte[] derEncode(
- byte[] hash)
- throws IOException
- {
- if (algId == null)
- {
- // For raw RSA, the DigestInfo must be prepared externally
- return hash;
- }
-
- DigestInfo dInfo = new DigestInfo(algId, hash);
-
- return dInfo.getEncoded(ASN1Encoding.DER);
- }
-
- static public class SHA1
- extends DigestSignatureSpi
- {
- public SHA1()
- {
- super(OIWObjectIdentifiers.idSHA1, new SHA1Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class SHA224
- extends DigestSignatureSpi
- {
- public SHA224()
- {
- super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class SHA256
- extends DigestSignatureSpi
- {
- public SHA256()
- {
- super(NISTObjectIdentifiers.id_sha256, new SHA256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class SHA384
- extends DigestSignatureSpi
- {
- public SHA384()
- {
- super(NISTObjectIdentifiers.id_sha384, new SHA384Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class SHA512
- extends DigestSignatureSpi
- {
- public SHA512()
- {
- super(NISTObjectIdentifiers.id_sha512, new SHA512Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class MD2
- extends DigestSignatureSpi
- {
- public MD2()
- {
- super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class MD4
- extends DigestSignatureSpi
- {
- public MD4()
- {
- super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class MD5
- extends DigestSignatureSpi
- {
- public MD5()
- {
- super(PKCSObjectIdentifiers.md5, new MD5Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class RIPEMD160
- extends DigestSignatureSpi
- {
- public RIPEMD160()
- {
- super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class RIPEMD128
- extends DigestSignatureSpi
- {
- public RIPEMD128()
- {
- super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class RIPEMD256
- extends DigestSignatureSpi
- {
- public RIPEMD256()
- {
- super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-
- static public class noneRSA
- extends DigestSignatureSpi
- {
- public noneRSA()
- {
- super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine()));
- }
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/ISOSignatureSpi.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/ISOSignatureSpi.java
deleted file mode 100644
index eb5d8aac..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/rsa/ISOSignatureSpi.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.rsa;
-
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.Signature;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.crypto.AsymmetricBlockCipher;
-import org.bouncycastle.crypto.CipherParameters;
-import org.bouncycastle.crypto.Digest;
-import org.bouncycastle.crypto.digests.MD5Digest;
-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
-import org.bouncycastle.crypto.digests.SHA1Digest;
-import org.bouncycastle.crypto.engines.RSABlindedEngine;
-import org.bouncycastle.crypto.signers.ISO9796d2Signer;
-
-public class ISOSignatureSpi
- extends Signature
-{
- private ISO9796d2Signer signer;
-
- protected ISOSignatureSpi(
- Digest digest,
- AsymmetricBlockCipher cipher)
- {
- super(digest.getAlgorithmName() + "withRSA/ISO9796-2");
- signer = new ISO9796d2Signer(cipher, digest, true);
- }
-
- protected void engineInitVerify(
- PublicKey publicKey)
- throws InvalidKeyException
- {
- CipherParameters param = RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey);
-
- signer.init(false, param);
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- CipherParameters param = RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey);
-
- signer.init(true, param);
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- signer.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- signer.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- try
- {
- byte[] sig = signer.generateSignature();
-
- return sig;
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- boolean yes = signer.verifySignature(sigBytes);
-
- return yes;
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- static public class SHA1WithRSAEncryption
- extends ISOSignatureSpi
- {
- public SHA1WithRSAEncryption()
- {
- super(new SHA1Digest(), new RSABlindedEngine());
- }
- }
-
- static public class MD5WithRSAEncryption
- extends ISOSignatureSpi
- {
- public MD5WithRSAEncryption()
- {
- super(new MD5Digest(), new RSABlindedEngine());
- }
- }
-
- static public class RIPEMD160WithRSAEncryption
- extends ISOSignatureSpi
- {
- public RIPEMD160WithRSAEncryption()
- {
- super(new RIPEMD160Digest(), new RSABlindedEngine());
- }
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/util/DSABase.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/util/DSABase.java
deleted file mode 100644
index 479fafcc..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/util/DSABase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.util;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.PrivateKey;
-import java.security.SecureRandom;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.spec.AlgorithmParameterSpec;
-
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
-import org.bouncycastle.crypto.DSA;
-import org.bouncycastle.crypto.Digest;
-
-public abstract class DSABase
- extends Signature
- implements PKCSObjectIdentifiers, X509ObjectIdentifiers
-{
- protected Digest digest;
- protected DSA signer;
- protected DSAEncoder encoder;
- private SecureRandom appRandom;
-
- protected DSABase(
- String name,
- Digest digest,
- DSA signer,
- DSAEncoder encoder)
- {
- super(name);
-
- this.digest = digest;
- this.signer = signer;
- this.encoder = encoder;
- }
-
- protected void engineInitSign(
- PrivateKey privateKey)
- throws InvalidKeyException
- {
- doEngineInitSign(privateKey, appRandom);
- }
-
- protected void engineUpdate(
- byte b)
- throws SignatureException
- {
- digest.update(b);
- }
-
- protected void engineUpdate(
- byte[] b,
- int off,
- int len)
- throws SignatureException
- {
- digest.update(b, off, len);
- }
-
- protected byte[] engineSign()
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- try
- {
- BigInteger[] sig = signer.generateSignature(hash);
-
- return encoder.encode(sig[0], sig[1]);
- }
- catch (Exception e)
- {
- throw new SignatureException(e.toString());
- }
- }
-
- protected boolean engineVerify(
- byte[] sigBytes)
- throws SignatureException
- {
- byte[] hash = new byte[digest.getDigestSize()];
-
- digest.doFinal(hash, 0);
-
- BigInteger[] sig;
-
- try
- {
- sig = encoder.decode(sigBytes);
- }
- catch (Exception e)
- {
- throw new SignatureException("error decoding signature bytes.");
- }
-
- return signer.verifySignature(hash, sig[0], sig[1]);
- }
-
- protected void engineSetParameter(
- AlgorithmParameterSpec params)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated replaced with <a href = "#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
- */
- protected void engineSetParameter(
- String param,
- Object value)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- /**
- * @deprecated
- */
- protected Object engineGetParameter(
- String param)
- {
- throw new UnsupportedOperationException("engineSetParameter unsupported");
- }
-
- protected abstract void doEngineInitSign(PrivateKey privateKey, SecureRandom random)
- throws InvalidKeyException;
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/CertificateFactory.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/CertificateFactory.java
deleted file mode 100644
index 2ed6ca69..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/CertificateFactory.java
+++ /dev/null
@@ -1,397 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.x509;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertPath;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactorySpi;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.ASN1Set;
-import org.bouncycastle.asn1.ASN1TaggedObject;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.pkcs.SignedData;
-import org.bouncycastle.asn1.x509.Certificate;
-import org.bouncycastle.asn1.x509.CertificateList;
-import org.bouncycastle.jce.provider.X509CRLObject;
-import org.bouncycastle.jce.provider.X509CertificateObject;
-
-/**
- * class for dealing with X509 certificates.
- * <p>
- * At the moment this will deal with "-----BEGIN CERTIFICATE-----" to "-----END CERTIFICATE-----"
- * base 64 encoded certs, as well as the BER binaries of certificates and some classes of PKCS#7
- * objects.
- */
-public class CertificateFactory
- extends CertificateFactorySpi
-{
- private static final PEMUtil PEM_CERT_PARSER = new PEMUtil("CERTIFICATE");
- private static final PEMUtil PEM_CRL_PARSER = new PEMUtil("CRL");
-
- private ASN1Set sData = null;
- private int sDataObjectCount = 0;
- private InputStream currentStream = null;
-
- private ASN1Set sCrlData = null;
- private int sCrlDataObjectCount = 0;
- private InputStream currentCrlStream = null;
-
- private java.security.cert.Certificate readDERCertificate(
- ASN1InputStream dIn)
- throws IOException, CertificateParsingException
- {
- ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
-
- if (seq.size() > 1
- && seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
- {
- if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
- {
- sData = SignedData.getInstance(ASN1Sequence.getInstance(
- (ASN1TaggedObject)seq.getObjectAt(1), true)).getCertificates();
-
- return getCertificate();
- }
- }
-
- return new X509CertificateObject(
- Certificate.getInstance(seq));
- }
-
- private java.security.cert.Certificate getCertificate()
- throws CertificateParsingException
- {
- if (sData != null)
- {
- while (sDataObjectCount < sData.size())
- {
- Object obj = sData.getObjectAt(sDataObjectCount++);
-
- if (obj instanceof ASN1Sequence)
- {
- return new X509CertificateObject(
- Certificate.getInstance(obj));
- }
- }
- }
-
- return null;
- }
-
- private java.security.cert.Certificate readPEMCertificate(
- InputStream in)
- throws IOException, CertificateParsingException
- {
- ASN1Sequence seq = PEM_CERT_PARSER.readPEMObject(in);
-
- if (seq != null)
- {
- return new X509CertificateObject(
- Certificate.getInstance(seq));
- }
-
- return null;
- }
-
- protected CRL createCRL(CertificateList c)
- throws CRLException
- {
- return new X509CRLObject(c);
- }
-
- private CRL readPEMCRL(
- InputStream in)
- throws IOException, CRLException
- {
- ASN1Sequence seq = PEM_CRL_PARSER.readPEMObject(in);
-
- if (seq != null)
- {
- return createCRL(
- CertificateList.getInstance(seq));
- }
-
- return null;
- }
-
- private CRL readDERCRL(
- ASN1InputStream aIn)
- throws IOException, CRLException
- {
- ASN1Sequence seq = (ASN1Sequence)aIn.readObject();
-
- if (seq.size() > 1
- && seq.getObjectAt(0) instanceof ASN1ObjectIdentifier)
- {
- if (seq.getObjectAt(0).equals(PKCSObjectIdentifiers.signedData))
- {
- sCrlData = SignedData.getInstance(ASN1Sequence.getInstance(
- (ASN1TaggedObject)seq.getObjectAt(1), true)).getCRLs();
-
- return getCRL();
- }
- }
-
- return createCRL(
- CertificateList.getInstance(seq));
- }
-
- private CRL getCRL()
- throws CRLException
- {
- if (sCrlData == null || sCrlDataObjectCount >= sCrlData.size())
- {
- return null;
- }
-
- return createCRL(
- CertificateList.getInstance(
- sCrlData.getObjectAt(sCrlDataObjectCount++)));
- }
-
- /**
- * Generates a certificate object and initializes it with the data
- * read from the input stream inStream.
- */
- public java.security.cert.Certificate engineGenerateCertificate(
- InputStream in)
- throws CertificateException
- {
- if (currentStream == null)
- {
- currentStream = in;
- sData = null;
- sDataObjectCount = 0;
- }
- else if (currentStream != in) // reset if input stream has changed
- {
- currentStream = in;
- sData = null;
- sDataObjectCount = 0;
- }
-
- try
- {
- if (sData != null)
- {
- if (sDataObjectCount != sData.size())
- {
- return getCertificate();
- }
- else
- {
- sData = null;
- sDataObjectCount = 0;
- return null;
- }
- }
-
- PushbackInputStream pis = new PushbackInputStream(in);
- int tag = pis.read();
-
- if (tag == -1)
- {
- return null;
- }
-
- pis.unread(tag);
-
- if (tag != 0x30) // assume ascii PEM encoded.
- {
- return readPEMCertificate(pis);
- }
- else
- {
- return readDERCertificate(new ASN1InputStream(pis));
- }
- }
- catch (Exception e)
- {
- throw new ExCertificateException(e);
- }
- }
-
- /**
- * Returns a (possibly empty) collection view of the certificates
- * read from the given input stream inStream.
- */
- public Collection engineGenerateCertificates(
- InputStream inStream)
- throws CertificateException
- {
- java.security.cert.Certificate cert;
- List certs = new ArrayList();
-
- while ((cert = engineGenerateCertificate(inStream)) != null)
- {
- certs.add(cert);
- }
-
- return certs;
- }
-
- /**
- * Generates a certificate revocation list (CRL) object and initializes
- * it with the data read from the input stream inStream.
- */
- public CRL engineGenerateCRL(
- InputStream inStream)
- throws CRLException
- {
- if (currentCrlStream == null)
- {
- currentCrlStream = inStream;
- sCrlData = null;
- sCrlDataObjectCount = 0;
- }
- else if (currentCrlStream != inStream) // reset if input stream has changed
- {
- currentCrlStream = inStream;
- sCrlData = null;
- sCrlDataObjectCount = 0;
- }
-
- try
- {
- if (sCrlData != null)
- {
- if (sCrlDataObjectCount != sCrlData.size())
- {
- return getCRL();
- }
- else
- {
- sCrlData = null;
- sCrlDataObjectCount = 0;
- return null;
- }
- }
-
- PushbackInputStream pis = new PushbackInputStream(inStream);
- int tag = pis.read();
-
- if (tag == -1)
- {
- return null;
- }
-
- pis.unread(tag);
-
- if (tag != 0x30) // assume ascii PEM encoded.
- {
- return readPEMCRL(pis);
- }
- else
- { // lazy evaluate to help processing of large CRLs
- return readDERCRL(new ASN1InputStream(pis, true));
- }
- }
- catch (CRLException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new CRLException(e.toString());
- }
- }
-
- /**
- * Returns a (possibly empty) collection view of the CRLs read from
- * the given input stream inStream.
- *
- * The inStream may contain a sequence of DER-encoded CRLs, or
- * a PKCS#7 CRL set. This is a PKCS#7 SignedData object, with the
- * only signficant field being crls. In particular the signature
- * and the contents are ignored.
- */
- public Collection engineGenerateCRLs(
- InputStream inStream)
- throws CRLException
- {
- CRL crl;
- List crls = new ArrayList();
-
- while ((crl = engineGenerateCRL(inStream)) != null)
- {
- crls.add(crl);
- }
-
- return crls;
- }
-
- public Iterator engineGetCertPathEncodings()
- {
- return null; // TODO: PKIXCertPath.certPathEncodings.iterator();
- }
-
- public CertPath engineGenerateCertPath(
- InputStream inStream)
- throws CertificateException
- {
- return engineGenerateCertPath(inStream, "PkiPath");
- }
-
- public CertPath engineGenerateCertPath(
- InputStream inStream,
- String encoding)
- throws CertificateException
- {
- return new PKIXCertPath(inStream, encoding);
- }
-
- public CertPath engineGenerateCertPath(
- List certificates)
- throws CertificateException
- {
- Iterator iter = certificates.iterator();
- Object obj;
- while (iter.hasNext())
- {
- obj = iter.next();
- if (obj != null)
- {
- if (!(obj instanceof X509Certificate))
- {
- throw new CertificateException("list contains non X509Certificate object while creating CertPath\n" + obj.toString());
- }
- }
- }
- return new PKIXCertPath(certificates);
- }
-
- private class ExCertificateException
- extends CertificateException
- {
- private Throwable cause;
-
- public ExCertificateException(Throwable cause)
- {
- this.cause = cause;
- }
-
- public ExCertificateException(String msg, Throwable cause)
- {
- super(msg);
-
- this.cause = cause;
- }
-
- public Throwable getCause()
- {
- return cause;
- }
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
deleted file mode 100644
index 1b97e5fd..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
+++ /dev/null
@@ -1,379 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.x509;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.security.NoSuchProviderException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.bouncycastle.jce.X509Principal;
-import org.bouncycastle.jce.PrincipalUtil;
-import org.bouncycastle.asn1.ASN1Encodable;
-import org.bouncycastle.asn1.ASN1EncodableVector;
-import org.bouncycastle.asn1.ASN1Encoding;
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.ASN1Integer;
-import org.bouncycastle.asn1.ASN1Primitive;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DERSequence;
-import org.bouncycastle.asn1.DERSet;
-import org.bouncycastle.asn1.pkcs.ContentInfo;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.pkcs.SignedData;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.util.io.pem.PemObject;
-import org.bouncycastle.util.io.pem.PemWriter;
-
-/**
- * CertPath implementation for X.509 certificates.
- * <br />
- **/
-public class PKIXCertPath
- extends CertPath
-{
- static final List certPathEncodings;
-
- static
- {
- List encodings = new ArrayList();
- encodings.add("PkiPath");
- encodings.add("PEM");
- encodings.add("PKCS7");
- certPathEncodings = Collections.unmodifiableList(encodings);
- }
-
- private List certificates;
-
- /**
- * @param certs
- */
- private List sortCerts(
- List certs)
- {
- try
- {
- if (certs.size() < 2)
- {
- return certs;
- }
-
- X509Principal issuer = PrincipalUtil.getIssuerX509Principal(((X509Certificate)certs.get(0)));
- boolean okay = true;
-
- for (int i = 1; i != certs.size(); i++)
- {
- X509Certificate cert = (X509Certificate)certs.get(i);
-
- if (issuer.equals(PrincipalUtil.getSubjectX509Principal(cert)))
- {
- issuer = PrincipalUtil.getIssuerX509Principal(((X509Certificate)certs.get(i)));
- }
- else
- {
- okay = false;
- break;
- }
- }
-
- if (okay)
- {
- return certs;
- }
-
- // find end-entity cert
- List retList = new ArrayList(certs.size());
- List orig = new ArrayList(certs);
-
- for (int i = 0; i < certs.size(); i++)
- {
- X509Certificate cert = (X509Certificate)certs.get(i);
- boolean found = false;
-
- X509Principal subject = PrincipalUtil.getSubjectX509Principal(cert);
-
- for (int j = 0; j != certs.size(); j++)
- {
- X509Certificate c = (X509Certificate)certs.get(j);
- if (PrincipalUtil.getIssuerX509Principal(c).equals(subject))
- {
- found = true;
- break;
- }
- }
-
- if (!found)
- {
- retList.add(cert);
- certs.remove(i);
- }
- }
-
- // can only have one end entity cert - something's wrong, give up.
- if (retList.size() > 1)
- {
- return orig;
- }
-
- for (int i = 0; i != retList.size(); i++)
- {
- issuer = PrincipalUtil.getIssuerX509Principal(((X509Certificate)retList.get(i)));
-
- for (int j = 0; j < certs.size(); j++)
- {
- X509Certificate c = (X509Certificate)certs.get(j);
- if (issuer.equals(PrincipalUtil.getSubjectX509Principal(c)))
- {
- retList.add(c);
- certs.remove(j);
- break;
- }
- }
- }
-
- // make sure all certificates are accounted for.
- if (certs.size() > 0)
- {
- return orig;
- }
-
- return retList;
- }
- catch (Exception e)
- {
- return certs;
- }
- }
-
- PKIXCertPath(List certificates)
- {
- super("X.509");
- this.certificates = sortCerts(new ArrayList(certificates));
- }
-
- /**
- * Creates a CertPath of the specified type.
- * This constructor is protected because most users should use
- * a CertificateFactory to create CertPaths.
- **/
- PKIXCertPath(
- InputStream inStream,
- String encoding)
- throws CertificateException
- {
- super("X.509");
- try
- {
- if (encoding.equalsIgnoreCase("PkiPath"))
- {
- ASN1InputStream derInStream = new ASN1InputStream(inStream);
- ASN1Primitive derObject = derInStream.readObject();
- if (!(derObject instanceof ASN1Sequence))
- {
- throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath");
- }
- Enumeration e = ((ASN1Sequence)derObject).getObjects();
- certificates = new ArrayList();
- CertificateFactory certFactory = CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME);
- while (e.hasMoreElements())
- {
- ASN1Encodable element = (ASN1Encodable)e.nextElement();
- byte[] encoded = element.toASN1Primitive().getEncoded(ASN1Encoding.DER);
- certificates.add(0, certFactory.generateCertificate(
- new ByteArrayInputStream(encoded)));
- }
- }
- else if (encoding.equalsIgnoreCase("PKCS7") || encoding.equalsIgnoreCase("PEM"))
- {
- inStream = new BufferedInputStream(inStream);
- certificates = new ArrayList();
- CertificateFactory certFactory= CertificateFactory.getInstance("X.509", BouncyCastleProvider.PROVIDER_NAME);
- Certificate cert;
- while ((cert = certFactory.generateCertificate(inStream)) != null)
- {
- certificates.add(cert);
- }
- }
- else
- {
- throw new CertificateException("unsupported encoding: " + encoding);
- }
- }
- catch (IOException ex)
- {
- throw new CertificateException("IOException throw while decoding CertPath:\n" + ex.toString());
- }
- catch (NoSuchProviderException ex)
- {
- throw new CertificateException("BouncyCastle provider not found while trying to get a CertificateFactory:\n" + ex.toString());
- }
-
- this.certificates = sortCerts(certificates);
- }
-
- /**
- * Returns an iteration of the encodings supported by this
- * certification path, with the default encoding
- * first. Attempts to modify the returned Iterator via its
- * remove method result in an UnsupportedOperationException.
- *
- * @return an Iterator over the names of the supported encodings (as Strings)
- **/
- public Iterator getEncodings()
- {
- return certPathEncodings.iterator();
- }
-
- /**
- * Returns the encoded form of this certification path, using
- * the default encoding.
- *
- * @return the encoded bytes
- * @exception java.security.cert.CertificateEncodingException if an encoding error occurs
- **/
- public byte[] getEncoded()
- throws CertificateEncodingException
- {
- Iterator iter = getEncodings();
- if (iter.hasNext())
- {
- Object enc = iter.next();
- if (enc instanceof String)
- {
- return getEncoded((String)enc);
- }
- }
- return null;
- }
-
- /**
- * Returns the encoded form of this certification path, using
- * the specified encoding.
- *
- * @param encoding the name of the encoding to use
- * @return the encoded bytes
- * @exception java.security.cert.CertificateEncodingException if an encoding error
- * occurs or the encoding requested is not supported
- *
- **/
- public byte[] getEncoded(String encoding)
- throws CertificateEncodingException
- {
- if (encoding.equalsIgnoreCase("PkiPath"))
- {
- ASN1EncodableVector v = new ASN1EncodableVector();
-
- ListIterator iter = certificates.listIterator(certificates.size());
- while (iter.hasPrevious())
- {
- v.add(toASN1Object((X509Certificate)iter.previous()));
- }
-
- return toDEREncoded(new DERSequence(v));
- }
- else if (encoding.equalsIgnoreCase("PKCS7"))
- {
- ContentInfo encInfo = new ContentInfo(PKCSObjectIdentifiers.data, null);
-
- ASN1EncodableVector v = new ASN1EncodableVector();
- for (int i = 0; i != certificates.size(); i++)
- {
- v.add(toASN1Object((X509Certificate)certificates.get(i)));
- }
-
- SignedData sd = new SignedData(
- new ASN1Integer(1),
- new DERSet(),
- encInfo,
- new DERSet(v),
- null,
- new DERSet());
-
- return toDEREncoded(new ContentInfo(
- PKCSObjectIdentifiers.signedData, sd));
- }
- else if (encoding.equalsIgnoreCase("PEM"))
- {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- PemWriter pWrt = new PemWriter(new OutputStreamWriter(bOut));
-
- try
- {
- for (int i = 0; i != certificates.size(); i++)
- {
- pWrt.writeObject(new PemObject("CERTIFICATE", ((X509Certificate)certificates.get(i)).getEncoded()));
- }
-
- pWrt.close();
- }
- catch (Exception e)
- {
- throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
- }
-
- return bOut.toByteArray();
- }
- else
- {
- throw new CertificateEncodingException("unsupported encoding: " + encoding);
- }
- }
-
- /**
- * Returns the list of certificates in this certification
- * path. The List returned must be immutable and thread-safe.
- *
- * @return an immutable List of Certificates (may be empty, but not null)
- **/
- public List getCertificates()
- {
- return Collections.unmodifiableList(new ArrayList(certificates));
- }
-
- /**
- * Return a DERObject containing the encoded certificate.
- *
- * @param cert the X509Certificate object to be encoded
- *
- * @return the DERObject
- **/
- private ASN1Primitive toASN1Object(
- X509Certificate cert)
- throws CertificateEncodingException
- {
- try
- {
- return new ASN1InputStream(cert.getEncoded()).readObject();
- }
- catch (Exception e)
- {
- throw new CertificateEncodingException("Exception while encoding certificate: " + e.toString());
- }
- }
-
- private byte[] toDEREncoded(ASN1Encodable obj)
- throws CertificateEncodingException
- {
- try
- {
- return obj.toASN1Primitive().getEncoded(ASN1Encoding.DER);
- }
- catch (IOException e)
- {
- throw new CertificateEncodingException("Exception thrown: " + e);
- }
- }
-}
diff --git a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/SignatureUtil.java b/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/SignatureUtil.java
deleted file mode 100644
index af18e625..00000000
--- a/prov/src/main/jdk1.1/org/bouncycastle/jcajce/provider/asymmetric/x509/SignatureUtil.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.bouncycastle.jcajce.provider.asymmetric.x509;
-
-import java.io.IOException;
-import java.security.AlgorithmParameters;
-import java.security.GeneralSecurityException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Signature;
-import java.security.SignatureException;
-
-import org.bouncycastle.asn1.ASN1Encodable;
-import org.bouncycastle.asn1.ASN1Encoding;
-import org.bouncycastle.asn1.ASN1Null;
-import org.bouncycastle.asn1.ASN1ObjectIdentifier;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.DERNull;
-import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
-import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
-import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
-import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
-import org.bouncycastle.asn1.pkcs.RSASSAPSSparams;
-import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
-
-class SignatureUtil
-{
- private static final ASN1Null derNull = new DERNull();
-
- static String getSignatureName(
- AlgorithmIdentifier sigAlgId)
- {
- ASN1Encodable params = sigAlgId.getParameters();
-
- if (params != null && !derNull.equals(params))
- {
- if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
- {
- RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
-
- return getDigestAlgName(rsaParams.getHashAlgorithm().getAlgorithm()) + "withRSAandMGF1";
- }
- if (sigAlgId.getAlgorithm().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
- {
- ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
-
- return getDigestAlgName((ASN1ObjectIdentifier)ecDsaParams.getObjectAt(0)) + "withECDSA";
- }
- }
-
- return sigAlgId.getAlgorithm().getId();
- }
-
- /**
- * Return the digest algorithm using one of the standard JCA string
- * representations rather the the algorithm identifier (if possible).
- */
- private static String getDigestAlgName(
- ASN1ObjectIdentifier digestAlgOID)
- {
- if (PKCSObjectIdentifiers.md5.equals(digestAlgOID))
- {
- return "MD5";
- }
- else if (OIWObjectIdentifiers.idSHA1.equals(digestAlgOID))
- {
- return "SHA1";
- }
- else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
- {
- return "SHA224";
- }
- else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOID))
- {
- return "SHA256";
- }
- else if (NISTObjectIdentifiers.id_sha384.equals(digestAlgOID))
- {
- return "SHA384";
- }
- else if (NISTObjectIdentifiers.id_sha512.equals(digestAlgOID))
- {
- return "SHA512";
- }
- else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
- {
- return "RIPEMD128";
- }
- else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
- {
- return "RIPEMD160";
- }
- else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
- {
- return "RIPEMD256";
- }
- else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
- {
- return "GOST3411";
- }
- else
- {
- return digestAlgOID.getId();
- }
- }
-}