bcpkix-jdk15on-147

ERSequenceGenerator localBERSequenceGenerator3 = new BERSequenceGenerator(localBERSequenceGenerator2.getRawOutputStream());
      localBERSequenceGenerator3.addObject(CMSObjectIdentifiers.data);
      AlgorithmIdentifier localAlgorithmIdentifier = paramOutputEncryptor.getAlgorithmIdentifier();
      localBERSequenceGenerator3.getRawOutputStream().write(localAlgorithmIdentifier.getEncoded());
      OutputStream localOutputStream = CMSUtils.createBEROctetOutputStream(localBERSequenceGenerator3.getRawOutputStream(), 0, false, _bufferSize);
      return new CmsEnvelopedDataOutputStream(paramOutputEncryptor.getOutputStream(localOutputStream), localBERSequenceGenerator1, localBERSequenceGenerator2, localBERSequenceGenerator3);
    }
    catch (IOException localIOException)
    {
      throw new CMSException("exception decoding algorithm parameters.", localIOException);
    }
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString1, String paramString2)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException, IOException
  {
    return open(paramOutputStream, paramString1, CMSUtils.getProvider(paramString2));
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString, Provider paramProvider)
    throws NoSuchAlgorithmException, CMSException, IOException
  {
    KeyGenerator localKeyGenerator = CMSEnvelopedHelper.INSTANCE.createSymmetricKeyGenerator(paramString, paramProvider);
    localKeyGenerator.init(rand);
    return open(paramOutputStream, paramString, -1, localKeyGenerator.getProvider(), paramProvider);
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString1, int paramInt, String paramString2)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException, IOException
  {
    return open(paramOutputStream, paramString1, paramInt, CMSUtils.getProvider(paramString2));
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString, int paramInt, Provider paramProvider)
    throws NoSuchAlgorithmException, CMSException, IOException
  {
    KeyGenerator localKeyGenerator = CMSEnvelopedHelper.INSTANCE.createSymmetricKeyGenerator(paramString, paramProvider);
    localKeyGenerator.init(paramInt, rand);
    return open(paramOutputStream, paramString, -1, localKeyGenerator.getProvider(), paramProvider);
  }
  
  public OutputStream open(OutputStream paramOutputStream, OutputEncryptor paramOutputEncryptor)
    throws CMSException, IOException
  {
    return doOpen(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), paramOutputStream, paramOutputEncryptor);
  }
  
  public OutputStream open(ASN1ObjectIdentifier paramASN1ObjectIdentifier, OutputStream paramOutputStream, OutputEncryptor paramOutputEncryptor)
    throws CMSException, IOException
  {
    return doOpen(paramASN1ObjectIdentifier, paramOutputStream, paramOutputEncryptor);
  }
  
  private class CmsEnvelopedDataOutputStream
    extends OutputStream
  {
    private OutputStream _out;
    private BERSequenceGenerator _cGen;
    private BERSequenceGenerator _envGen;
    private BERSequenceGenerator _eiGen;
    
    public CmsEnvelopedDataOutputStream(OutputStream paramOutputStream, BERSequenceGenerator paramBERSequenceGenerator1, BERSequenceGenerator paramBERSequenceGenerator2, BERSequenceGenerator paramBERSequenceGenerator3)
    {
      _out = paramOutputStream;
      _cGen = paramBERSequenceGenerator1;
      _envGen = paramBERSequenceGenerator2;
      _eiGen = paramBERSequenceGenerator3;
    }
    
    public void write(int paramInt)
      throws IOException
    {
      _out.write(paramInt);
    }
    
    public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
      throws IOException
    {
      _out.write(paramArrayOfByte, paramInt1, paramInt2);
    }
    
    public void write(byte[] paramArrayOfByte)
      throws IOException
    {
      _out.write(paramArrayOfByte);
    }
    
    public void close()
      throws IOException
    {
      _out.close();
      _eiGen.close();
      if (unprotectedAttributeGenerator != null)
      {
        AttributeTable localAttributeTable = unprotectedAttributeGenerator.getAttributes(new HashMap());
        BERSet localBERSet = new BERSet(localAttributeTable.toASN1EncodableVector());
        _envGen.addObject(new DERTaggedObject(false, 1, localBERSet));
      }
      _envGen.close();
      _cGen.close();
    }
  }
}

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

import java.io.IOException;
import java.security.AlgorithmParameters;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.crypto.SecretKey;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.cms.KEKIdentifier;
import org.bouncycastle.asn1.cms.OriginatorInfo;
import org.bouncycastle.asn1.kisa.KISAObjectIdentifiers;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.ntt.NTTObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.cms.jcajce.JceKEKRecipientInfoGenerator;
import org.bouncycastle.cms.jcajce.JceKeyAgreeRecipientInfoGenerator;
import org.bouncycastle.cms.jcajce.JceKeyTransRecipientInfoGenerator;
import org.bouncycastle.cms.jcajce.JcePasswordRecipientInfoGenerator;

public class CMSEnvelopedGenerator
{
  public static final String DES_EDE3_CBC = PKCSObjectIdentifiers.des_EDE3_CBC.getId();
  public static final String RC2_CBC = PKCSObjectIdentifiers.RC2_CBC.getId();
  public static final String IDEA_CBC = "1.3.6.1.4.1.188.7.1.1.2";
  public static final String CAST5_CBC = "1.2.840.113533.7.66.10";
  public static final String AES128_CBC = NISTObjectIdentifiers.id_aes128_CBC.getId();
  public static final String AES192_CBC = NISTObjectIdentifiers.id_aes192_CBC.getId();
  public static final String AES256_CBC = NISTObjectIdentifiers.id_aes256_CBC.getId();
  public static final String CAMELLIA128_CBC = NTTObjectIdentifiers.id_camellia128_cbc.getId();
  public static final String CAMELLIA192_CBC = NTTObjectIdentifiers.id_camellia192_cbc.getId();
  public static final String CAMELLIA256_CBC = NTTObjectIdentifiers.id_camellia256_cbc.getId();
  public static final String SEED_CBC = KISAObjectIdentifiers.id_seedCBC.getId();
  public static final String DES_EDE3_WRAP = PKCSObjectIdentifiers.id_alg_CMS3DESwrap.getId();
  public static final String AES128_WRAP = NISTObjectIdentifiers.id_aes128_wrap.getId();
  public static final String AES192_WRAP = NISTObjectIdentifiers.id_aes192_wrap.getId();
  public static final String AES256_WRAP = NISTObjectIdentifiers.id_aes256_wrap.getId();
  public static final String CAMELLIA128_WRAP = NTTObjectIdentifiers.id_camellia128_wrap.getId();
  public static final String CAMELLIA192_WRAP = NTTObjectIdentifiers.id_camellia192_wrap.getId();
  public static final String CAMELLIA256_WRAP = NTTObjectIdentifiers.id_camellia256_wrap.getId();
  public static final String SEED_WRAP = KISAObjectIdentifiers.id_npki_app_cmsSeed_wrap.getId();
  public static final String ECDH_SHA1KDF = X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme.getId();
  public static final String ECMQV_SHA1KDF = X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme.getId();
  final List oldRecipientInfoGenerators = new ArrayList();
  final List recipientInfoGenerators = new ArrayList();
  protected CMSAttributeTableGenerator unprotectedAttributeGenerator = null;
  final SecureRandom rand;
  protected OriginatorInfo originatorInfo;
  
  public CMSEnvelopedGenerator()
  {
    this(new SecureRandom());
  }
  
  public CMSEnvelopedGenerator(SecureRandom paramSecureRandom)
  {
    rand = paramSecureRandom;
  }
  
  public void setUnprotectedAttributeGenerator(CMSAttributeTableGenerator paramCMSAttributeTableGenerator)
  {
    unprotectedAttributeGenerator = paramCMSAttributeTableGenerator;
  }
  
  public void setOriginatorInfo(OriginatorInformation paramOriginatorInformation)
  {
    originatorInfo = paramOriginatorInformation.toASN1Structure();
  }
  
  /**
   * @deprecated
   */
  public void addKeyTransRecipient(X509Certificate paramX509Certificate)
    throws IllegalArgumentException
  {
    try
    {
      oldRecipientInfoGenerators.add(new JceKeyTransRecipientInfoGenerator(paramX509Certificate));
    }
    catch (CertificateEncodingException localCertificateEncodingException)
    {
      throw new IllegalArgumentException("unable to encode certificate: " + localCertificateEncodingException.getMessage());
    }
  }
  
