bcpkix-jdk15on-147

tor.bc.BcRSAAsymmetricKeyWrapper;

public class BcRSAKeyTransRecipientInfoGenerator
  extends BcKeyTransRecipientInfoGenerator
{
  public BcRSAKeyTransRecipientInfoGenerator(byte[] paramArrayOfByte, AlgorithmIdentifier paramAlgorithmIdentifier, AsymmetricKeyParameter paramAsymmetricKeyParameter)
  {
    super(paramArrayOfByte, new BcRSAAsymmetricKeyWrapper(paramAlgorithmIdentifier, paramAsymmetricKeyParameter));
  }
  
  public BcRSAKeyTransRecipientInfoGenerator(X509CertificateHolder paramX509CertificateHolder)
    throws IOException
  {
    super(paramX509CertificateHolder, new BcRSAAsymmetricKeyWrapper(paramX509CertificateHolder.getSubjectPublicKeyInfo().getAlgorithmId(), paramX509CertificateHolder.getSubjectPublicKeyInfo()));
  }
}

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

import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cms.CMSSignatureAlgorithmNameGenerator;
import org.bouncycastle.cms.SignerInformationVerifier;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder;
import org.bouncycastle.operator.bc.BcRSAContentVerifierProviderBuilder;

public class BcRSASignerInfoVerifierBuilder
{
  private BcRSAContentVerifierProviderBuilder contentVerifierProviderBuilder;
  private DigestCalculatorProvider digestCalculatorProvider;
  private CMSSignatureAlgorithmNameGenerator sigAlgNameGen;
  private SignatureAlgorithmIdentifierFinder sigAlgIdFinder;
  
  public BcRSASignerInfoVerifierBuilder(CMSSignatureAlgorithmNameGenerator paramCMSSignatureAlgorithmNameGenerator, SignatureAlgorithmIdentifierFinder paramSignatureAlgorithmIdentifierFinder, DigestAlgorithmIdentifierFinder paramDigestAlgorithmIdentifierFinder, DigestCalculatorProvider paramDigestCalculatorProvider)
  {
    sigAlgNameGen = paramCMSSignatureAlgorithmNameGenerator;
    sigAlgIdFinder = paramSignatureAlgorithmIdentifierFinder;
    contentVerifierProviderBuilder = new BcRSAContentVerifierProviderBuilder(paramDigestAlgorithmIdentifierFinder);
    digestCalculatorProvider = paramDigestCalculatorProvider;
  }
  
  public SignerInformationVerifier build(X509CertificateHolder paramX509CertificateHolder)
    throws OperatorCreationException
  {
    return new SignerInformationVerifier(sigAlgNameGen, sigAlgIdFinder, contentVerifierProviderBuilder.build(paramX509CertificateHolder), digestCalculatorProvider);
  }
  
  public SignerInformationVerifier build(AsymmetricKeyParameter paramAsymmetricKeyParameter)
    throws OperatorCreationException
  {
    return new SignerInformationVerifier(sigAlgNameGen, sigAlgIdFinder, contentVerifierProviderBuilder.build(paramAsymmetricKeyParameter), digestCalculatorProvider);
  }
}

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

import java.security.Provider;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.TBSCertificateStructure;
import org.bouncycastle.asn1.x509.X509Extension;

class CMSUtils
{
  static TBSCertificateStructure getTBSCertificateStructure(X509Certificate paramX509Certificate)
    throws CertificateEncodingException
  {
    return TBSCertificateStructure.getInstance(paramX509Certificate.getTBSCertificate());
  }
  
  static IssuerAndSerialNumber getIssuerAndSerialNumber(X509Certificate paramX509Certificate)
    throws CertificateEncodingException
  {
    Certificate localCertificate = Certificate.getInstance(paramX509Certificate.getEncoded());
    return new IssuerAndSerialNumber(localCertificate.getIssuer(), paramX509Certificate.getSerialNumber());
  }
  
  static byte[] getSubjectKeyId(X509Certificate paramX509Certificate)
  {
    byte[] arrayOfByte = paramX509Certificate.getExtensionValue(X509Extension.subjectKeyIdentifier.getId());
    if (arrayOfByte != null) {
      return ASN1OctetString.getInstance(ASN1OctetString.getInstance(arrayOfByte).getOctets()).getOctets();
    }
    return null;
  }
  
  static EnvelopedDataHelper createContentHelper(Provider paramProvider)
  {
    if (paramProvider != null) {
      return new EnvelopedDataHelper(new ProviderJcaJceExtHelper(paramProvider));
    }
    return new EnvelopedDataHelper(new DefaultJcaJceExtHelper());
  }
  
  static EnvelopedDataHelper createContentHelper(String paramString)
  {
    if (paramString != null) {
      return new EnvelopedDataHelper(new NamedJcaJceExtHelper(paramString));
    }
    return new EnvelopedDataHelper(new DefaultJcaJceExtHelper());
  }
}

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

import java.security.PrivateKey;
import javax.crypto.SecretKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.jcajce.DefaultJcaJceHelper;
import org.bouncycastle.operator.SymmetricKeyUnwrapper;
import org.bouncycastle.operator.jcajce.JceAsymmetricKeyUnwrapper;
import org.bouncycastle.operator.jcajce.JceSymmetricKeyUnwrapper;

class DefaultJcaJceExtHelper
  extends DefaultJcaJceHelper
  implements JcaJceExtHelper
{
  public JceAsymmetricKeyUnwrapper createAsymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, PrivateKey paramPrivateKey)
  {
    return new JceAsymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramPrivateKey);
  }
  
  public SymmetricKeyUnwrapper createSymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, SecretKey paramSecretKey)
  {
    return new JceSymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramSecretKey);
  }
}

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

import java.io.IOException;
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSEnvelopedDataGenerator;
import org.bouncycastle.cms.CMSException;

class EnvelopedDataHelper$1
  implements EnvelopedDataHelper.JCECallback
{
  EnvelopedDataHelper$1(EnvelopedDataHelper paramEnvelopedDataHelper, AlgorithmIdentifier paramAlgorithmIdentifier, Key paramKey)
    throws NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, CMSException
  {}
  
  public Object doInJCE()
    throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
  {
    Cipher localCipher = this$0.createCipher(val$encryptionAlgID.getAlgorithm());
    ASN1Encodable localASN1Encodable = val$encryptionAlgID.getParameters();
    String str = val$encryptionAlgID.getAlgorithm().getId();
    if ((localASN1Encodable != null) && (!(localASN1Encodable instanceof ASN1Null))) {
      try
      {
        AlgorithmParameters localAlgorithmParameters = this$0.createAlgorithmParameters(val$encryptionAlgID.getAlgorithm());
        try
        {
          localAlgorithmParameters.init(localASN1Encodable.toASN1Primitive().getEncoded(), "ASN.1");
        }
        catch (IOException localIOException)
        {
          throw new CMSException("error decoding algorithm parameters.", localIOException);
        }
        localCipher.init(2, val$sKey, localAlgorithmParameters);
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
      {
        if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals(CMSEnvelopedDataGenerator.AES128_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES192_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES256_CBC))) {
          localCipher.init(2, val$sKey, new IvParameterSpec(ASN1OctetString.getInstance(localASN1Encodable).getOctets()));
        } else {
          throw localNoSuchAlgorithmException;
        }
      }
    } else if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals("1.2.840.113533.7.66.10"))) {
      localCipher.init(2, val$sKey, new IvParameterSpec(new byte[8]));
    } else {
      localCipher.init(2, val$sKey);
    }
    return localCipher;
  }
}

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

import java.io.IOException;
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;

