bcpkix-jdk15on-147

throw new InvalidKeyException("error encoding public key");
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.mozilla.SignedPublicKeyAndChallenge
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;

public class EncryptionException
  extends IOException
{
  private Throwable cause;
  
  public EncryptionException(String paramString)
  {
    super(paramString);
  }
  
  public EncryptionException(String paramString, Throwable paramThrowable)
  {
    super(paramString);
    cause = paramThrowable;
  }
  
  public Throwable getCause()
  {
    return cause;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.EncryptionException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyPair;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Security;
import java.security.cert.CRLException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509CRL;
import java.security.cert.X509Certificate;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.DSAParameter;
import org.bouncycastle.jce.PKCS10CertificationRequest;
import org.bouncycastle.util.Strings;
import org.bouncycastle.util.io.pem.PemGenerationException;
import org.bouncycastle.util.io.pem.PemHeader;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectGenerator;
import org.bouncycastle.x509.X509AttributeCertificate;
import org.bouncycastle.x509.X509V2AttributeCertificate;

public class MiscPEMGenerator
  implements PemObjectGenerator
{
  private static final byte[] hexEncodingTable = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70 };
  private Object obj;
  private String algorithm;
  private char[] password;
  private SecureRandom random;
  private Provider provider;
  
  public MiscPEMGenerator(Object paramObject)
  {
    obj = paramObject;
  }
  
  public MiscPEMGenerator(Object paramObject, String paramString, char[] paramArrayOfChar, SecureRandom paramSecureRandom, Provider paramProvider)
  {
    obj = paramObject;
    algorithm = paramString;
    password = paramArrayOfChar;
    random = paramSecureRandom;
    provider = paramProvider;
  }
  
  public MiscPEMGenerator(Object paramObject, String paramString1, char[] paramArrayOfChar, SecureRandom paramSecureRandom, String paramString2)
    throws NoSuchProviderException
  {
    obj = paramObject;
    algorithm = paramString1;
    password = paramArrayOfChar;
    random = paramSecureRandom;
    if (paramString2 != null)
    {
      provider = Security.getProvider(paramString2);
      if (provider == null) {
        throw new NoSuchProviderException("cannot find provider: " + paramString2);
      }
    }
  }
  
  private PemObject createPemObject(Object paramObject)
    throws IOException
  {
    if ((paramObject instanceof PemObject)) {
      return (PemObject)paramObject;
    }
    if ((paramObject instanceof PemObjectGenerator)) {
      return ((PemObjectGenerator)paramObject).generate();
    }
    String str;
    byte[] arrayOfByte;
    if ((paramObject instanceof X509Certificate))
    {
      str = "CERTIFICATE";
      try
      {
        arrayOfByte = ((X509Certificate)paramObject).getEncoded();
      }
      catch (CertificateEncodingException localCertificateEncodingException)
      {
        throw new PemGenerationException("Cannot encode object: " + localCertificateEncodingException.toString());
      }
    }
    else if ((paramObject instanceof X509CRL))
    {
      str = "X509 CRL";
      try
      {
        arrayOfByte = ((X509CRL)paramObject).getEncoded();
      }
      catch (CRLException localCRLException)
      {
        throw new PemGenerationException("Cannot encode object: " + localCRLException.toString());
      }
    }
    else
    {
      if ((paramObject instanceof KeyPair)) {
        return createPemObject(((KeyPair)paramObject).getPrivate());
      }
      if ((paramObject instanceof PrivateKey))
      {
        PrivateKeyInfo localPrivateKeyInfo = new PrivateKeyInfo((ASN1Sequence)ASN1Primitive.fromByteArray(((Key)paramObject).getEncoded()));
        if ((paramObject instanceof java.security.interfaces.RSAPrivateKey))
        {
          str = "RSA PRIVATE KEY";
          arrayOfByte = localPrivateKeyInfo.parsePrivateKey().toASN1Primitive().getEncoded();
        }
        else if ((paramObject instanceof DSAPrivateKey))
        {
          str = "DSA PRIVATE KEY";
          DSAParameter localDSAParameter = DSAParameter.getInstance(localPrivateKeyInfo.getPrivateKeyAlgorithm().getParameters());
          ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
          localASN1EncodableVector.add(new DERInteger(0));
          localASN1EncodableVector.add(new DERInteger(localDSAParameter.getP()));
          localASN1EncodableVector.add(new DERInteger(localDSAParameter.getQ()));
          localASN1EncodableVector.add(new DERInteger(localDSAParameter.getG()));
          BigInteger localBigInteger1 = ((DSAPrivateKey)paramObject).getX();
          BigInteger localBigInteger2 = localDSAParameter.getG().modPow(localBigInteger1, localDSAParameter.getP());
          localASN1EncodableVector.add(new DERInteger(localBigInteger2));
          localASN1EncodableVector.add(new DERInteger(localBigInteger1));
          arrayOfByte = new DERSequence(localASN1EncodableVector).getEncoded();
        }
        else if (((PrivateKey)paramObject).getAlgorithm().equals("ECDSA"))
        {
          str = "EC PRIVATE KEY";
          arrayOfByte = localPrivateKeyInfo.parsePrivateKey().toASN1Primitive().getEncoded();
        }
        else
        {
          throw new IOException("Cannot identify private key");
        }
      }
      else if ((paramObject instanceof PublicKey))
      {
        str = "PUBLIC KEY";
        arrayOfByte = ((PublicKey)paramObject).getEncoded();
      }
      else if ((paramObject instanceof X509AttributeCertificate))
      {
        str = "ATTRIBUTE CERTIFICATE";
        arrayOfByte = ((X509V2AttributeCertificate)paramObject).getEncoded();
      }
      else if ((paramObject instanceof PKCS10CertificationRequest))
      {
        str = "CERTIFICATE REQUEST";
        arrayOfByte = ((PKCS10CertificationRequest)paramObject).getEncoded();
      }
      else if ((paramObject instanceof ContentInfo))
      {
        str = "PKCS7";
        arrayOfByte = ((ContentInfo)paramObject).getEncoded();
      }
      else
      {
        throw new PemGenerationException("unknown object passed - can't encode.");
      }
    }
    return new PemObject(str, arrayOfByte);
  }
  
  private String getHexEncoded(byte[] paramArrayOfByte)
    throws IOException
  {
    char[] arrayOfChar = new char[paramArrayOfByte.length * 2];
    for (int i = 0; i != paramArrayOfByte.length; i++)
    {
      int j = paramArrayOfByte[i] & 0xFF;
      arrayOfChar[(2 * i)] = ((char)hexEncodingTable[(j >>> 4)]);
      arrayOfChar[(2 * i + 1)] = ((char)hexEncodingTable[(j & 0xF)]);
    }
    return new String(arrayOfChar);
  }
  
  private PemObject createPemObject(Object paramObject, String paramString, char[] paramArrayOfChar, SecureRandom paramSecureRandom)
    throws IOException
  {
    if ((paramObject instanceof KeyPair)) {
      return createPemObject(((KeyPair)paramObject).getPrivate(), paramString, paramArrayOfChar, paramSecureRandom);
    }
    String str = null;
    byte[] arrayOfByte = null;
    Object localObject2;
    if ((paramObject instanceof RSAPrivateCrtKey))
    {
      str = "RSA PRIVATE KEY";
      localObject1 = (RSAPrivateCrtKey)paramObject;
      localObject2 = new org.bouncycastle.asn1.pkcs.RSAPrivateKey(((RSAPrivateCrtKey)localObject1).getModulus(), ((RSAPrivateCrtKey)localObject1).getPublicExponent(), ((RSAPrivateCrtKey)localObject1).getPrivateExponent(), ((RSAPrivateCrtKey)localObject1).getPrimeP(), ((RSAPrivateCrtKey)localObject1).getPrimeQ(), ((RSAPrivateCrtKey)localObject1).getPrimeExponentP(), ((RSAPrivateCrtKey)localObject1).getPrimeExponentQ(), ((RSAPrivateCrtKey)localObject1).getCrtCoefficient());
      arrayOfByte = ((org.bouncycastle.asn1.pkcs.RSAPrivateKey)localObject2).getEncoded();
    }
    else if ((paramObject instanceof DSAPrivateKey))
    {
      str = "DSA PRIVATE KEY";
      localObject1 = (DSAPrivateKey)paramObject;
      localObject2 = ((DSAPrivateKey)localObject1).getParams();
      localObject3 = new ASN1EncodableVector();
      ((ASN1EncodableVector)localObject3).add(new DERInteger(0));
      ((ASN1EncodableVector)localObject3).add(new DERInteger(((DSAParams)localObject2).getP()));
      ((ASN1EncodableVector)localObject3).add(new DERInteger(((DSAParams)localObject2).getQ()));
      ((ASN1EncodableVector)localObject3).add(new DERInteger(((DSAParams)localObject2).getG()));
      localObject4 = ((DSAPrivateKey)localObject1).getX();
      localObject5 = ((DSAParams)localObject2).getG().modPow((BigInteger)localObject4, ((DSAParams)localObject2).getP());
      ((ASN1EncodableVector)localObject3).add(new DERInteger((BigInteger)localObject5));
      ((ASN1EncodableVector)localObject3).add(new DERInteger((BigInteger)localObject4));
      arrayOfByte = new DERSequence((ASN1EncodableVector)localObject3).getEncoded();
    }
    else if (((paramObject instanceof PrivateKey)) && ("ECDSA".equals(((PrivateKey)paramObject).getAlgorithm())))
    {
      str = "EC PRIVATE KEY";
      localObject1 = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(((PrivateKey)paramObject).getEncoded()));
      arrayOfByte = ((PrivateKeyInfo)localObject1).parsePrivateKey().toASN1Primitive().getEncoded();
    }
    if ((str == null) || (arrayOfByte == null)) {
      throw new IllegalArgumentException("Object type not supported: " + paramObject.getClass().getName());
    }
    Object localObject1 = Strings.toUpperCase(paramString);
    if (((String)localObject1).equals("DESEDE")) {
      localObject1 = "DES-EDE3-CBC";
    }
    int i = ((String)localObject1).startsWith("AES-") ? 16 : 8;
    Object localObject3 = new byte[i];
    paramSecureRandom.nextBytes((byte[])localObject3);
    Object localObject4 = PEMUtilities.crypt(true, provider, arrayOfByte, paramArrayOfChar, (String)localObject1, (byte[])localObject3);
    Object localObject5 = new ArrayList(2);
    ((List)localObject5).add(new PemHeader("Proc-Type", "4,ENCRYPTED"));
    ((List)localObject5).add(new PemHeader("DEK-Info", (String)localObject1 + "," + getHexEncoded((byte[])localObject3)));
    return new PemObject(str, (List)localObject5, (byte[])localObject4);
  }
  
  public PemObject generate()
    throws PemGenerationException
  {
    try
    {
      if (algorithm != null) {
        return createPemObject(obj, algorithm, password, random);
      }
      return createPemObject(obj);
    }
    catch (IOException localIOException)
    {
      throw new PemGenerationException("encoding exception: " + localIOException.getMessage(), localIOException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.MiscPEMGenerator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;

public class PEMException
  extends IOException
{
  Exception underlying;
  
  public PEMException(String paramString)
  {
    super(paramString);
  }
  
  public PEMException(String paramString, Exception paramException)
  {
    super(paramString);
    underlying = paramException;
  }
  
  public Exception getUnderlyingException()
  {
    return underlying;
  }
  
  public Throwable getCause()
  {
    return underlying;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

class PEMReader$1 {}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.spec.DSAPrivateKeySpec;
import java.security.spec.DSAPublicKeySpec;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.util.io.pem.PemObject;

class PEMReader$DSAKeyPairParser
  extends PEMReader.KeyPairParser
{
  public PEMReader$DSAKeyPairParser(PEMReader paramPEMReader, String paramString)
  {
    super(paramPEMReader, paramString);
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      ASN1Sequence localASN1Sequence = readKeyPair(paramPemObject);
      if (localASN1Sequence.size() != 6) {
        throw new PEMException("malformed sequence in DSA private key");
      }
      DERInteger localDERInteger1 = (DERInteger)localASN1Sequence.getObjectAt(1);
      DERInteger localDERInteger2 = (DERInteger)localASN1Sequence.getObjectAt(2);
      DERInteger localDERInteger3 = (DERInteger)localASN1Sequence.getObjectAt(3);
      DERInteger localDERInteger4 = (DERInteger)localASN1Sequence.getObjectAt(4);
      DERInteger localDERInteger5 = (DERInteger)localASN1Sequence.getObjectAt(5);
      DSAPrivateKeySpec localDSAPrivateKeySpec = new DSAPrivateKeySpec(localDERInteger5.getValue(), localDERInteger1.getValue(), localDERInteger2.getValue(), localDERInteger3.getValue());
      DSAPublicKeySpec localDSAPublicKeySpec = new DSAPublicKeySpec(localDERInteger4.getValue(), localDERInteger1.getValue(), localDERInteger2.getValue(), localDERInteger3.getValue());
      KeyFactory localKeyFactory = KeyFactory.getInstance("DSA", provider);
      return new KeyPair(localKeyFactory.generatePublic(localDSAPublicKeySpec), localKeyFactory.generatePrivate(localDSAPrivateKeySpec));
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (Exception localException)
    {
      throw new PEMException("problem creating DSA private key: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.DSAKeyPairParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.sec.ECPrivateKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.util.io.pem.PemObject;

class PEMReader$ECDSAKeyPairParser
  extends PEMReader.KeyPairParser
{
  public PEMReader$ECDSAKeyPairParser(PEMReader paramPEMReader, String paramString)
  {
    super(paramPEMReader, paramString);
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      ASN1Sequence localASN1Sequence = readKeyPair(paramPemObject);
      ECPrivateKey localECPrivateKey = ECPrivateKey.getInstance(localASN1Sequence);
      AlgorithmIdentifier localAlgorithmIdentifier = new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, localECPrivateKey.getParameters());
      PrivateKeyInfo localPrivateKeyInfo = new PrivateKeyInfo(localAlgorithmIdentifier, localECPrivateKey);
      SubjectPublicKeyInfo localSubjectPublicKeyInfo = new SubjectPublicKeyInfo(localAlgorithmIdentifier, localECPrivateKey.getPublicKey().getBytes());
      PKCS8EncodedKeySpec localPKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(localPrivateKeyInfo.getEncoded());
      X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(localSubjectPublicKeyInfo.getEncoded());
      KeyFactory localKeyFactory = KeyFactory.getInstance("ECDSA", provider);
      return new KeyPair(localKeyFactory.generatePublic(localX509EncodedKeySpec), localKeyFactory.generatePrivate(localPKCS8EncodedKeySpec));
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (Exception localException)
    {
      throw new PEMException("problem creating EC private key: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.ECDSAKeyPairParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$ECNamedCurveSpecParser
  implements PemObjectParser
{
  private PEMReader$ECNamedCurveSpecParser(PEMReader paramPEMReader) {}
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      DERObjectIdentifier localDERObjectIdentifier = (DERObjectIdentifier)ASN1Primitive.fromByteArray(paramPemObject.getContent());
      ECNamedCurveParameterSpec localECNamedCurveParameterSpec = ECNamedCurveTable.getParameterSpec(localDERObjectIdentifier.getId());
      if (localECNamedCurveParameterSpec == null) {
        throw new IOException("object ID not found in EC curve table");
      }
      return localECNamedCurveParameterSpec;
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (Exception localException)
    {
      throw new PEMException("exception extracting EC named curve: " + localException.toString());
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.ECNamedCurveSpecParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.math.BigInteger;
import java.security.AlgorithmParameters;
import java.security.Key;
import java.security.KeyFactory;
import java.security.spec.KeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.EncryptionScheme;
import org.bouncycastle.asn1.pkcs.KeyDerivationFunc;
import org.bouncycastle.asn1.pkcs.PBEParameter;
import org.bouncycastle.asn1.pkcs.PBES2Parameters;
import org.bouncycastle.asn1.pkcs.PBKDF2Params;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$EncryptedPrivateKeyParser
  implements PemObjectParser
{
  private String symProvider;
  private String asymProvider;
  
  public PEMReader$EncryptedPrivateKeyParser(PEMReader paramPEMReader, String paramString1, String paramString2)
  {
    symProvider = paramString1;
    asymProvider = paramString2;
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      EncryptedPrivateKeyInfo localEncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(paramPemObject.getContent()));
      AlgorithmIdentifier localAlgorithmIdentifier = localEncryptedPrivateKeyInfo.getEncryptionAlgorithm();
      if (PEMReader.access$400(this$0) == null) {
        throw new PEMException("no PasswordFinder specified");
      }
      Object localObject1;
      Object localObject2;
      Object localObject3;
      Object localObject4;
      Object localObject5;
      Object localObject6;
      Object localObject7;
      Object localObject8;
      if (PEMUtilities.isPKCS5Scheme2(localAlgorithmIdentifier.getAlgorithm()))
      {
        localObject1 = PBES2Parameters.getInstance(localAlgorithmIdentifier.getParameters());
        localObject2 = ((PBES2Parameters)localObject1).getKeyDerivationFunc();
        localObject3 = ((PBES2Parameters)localObject1).getEncryptionScheme();
        localObject4 = (PBKDF2Params)((KeyDerivationFunc)localObject2).getParameters();
        int i = ((PBKDF2Params)localObject4).getIterationCount().intValue();
        localObject5 = ((PBKDF2Params)localObject4).getSalt();
        localObject6 = ((EncryptionScheme)localObject3).getAlgorithm().getId();
        localObject7 = PEMUtilities.generateSecretKeyForPKCS5Scheme2((String)localObject6, PEMReader.access$400(this$0).getPassword(), (byte[])localObject5, i);
        localObject8 = Cipher.getInstance((String)localObject6, symProvider);
        AlgorithmParameters localAlgorithmParameters = AlgorithmParameters.getInstance((String)localObject6, symProvider);
        localAlgorithmParameters.init(((EncryptionScheme)localObject3).getParameters().toASN1Primitive().getEncoded());
        ((Cipher)localObject8).init(2, (Key)localObject7, localAlgorithmParameters);
        PrivateKeyInfo localPrivateKeyInfo = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(((Cipher)localObject8).doFinal(localEncryptedPrivateKeyInfo.getEncryptedData())));
        PKCS8EncodedKeySpec localPKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(localPrivateKeyInfo.getEncoded());
        KeyFactory localKeyFactory = KeyFactory.getInstance(localPrivateKeyInfo.getPrivateKeyAlgorithm().getAlgorithm().getId(), asymProvider);
        return localKeyFactory.generatePrivate(localPKCS8EncodedKeySpec);
      }
      PBEParameterSpec localPBEParameterSpec;
      if (PEMUtilities.isPKCS12(localAlgorithmIdentifier.getAlgorithm()))
      {
        localObject1 = PKCS12PBEParams.getInstance(localAlgorithmIdentifier.getParameters());
        localObject2 = localAlgorithmIdentifier.getAlgorithm().getId();
        localObject3 = new PBEKeySpec(PEMReader.access$400(this$0).getPassword());
        localObject4 = SecretKeyFactory.getInstance((String)localObject2, symProvider);
        localPBEParameterSpec = new PBEParameterSpec(((PKCS12PBEParams)localObject1).getIV(), ((PKCS12PBEParams)localObject1).getIterations().intValue());
        localObject5 = Cipher.getInstance((String)localObject2, symProvider);
        ((Cipher)localObject5).init(2, ((SecretKeyFactory)localObject4).generateSecret((KeySpec)localObject3), localPBEParameterSpec);
        localObject6 = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(((Cipher)localObject5).doFinal(localEncryptedPrivateKeyInfo.getEncryptedData())));
        localObject7 = new PKCS8EncodedKeySpec(((PrivateKeyInfo)localObject6).getEncoded());
        localObject8 = KeyFactory.getInstance(((PrivateKeyInfo)localObject6).getAlgorithmId().getAlgorithm().getId(), asymProvider);
        return ((KeyFactory)localObject8).generatePrivate((KeySpec)localObject7);
      }
      if (PEMUtilities.isPKCS5Scheme1(localAlgorithmIdentifier.getAlgorithm()))
      {
        localObject1 = PBEParameter.getInstance(localAlgorithmIdentifier.getParameters());
        localObject2 = localAlgorithmIdentifier.getAlgorithm().getId();
        localObject3 = new PBEKeySpec(PEMReader.access$400(this$0).getPassword());
        localObject4 = SecretKeyFactory.getInstance((String)localObject2, symProvider);
        localPBEParameterSpec = new PBEParameterSpec(((PBEParameter)localObject1).getSalt(), ((PBEParameter)localObject1).getIterationCount().intValue());
        localObject5 = Cipher.getInstance((String)localObject2, symProvider);
        ((Cipher)localObject5).init(2, ((SecretKeyFactory)localObject4).generateSecret((KeySpec)localObject3), localPBEParameterSpec);
        localObject6 = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(((Cipher)localObject5).doFinal(localEncryptedPrivateKeyInfo.getEncryptedData())));
        localObject7 = new PKCS8EncodedKeySpec(((PrivateKeyInfo)localObject6).getEncoded());
        localObject8 = KeyFactory.getInstance(((PrivateKeyInfo)localObject6).getAlgorithmId().getAlgorithm().getId(), asymProvider);
        return ((KeyFactory)localObject8).generatePrivate((KeySpec)localObject7);
      }
      throw new PEMException("Unknown algorithm: " + localAlgorithmIdentifier.getAlgorithm());
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (Exception localException)
    {
      throw new PEMException("problem parsing ENCRYPTED PRIVATE KEY: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.EncryptedPrivateKeyParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.util.encoders.Hex;
import org.bouncycastle.util.io.pem.PemHeader;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

abstract class PEMReader$KeyPairParser
  implements PemObjectParser
{
  protected String provider;
  
  public PEMReader$KeyPairParser(PEMReader paramPEMReader, String paramString)
  {
    provider = paramString;
  }
  
  protected ASN1Sequence readKeyPair(PemObject paramPemObject)
    throws IOException
  {
    int i = 0;
    String str1 = null;
    List localList = paramPemObject.getHeaders();
    Object localObject1 = localList.iterator();
    Object localObject2;
    while (((Iterator)localObject1).hasNext())
    {
      localObject2 = (PemHeader)((Iterator)localObject1).next();
      if ((((PemHeader)localObject2).getName().equals("Proc-Type")) && (((PemHeader)localObject2).getValue().equals("4,ENCRYPTED"))) {
        i = 1;
      } else if (((PemHeader)localObject2).getName().equals("DEK-Info")) {
        str1 = ((PemHeader)localObject2).getValue();
      }
    }
    localObject1 = paramPemObject.getContent();
    if (i != 0)
    {
      if (PEMReader.access$400(this$0) == null) {
        throw new PasswordException("No password finder specified, but a password is required");
      }
      localObject2 = PEMReader.access$400(this$0).getPassword();
      if (localObject2 == null) {
        throw new PasswordException("Password is null, but a password is required");
      }
      StringTokenizer localStringTokenizer = new StringTokenizer(str1, ",");
      String str2 = localStringTokenizer.nextToken();
      byte[] arrayOfByte = Hex.decode(localStringTokenizer.nextToken());
      localObject1 = PEMUtilities.crypt(false, provider, (byte[])localObject1, (char[])localObject2, str2, arrayOfByte);
    }
    try
    {
      return ASN1Sequence.getInstance(ASN1Primitive.fromByteArray((byte[])localObject1));
    }
    catch (IOException localIOException)
    {
      if (i != 0) {
        throw new PEMException("exception decoding - please check password and data.", localIOException);
      }
      throw new PEMException(localIOException.getMessage(), localIOException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      if (i != 0) {
        throw new PEMException("exception decoding - please check password and data.", localIllegalArgumentException);
      }
      throw new PEMException(localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.KeyPairParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import org.bouncycastle.jce.PKCS10CertificationRequest;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$PKCS10CertificationRequestParser
  implements PemObjectParser
{
  private PEMReader$PKCS10CertificationRequestParser(PEMReader paramPEMReader) {}
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      return new PKCS10CertificationRequest(paramPemObject.getContent());
    }
    catch (Exception localException)
    {
      throw new PEMException("problem parsing certrequest: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.PKCS10CertificationRequestParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$PKCS7Parser
  implements PemObjectParser
{
  private PEMReader$PKCS7Parser(PEMReader paramPEMReader) {}
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      ASN1InputStream localASN1InputStream = new ASN1InputStream(paramPemObject.getContent());
      return ContentInfo.getInstance(localASN1InputStream.readObject());
    }
    catch (Exception localException)
    {
      throw new PEMException("problem parsing PKCS7 object: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.PKCS7Parser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$PrivateKeyParser
  implements PemObjectParser
{
  private String provider;
  
  public PEMReader$PrivateKeyParser(PEMReader paramPEMReader, String paramString)
  {
    provider = paramString;
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      PrivateKeyInfo localPrivateKeyInfo = PrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(paramPemObject.getContent()));
      PKCS8EncodedKeySpec localPKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(paramPemObject.getContent());
      KeyFactory localKeyFactory = KeyFactory.getInstance(localPrivateKeyInfo.getAlgorithmId().getAlgorithm().getId(), provider);
      return localKeyFactory.generatePrivate(localPKCS8EncodedKeySpec);
    }
    catch (Exception localException)
    {
      throw new PEMException("problem parsing PRIVATE KEY: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.PrivateKeyParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$PublicKeyParser
  implements PemObjectParser
{
  private String provider;
  
  public PEMReader$PublicKeyParser(PEMReader paramPEMReader, String paramString)
  {
    provider = paramString;
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(paramPemObject.getContent());
    String[] arrayOfString = { "DSA", "RSA" };
    for (int i = 0; i < arrayOfString.length; i++) {
      try
      {
        KeyFactory localKeyFactory = KeyFactory.getInstance(arrayOfString[i], provider);
        PublicKey localPublicKey = localKeyFactory.generatePublic(localX509EncodedKeySpec);
        return localPublicKey;
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}catch (InvalidKeySpecException localInvalidKeySpecException) {}catch (NoSuchProviderException localNoSuchProviderException)
      {
        throw new RuntimeException("can't find provider " + provider);
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.PublicKeyParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.spec.RSAPrivateCrtKeySpec;
import java.security.spec.RSAPublicKeySpec;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.pkcs.RSAPrivateKey;
import org.bouncycastle.util.io.pem.PemObject;

class PEMReader$RSAKeyPairParser
  extends PEMReader.KeyPairParser
{
  public PEMReader$RSAKeyPairParser(PEMReader paramPEMReader, String paramString)
  {
    super(paramPEMReader, paramString);
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      ASN1Sequence localASN1Sequence = readKeyPair(paramPemObject);
      if (localASN1Sequence.size() != 9) {
        throw new PEMException("malformed sequence in RSA private key");
      }
      RSAPrivateKey localRSAPrivateKey = RSAPrivateKey.getInstance(localASN1Sequence);
      RSAPublicKeySpec localRSAPublicKeySpec = new RSAPublicKeySpec(localRSAPrivateKey.getModulus(), localRSAPrivateKey.getPublicExponent());
      RSAPrivateCrtKeySpec localRSAPrivateCrtKeySpec = new RSAPrivateCrtKeySpec(localRSAPrivateKey.getModulus(), localRSAPrivateKey.getPublicExponent(), localRSAPrivateKey.getPrivateExponent(), localRSAPrivateKey.getPrime1(), localRSAPrivateKey.getPrime2(), localRSAPrivateKey.getExponent1(), localRSAPrivateKey.getExponent2(), localRSAPrivateKey.getCoefficient());
      KeyFactory localKeyFactory = KeyFactory.getInstance("RSA", provider);
      return new KeyPair(localKeyFactory.generatePublic(localRSAPublicKeySpec), localKeyFactory.generatePrivate(localRSAPrivateCrtKeySpec));
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (Exception localException)
    {
      throw new PEMException("problem creating RSA private key: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.RSAKeyPairParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import java.security.KeyFactory;
import java.security.NoSuchProviderException;
import java.security.spec.RSAPublicKeySpec;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.pkcs.RSAPublicKey;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$RSAPublicKeyParser
  implements PemObjectParser
{
  private String provider;
  
  public PEMReader$RSAPublicKeyParser(PEMReader paramPEMReader, String paramString)
  {
    provider = paramString;
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    try
    {
      ASN1InputStream localASN1InputStream = new ASN1InputStream(paramPemObject.getContent());
      ASN1Primitive localASN1Primitive = localASN1InputStream.readObject();
      ASN1Sequence localASN1Sequence = (ASN1Sequence)localASN1Primitive;
      RSAPublicKey localRSAPublicKey = RSAPublicKey.getInstance(localASN1Sequence);
      RSAPublicKeySpec localRSAPublicKeySpec = new RSAPublicKeySpec(localRSAPublicKey.getModulus(), localRSAPublicKey.getPublicExponent());
      KeyFactory localKeyFactory = KeyFactory.getInstance("RSA", provider);
      return localKeyFactory.generatePublic(localRSAPublicKeySpec);
    }
    catch (IOException localIOException)
    {
      throw localIOException;
    }
    catch (NoSuchProviderException localNoSuchProviderException)
    {
      throw new IOException("can't find provider " + provider);
    }
    catch (Exception localException)
    {
      throw new PEMException("problem extracting key: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.RSAPublicKeyParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.IOException;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;
import org.bouncycastle.x509.X509V2AttributeCertificate;

class PEMReader$X509AttributeCertificateParser
  implements PemObjectParser
{
  private PEMReader$X509AttributeCertificateParser(PEMReader paramPEMReader) {}
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    return new X509V2AttributeCertificate(paramPemObject.getContent());
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.X509AttributeCertificateParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.cert.CertificateFactory;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$X509CRLParser
  implements PemObjectParser
{
  private String provider;
  
  public PEMReader$X509CRLParser(PEMReader paramPEMReader, String paramString)
  {
    provider = paramString;
  }
  
  public Object parseObject(PemObject paramPemObject)
    throws IOException
  {
    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramPemObject.getContent());
    try
    {
      CertificateFactory localCertificateFactory = CertificateFactory.getInstance("X.509", provider);
      return localCertificateFactory.generateCRL(localByteArrayInputStream);
    }
    catch (Exception localException)
    {
      throw new PEMException("problem parsing cert: " + localException.toString(), localException);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.openssl.PEMReader.X509CRLParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.openssl;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.cert.CertificateFactory;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemObjectParser;

class PEMReader$X509CertificateParser
  implements PemObjectParser
{
  private String provider;
  
  public PEMReader$X509CertificateParser(PEMReader para
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd