bcpkix-jdk15on-147

ProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410");
    oids.put(new ASN1ObjectIdentifier("1.2.840.113549.1.1.4"), "MD5WITHRSA");
    oids.put(new ASN1ObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
    oids.put(new ASN1ObjectIdentifier("1.2.840.10040.4.3"), "SHA1WITHDSA");
    oids.put(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1WITHECDSA");
    oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA");
    oids.put(X9ObjectIdentifiers.ecdsa_with_SHA256, "SHA256WITHECDSA");
    oids.put(X9ObjectIdentifiers.ecdsa_with_SHA384, "SHA384WITHECDSA");
    oids.put(X9ObjectIdentifiers.ecdsa_with_SHA512, "SHA512WITHECDSA");
    oids.put(OIWObjectIdentifiers.sha1WithRSA, "SHA1WITHRSA");
    oids.put(OIWObjectIdentifiers.dsaWithSHA1, "SHA1WITHDSA");
    oids.put(NISTObjectIdentifiers.dsa_with_sha224, "SHA224WITHDSA");
    oids.put(NISTObjectIdentifiers.dsa_with_sha256, "SHA256WITHDSA");
    asymmetricWrapperAlgNames.put(PKCSObjectIdentifiers.rsaEncryption, "RSA/ECB/PKCS1Padding");
    symmetricWrapperAlgNames.put(PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "DESEDEWrap");
    symmetricWrapperAlgNames.put(PKCSObjectIdentifiers.id_alg_CMSRC2wrap, "RC2Wrap");
    symmetricWrapperAlgNames.put(NISTObjectIdentifiers.id_aes128_wrap, "AESWrap");
    symmetricWrapperAlgNames.put(NISTObjectIdentifiers.id_aes192_wrap, "AESWrap");
    symmetricWrapperAlgNames.put(NISTObjectIdentifiers.id_aes256_wrap, "AESWrap");
    symmetricWrapperAlgNames.put(NTTObjectIdentifiers.id_camellia128_wrap, "CamelliaWrap");
    symmetricWrapperAlgNames.put(NTTObjectIdentifiers.id_camellia192_wrap, "CamelliaWrap");
    symmetricWrapperAlgNames.put(NTTObjectIdentifiers.id_camellia256_wrap, "CamelliaWrap");
    symmetricWrapperAlgNames.put(KISAObjectIdentifiers.id_npki_app_cmsSeed_wrap, "SEEDWrap");
    symmetricWrapperAlgNames.put(PKCSObjectIdentifiers.des_EDE3_CBC, "DESede");
    symmetricKeyAlgNames.put(NISTObjectIdentifiers.aes, "AES");
    symmetricKeyAlgNames.put(NISTObjectIdentifiers.id_aes128_CBC, "AES");
    symmetricKeyAlgNames.put(NISTObjectIdentifiers.id_aes192_CBC, "AES");
    symmetricKeyAlgNames.put(NISTObjectIdentifiers.id_aes256_CBC, "AES");
    symmetricKeyAlgNames.put(PKCSObjectIdentifiers.des_EDE3_CBC, "DESede");
    symmetricKeyAlgNames.put(PKCSObjectIdentifiers.RC2_CBC, "RC2");
  }
  
  private static class OpCertificateException
    extends CertificateException
  {
    private Throwable cause;
    
    public OpCertificateException(String paramString, Throwable paramThrowable)
    {
      super();
      cause = paramThrowable;
    }
    
    public Throwable getCause()
    {
      return cause;
    }
  }
}

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

import java.security.Key;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.operator.GenericKey;