class EnvelopedDataHelper$2
  implements EnvelopedDataHelper.JCECallback
{
  EnvelopedDataHelper$2(EnvelopedDataHelper paramEnvelopedDataHelper, AlgorithmIdentifier paramAlgorithmIdentifier, Key paramKey)
    throws NoSuchProviderException, InvalidParameterSpecException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, CMSException
  {}
  
  public Object doInJCE()
    throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
  {
    Mac localMac = this$0.createMac(val$macAlgId.getAlgorithm());
    ASN1Encodable localASN1Encodable = val$macAlgId.getParameters();
    String str = val$macAlgId.getAlgorithm().getId();
    if ((localASN1Encodable != null) && (!(localASN1Encodable instanceof ASN1Null))) {
      try
      {
        AlgorithmParameters localAlgorithmParameters = this$0.createAlgorithmParameters(val$macAlgId.getAlgorithm());
        try
        {
          localAlgorithmParameters.init(localASN1Encodable.toASN1Primitive().getEncoded(), "ASN.1");
        }
        catch (IOException localIOException)
        {
          throw new CMSException("error decoding algorithm parameters.", localIOException);
        }
        localMac.init(val$sKey, localAlgorithmParameters.getParameterSpec(IvParameterSpec.class));
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
      {
        throw localNoSuchAlgorithmException;
      }
    } else {
      localMac.init(val$sKey);
    }
    return localMac;
  }
}

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

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.NoSuchPaddingException;
import org.bouncycastle.cms.CMSException;

abstract interface EnvelopedDataHelper$JCECallback
{
  public abstract Object doInJCE()
    throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException;
}

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

import java.io.IOException;
import java.security.AlgorithmParameterGenerator;
import java.security.AlgorithmParameters;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.Cipher;
import javax.crypto.KeyAgreement;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.RC2ParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.RC2CBCParameter;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSAlgorithm;
import org.bouncycastle.cms.CMSEnvelopedDataGenerator;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.SymmetricKeyUnwrapper;
import org.bouncycastle.operator.jcajce.JceAsymmetricKeyUnwrapper;

class EnvelopedDataHelper
{
  protected static final Map BASE_CIPHER_NAMES = new HashMap();
  protected static final Map CIPHER_ALG_NAMES = new HashMap();
  protected static final Map MAC_ALG_NAMES = new HashMap();
  private static final short[] rc2Table = { 189, 86, 234, 242, 162, 241, 172, 42, 176, 147, 209, 156, 27, 51, 253, 208, 48, 4, 182, 220, 125, 223, 50, 75, 247, 203, 69, 155, 49, 187, 33, 90, 65, 159, 225, 217, 74, 77, 158, 218, 160, 104, 44, 195, 39, 95, 128, 54, 62, 238, 251, 149, 26, 254, 206, 168, 52, 169, 19, 240, 166, 63, 216, 12, 120, 36, 175, 35, 82, 193, 103, 23, 245, 102, 144, 231, 232, 7, 184, 96, 72, 230, 30, 83, 243, 146, 164, 114, 140, 8, 21, 110, 134, 0, 132, 250, 244, 127, 138, 66, 25, 246, 219, 205, 20, 141, 80, 18, 186, 60, 6, 78, 236, 179, 53, 17, 161, 136, 142, 43, 148, 153, 183, 113, 116, 211, 228, 191, 58, 222, 150, 14, 188, 10, 237, 119, 252, 55, 107, 3, 121, 137, 98, 198, 215, 192, 210, 124, 106, 139, 34, 163, 91, 5, 93, 2, 117, 213, 97, 227, 24, 143, 85, 81, 173, 31, 11, 94, 133, 229, 194, 87, 99, 202, 61, 108, 180, 197, 204, 112, 178, 145, 89, 13, 71, 32, 200, 79, 88, 224, 1, 226, 22, 56, 196, 111, 59, 15, 101, 70, 190, 126, 45, 123, 130, 249, 64, 181, 29, 115, 248, 235, 38, 199, 135, 151, 37, 84, 177, 40, 170, 152, 157, 165, 100, 109, 122, 212, 16, 129, 68, 239, 73, 214, 174, 46, 221, 118, 92, 47, 167, 28, 201, 9, 105, 154, 131, 207, 41, 57, 185, 233, 76, 255, 67, 171 };
  private static final short[] rc2Ekb = { 93, 190, 155, 139, 17, 153, 110, 77, 89, 243, 133, 166, 63, 183, 131, 197, 228, 115, 107, 58, 104, 90, 192, 71, 160, 100, 52, 12, 241, 208, 82, 165, 185, 30, 150, 67, 65, 216, 212, 44, 219, 248, 7, 119, 42, 202, 235, 239, 16, 28, 22, 13, 56, 114, 47, 137, 193, 249, 128, 196, 109, 174, 48, 61, 206, 32, 99, 254, 230, 26, 199, 184, 80, 232, 36, 23, 252, 37, 111, 187, 106, 163, 68, 83, 217, 162, 1, 171, 188, 182, 31, 152, 238, 154, 167, 45, 79, 158, 142, 172, 224, 198, 73, 70, 41, 244, 148, 138, 175, 225, 91, 195, 179, 123, 87, 209, 124, 156, 237, 135, 64, 140, 226, 203, 147, 20, 201, 97, 46, 229, 204, 246, 94, 168, 92, 214, 117, 141, 98, 149, 88, 105, 118, 161, 74, 181, 85, 9, 120, 51, 130, 215, 221, 121, 245, 27, 11, 222, 38, 33, 40, 116, 4, 151, 86, 223, 60, 240, 55, 57, 220, 255, 6, 164, 234, 66, 8, 218, 180, 113, 176, 207, 18, 122, 78, 250, 108, 29, 132, 0, 200, 127, 145, 69, 170, 43, 194, 177, 143, 213, 186, 242, 173, 25, 178, 103, 54, 247, 15, 10, 146, 125, 227, 157, 233, 144, 62, 35, 39, 102, 19, 236, 129, 21, 189, 34, 191, 159, 126, 169, 81, 75, 76, 251, 2, 211, 112, 134, 49, 231, 59, 5, 3, 84, 96, 72, 101, 24, 210, 205, 95, 50, 136, 14, 53, 253 };
  private JcaJceExtHelper helper;
  
  EnvelopedDataHelper(JcaJceExtHelper paramJcaJceExtHelper)
  {
    helper = paramJcaJceExtHelper;
  }
  
  String getBaseCipherName(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str == null) {
      return paramASN1ObjectIdentifier.getId();
    }
    return str;
  }
  
  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");
  }
  
  Key getJceKey(ASN1ObjectIdentifier paramASN1ObjectIdentifier, GenericKey paramGenericKey)
  {
    if ((paramGenericKey.getRepresentation() instanceof Key)) {
      return (Key)paramGenericKey.getRepresentation();
    }
    if ((paramGenericKey.getRepresentation() instanceof byte[])) {
      return new SecretKeySpec((byte[])paramGenericKey.getRepresentation(), getBaseCipherName(paramASN1ObjectIdentifier));
    }
    throw new IllegalArgumentException("unknown generic key type");
  }
  
  Cipher createCipher(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)CIPHER_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createCipher(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createCipher(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  Mac createMac(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)MAC_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createMac(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createMac(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create mac: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  Cipher createRFC3211Wrapper(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str == null) {
      throw new CMSException("no name for " + paramASN1ObjectIdentifier);
    }
    str = str + "RFC3211Wrap";
    try
    {
      return helper.createCipher(str);
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  KeyAgreement createKeyAgreement(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyAgreement(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyAgreement(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create key pair generator: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  AlgorithmParameterGenerator createAlgorithmParameterGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws GeneralSecurityException
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str != null) {
      try
      {
        return helper.createAlgorithmParameterGenerator(str);
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
    }
    return helper.createAlgorithmParameterGenerator(paramASN1ObjectIdentifier.getId());
  }
  
  Cipher createContentCipher(final Key paramKey, final AlgorithmIdentifier paramAlgorithmIdentifier)
    throws CMSException
  {
    (Cipher)execute(new JCECallback()
    {
      public Object doInJCE()
        throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
      {
        Cipher localCipher = createCipher(paramAlgorithmIdentifier.getAlgorithm());
        ASN1Encodable localASN1Encodable = paramAlgorithmIdentifier.getParameters();
        String str = paramAlgorithmIdentifier.getAlgorithm().getId();
        if ((localASN1Encodable != null) && (!(localASN1Encodable instanceof ASN1Null))) {
          try
          {
            AlgorithmParameters localAlgorithmParameters = createAlgorithmParameters(paramAlgorithmIdentifier.getAlgorithm());
            try
            {
              localAlgorithmParameters.init(localASN1Encodable.toASN1Primitive().getEncoded(), "ASN.1");
            }
            catch (IOException localIOException)
            {
              throw new CMSException("error decoding algorithm parameters.", localIOException);
            }
            localCipher.init(2, paramKey, localAlgorithmParameters);
          }
          catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
          {
            if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals(CMSEnvelopedDataGenerator.AES128_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES192_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES256_CBC))) {
              localCipher.init(2, paramKey, new IvParameterSpec(ASN1OctetString.getInstance(localASN1Encodable).getOctets()));
            } else {
              throw localNoSuchAlgorithmException;
            }
          }
        } else if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals("1.2.840.113533.7.66.10"))) {
          localCipher.init(2, paramKey, new IvParameterSpec(new byte[8]));
        } else {
          localCipher.init(2, paramKey);
        }
        return localCipher;
      }
    });
  }
  
  Mac createContentMac(final Key paramKey, final AlgorithmIdentifier paramAlgorithmIdentifier)
    throws CMSException
  {
    (Mac)execute(new JCECallback()
    {
      public Object doInJCE()
        throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
      {
        Mac localMac = createMac(paramAlgorithmIdentifier.getAlgorithm());
        ASN1Encodable localASN1Encodable = paramAlgorithmIdentifier.getParameters();
        String str = paramAlgorithmIdentifier.getAlgorithm().getId();
        if ((localASN1Encodable != null) && (!(localASN1Encodable instanceof ASN1Null))) {
          try
          {
            AlgorithmParameters localAlgorithmParameters = createAlgorithmParameters(paramAlgorithmIdentifier.getAlgorithm());
            try
            {
              localAlgorithmParameters.init(localASN1Encodable.toASN1Primitive().getEncoded(), "ASN.1");
            }
            catch (IOException localIOException)
            {
              throw new CMSException("error decoding algorithm parameters.", localIOException);
            }
            localMac.init(paramKey, localAlgorithmParameters.getParameterSpec(IvParameterSpec.class));
          }
          catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
          {
            throw localNoSuchAlgorithmException;
          }
        } else {
          localMac.init(paramKey);
        }
        return localMac;
      }
    });
  }
  
  AlgorithmParameters createAlgorithmParameters(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws NoSuchAlgorithmException, NoSuchProviderException
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str != null) {
      try
      {
        return helper.createAlgorithmParameters(str);
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
    }
    return helper.createAlgorithmParameters(paramASN1ObjectIdentifier.getId());
  }
  
  KeyPairGenerator createKeyPairGenerator(DERObjectIdentifier paramDERObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)BASE_CIPHER_NAMES.get(paramDERObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyPairGenerator(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyPairGenerator(paramDERObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create key pair generator: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  public KeyGenerator createKeyGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyGenerator(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyGenerator(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create key generator: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  AlgorithmParameters generateParameters(ASN1ObjectIdentifier paramASN1ObjectIdentifier, SecretKey paramSecretKey, SecureRandom paramSecureRandom)
    throws CMSException
  {
    try
    {
      AlgorithmParameterGenerator localAlgorithmParameterGenerator = createAlgorithmParameterGenerator(paramASN1ObjectIdentifier);
      if (paramASN1ObjectIdentifier.equals(CMSEnvelopedDataGenerator.RC2_CBC))
      {
        byte[] arrayOfByte = new byte[8];
        paramSecureRandom.nextBytes(arrayOfByte);
        try
        {
          localAlgorithmParameterGenerator.init(new RC2ParameterSpec(paramSecretKey.getEncoded().length * 8, arrayOfByte), paramSecureRandom);
        }
        catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
        {
          throw new CMSException("parameters generation error: " + localInvalidAlgorithmParameterException, localInvalidAlgorithmParameterException);
        }
      }
      return localAlgorithmParameterGenerator.generateParameters();
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      return null;
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("exception creating algorithm parameter generator: " + localGeneralSecurityException, localGeneralSecurityException);
    }
  }
  
  AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier paramASN1ObjectIdentifier, AlgorithmParameters paramAlgorithmParameters)
    throws CMSException
  {
    Object localObject;
    if (paramAlgorithmParameters != null) {
      try
      {
        localObject = ASN1Primitive.fromByteArray(paramAlgorithmParameters.getEncoded("ASN.1"));
      }
      catch (IOException localIOException)
      {
        throw new CMSException("cannot encode parameters: " + localIOException.getMessage(), localIOException);
      }
    } else {
      localObject = DERNull.INSTANCE;
    }
    return new AlgorithmIdentifier(paramASN1ObjectIdentifier, (ASN1Encodable)localObject);
  }
  
  static Object execute(JCECallback paramJCECallback)
    throws CMSException
  {
    try
    {
      return paramJCECallback.doInJCE();
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      throw new CMSException("can't find algorithm.", localNoSuchAlgorithmException);
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
      throw new CMSException("key invalid in message.", localInvalidKeyException);
    }
    catch (NoSuchProviderException localNoSuchProviderException)
    {
      throw new CMSException("can't find provider.", localNoSuchProviderException);
    }
    catch (NoSuchPaddingException localNoSuchPaddingException)
    {
      throw new CMSException("required padding not supported.", localNoSuchPaddingException);
    }
    catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
    {
      throw new CMSException("algorithm parameters invalid.", localInvalidAlgorithmParameterException);
    }
    catch (InvalidParameterSpecException localInvalidParameterSpecException)
    {
      throw new CMSException("MAC algorithm parameter spec invalid.", localInvalidParameterSpecException);
    }
  }
  
  public KeyFactory createKeyFactory(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    try
    {
      String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyFactory(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyFactory(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot create key factory: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  public JceAsymmetricKeyUnwrapper createAsymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, PrivateKey paramPrivateKey)
  {
    return helper.createAsymmetricUnwrapper(paramAlgorithmIdentifier, paramPrivateKey);
  }
  
  public SymmetricKeyUnwrapper createSymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, SecretKey paramSecretKey)
  {
    return helper.createSymmetricUnwrapper(paramAlgorithmIdentifier, paramSecretKey);
  }
  
  public AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier paramASN1ObjectIdentifier, AlgorithmParameterSpec paramAlgorithmParameterSpec)
  {
    if ((paramAlgorithmParameterSpec instanceof IvParameterSpec)) {
      return new AlgorithmIdentifier(paramASN1ObjectIdentifier, new DEROctetString(((IvParameterSpec)paramAlgorithmParameterSpec).getIV()));
    }
    if ((paramAlgorithmParameterSpec instanceof RC2ParameterSpec))
    {
      RC2ParameterSpec localRC2ParameterSpec = (RC2ParameterSpec)paramAlgorithmParameterSpec;
      int i = ((RC2ParameterSpec)paramAlgorithmParameterSpec).getEffectiveKeyBits();
      if (i != -1)
      {
        int j;
        if (i < 256) {
          j = rc2Table[i];
        } else {
          j = i;
        }
        return new AlgorithmIdentifier(paramASN1ObjectIdentifier, new RC2CBCParameter(j, localRC2ParameterSpec.getIV()));
      }
      return new AlgorithmIdentifier(paramASN1ObjectIdentifier, new RC2CBCParameter(localRC2ParameterSpec.getIV()));
    }
    throw new IllegalStateException("unknown parameter spec: " + paramAlgorithmParameterSpec);
  }
  
  static
  {
    BASE_CIPHER_NAMES.put(CMSAlgorithm.DES_EDE3_CBC, "DESEDE");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.AES128_CBC, "AES");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.AES192_CBC, "AES");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.AES256_CBC, "AES");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.RC2_CBC, "RC2");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.CAST5_CBC, "CAST5");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.CAMELLIA128_CBC, "Camellia");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.CAMELLIA192_CBC, "Camellia");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.CAMELLIA256_CBC, "Camellia");
    BASE_CIPHER_NAMES.put(CMSAlgorithm.SEED_CBC, "SEED");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.DES_EDE3_CBC, "DESEDE/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES128_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES192_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES256_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(PKCSObjectIdentifiers.rsaEncryption, "RSA/ECB/PKCS1Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.CAST5_CBC, "CAST5/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.CAMELLIA128_CBC, "Camellia/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.CAMELLIA192_CBC, "Camellia/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.CAMELLIA256_CBC, "Camellia/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.SEED_CBC, "SEED/CBC/PKCS5Padding");
    MAC_ALG_NAMES.put(CMSAlgorithm.DES_EDE3_CBC, "DESEDEMac");
    MAC_ALG_NAMES.put(CMSAlgorithm.AES128_CBC, "AESMac");
    MAC_ALG_NAMES.put(CMSAlgorithm.AES192_CBC, "AESMac");
    MAC_ALG_NAMES.put(CMSAlgorithm.AES256_CBC, "AESMac");
    MAC_ALG_NAMES.put(CMSAlgorithm.RC2_CBC, "RC2Mac");
  }
  
  static abstract interface JCECallback
  {
    public abstract Object doInJCE()
      throws CMSException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException;
  }
}

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