  /**
   * @deprecated
   */
  public void addKeyTransRecipient(PublicKey paramPublicKey, byte[] paramArrayOfByte)
    throws IllegalArgumentException
  {
    oldRecipientInfoGenerators.add(new JceKeyTransRecipientInfoGenerator(paramArrayOfByte, paramPublicKey));
  }
  
  /**
   * @deprecated
   */
  public void addKEKRecipient(SecretKey paramSecretKey, byte[] paramArrayOfByte)
  {
    addKEKRecipient(paramSecretKey, new KEKIdentifier(paramArrayOfByte, null, null));
  }
  
  /**
   * @deprecated
   */
  public void addKEKRecipient(SecretKey paramSecretKey, KEKIdentifier paramKEKIdentifier)
  {
    oldRecipientInfoGenerators.add(new JceKEKRecipientInfoGenerator(paramKEKIdentifier, paramSecretKey));
  }
  
  /**
   * @deprecated
   */
  public void addPasswordRecipient(CMSPBEKey paramCMSPBEKey, String paramString)
  {
    oldRecipientInfoGenerators.add(new JcePasswordRecipientInfoGenerator(new ASN1ObjectIdentifier(paramString), paramCMSPBEKey.getPassword()).setSaltAndIterationCount(paramCMSPBEKey.getSalt(), paramCMSPBEKey.getIterationCount()).setPasswordConversionScheme((paramCMSPBEKey instanceof PKCS5Scheme2UTF8PBEKey) ? 1 : 0));
  }
  
  /**
   * @deprecated
   */
  public void addKeyAgreementRecipient(String paramString1, PrivateKey paramPrivateKey, PublicKey paramPublicKey, X509Certificate paramX509Certificate, String paramString2, String paramString3)
    throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException
  {
    addKeyAgreementRecipient(paramString1, paramPrivateKey, paramPublicKey, paramX509Certificate, paramString2, CMSUtils.getProvider(paramString3));
  }
  