class OperatorUtils
{
  static Key getJceKey(GenericKey paramGenericKey)
  {
    if ((paramGenericKey.getRepresentation() instanceof Key)) {
      return (Key)paramGenericKey.getRepresentation();
    }
    if ((paramGenericKey.getRepresentation() instanceof byte[])) {
      return new SecretKeySpec((byte[])paramGenericKey.getRepresentation(), "ENC");
    }
    throw new IllegalArgumentException("unknown generic key type");
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.operator.jcajce.OperatorUtils
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.pkcs;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import org.bouncycastle.asn1.pkcs.MacData;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.DigestInfo;
import org.bouncycastle.operator.MacCalculator;

class MacDataGenerator
{
  private PKCS12MacCalculatorBuilder builder;
  
  MacDataGenerator(PKCS12MacCalculatorBuilder paramPKCS12MacCalculatorBuilder)
  {
    builder = paramPKCS12MacCalculatorBuilder;
  }
  
  public MacData build(char[] paramArrayOfChar, byte[] paramArrayOfByte)
    throws PKCSException
  {
    MacCalculator localMacCalculator = builder.build(paramArrayOfChar);
    AlgorithmIdentifier localAlgorithmIdentifier = localMacCalculator.getAlgorithmIdentifier();
    OutputStream localOutputStream = localMacCalculator.getOutputStream();
    try
    {
      localOutputStream.write(paramArrayOfByte);
      localOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new PKCSException("unable to process data: " + localIOException.getMessage(), localIOException);
    }
    DigestInfo localDigestInfo = new DigestInfo(builder.getDigestAlgorithmIdentifier(), localMacCalculator.getMac());
    PKCS12PBEParams localPKCS12PBEParams = PKCS12PBEParams.getInstance(localAlgorithmIdentifier.getParameters());
    return new MacData(localDigestInfo, localPKCS12PBEParams.getIV(), localPKCS12PBEParams.getIterations().intValue());
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.pkcs.Attribute;
import org.bouncycastle.asn1.pkcs.CertificationRequest;
import org.bouncycastle.asn1.pkcs.CertificationRequestInfo;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;

public class PKCS10CertificationRequest
{
  private static Attribute[] EMPTY_ARRAY = new Attribute[0];
  private CertificationRequest certificationRequest;
  
  private static CertificationRequest parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return CertificationRequest.getInstance(ASN1Primitive.fromByteArray(paramArrayOfByte));
    }
    catch (ClassCastException localClassCastException)
    {
      throw new PKCSIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new PKCSIOException("malformed data: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
  }
  
  public PKCS10CertificationRequest(CertificationRequest paramCertificationRequest)
  {
    certificationRequest = paramCertificationRequest;
  }
  
  public PKCS10CertificationRequest(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseBytes(paramArrayOfByte));
  }
  
  public CertificationRequest toASN1Structure()
  {
    return certificationRequest;
  }
  
  public X500Name getSubject()
  {
    return X500Name.getInstance(certificationRequest.getCertificationRequestInfo().getSubject());
  }
  
  public AlgorithmIdentifier getSignatureAlgorithm()
  {
    return certificationRequest.getSignatureAlgorithm();
  }
  
  public byte[] getSignature()
  {
    return certificationRequest.getSignature().getBytes();
  }
  
  public SubjectPublicKeyInfo getSubjectPublicKeyInfo()
  {
    return certificationRequest.getCertificationRequestInfo().getSubjectPublicKeyInfo();
  }
  
  public Attribute[] getAttributes()
  {
    ASN1Set localASN1Set = certificationRequest.getCertificationRequestInfo().getAttributes();
    if (localASN1Set == null) {
      return EMPTY_ARRAY;
    }
    Attribute[] arrayOfAttribute = new Attribute[localASN1Set.size()];
    for (int i = 0; i != localASN1Set.size(); i++) {
      arrayOfAttribute[i] = Attribute.getInstance(localASN1Set.getObjectAt(i));
    }
    return arrayOfAttribute;
  }
  
  public Attribute[] getAttributes(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    ASN1Set localASN1Set = certificationRequest.getCertificationRequestInfo().getAttributes();
    if (localASN1Set == null) {
      return EMPTY_ARRAY;
    }
    ArrayList localArrayList = new ArrayList();
    for (int i = 0; i != localASN1Set.size(); i++)
    {
      Attribute localAttribute = Attribute.getInstance(localASN1Set.getObjectAt(i));
      if (localAttribute.getAttrType().equals(paramASN1ObjectIdentifier)) {
        localArrayList.add(localAttribute);
      }
    }
    if (localArrayList.size() == 0) {
      return EMPTY_ARRAY;
    }
    return (Attribute[])localArrayList.toArray(new Attribute[localArrayList.size()]);
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return certificationRequest.getEncoded();
  }
  
  public boolean isSignatureValid(ContentVerifierProvider paramContentVerifierProvider)
    throws PKCSException
  {
    CertificationRequestInfo localCertificationRequestInfo = certificationRequest.getCertificationRequestInfo();
    ContentVerifier localContentVerifier;
    try
    {
      localContentVerifier = paramContentVerifierProvider.get(certificationRequest.getSignatureAlgorithm());
      OutputStream localOutputStream = localContentVerifier.getOutputStream();
      localOutputStream.write(localCertificationRequestInfo.getEncoded("DER"));
      localOutputStream.close();
    }
    catch (Exception localException)
    {
      throw new PKCSException("unable to process signature: " + localException.getMessage(), localException);
    }
    return localContentVerifier.verify(certificationRequest.getSignature().getBytes());
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if (!(paramObject instanceof PKCS10CertificationRequest)) {
      return false;
    }
    PKCS10CertificationRequest localPKCS10CertificationRequest = (PKCS10CertificationRequest)paramObject;
    return toASN1Structure().equals(localPKCS10CertificationRequest.toASN1Structure());
  }
  
  public int hashCode()
  {
    return toASN1Structure().hashCode();
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.pkcs.Attribute;
import org.bouncycastle.asn1.pkcs.CertificationRequest;
import org.bouncycastle.asn1.pkcs.CertificationRequestInfo;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.ContentSigner;

public class PKCS10CertificationRequestBuilder
{
  private SubjectPublicKeyInfo publicKeyInfo;
  private X500Name subject;
  private List attributes = new ArrayList();
  
  public PKCS10CertificationRequestBuilder(X500Name paramX500Name, SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    subject = paramX500Name;
    publicKeyInfo = paramSubjectPublicKeyInfo;
  }
  
  public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier paramASN1ObjectIdentifier, ASN1Encodable paramASN1Encodable)
  {
    attributes.add(new Attribute(paramASN1ObjectIdentifier, new DERSet(paramASN1Encodable)));
    return this;
  }
  
  public PKCS10CertificationRequestBuilder addAttribute(ASN1ObjectIdentifier paramASN1ObjectIdentifier, ASN1Encodable[] paramArrayOfASN1Encodable)
  {
    attributes.add(new Attribute(paramASN1ObjectIdentifier, new DERSet(paramArrayOfASN1Encodable)));
    return this;
  }
  
  public PKCS10CertificationRequest build(ContentSigner paramContentSigner)
  {
    CertificationRequestInfo localCertificationRequestInfo;
    Object localObject;
    if (attributes.isEmpty())
    {
      localCertificationRequestInfo = new CertificationRequestInfo(subject, publicKeyInfo, null);
    }
    else
    {
      localObject = new ASN1EncodableVector();
      Iterator localIterator = attributes.iterator();
      while (localIterator.hasNext()) {
        ((ASN1EncodableVector)localObject).add(Attribute.getInstance(localIterator.next()));
      }
      localCertificationRequestInfo = new CertificationRequestInfo(subject, publicKeyInfo, new DERSet((ASN1EncodableVector)localObject));
    }
    try
    {
      localObject = paramContentSigner.getOutputStream();
      ((OutputStream)localObject).write(localCertificationRequestInfo.getEncoded("DER"));
      ((OutputStream)localObject).close();
      return new PKCS10CertificationRequest(new CertificationRequest(localCertificationRequestInfo, paramContentSigner.getAlgorithmIdentifier(), new DERBitString(paramContentSigner.getSignature())));
    }
    catch (IOException localIOException)
    {
      throw new IllegalStateException("cannot produce certification request signature");
    }
  }
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.MacCalculator;

public abstract interface PKCS12MacCalculatorBuilder
{
  public abstract MacCalculator build(char[] paramArrayOfChar);
  
  public abstract AlgorithmIdentifier getDigestAlgorithmIdentifier();
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

public abstract interface PKCS12MacCalculatorBuilderProvider
{
  public abstract PKCS12MacCalculatorBuilder get(AlgorithmIdentifier paramAlgorithmIdentifier);
}

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

import java.io.IOException;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.pkcs.ContentInfo;
import org.bouncycastle.asn1.pkcs.MacData;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.pkcs.Pfx;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.DigestInfo;
import org.bouncycastle.util.Arrays;

public class PKCS12PfxPdu
{
  private Pfx pfx;
  
  public PKCS12PfxPdu(Pfx paramPfx)
  {
    pfx = paramPfx;
  }
  
  public ContentInfo[] getContentInfos()
  {
    ASN1Sequence localASN1Sequence = ASN1Sequence.getInstance(ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets());
    ContentInfo[] arrayOfContentInfo = new ContentInfo[localASN1Sequence.size()];
    for (int i = 0; i != localASN1Sequence.size(); i++) {
      arrayOfContentInfo[i] = ContentInfo.getInstance(localASN1Sequence.getObjectAt(i));
    }
    return arrayOfContentInfo;
  }
  
  public boolean hasMac()
  {
    return pfx.getMacData() != null;
  }
  
  public boolean isMacValid(PKCS12MacCalculatorBuilderProvider paramPKCS12MacCalculatorBuilderProvider, char[] paramArrayOfChar)
    throws PKCSException
  {
    if (hasMac())
    {
      MacData localMacData1 = pfx.getMacData();
      MacDataGenerator localMacDataGenerator = new MacDataGenerator(paramPKCS12MacCalculatorBuilderProvider.get(new AlgorithmIdentifier(localMacData1.getMac().getAlgorithmId().getAlgorithm(), new PKCS12PBEParams(localMacData1.getSalt(), localMacData1.getIterationCount().intValue()))));
      try
      {
        MacData localMacData2 = localMacDataGenerator.build(paramArrayOfChar, ASN1OctetString.getInstance(pfx.getAuthSafe().getContent()).getOctets());
        return Arrays.constantTimeAreEqual(localMacData2.getEncoded(), pfx.getMacData().getEncoded());
      }
      catch (IOException localIOException)
      {
        throw new PKCSException("unable to process AuthSafe: " + localIOException.getMessage());
      }
    }
    throw new IllegalStateException("no MAC present on PFX");
  }
  
  public Pfx toASN1Structure()
  {
    return pfx;
  }
}

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

import java.io.IOException;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DLSequence;
import org.bouncycastle.asn1.pkcs.AuthenticatedSafe;
import org.bouncycastle.asn1.pkcs.ContentInfo;
import org.bouncycastle.asn1.pkcs.MacData;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.Pfx;
import org.bouncycastle.cms.CMSEncryptedData;
import org.bouncycastle.cms.CMSEncryptedDataGenerator;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.CMSProcessableByteArray;
import org.bouncycastle.operator.OutputEncryptor;

public class PKCS12PfxPduBuilder
{
  private ASN1EncodableVector dataVector = new ASN1EncodableVector();
  
  public PKCS12PfxPduBuilder addData(PKCS12SafeBag paramPKCS12SafeBag)
    throws IOException
  {
    dataVector.add(new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(new DLSequence(paramPKCS12SafeBag.toASN1Structure()).getEncoded())));
    return this;
  }
  
  public PKCS12PfxPduBuilder addEncryptedData(OutputEncryptor paramOutputEncryptor, PKCS12SafeBag paramPKCS12SafeBag)
    throws IOException
  {
    return addEncryptedData(paramOutputEncryptor, new DERSequence(paramPKCS12SafeBag.toASN1Structure()));
  }
  
  public PKCS12PfxPduBuilder addEncryptedData(OutputEncryptor paramOutputEncryptor, PKCS12SafeBag[] paramArrayOfPKCS12SafeBag)
    throws IOException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    for (int i = 0; i != paramArrayOfPKCS12SafeBag.length; i++) {
      localASN1EncodableVector.add(paramArrayOfPKCS12SafeBag[i].toASN1Structure());
    }
    return addEncryptedData(paramOutputEncryptor, new DLSequence(localASN1EncodableVector));
  }
  
  private PKCS12PfxPduBuilder addEncryptedData(OutputEncryptor paramOutputEncryptor, ASN1Sequence paramASN1Sequence)
    throws IOException
  {
    CMSEncryptedDataGenerator localCMSEncryptedDataGenerator = new CMSEncryptedDataGenerator();
    try
    {
      dataVector.add(localCMSEncryptedDataGenerator.generate(new CMSProcessableByteArray(paramASN1Sequence.getEncoded()), paramOutputEncryptor).toASN1Structure());
    }
    catch (CMSException localCMSException)
    {
      throw new PKCSIOException(localCMSException.getMessage(), localCMSException.getCause());
    }
    return this;
  }
  
  public PKCS12PfxPdu build(PKCS12MacCalculatorBuilder paramPKCS12MacCalculatorBuilder, char[] paramArrayOfChar)
    throws PKCSException
  {
    AuthenticatedSafe localAuthenticatedSafe = AuthenticatedSafe.getInstance(new DLSequence(dataVector));
    byte[] arrayOfByte;
    try
    {
      arrayOfByte = localAuthenticatedSafe.getEncoded();
    }
    catch (IOException localIOException)
    {
      throw new PKCSException("unable to encode AuthenticatedSafe: " + localIOException.getMessage(), localIOException);
    }
    ContentInfo localContentInfo = new ContentInfo(PKCSObjectIdentifiers.data, new DEROctetString(arrayOfByte));
    MacData localMacData = null;
    if (paramPKCS12MacCalculatorBuilder != null)
    {
      localObject = new MacDataGenerator(paramPKCS12MacCalculatorBuilder);
      localMacData = ((MacDataGenerator)localObject).build(paramArrayOfChar, arrayOfByte);
    }
    Object localObject = new Pfx(localContentInfo, localMacData);
    return new PKCS12PfxPdu((Pfx)localObject);
  }
}

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

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.pkcs.Attribute;
import org.bouncycastle.asn1.pkcs.CRLBag;
import org.bouncycastle.asn1.pkcs.CertBag;
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.SafeBag;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;

public class PKCS12SafeBag
{
  private SafeBag safeBag;
  
  public PKCS12SafeBag(SafeBag paramSafeBag)
  {
    safeBag = paramSafeBag;
  }
  
  public SafeBag toASN1Structure()
  {
    return safeBag;
  }
  
  public ASN1ObjectIdentifier getType()
  {
    return safeBag.getBagId();
  }
  
  public Attribute[] getAttributes()
  {
    ASN1Set localASN1Set = safeBag.getBagAttributes();
    if (localASN1Set == null) {
      return null;
    }
    Attribute[] arrayOfAttribute = new Attribute[localASN1Set.size()];
    for (int i = 0; i != localASN1Set.size(); i++) {
      arrayOfAttribute[i] = Attribute.getInstance(localASN1Set.getObjectAt(i));
    }
    return arrayOfAttribute;
  }
  
  public Object getBagValue()
  {
    if (getType().equals(PKCSObjectIdentifiers.pkcs8ShroudedKeyBag)) {
      return new PKCS8EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfo.getInstance(safeBag.getBagValue()));
    }
    Object localObject;
    if (getType().equals(PKCSObjectIdentifiers.certBag))
    {
      localObject = CertBag.getInstance(safeBag.getBagValue());
      return new X509CertificateHolder(Certificate.getInstance(ASN1OctetString.getInstance(((CertBag)localObject).getCertValue()).getOctets()));
    }
    if (getType().equals(PKCSObjectIdentifiers.keyBag)) {
      return PrivateKeyInfo.getInstance(safeBag.getBagValue());
    }
    if (getType().equals(PKCSObjectIdentifiers.crlBag))
    {
      localObject = CRLBag.getInstance(safeBag.getBagValue());
      return new X509CRLHolder(CertificateList.getInstance(ASN1OctetString.getInstance(((CRLBag)localObject).getCRLValue()).getOctets()));
    }
    return safeBag.getBagValue();
  }
}

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

import java.io.IOException;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.pkcs.Attribute;
import org.bouncycastle.asn1.pkcs.CertBag;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.SafeBag;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.OutputEncryptor;

public class PKCS12SafeBagBuilder
{
  private ASN1ObjectIdentifier bagType = PKCSObjectIdentifiers.crlBag;
  private ASN1Encodable bagValue;
  private ASN1EncodableVector bagAttrs = new ASN1EncodableVector();
  
  public PKCS12SafeBagBuilder(PrivateKeyInfo paramPrivateKeyInfo, OutputEncryptor paramOutputEncryptor)
  {
    bagValue = new PKCS8EncryptedPrivateKeyInfoBuilder(paramPrivateKeyInfo).build(paramOutputEncryptor).toASN1Structure();
  }
  
  public PKCS12SafeBagBuilder(PrivateKeyInfo paramPrivateKeyInfo)
  {
    bagValue = paramPrivateKeyInfo;
  }
  
  public PKCS12SafeBagBuilder(X509CertificateHolder paramX509CertificateHolder)
    throws IOException
  {
    this(paramX509CertificateHolder.toASN1Structure());
  }
  
  public PKCS12SafeBagBuilder(X509CRLHolder paramX509CRLHolder)
    throws IOException
  {
    this(paramX509CRLHolder.toASN1Structure());
  }
  
  public PKCS12SafeBagBuilder(Certificate paramCertificate)
    throws IOException
  {
    bagValue = new CertBag(PKCSObjectIdentifiers.x509Certificate, new DEROctetString(paramCertificate.getEncoded()));
  }
  
  public PKCS12SafeBagBuilder(CertificateList paramCertificateList)
    throws IOException
  {
    bagValue = new CertBag(PKCSObjectIdentifiers.x509Crl, new DEROctetString(paramCertificateList.getEncoded()));
  }
  
  public PKCS12SafeBagBuilder addBagAttribute(ASN1ObjectIdentifier paramASN1ObjectIdentifier, ASN1Encodable paramASN1Encodable)
  {
    bagAttrs.add(new Attribute(paramASN1ObjectIdentifier, new DERSet(paramASN1Encodable)));
    return this;
  }
  
  public PKCS12SafeBag build()
  {
    return new PKCS12SafeBag(new SafeBag(bagType, bagValue, new DERSet(bagAttrs)));
  }
}

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

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.SafeBag;
import org.bouncycastle.cms.CMSEncryptedData;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.operator.InputDecryptorProvider;

public class PKCS12SafeBagFactory
{
  private ASN1Sequence safeBagSeq;
  
  public PKCS12SafeBagFactory(org.bouncycastle.asn1.pkcs.ContentInfo paramContentInfo)
  {
    if (paramContentInfo.getContentType().equals(PKCSObjectIdentifiers.encryptedData)) {
      throw new IllegalArgumentException("encryptedData requires constructor with decryptor.");
    }
    safeBagSeq = ASN1Sequence.getInstance(ASN1OctetString.getInstance(paramContentInfo.getContent()).getOctets());
  }
  
  public PKCS12SafeBagFactory(org.bouncycastle.asn1.pkcs.ContentInfo paramContentInfo, InputDecryptorProvider paramInputDecryptorProvider)
    throws PKCSException
  {
    if (paramContentInfo.getContentType().equals(PKCSObjectIdentifiers.encryptedData))
    {
      CMSEncryptedData localCMSEncryptedData = new CMSEncryptedData(org.bouncycastle.asn1.cms.ContentInfo.getInstance(paramContentInfo));
      try
      {
        safeBagSeq = ASN1Sequence.getInstance(localCMSEncryptedData.getContent(paramInputDecryptorProvider));
      }
      catch (CMSException localCMSException)
      {
        throw new PKCSException("unable to extract data: " + localCMSException.getMessage(), localCMSException);
      }
      return;
    }
    throw new IllegalArgumentException("encryptedData requires constructor with decryptor.");
  }
  
  public PKCS12SafeBag[] getSafeBags()
  {
    PKCS12SafeBag[] arrayOfPKCS12SafeBag = new PKCS12SafeBag[safeBagSeq.size()];
    for (int i = 0; i != safeBagSeq.size(); i++) {
      arrayOfPKCS12SafeBag[i] = new PKCS12SafeBag(SafeBag.getInstance(safeBagSeq.getObjectAt(i)));
    }
    return arrayOfPKCS12SafeBag;
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.operator.InputDecryptor;
import org.bouncycastle.operator.InputDecryptorProvider;
import org.bouncycastle.util.io.Streams;

public class PKCS8EncryptedPrivateKeyInfo
{
  private EncryptedPrivateKeyInfo encryptedPrivateKeyInfo;
  
  public PKCS8EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfo paramEncryptedPrivateKeyInfo)
  {
    encryptedPrivateKeyInfo = paramEncryptedPrivateKeyInfo;
  }
  
  public EncryptedPrivateKeyInfo toASN1Structure()
  {
    return encryptedPrivateKeyInfo;
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return encryptedPrivateKeyInfo.getEncoded();
  }
  
  public PrivateKeyInfo decryptPrivateKeyInfo(InputDecryptorProvider paramInputDecryptorProvider)
    throws PKCSException
  {
    InputDecryptor localInputDecryptor = paramInputDecryptorProvider.get(encryptedPrivateKeyInfo.getEncryptionAlgorithm());
    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(encryptedPrivateKeyInfo.getEncryptedData());
    try
    {
      return PrivateKeyInfo.getInstance(Streams.readAll(localInputDecryptor.getInputStream(localByteArrayInputStream)));
    }
    catch (Exception localException)
    {
      throw new PKCSException("unable to read encrypted data: " + localException.getMessage(), localException);
    }
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.operator.OutputEncryptor;

public class PKCS8EncryptedPrivateKeyInfoBuilder
{
  private PrivateKeyInfo privateKeyInfo;
  
  public PKCS8EncryptedPrivateKeyInfoBuilder(PrivateKeyInfo paramPrivateKeyInfo)
  {
    privateKeyInfo = paramPrivateKeyInfo;
  }
  
  public PKCS8EncryptedPrivateKeyInfo build(OutputEncryptor paramOutputEncryptor)
  {
    try
    {
      ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
      OutputStream localOutputStream = paramOutputEncryptor.getOutputStream(localByteArrayOutputStream);
      localOutputStream.write(privateKeyInfo.getEncoded());
      localOutputStream.close();
      return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(paramOutputEncryptor.getAlgorithmIdentifier(), localByteArrayOutputStream.toByteArray()));
    }
    catch (IOException localIOException)
    {
      throw new IllegalStateException("cannot encode privateKeyInfo");
    }
  }
}

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

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

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

import java.io.IOException;

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

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

import java.security.SecureRandom;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.pkcs.PKCS12MacCalculatorBuilder;

public class BcPKCS12MacCalculatorBuilder
  implements PKCS12MacCalculatorBuilder
{
  private ExtendedDigest digest;
  private AlgorithmIdentifier algorithmIdentifier;
  private SecureRandom random;
  private int saltLength;
  private int iterationCount = 1024;
  
  public BcPKCS12MacCalculatorBuilder()
  {
    this(new SHA1Digest(), new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE));
  }
  
  public BcPKCS12MacCalculatorBuilder(ExtendedDigest paramExtendedDigest, AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    digest = paramExtendedDigest;
    algorithmIdentifier = paramAlgorithmIdentifier;
    saltLength = paramExtendedDigest.getDigestSize();
  }
  
  public AlgorithmIdentifier getDigestAlgorithmIdentifier()
  {
    return algorithmIdentifier;
  }
  
  public MacCalculator build(char[] paramArrayOfChar)
  {
    if (random == null) {
      random = new SecureRandom();
    }
    byte[] arrayOfByte = new byte[saltLength];
    random.nextBytes(arrayOfByte);
    return PKCS12PBEUtils.createMacCalculator(algorithmIdentifier.getAlgorithm(), digest, new PKCS12PBEParams(arrayOfByte, iterationCount), paramArrayOfChar);
  }
}

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

import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.pkcs.PKCS12MacCalculatorBuilder;

class BcPKCS12MacCalculatorBuilderProviderBuilder$1
  implements PKCS12MacCalculatorBuilder
{
  BcPKCS12MacCalculatorBuilderProviderBuilder$1(BcPKCS12MacCalculatorBuilderProviderBuilder paramBcPKCS12MacCalculatorBuilderProviderBuilder, AlgorithmIdentifier paramAlgorithmIdentifier) {}
  
  public MacCalculator build(char[] paramArrayOfChar)
  {
    PKCS12PBEParams localPKCS12PBEParams = PKCS12PBEParams.getInstance(val$algorithmIdentifier.getParameters());
    return PKCS12PBEUtils.createMacCalculator(BcPKCS12MacCalculatorBuilderProviderBuilder.access$000(this$0).getAlgorithm(), BcPKCS12MacCalculatorBuilderProviderBuilder.access$100(this$0), localPKCS12PBEParams, paramArrayOfChar);
  }
  
  public AlgorithmIdentifier getDigestAlgorithmIdentifier()
  {
    return BcPKCS12MacCalculatorBuilderProviderBuilder.access$000(this$0);
  }
}

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

import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.ExtendedDigest;
import org.bouncycastle.crypto.digests.SHA1Digest;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.pkcs.PKCS12MacCalculatorBuilder;
import org.bouncycastle.pkcs.PKCS12MacCalculatorBuilderProvider;

public class BcPKCS12MacCalculatorBuilderProviderBuilder
  implements PKCS12MacCalculatorBuilderProvider
{
  private ExtendedDigest digest;
  private AlgorithmIdentifier digestAlgorithmIdentifier;
  
  public BcPKCS12MacCalculatorBuilderProviderBuilder()
  {
    this(new SHA1Digest(), new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE));
  }
  
  public BcPKCS12MacCalculatorBuilderProviderBuilder(ExtendedDigest paramExtendedDigest, AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    digest = paramExtendedDigest;
    digestAlgorithmIdentifier = paramAlgorithmIdentifier;
  }
  
  public PKCS12MacCalculatorBuilder get(final AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    new PKCS12MacCalculatorBuilder()
    {
      public MacCalculator build(char[] paramAnonymousArrayOfChar)
      {
        PKCS12PBEParams localPKCS12PBEParams = PKCS12PBEParams.getInstance(paramAlgorithmIdentifier.getParameters());
        return PKCS12PBEUtils.createMacCalculator(digestAlgorithmIdentifier.getAlgorithm(), digest, localPKCS12PBEParams, paramAnonymousArrayOfChar);
      }
      
      public AlgorithmIdentifier getDigestAlgorithmIdentifier()
      {
        return digestAlgorithmIdentifier;
      }
    };
  }
}

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

import java.io.InputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
import org.bouncycastle.crypto.io.CipherInputStream;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.InputDecryptor;

class BcPKCS12PBEInputDecryptorProviderBuilder$1$1
  implements InputDecryptor
{
  BcPKCS12PBEInputDecryptorProviderBuilder$1$1(BcPKCS12PBEInputDecryptorProviderBuilder.1 param1, AlgorithmIdentifier paramAlgorithmIdentifier, PaddedBufferedBlockCipher paramPaddedBufferedBlockCipher) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$algorithmIdentifier;
  }
  
  public InputStream getInputStream(InputStream paramInputStream)
  {
    return new CipherInputStream(paramInputStream, val$engine);
  }
  
  public GenericKey getKey()
  {
    return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(this$1.val$password));
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.pkcs.bc.BcPKCS12PBEInputDecryptorProviderBuilder.1.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.pkcs.bc;

import java.io.InputStream;
import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
import org.bouncycastle.crypto.io.CipherInputStream;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.InputDecryptor;
import org.bouncycastle.operator.InputDecryptorProvider;

class BcPKCS12PBEInputDecryptorProviderBuilder$1
  implements InputDecryptorProvider
{
  BcPKCS12PBEInputDecryptorProviderBuilder$1(BcPKCS12PBEInputDecryptorProviderBuilder paramBcPKCS12PBEInputDecryptorProviderBuilder, char[] paramArrayOfChar) {}
  
  public InputDecryptor get(final AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    final PaddedBufferedBlockCipher localPaddedBufferedBlockCipher = PKCS12PBEUtils.getEngine(paramAlgorithmIdentifier.getAlgorithm());
    PKCS12PBEParams localPKCS12PBEParams = PKCS12PBEParams.getInstance(paramAlgorithmIdentifier.getParameters());
    CipherParameters localCipherParameters = PKCS12PBEUtils.createCipherParameters(paramAlgorithmIdentifier.getAlgorithm(), BcPKCS12PBEInputDecryptorProviderBuilder.access$000(this$0), localPaddedBufferedBlockCipher.getBlockSize(), localPKCS12PBEParams, val$password);
    localPaddedBufferedBlockCipher.init(false, localCipherParameters);
    new InputDecryptor()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier;
      }
      
      public InputStream getInputStream(InputStream paramAnonymousInputStream)
      {
        return new CipherInputStream(paramAnonymousInputStream, localPaddedBufferedBlockCipher);
      }
      
      public GenericKey getKey()
      {
        return new GenericKey(PKCS12ParametersGenerator.PKCS12PasswordToBytes(val$password));
      }
    };
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.pkcs.bc.BcPKC
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-2017. Infinite Loop Ltd