import java.security.PrivateKey;
import javax.crypto.SecretKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.jcajce.JcaJceHelper;
import org.bouncycastle.operator.SymmetricKeyUnwrapper;
import org.bouncycastle.operator.jcajce.JceAsymmetricKeyUnwrapper;

public abstract interface JcaJceExtHelper
  extends JcaJceHelper
{
  public abstract JceAsymmetricKeyUnwrapper createAsymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, PrivateKey paramPrivateKey);
  
  public abstract SymmetricKeyUnwrapper createSymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, SecretKey paramSecretKey);
}

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

import java.io.IOException;
import java.security.cert.X509CertSelector;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cms.KeyTransRecipientId;
import org.bouncycastle.cms.SignerId;

public class JcaSelectorConverter
{
  public SignerId getSignerId(X509CertSelector paramX509CertSelector)
  {
    try
    {
      if (paramX509CertSelector.getSubjectKeyIdentifier() != null) {
        return new SignerId(X500Name.getInstance(paramX509CertSelector.getIssuerAsBytes()), paramX509CertSelector.getSerialNumber(), ASN1OctetString.getInstance(paramX509CertSelector.getSubjectKeyIdentifier()).getOctets());
      }
      return new SignerId(X500Name.getInstance(paramX509CertSelector.getIssuerAsBytes()), paramX509CertSelector.getSerialNumber());
    }
    catch (IOException localIOException)
    {
      throw new IllegalArgumentException("unable to convert issuer: " + localIOException.getMessage());
    }
  }
  