  /**
   * @deprecated
   */
  public void addKeyAgreementRecipient(String paramString1, PrivateKey paramPrivateKey, PublicKey paramPublicKey, X509Certificate paramX509Certificate, String paramString2, Provider paramProvider)
    throws NoSuchAlgorithmException, InvalidKeyException
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.add(paramX509Certificate);
    addKeyAgreementRecipients(paramString1, paramPrivateKey, paramPublicKey, localArrayList, paramString2, paramProvider);
  }
  
  /**
   * @deprecated
   */
  public void addKeyAgreementRecipients(String paramString1, PrivateKey paramPrivateKey, PublicKey paramPublicKey, Collection paramCollection, String paramString2, String paramString3)
    throws NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException
  {
    addKeyAgreementRecipients(paramString1, paramPrivateKey, paramPublicKey, paramCollection, paramString2, CMSUtils.getProvider(paramString3));
  }
  
  /**
   * @deprecated
   */
  public void addKeyAgreementRecipients(String paramString1, PrivateKey paramPrivateKey, PublicKey paramPublicKey, Collection paramCollection, String paramString2, Provider paramProvider)
    throws NoSuchAlgorithmException, InvalidKeyException
  {
    JceKeyAgreeRecipientInfoGenerator localJceKeyAgreeRecipientInfoGenerator = new JceKeyAgreeRecipientInfoGenerator(new ASN1ObjectIdentifier(paramString1), paramPrivateKey, paramPublicKey, new ASN1ObjectIdentifier(paramString2)).setProvider(paramProvider);
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext()) {
      try
      {
        localJceKeyAgreeRecipientInfoGenerator.addRecipient((X509Certificate)localIterator.next());
      }
      catch (CertificateEncodingException localCertificateEncodingException)
      {
        throw new IllegalArgumentException("unable to encode certificate: " + localCertificateEncodingException.getMessage());
      }
    }
    oldRecipientInfoGenerators.add(localJceKeyAgreeRecipientInfoGenerator);
  }
  
  public void addRecipientInfoGenerator(RecipientInfoGenerator paramRecipientInfoGenerator)
  {
    recipientInfoGenerators.add(paramRecipientInfoGenerator);
  }
  
  protected AlgorithmIdentifier getAlgorithmIdentifier(String paramString, AlgorithmParameters paramAlgorithmParameters)
    throws IOException
  {
    Object localObject;
    if (paramAlgorithmParameters != null) {
      localObject = ASN1Primitive.fromByteArray(paramAlgorithmParameters.getEncoded("ASN.1"));
    } else {
      localObject = DERNull.INSTANCE;
    }
    return new AlgorithmIdentifier(new ASN1ObjectIdentifier(paramString), (ASN1Encodable)localObject);
  }
  
  protected void convertOldRecipients(SecureRandom paramSecureRandom, Provider paramProvider)
  {
    Iterator localIterator = oldRecipientInfoGenerators.iterator();
    while (localIterator.hasNext())
    {
      Object localObject1 = localIterator.next();
      Object localObject2;
      if ((localObject1 instanceof JceKeyTransRecipientInfoGenerator))
      {
        localObject2 = (JceKeyTransRecipientInfoGenerator)localObject1;
        if (paramProvider != null) {
          ((JceKeyTransRecipientInfoGenerator)localObject2).setProvider(paramProvider);
        }
        recipientInfoGenerators.add(localObject2);
      }
      else if ((localObject1 instanceof KEKRecipientInfoGenerator))
      {
        localObject2 = (JceKEKRecipientInfoGenerator)localObject1;
        if (paramProvider != null) {
          ((JceKEKRecipientInfoGenerator)localObject2).setProvider(paramProvider);
        }
        ((JceKEKRecipientInfoGenerator)localObject2).setSecureRandom(paramSecureRandom);
        recipientInfoGenerators.add(localObject2);
      }
      else if ((localObject1 instanceof JcePasswordRecipientInfoGenerator))
      {
        localObject2 = (JcePasswordRecipientInfoGenerator)localObject1;
        if (paramProvider != null) {
          ((JcePasswordRecipientInfoGenerator)localObject2).setProvider(paramProvider);
        }
        ((JcePasswordRecipientInfoGenerator)localObject2).setSecureRandom(paramSecureRandom);
        recipientInfoGenerators.add(localObject2);
      }
      else if ((localObject1 instanceof JceKeyAgreeRecipientInfoGenerator))
      {
        localObject2 = (JceKeyAgreeRecipientInfoGenerator)localObject1;
        if (paramProvider != null) {
          ((JceKeyAgreeRecipientInfoGenerator)localObject2).setProvider(paramProvider);
        }
        ((JceKeyAgreeRecipientInfoGenerator)localObject2).setSecureRandom(paramSecureRandom);
        recipientInfoGenerators.add(localObject2);
      }
    }
    oldRecipientInfoGenerators.clear();
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

class CMSEnvelopedHelper$CMSAuthenticatedSecureReadable
  implements CMSSecureReadable
{
  private AlgorithmIdentifier algorithm;
  private CMSReadable readable;
  
  CMSEnvelopedHelper$CMSAuthenticatedSecureReadable(AlgorithmIdentifier paramAlgorithmIdentifier, CMSReadable paramCMSReadable)
  {
    algorithm = paramAlgorithmIdentifier;
    readable = paramCMSReadable;
  }
  
  public InputStream getInputStream()
    throws IOException, CMSException
  {
    return readable.getInputStream();
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.operator.DigestCalculator;

class CMSEnvelopedHelper$CMSDigestAuthenticatedSecureReadable$1
  extends FilterInputStream
{
  CMSEnvelopedHelper$CMSDigestAuthenticatedSecureReadable$1(CMSEnvelopedHelper.CMSDigestAuthenticatedSecureReadable paramCMSDigestAuthenticatedSecureReadable, InputStream paramInputStream)
    throws IOException
  {
    super(paramInputStream);
  }
  
  public int read()
    throws IOException
  {
    int i = in.read();
    if (i >= 0) {
      CMSEnvelopedHelper.CMSDigestAuthenticatedSecureReadable.access$000(this$0).getOutputStream().write(i);
    }
    return i;
  }
  
  public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    int i = in.read(paramArrayOfByte, paramInt1, paramInt2);
    if (i >= 0) {
      CMSEnvelopedHelper.CMSDigestAuthenticatedSecureReadable.access$000(this$0).getOutputStream().write(paramArrayOfByte, paramInt1, i);
    }
    return i;
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.operator.DigestCalculator;

class CMSEnvelopedHelper$CMSDigestAuthenticatedSecureReadable
  implements CMSSecureReadable
{
  private DigestCalculator digestCalculator;
  private CMSReadable readable;
  
  public CMSEnvelopedHelper$CMSDigestAuthenticatedSecureReadable(DigestCalculator paramDigestCalculator, CMSReadable paramCMSReadable)
  {
    digestCalculator = paramDigestCalculator;
    readable = paramCMSReadable;
  }
  
  public InputStream getInputStream()
    throws IOException, CMSException
  {
    new FilterInputStream(readable.getInputStream())
    {
      public int read()
        throws IOException
      {
        int i = in.read();
        if (i >= 0) {
          digestCalculator.getOutputStream().write(i);
        }
        return i;
      }
      
      public int read(byte[] paramAnonymousArrayOfByte, int paramAnonymousInt1, int paramAnonymousInt2)
        throws IOException
      {
        int i = in.read(paramAnonymousArrayOfByte, paramAnonymousInt1, paramAnonymousInt2);
        if (i >= 0) {
          digestCalculator.getOutputStream().write(paramAnonymousArrayOfByte, paramAnonymousInt1, i);
        }
        return i;
      }
    };
  }
  
  public byte[] getDigest()
  {
    return digestCalculator.getDigest();
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

class CMSEnvelopedHelper$CMSEnvelopedSecureReadable
  implements CMSSecureReadable
{
  private AlgorithmIdentifier algorithm;
  private CMSReadable readable;
  
  CMSEnvelopedHelper$CMSEnvelopedSecureReadable(AlgorithmIdentifier paramAlgorithmIdentifier, CMSReadable paramCMSReadable)
  {
    algorithm = paramAlgorithmIdentifier;
    readable = paramCMSReadable;
  }
  
  public InputStream getInputStream()
    throws IOException, CMSException
  {
    return readable.getInputStream();
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.crypto.KeyGenerator;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.cms.KEKRecipientInfo;
import org.bouncycastle.asn1.cms.KeyAgreeRecipientInfo;
import org.bouncycastle.asn1.cms.KeyTransRecipientInfo;
import org.bouncycastle.asn1.cms.PasswordRecipientInfo;
import org.bouncycastle.asn1.cms.RecipientInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.DigestCalculator;

class CMSEnvelopedHelper
{
  static final CMSEnvelopedHelper INSTANCE = new CMSEnvelopedHelper();
  private static final Map KEYSIZES = new HashMap();
  private static final Map BASE_CIPHER_NAMES = new HashMap();
  private static final Map CIPHER_ALG_NAMES = new HashMap();
  private static final Map MAC_ALG_NAMES = new HashMap();
  
  KeyGenerator createSymmetricKeyGenerator(String paramString, Provider paramProvider)
    throws NoSuchAlgorithmException
  {
    try
    {
      return createKeyGenerator(paramString, paramProvider);
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException1)
    {
      try
      {
        String str = (String)BASE_CIPHER_NAMES.get(paramString);
        if (str != null) {
          return createKeyGenerator(str, paramProvider);
        }
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException2) {}
      if (paramProvider != null) {
        return createSymmetricKeyGenerator(paramString, null);
      }
      throw localNoSuchAlgorithmException1;
    }
  }
  
  int getKeySize(String paramString)
  {
    Integer localInteger = (Integer)KEYSIZES.get(paramString);
    if (localInteger == null) {
      throw new IllegalArgumentException("no keysize for " + paramString);
    }
    return localInteger.intValue();
  }
  
  private KeyGenerator createKeyGenerator(String paramString, Provider paramProvider)
    throws NoSuchAlgorithmException
  {
    if (paramProvider != null) {
      return KeyGenerator.getInstance(paramString, paramProvider);
    }
    return KeyGenerator.getInstance(paramString);
  }
  
  static RecipientInformationStore buildRecipientInformationStore(ASN1Set paramASN1Set, AlgorithmIdentifier paramAlgorithmIdentifier, CMSSecureReadable paramCMSSecureReadable)
  {
    return buildRecipientInformationStore(paramASN1Set, paramAlgorithmIdentifier, paramCMSSecureReadable, null);
  }
  
  static RecipientInformationStore buildRecipientInformationStore(ASN1Set paramASN1Set, AlgorithmIdentifier paramAlgorithmIdentifier, CMSSecureReadable paramCMSSecureReadable, AuthAttributesProvider paramAuthAttributesProvider)
  {
    ArrayList localArrayList = new ArrayList();
    for (int i = 0; i != paramASN1Set.size(); i++)
    {
      RecipientInfo localRecipientInfo = RecipientInfo.getInstance(paramASN1Set.getObjectAt(i));
      readRecipientInfo(localArrayList, localRecipientInfo, paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider);
    }
    return new RecipientInformationStore(localArrayList);
  }
  
  private static void readRecipientInfo(List paramList, RecipientInfo paramRecipientInfo, AlgorithmIdentifier paramAlgorithmIdentifier, CMSSecureReadable paramCMSSecureReadable, AuthAttributesProvider paramAuthAttributesProvider)
  {
    ASN1Encodable localASN1Encodable = paramRecipientInfo.getInfo();
    if ((localASN1Encodable instanceof KeyTransRecipientInfo)) {
      paramList.add(new KeyTransRecipientInformation((KeyTransRecipientInfo)localASN1Encodable, paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider));
    } else if ((localASN1Encodable instanceof KEKRecipientInfo)) {
      paramList.add(new KEKRecipientInformation((KEKRecipientInfo)localASN1Encodable, paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider));
    } else if ((localASN1Encodable instanceof KeyAgreeRecipientInfo)) {
      KeyAgreeRecipientInformation.readRecipientInfo(paramList, (KeyAgreeRecipientInfo)localASN1Encodable, paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider);
    } else if ((localASN1Encodable instanceof PasswordRecipientInfo)) {
      paramList.add(new PasswordRecipientInformation((PasswordRecipientInfo)localASN1Encodable, paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider));
    }
  }
  
  static
  {
    KEYSIZES.put(CMSEnvelopedGenerator.DES_EDE3_CBC, new Integer(192));
    KEYSIZES.put(CMSEnvelopedGenerator.AES128_CBC, new Integer(128));
    KEYSIZES.put(CMSEnvelopedGenerator.AES192_CBC, new Integer(192));
    KEYSIZES.put(CMSEnvelopedGenerator.AES256_CBC, new Integer(256));
    BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.DES_EDE3_CBC, "DESEDE");
    BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES128_CBC, "AES");
    BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES192_CBC, "AES");
    BASE_CIPHER_NAMES.put(CMSEnvelopedGenerator.AES256_CBC, "AES");
    CIPHER_ALG_NAMES.put(CMSEnvelopedGenerator.DES_EDE3_CBC, "DESEDE/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSEnvelopedGenerator.AES128_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSEnvelopedGenerator.AES192_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSEnvelopedGenerator.AES256_CBC, "AES/CBC/PKCS5Padding");
    MAC_ALG_NAMES.put(CMSEnvelopedGenerator.DES_EDE3_CBC, "DESEDEMac");
    MAC_ALG_NAMES.put(CMSEnvelopedGenerator.AES128_CBC, "AESMac");
    MAC_ALG_NAMES.put(CMSEnvelopedGenerator.AES192_CBC, "AESMac");
    MAC_ALG_NAMES.put(CMSEnvelopedGenerator.AES256_CBC, "AESMac");
  }
  
  static class CMSAuthenticatedSecureReadable
    implements CMSSecureReadable
  {
    private AlgorithmIdentifier algorithm;
    private CMSReadable readable;
    
    CMSAuthenticatedSecureReadable(AlgorithmIdentifier paramAlgorithmIdentifier, CMSReadable paramCMSReadable)
    {
      algorithm = paramAlgorithmIdentifier;
      readable = paramCMSReadable;
    }
    
    public InputStream getInputStream()
      throws IOException, CMSException
    {
      return readable.getInputStream();
    }
  }
  
  static class CMSDigestAuthenticatedSecureReadable
    implements CMSSecureReadable
  {
    private DigestCalculator digestCalculator;
    private CMSReadable readable;
    
    public CMSDigestAuthenticatedSecureReadable(DigestCalculator paramDigestCalculator, CMSReadable paramCMSReadable)
    {
      digestCalculator = paramDigestCalculator;
      readable = paramCMSReadable;
    }
    
    public InputStream getInputStream()
      throws IOException, CMSException
    {
      new FilterInputStream(readable.getInputStream())
      {
        public int read()
          throws IOException
        {
          int i = in.read();
          if (i >= 0) {
            digestCalculator.getOutputStream().write(i);
          }
          return i;
        }
        
        public int read(byte[] paramAnonymousArrayOfByte, int paramAnonymousInt1, int paramAnonymousInt2)
          throws IOException
        {
          int i = in.read(paramAnonymousArrayOfByte, paramAnonymousInt1, paramAnonymousInt2);
          if (i >= 0) {
            digestCalculator.getOutputStream().write(paramAnonymousArrayOfByte, paramAnonymousInt1, i);
          }
          return i;
        }
      };
    }
    
    public byte[] getDigest()
    {
      return digestCalculator.getDigest();
    }
  }
  
  static class CMSEnvelopedSecureReadable
    implements CMSSecureReadable
  {
    private AlgorithmIdentifier algorithm;
    private CMSReadable readable;
    
    CMSEnvelopedSecureReadable(AlgorithmIdentifier paramAlgorithmIdentifier, CMSReadable paramCMSReadable)
    {
      algorithm = paramAlgorithmIdentifier;
      readable = paramCMSReadable;
    }
    
    public InputStream getInputStream()
      throws IOException, CMSException
    {
      return readable.getInputStream();
    }
  }
}

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

public class CMSException
  extends Exception
{
  Exception e;
  
  public CMSException(String paramString)
  {
    super(paramString);
  }
  
  public CMSException(String paramString, Exception paramException)
  {
    super(paramString);
    e = paramException;
  }
  
  public Exception getUnderlyingException()
  {
    return e;
  }
  
  public Throwable getCause()
  {
    return e;
  }
}

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

import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.interfaces.PBEKey;
import javax.crypto.spec.PBEParameterSpec;

public abstract class CMSPBEKey
  implements PBEKey
{
  private char[] password;
  private byte[] salt;
  private int iterationCount;
  
  protected static PBEParameterSpec getParamSpec(AlgorithmParameters paramAlgorithmParameters)
    throws InvalidAlgorithmParameterException
  {
    try
    {
      return (PBEParameterSpec)paramAlgorithmParameters.getParameterSpec(PBEParameterSpec.class);
    }
    catch (InvalidParameterSpecException localInvalidParameterSpecException)
    {
      throw new InvalidAlgorithmParameterException("cannot process PBE spec: " + localInvalidParameterSpecException.getMessage());
    }
  }
  
  public CMSPBEKey(char[] paramArrayOfChar, byte[] paramArrayOfByte, int paramInt)
  {
    password = paramArrayOfChar;
    salt = paramArrayOfByte;
    iterationCount = paramInt;
  }
  
  public CMSPBEKey(char[] paramArrayOfChar, PBEParameterSpec paramPBEParameterSpec)
  {
    this(paramArrayOfChar, paramPBEParameterSpec.getSalt(), paramPBEParameterSpec.getIterationCount());
  }
  
  public char[] getPassword()
  {
    return password;
  }
  
  public byte[] getSalt()
  {
    return salt;
  }
  
  public int getIterationCount()
  {
    return iterationCount;
  }
  
  public String getAlgorithm()
  {
    return "PKCS5S2";
  }
  
  public String getFormat()
  {
    return "RAW";
  }
  
  public byte[] getEncoded()
  {
    return null;
  }
  
  abstract byte[] getEncoded(String paramString);
}

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

import java.io.IOException;
import java.io.OutputStream;

public abstract interface CMSProcessable
{
  public abstract void write(OutputStream paramOutputStream)
    throws IOException, CMSException;
  
  public abstract Object getContent();
}

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

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
import org.bouncycastle.util.Arrays;

public class CMSProcessableByteArray
  implements CMSTypedData, CMSReadable
{
  private final ASN1ObjectIdentifier type;
  private final byte[] bytes;
  
  public CMSProcessableByteArray(byte[] paramArrayOfByte)
  {
    this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), paramArrayOfByte);
  }
  
  public CMSProcessableByteArray(ASN1ObjectIdentifier paramASN1ObjectIdentifier, byte[] paramArrayOfByte)
  {
    type = paramASN1ObjectIdentifier;
    bytes = paramArrayOfByte;
  }
  
  public InputStream getInputStream()
  {
    return new ByteArrayInputStream(bytes);
  }
  
  public void write(OutputStream paramOutputStream)
    throws IOException, CMSException
  {
    paramOutputStream.write(bytes);
  }
  
  public Object getContent()
  {
    return Arrays.clone(bytes);
  }
  
  public ASN1ObjectIdentifier getContentType()
  {
    return type;
  }
}

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

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;

public class CMSProcessableFile
  implements CMSTypedData, CMSReadable
{
  private static final int DEFAULT_BUF_SIZE = 32768;
  private final ASN1ObjectIdentifier type;
  private final File file;
  private final byte[] buf;
  
  public CMSProcessableFile(File paramFile)
  {
    this(paramFile, 32768);
  }
  
  public CMSProcessableFile(File paramFile, int paramInt)
  {
    this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), paramFile, paramInt);
  }
  
  public CMSProcessableFile(ASN1ObjectIdentifier paramASN1ObjectIdentifier, File paramFile, int paramInt)
  {
    type = paramASN1ObjectIdentifier;
    file = paramFile;
    buf = new byte[paramInt];
  }
  
  public InputStream getInputStream()
    throws IOException, CMSException
  {
    return new BufferedInputStream(new FileInputStream(file), 32768);
  }
  
  public void write(OutputStream paramOutputStream)
    throws IOException, CMSException
  {
    FileInputStream localFileInputStream = new FileInputStream(file);
    int i;
    while ((i = localFileInputStream.read(buf, 0, buf.length)) > 0) {
      paramOutputStream.write(buf, 0, i);
    }
    localFileInputStream.close();
  }
  
  public Object getContent()
  {
    return file;
  }
  
  public ASN1ObjectIdentifier getContentType()
  {
    return type;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.util.io.Streams;

class CMSProcessableInputStream
  implements CMSProcessable, CMSReadable
{
  private InputStream input;
  private boolean used = false;
  
  public CMSProcessableInputStream(InputStream paramInputStream)
  {
    input = paramInputStream;
  }
  
  public InputStream getInputStream()
  {
    checkSingleUsage();
    return input;
  }
  
  public void write(OutputStream paramOutputStream)
    throws IOException, CMSException
  {
    checkSingleUsage();
    Streams.pipeAll(input, paramOutputStream);
    input.close();
  }
  
  public Object getContent()
  {
    return getInputStream();
  }
  
  private synchronized void checkSingleUsage()
  {
    if (used) {
      throw new IllegalStateException("CMSProcessableInputStream can only be used once");
    }
    used = true;
  }
}

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

import java.io.IOException;
import java.io.InputStream;

abstract interface CMSReadable
{
  public abstract InputStream getInputStream()
    throws IOException, CMSException;
}

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

public class CMSRuntimeException
  extends RuntimeException
{
  Exception e;
  
  public CMSRuntimeException(String paramString)
  {
    super(paramString);
  }
  
  public CMSRuntimeException(String paramString, Exception paramException)
  {
    super(paramString);
    e = paramException;
  }
  
  public Exception getUnderlyingException()
  {
    return e;
  }
  
  public Throwable getCause()
  {
    return e;
  }
}

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

import java.io.IOException;
import java.io.InputStream;

abstract interface CMSSecureReadable
{
  public abstract InputStream getInputStream()
    throws IOException, CMSException;
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

public abstract interface CMSSignatureAlgorithmNameGenerator
{
  public abstract String getSignatureName(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2);
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

public abstract interface CMSSignatureEncryptionAlgorithmFinder
{
  public abstract AlgorithmIdentifier findEncryptionAlgorithm(AlgorithmIdentifier paramAlgorithmIdentifier);
}

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

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.cert.CertStore;
import java.security.cert.CertStoreException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.BERSequence;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.SignedData;
import org.bouncycastle.asn1.cms.SignerInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.AttributeCertificate;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.cert.X509AttributeCertificateHolder;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;
import org.bouncycastle.util.CollectionStore;
import org.bouncycastle.util.Store;
import org.bouncycastle.x509.NoSuchStoreException;
import org.bouncycastle.x509.X509Store;

public class CMSSignedData
{
  private static final CMSSignedHelper HELPER = CMSSignedHelper.INSTANCE;
  SignedData signedData;
  ContentInfo contentInfo;
  CMSProcessable signedContent;
  SignerInformationStore signerInfoStore;
  X509Store attributeStore;
  X509Store certificateStore;
  X509Store crlStore;
  private Map hashes;
  
  private CMSSignedData(CMSSignedData paramCMSSignedData)
  {
    signedData = signedData;
    
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