  public KeyTransRecipientId getKeyTransRecipientId(X509CertSelector paramX509CertSelector)
  {
    try
    {
      if (paramX509CertSelector.getSubjectKeyIdentifier() != null) {
        return new KeyTransRecipientId(X500Name.getInstance(paramX509CertSelector.getIssuerAsBytes()), paramX509CertSelector.getSerialNumber(), ASN1OctetString.getInstance(paramX509CertSelector.getSubjectKeyIdentifier()).getOctets());
      }
      return new KeyTransRecipientId(X500Name.getInstance(paramX509CertSelector.getIssuerAsBytes()), paramX509CertSelector.getSerialNumber());
    }
    catch (IOException localIOException)
    {
      throw new IllegalArgumentException("unable to convert issuer: " + localIOException.getMessage());
    }
  }
}

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

import java.math.BigInteger;
import java.security.cert.X509Certificate;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cms.SignerId;

public class JcaSignerId
  extends SignerId
{
  public JcaSignerId(X509Certificate paramX509Certificate)
  {
    super(convertPrincipal(paramX509Certificate.getIssuerX500Principal()), paramX509Certificate.getSerialNumber(), CMSUtils.getSubjectKeyId(paramX509Certificate));
  }
  
  public JcaSignerId(X500Principal paramX500Principal, BigInteger paramBigInteger)
  {
    super(convertPrincipal(paramX500Principal), paramBigInteger);
  }
  
  public JcaSignerId(X500Principal paramX500Principal, BigInteger paramBigInteger, byte[] paramArrayOfByte)
  {
    super(convertPrincipal(paramX500Principal), paramBigInteger, paramArrayOfByte);
  }
  
  private static X500Name convertPrincipal(X500Principal paramX500Principal)
  {
    if (paramX500Principal == null) {
      return null;
    }
    return X500Name.getInstance(paramX500Principal.getEncoded());
  }
}

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

import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import org.bouncycastle.cms.CMSAttributeTableGenerator;
import org.bouncycastle.cms.SignerInfoGenerator;
import org.bouncycastle.cms.SignerInfoGeneratorBuilder;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.operator.OperatorCreationException;

public class JcaSignerInfoGeneratorBuilder
{
  private SignerInfoGeneratorBuilder builder;
  
  public JcaSignerInfoGeneratorBuilder(DigestCalculato
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