bcpkix-jdk15on-147

tentInfo.getContent(16));
      ContentInfoParser localContentInfoParser = localCompressedDataParser.getEncapContentInfo();
      InputExpander localInputExpander = paramInputExpanderProvider.get(localCompressedDataParser.getCompressionAlgorithmIdentifier());
      ASN1OctetStringParser localASN1OctetStringParser = (ASN1OctetStringParser)localContentInfoParser.getContent(4);
      return new CMSTypedStream(localContentInfoParser.getContentType().getId(), localInputExpander.getInputStream(localASN1OctetStringParser.getOctetStream()));
    }
    catch (IOException localIOException)
    {
      throw new CMSException("IOException reading compressed content.", localIOException);
    }
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.BERSequenceGenerator;

class CMSCompressedDataStreamGenerator$CmsCompressedOutputStream
  extends OutputStream
{
  private OutputStream _out;
  private BERSequenceGenerator _sGen;
  private BERSequenceGenerator _cGen;
  private BERSequenceGenerator _eiGen;
  
  CMSCompressedDataStreamGenerator$CmsCompressedOutputStream(CMSCompressedDataStreamGenerator paramCMSCompressedDataStreamGenerator, OutputStream paramOutputStream, BERSequenceGenerator paramBERSequenceGenerator1, BERSequenceGenerator paramBERSequenceGenerator2, BERSequenceGenerator paramBERSequenceGenerator3)
  {
    _out = paramOutputStream;
    _sGen = paramBERSequenceGenerator1;
    _cGen = 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();
    _cGen.close();
    _sGen.close();
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.BERSequenceGenerator;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.DERObjectIdentifier;
import org.bouncycastle.asn1.DERSequenceGenerator;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
import org.bouncycastle.operator.OutputCompressor;

public class CMSCompressedDataStreamGenerator
{
  public static final String ZLIB = "1.2.840.113549.1.9.16.3.8";
  private int _bufferSize;
  
  public void setBufferSize(int paramInt)
  {
    _bufferSize = paramInt;
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString)
    throws IOException
  {
    return open(paramOutputStream, CMSObjectIdentifiers.data.getId(), paramString);
  }
  
  /**
   * @deprecated
   */
  public OutputStream open(OutputStream paramOutputStream, String paramString1, String paramString2)
    throws IOException
  {
    BERSequenceGenerator localBERSequenceGenerator1 = new BERSequenceGenerator(paramOutputStream);
    localBERSequenceGenerator1.addObject(CMSObjectIdentifiers.compressedData);
    BERSequenceGenerator localBERSequenceGenerator2 = new BERSequenceGenerator(localBERSequenceGenerator1.getRawOutputStream(), 0, true);
    localBERSequenceGenerator2.addObject(new DERInteger(0));
    DERSequenceGenerator localDERSequenceGenerator = new DERSequenceGenerator(localBERSequenceGenerator2.getRawOutputStream());
    localDERSequenceGenerator.addObject(new DERObjectIdentifier("1.2.840.113549.1.9.16.3.8"));
    localDERSequenceGenerator.close();
    BERSequenceGenerator localBERSequenceGenerator3 = new BERSequenceGenerator(localBERSequenceGenerator2.getRawOutputStream());
    localBERSequenceGenerator3.addObject(new DERObjectIdentifier(paramString1));
    OutputStream localOutputStream = CMSUtils.createBEROctetOutputStream(localBERSequenceGenerator3.getRawOutputStream(), 0, true, _bufferSize);
    return new CmsCompressedOutputStream(new DeflaterOutputStream(localOutputStream), localBERSequenceGenerator1, localBERSequenceGenerator2, localBERSequenceGenerator3);
  }
  
  public OutputStream open(OutputStream paramOutputStream, OutputCompressor paramOutputCompressor)
    throws IOException
  {
    return open(CMSObjectIdentifiers.data, paramOutputStream, paramOutputCompressor);
  }
  
  public OutputStream open(ASN1ObjectIdentifier paramASN1ObjectIdentifier, OutputStream paramOutputStream, OutputCompressor paramOutputCompressor)
    throws IOException
  {
    BERSequenceGenerator localBERSequenceGenerator1 = new BERSequenceGenerator(paramOutputStream);
    localBERSequenceGenerator1.addObject(CMSObjectIdentifiers.compressedData);
    BERSequenceGenerator localBERSequenceGenerator2 = new BERSequenceGenerator(localBERSequenceGenerator1.getRawOutputStream(), 0, true);
    localBERSequenceGenerator2.addObject(new DERInteger(0));
    localBERSequenceGenerator2.addObject(paramOutputCompressor.getAlgorithmIdentifier());
    BERSequenceGenerator localBERSequenceGenerator3 = new BERSequenceGenerator(localBERSequenceGenerator2.getRawOutputStream());
    localBERSequenceGenerator3.addObject(paramASN1ObjectIdentifier);
    OutputStream localOutputStream = CMSUtils.createBEROctetOutputStream(localBERSequenceGenerator3.getRawOutputStream(), 0, true, _bufferSize);
    return new CmsCompressedOutputStream(paramOutputCompressor.getOutputStream(localOutputStream), localBERSequenceGenerator1, localBERSequenceGenerator2, localBERSequenceGenerator3);
  }
  
  private class CmsCompressedOutputStream
    extends OutputStream
  {
    private OutputStream _out;
    private BERSequenceGenerator _sGen;
    private BERSequenceGenerator _cGen;
    private BERSequenceGenerator _eiGen;
    
    CmsCompressedOutputStream(OutputStream paramOutputStream, BERSequenceGenerator paramBERSequenceGenerator1, BERSequenceGenerator paramBERSequenceGenerator2, BERSequenceGenerator paramBERSequenceGenerator3)
    {
      _out = paramOutputStream;
      _sGen = paramBERSequenceGenerator1;
      _cGen = 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();
      _cGen.close();
      _sGen.close();
    }
  }
}

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

import org.bouncycastle.asn1.DERObjectIdentifier;

public class CMSConfig
{
  public static void setSigningEncryptionAlgorithmMapping(String paramString1, String paramString2)
  {
    DERObjectIdentifier localDERObjectIdentifier = new DERObjectIdentifier(paramString1);
    CMSSignedHelper.INSTANCE.setSigningEncryptionAlgorithmMapping(localDERObjectIdentifier, paramString2);
  }
  
  public static void setSigningDigestAlgorithmMapping(String paramString1, String paramString2)
  {
    DERObjectIdentifier localDERObjectIdentifier = new DERObjectIdentifier(paramString1);
    CMSSignedHelper.INSTANCE.setSigningDigestAlgorithmMapping(localDERObjectIdentifier, paramString2);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.CMSConfig
 * 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.ASN1SequenceParser;
import org.bouncycastle.asn1.ASN1StreamParser;
import org.bouncycastle.asn1.cms.ContentInfoParser;

public class CMSContentInfoParser
{
  protected ContentInfoParser _contentInfo;
  protected InputStream _data;
  
  protected CMSContentInfoParser(InputStream paramInputStream)
    throws CMSException
  {
    _data = paramInputStream;
    try
    {
      ASN1StreamParser localASN1StreamParser = new ASN1StreamParser(paramInputStream);
      _contentInfo = new ContentInfoParser((ASN1SequenceParser)localASN1StreamParser.readObject());
    }
    catch (IOException localIOException)
    {
      throw new CMSException("IOException reading content.", localIOException);
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CMSException("Unexpected object reading content.", localClassCastException);
    }
  }
  
  public void close()
    throws IOException
  {
    _data.close();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.CMSContentInfoParser
 * 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 org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.EncryptedContentInfo;
import org.bouncycastle.asn1.cms.EncryptedData;
import org.bouncycastle.operator.InputDecryptor;
import org.bouncycastle.operator.InputDecryptorProvider;

public class CMSEncryptedData
{
  private ContentInfo contentInfo;
  private EncryptedData encryptedData;
  
  public CMSEncryptedData(ContentInfo paramContentInfo)
  {
    contentInfo = paramContentInfo;
    encryptedData = EncryptedData.getInstance(paramContentInfo.getContent());
  }
  
  public byte[] getContent(InputDecryptorProvider paramInputDecryptorProvider)
    throws CMSException
  {
    try
    {
      return CMSUtils.streamToByteArray(getContentStream(paramInputDecryptorProvider).getContentStream());
    }
    catch (IOException localIOException)
    {
      throw new CMSException("unable to parse internal stream: " + localIOException.getMessage(), localIOException);
    }
  }
  
  public CMSTypedStream getContentStream(InputDecryptorProvider paramInputDecryptorProvider)
    throws CMSException
  {
    EncryptedContentInfo localEncryptedContentInfo = encryptedData.getEncryptedContentInfo();
    InputDecryptor localInputDecryptor = paramInputDecryptorProvider.get(localEncryptedContentInfo.getContentEncryptionAlgorithm());
    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(localEncryptedContentInfo.getEncryptedContent().getOctets());
    return new CMSTypedStream(localEncryptedContentInfo.getContentType(), localInputDecryptor.getInputStream(localByteArrayInputStream));
  }
  
  public ContentInfo toASN1Structure()
  {
    return contentInfo;
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import org.bouncycastle.asn1.BEROctetString;
import org.bouncycastle.asn1.BERSet;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.EncryptedContentInfo;
import org.bouncycastle.asn1.cms.EncryptedData;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.OutputEncryptor;

public class CMSEncryptedDataGenerator
  extends CMSEncryptedGenerator
{
  private CMSEncryptedData doGenerate(CMSTypedData paramCMSTypedData, OutputEncryptor paramOutputEncryptor)
    throws CMSException
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    try
    {
      OutputStream localOutputStream = paramOutputEncryptor.getOutputStream(localByteArrayOutputStream);
      paramCMSTypedData.write(localOutputStream);
      localOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new CMSException("");
    }
    byte[] arrayOfByte = localByteArrayOutputStream.toByteArray();
    AlgorithmIdentifier localAlgorithmIdentifier = paramOutputEncryptor.getAlgorithmIdentifier();
    BEROctetString localBEROctetString = new BEROctetString(arrayOfByte);
    EncryptedContentInfo localEncryptedContentInfo = new EncryptedContentInfo(paramCMSTypedData.getContentType(), localAlgorithmIdentifier, localBEROctetString);
    BERSet localBERSet = null;
    if (unprotectedAttributeGenerator != null)
    {
      localObject = unprotectedAttributeGenerator.getAttributes(new HashMap());
      localBERSet = new BERSet(((AttributeTable)localObject).toASN1EncodableVector());
    }
    Object localObject = new ContentInfo(CMSObjectIdentifiers.encryptedData, new EncryptedData(localEncryptedContentInfo, localBERSet));
    return new CMSEncryptedData((ContentInfo)localObject);
  }
  
  public CMSEncryptedData generate(CMSTypedData paramCMSTypedData, OutputEncryptor paramOutputEncryptor)
    throws CMSException
  {
    return doGenerate(paramCMSTypedData, paramOutputEncryptor);
  }
}

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

public class CMSEncryptedGenerator
{
  protected CMSAttributeTableGenerator unprotectedAttributeGenerator = null;
  
  public void setUnprotectedAttributeGenerator(CMSAttributeTableGenerator paramCMSAttributeTableGenerator)
  {
    unprotectedAttributeGenerator = paramCMSAttributeTableGenerator;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.CMSEncryptedGenerator
 * 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.security.AlgorithmParameters;
import java.security.NoSuchProviderException;
import java.security.Provider;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.EncryptedContentInfo;
import org.bouncycastle.asn1.cms.EnvelopedData;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceAlgorithmIdentifierConverter;

public class CMSEnvelopedData
{
  RecipientInformationStore recipientInfoStore;
  ContentInfo contentInfo;
  private AlgorithmIdentifier encAlg;
  private ASN1Set unprotectedAttributes;
  private OriginatorInformation originatorInfo;
  
  public CMSEnvelopedData(byte[] paramArrayOfByte)
    throws CMSException
  {
    this(CMSUtils.readContentInfo(paramArrayOfByte));
  }
  
  public CMSEnvelopedData(InputStream paramInputStream)
    throws CMSException
  {
    this(CMSUtils.readContentInfo(paramInputStream));
  }
  
  public CMSEnvelopedData(ContentInfo paramContentInfo)
    throws CMSException
  {
    contentInfo = paramContentInfo;
    try
    {
      EnvelopedData localEnvelopedData = EnvelopedData.getInstance(paramContentInfo.getContent());
      if (localEnvelopedData.getOriginatorInfo() != null) {
        originatorInfo = new OriginatorInformation(localEnvelopedData.getOriginatorInfo());
      }
      ASN1Set localASN1Set = localEnvelopedData.getRecipientInfos();
      EncryptedContentInfo localEncryptedContentInfo = localEnvelopedData.getEncryptedContentInfo();
      encAlg = localEncryptedContentInfo.getContentEncryptionAlgorithm();
      CMSProcessableByteArray localCMSProcessableByteArray = new CMSProcessableByteArray(localEncryptedContentInfo.getEncryptedContent().getOctets());
      CMSEnvelopedHelper.CMSEnvelopedSecureReadable localCMSEnvelopedSecureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(encAlg, localCMSProcessableByteArray);
      recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(localASN1Set, encAlg, localCMSEnvelopedSecureReadable);
      unprotectedAttributes = localEnvelopedData.getUnprotectedAttrs();
    }
    catch (ClassCastException localClassCastException)
    {
      throw new CMSException("Malformed content.", localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new CMSException("Malformed content.", localIllegalArgumentException);
    }
  }
  
  private byte[] encodeObj(ASN1Encodable paramASN1Encodable)
    throws IOException
  {
    if (paramASN1Encodable != null) {
      return paramASN1Encodable.toASN1Primitive().getEncoded();
    }
    return null;
  }
  
  public OriginatorInformation getOriginatorInfo()
  {
    return originatorInfo;
  }
  
  public AlgorithmIdentifier getContentEncryptionAlgorithm()
  {
    return encAlg;
  }
  
  public String getEncryptionAlgOID()
  {
    return encAlg.getAlgorithm().getId();
  }
  
  public byte[] getEncryptionAlgParams()
  {
    try
    {
      return encodeObj(encAlg.getParameters());
    }
    catch (Exception localException)
    {
      throw new RuntimeException("exception getting encryption parameters " + localException);
    }
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getEncryptionAlgorithmParameters(String paramString)
    throws CMSException, NoSuchProviderException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramString).getAlgorithmParameters(encAlg);
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getEncryptionAlgorithmParameters(Provider paramProvider)
    throws CMSException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramProvider).getAlgorithmParameters(encAlg);
  }
  
  public RecipientInformationStore getRecipientInfos()
  {
    return recipientInfoStore;
  }
  
  /**
   * @deprecated
   */
  public ContentInfo getContentInfo()
  {
    return contentInfo;
  }
  
  public ContentInfo toASN1Structure()
  {
    return contentInfo;
  }
  
  public AttributeTable getUnprotectedAttributes()
  {
    if (unprotectedAttributes == null) {
      return null;
    }
    return new AttributeTable(unprotectedAttributes);
  }
  
  public byte[] getEncoded()
    throws IOException
  {
    return contentInfo.getEncoded();
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;

class CMSEnvelopedDataGenerator$1
  implements CMSTypedData
{
  CMSEnvelopedDataGenerator$1(CMSEnvelopedDataGenerator paramCMSEnvelopedDataGenerator, CMSProcessable paramCMSProcessable)
    throws CMSException, IOException
  {}
  
  public ASN1ObjectIdentifier getContentType()
  {
    return CMSObjectIdentifiers.data;
  }
  
  public void write(OutputStream paramOutputStream)
    throws IOException, CMSException
  {
    val$content.write(paramOutputStream);
  }
  
  public Object getContent()
  {
    return val$content;
  }
}

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.crypto.KeyGenerator;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.BEROctetString;
import org.bouncycastle.asn1.BERSet;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.cms.EncryptedContentInfo;
import org.bouncycastle.asn1.cms.EnvelopedData;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceCMSContentEncryptorBuilder;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.OutputEncryptor;

public class CMSEnvelopedDataGenerator
  extends CMSEnvelopedGenerator
{
  public CMSEnvelopedDataGenerator() {}
  
  /**
   * @deprecated
   */
  public CMSEnvelopedDataGenerator(SecureRandom paramSecureRandom)
  {
    super(paramSecureRandom);
  }
  
  private CMSEnvelopedData generate(final CMSProcessable paramCMSProcessable, String paramString, int paramInt, Provider paramProvider1, Provider paramProvider2)
    throws NoSuchAlgorithmException, CMSException
  {
    convertOldRecipients(rand, paramProvider2);
    JceCMSContentEncryptorBuilder localJceCMSContentEncryptorBuilder;
    if (paramInt != -1) {
      localJceCMSContentEncryptorBuilder = new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(paramString), paramInt);
    } else {
      localJceCMSContentEncryptorBuilder = new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(paramString));
    }
    localJceCMSContentEncryptorBuilder.setProvider(paramProvider1);
    localJceCMSContentEncryptorBuilder.setSecureRandom(rand);
    doGenerate(new CMSTypedData()
    {
      public ASN1ObjectIdentifier getContentType()
      {
        return CMSObjectIdentifiers.data;
      }
      
      public void write(OutputStream paramAnonymousOutputStream)
        throws IOException, CMSException
      {
        paramCMSProcessable.write(paramAnonymousOutputStream);
      }
      
      public Object getContent()
      {
        return paramCMSProcessable;
      }
    }, localJceCMSContentEncryptorBuilder.build());
  }
  
  private CMSEnvelopedData doGenerate(CMSTypedData paramCMSTypedData, OutputEncryptor paramOutputEncryptor)
    throws CMSException
  {
    if (!oldRecipientInfoGenerators.isEmpty()) {
      throw new IllegalStateException("can only use addRecipientGenerator() with this method");
    }
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    try
    {
      OutputStream localOutputStream = paramOutputEncryptor.getOutputStream(localByteArrayOutputStream);
      paramCMSTypedData.write(localOutputStream);
      localOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new CMSException("");
    }
    byte[] arrayOfByte = localByteArrayOutputStream.toByteArray();
    AlgorithmIdentifier localAlgorithmIdentifier = paramOutputEncryptor.getAlgorithmIdentifier();
    BEROctetString localBEROctetString = new BEROctetString(arrayOfByte);
    GenericKey localGenericKey = paramOutputEncryptor.getKey();
    Object localObject1 = recipientInfoGenerators.iterator();
    while (((Iterator)localObject1).hasNext())
    {
      localObject2 = (RecipientInfoGenerator)((Iterator)localObject1).next();
      localASN1EncodableVector.add(((RecipientInfoGenerator)localObject2).generate(localGenericKey));
    }
    localObject1 = new EncryptedContentInfo(paramCMSTypedData.getContentType(), localAlgorithmIdentifier, localBEROctetString);
    Object localObject2 = null;
    if (unprotectedAttributeGenerator != null)
    {
      localObject3 = unprotectedAttributeGenerator.getAttributes(new HashMap());
      localObject2 = new BERSet(((AttributeTable)localObject3).toASN1EncodableVector());
    }
    Object localObject3 = new ContentInfo(CMSObjectIdentifiers.envelopedData, new EnvelopedData(originatorInfo, new DERSet(localASN1EncodableVector), (EncryptedContentInfo)localObject1, (ASN1Set)localObject2));
    return new CMSEnvelopedData((ContentInfo)localObject3);
  }
  
  /**
   * @deprecated
   */
  public CMSEnvelopedData generate(CMSProcessable paramCMSProcessable, String paramString1, String paramString2)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
  {
    return generate(paramCMSProcessable, paramString1, CMSUtils.getProvider(paramString2));
  }
  
  /**
   * @deprecated
   */
  public CMSEnvelopedData generate(CMSProcessable paramCMSProcessable, String paramString, Provider paramProvider)
    throws NoSuchAlgorithmException, CMSException
  {
    KeyGenerator localKeyGenerator = CMSEnvelopedHelper.INSTANCE.createSymmetricKeyGenerator(paramString, paramProvider);
    return generate(paramCMSProcessable, paramString, -1, localKeyGenerator.getProvider(), paramProvider);
  }
  
  /**
   * @deprecated
   */
  public CMSEnvelopedData generate(CMSProcessable paramCMSProcessable, String paramString1, int paramInt, String paramString2)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
  {
    return generate(paramCMSProcessable, paramString1, paramInt, CMSUtils.getProvider(paramString2));
  }
  
  /**
   * @deprecated
   */
  public CMSEnvelopedData generate(CMSProcessable paramCMSProcessable, String paramString, int paramInt, Provider paramProvider)
    throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
  {
    KeyGenerator localKeyGenerator = CMSEnvelopedHelper.INSTANCE.createSymmetricKeyGenerator(paramString, paramProvider);
    return generate(paramCMSProcessable, paramString, paramInt, localKeyGenerator.getProvider(), paramProvider);
  }
  
  public CMSEnvelopedData generate(CMSTypedData paramCMSTypedData, OutputEncryptor paramOutputEncryptor)
    throws CMSException
  {
    return doGenerate(paramCMSTypedData, paramOutputEncryptor);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.CMSEnvelopedDataGenerator
 * 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.security.AlgorithmParameters;
import java.security.NoSuchProviderException;
import java.security.Provider;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetStringParser;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1SequenceParser;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.ASN1SetParser;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.ContentInfoParser;
import org.bouncycastle.asn1.cms.EncryptedContentInfoParser;
import org.bouncycastle.asn1.cms.EnvelopedDataParser;
import org.bouncycastle.asn1.cms.OriginatorInfo;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceAlgorithmIdentifierConverter;

public class CMSEnvelopedDataParser
  extends CMSContentInfoParser
{
  RecipientInformationStore recipientInfoStore;
  EnvelopedDataParser envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(16));
  private AlgorithmIdentifier encAlg;
  private AttributeTable unprotectedAttributes;
  private boolean attrNotRead = true;
  private OriginatorInformation originatorInfo;
  
  public CMSEnvelopedDataParser(byte[] paramArrayOfByte)
    throws CMSException, IOException
  {
    this(new ByteArrayInputStream(paramArrayOfByte));
  }
  
  public CMSEnvelopedDataParser(InputStream paramInputStream)
    throws CMSException, IOException
  {
    super(paramInputStream);
    OriginatorInfo localOriginatorInfo = envelopedData.getOriginatorInfo();
    if (localOriginatorInfo != null) {
      originatorInfo = new OriginatorInformation(localOriginatorInfo);
    }
    ASN1Set localASN1Set = ASN1Set.getInstance(envelopedData.getRecipientInfos().toASN1Primitive());
    EncryptedContentInfoParser localEncryptedContentInfoParser = envelopedData.getEncryptedContentInfo();
    encAlg = localEncryptedContentInfoParser.getContentEncryptionAlgorithm();
    CMSProcessableInputStream localCMSProcessableInputStream = new CMSProcessableInputStream(((ASN1OctetStringParser)localEncryptedContentInfoParser.getEncryptedContent(4)).getOctetStream());
    CMSEnvelopedHelper.CMSEnvelopedSecureReadable localCMSEnvelopedSecureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable(encAlg, localCMSProcessableInputStream);
    recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore(localASN1Set, encAlg, localCMSEnvelopedSecureReadable);
  }
  
  public String getEncryptionAlgOID()
  {
    return encAlg.getAlgorithm().toString();
  }
  
  public byte[] getEncryptionAlgParams()
  {
    try
    {
      return encodeObj(encAlg.getParameters());
    }
    catch (Exception localException)
    {
      throw new RuntimeException("exception getting encryption parameters " + localException);
    }
  }
  
  public AlgorithmIdentifier getContentEncryptionAlgorithm()
  {
    return encAlg;
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getEncryptionAlgorithmParameters(String paramString)
    throws CMSException, NoSuchProviderException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramString).getAlgorithmParameters(encAlg);
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getEncryptionAlgorithmParameters(Provider paramProvider)
    throws CMSException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramProvider).getAlgorithmParameters(encAlg);
  }
  
  public OriginatorInformation getOriginatorInfo()
  {
    return originatorInfo;
  }
  
  public RecipientInformationStore getRecipientInfos()
  {
    return recipientInfoStore;
  }
  
  public AttributeTable getUnprotectedAttributes()
    throws IOException
  {
    if ((unprotectedAttributes == null) && (attrNotRead))
    {
      ASN1SetParser localASN1SetParser = envelopedData.getUnprotectedAttrs();
      attrNotRead = false;
      if (localASN1SetParser != null)
      {
        ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
        ASN1Encodable localASN1Encodable;
        while ((localASN1Encodable = localASN1SetParser.readObject()) != null)
        {
          ASN1SequenceParser localASN1SequenceParser = (ASN1SequenceParser)localASN1Encodable;
          localASN1EncodableVector.add(localASN1SequenceParser.toASN1Primitive());
        }
        unprotectedAttributes = new AttributeTable(new DERSet(localASN1EncodableVector));
      }
    }
    return unprotectedAttributes;
  }
  
  private byte[] encodeObj(ASN1Encodable paramASN1Encodable)
    throws IOException
  {
    if (paramASN1Encodable != null) {
      return paramASN1Encodable.toASN1Primitive().getEncoded();
    }
    return null;
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import org.bouncycastle.asn1.BERSequenceGenerator;
import org.bouncycastle.asn1.BERSet;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.cms.AttributeTable;

class CMSEnvelopedDataStreamGenerator$CmsEnvelopedDataOutputStream
  extends OutputStream
{
  private OutputStream _out;
  private BERSequenceGenerator _cGen;
  private BERSequenceGenerator _envGen;
  private BERSequenceGenerator _eiGen;
  
  public CMSEnvelopedDataStreamGenerator$CmsEnvelopedDataOutputStream(CMSEnvelopedDataStreamGenerator paramCMSEnvelopedDataStreamGenerator, 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 (this$0.unprotectedAttributeGenerator != null)
    {
      AttributeTable localAttributeTable = this$0.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.CmsEnvelopedDataOutputStream
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cms;

import java.io.IOException;
import java.io.OutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.crypto.KeyGenerator;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.BERSequenceGenerator;
import org.bouncycastle.asn1.BERSet;
import org.bouncycastle.asn1.DERInteger;
import org.bouncycastle.asn1.DERSet;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
import org.bouncycastle.asn1.cms.EnvelopedData;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceCMSContentEncryptorBuilder;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.OutputEncryptor;

public class CMSEnvelopedDataStreamGenerator
  extends CMSEnvelopedGenerator
{
  private ASN1Set _unprotectedAttributes = null;
  private int _bufferSize;
  private boolean _berEncodeRecipientSet;
  
  public CMSEnvelopedDataStreamGenerator() {}
  
  /**
   * @deprecated
   */
  public CMSEnvelopedDataStreamGenerator(SecureRandom paramSecureRandom)
  {
    super(paramSecureRandom);
  }
  
  public void setBufferSize(int paramInt)
  {
    _bufferSize = paramInt;
  }
  
  public void setBEREncodeRecipients(boolean paramBoolean)
  {
    _berEncodeRecipientSet = paramBoolean;
  }
  
  private DERInteger getVersion()
  {
    if ((originatorInfo != null) || (_unprotectedAttributes != null)) {
      return new DERInteger(2);
    }
    return new DERInteger(0);
  }
  
  /**
   * @deprecated
   */
  private OutputStream open(OutputStream paramOutputStream, String paramString, int paramInt, Provider paramProvider1, Provider paramProvider2)
    throws NoSuchAlgorithmException, CMSException, IOException
  {
    convertOldRecipients(rand, paramProvider2);
    JceCMSContentEncryptorBuilder localJceCMSContentEncryptorBuilder;
    if (paramInt != -1) {
      localJceCMSContentEncryptorBuilder = new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(paramString), paramInt);
    } else {
      localJceCMSContentEncryptorBuilder = new JceCMSContentEncryptorBuilder(new ASN1ObjectIdentifier(paramString));
    }
    localJceCMSContentEncryptorBuilder.setProvider(paramProvider1);
    localJceCMSContentEncryptorBuilder.setSecureRandom(rand);
    return doOpen(CMSObjectIdentifiers.data, paramOutputStream, localJceCMSContentEncryptorBuilder.build());
  }
  
  private OutputStream doOpen(ASN1ObjectIdentifier paramASN1ObjectIdentifier, OutputStream paramOutputStream, OutputEncryptor paramOutputEncryptor)
    throws IOException, CMSException
  {
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    GenericKey localGenericKey = paramOutputEncryptor.getKey();
    Iterator localIterator = recipientInfoGenerators.iterator();
    while (localIterator.hasNext())
    {
      RecipientInfoGenerator localRecipientInfoGenerator = (RecipientInfoGenerator)localIterator.next();
      localASN1EncodableVector.add(localRecipientInfoGenerator.generate(localGenericKey));
    }
    return open(paramASN1ObjectIdentifier, paramOutputStream, localASN1EncodableVector, paramOutputEncryptor);
  }
  
  protected OutputStream open(ASN1ObjectIdentifier paramASN1ObjectIdentifier, OutputStream paramOutputStream, ASN1EncodableVector paramASN1EncodableVector, OutputEncryptor paramOutputEncryptor)
    throws IOException
  {
    BERSequenceGenerator localBERSequenceGenerator1 = new BERSequenceGenerator(paramOutputStream);
    localBERSequenceGenerator1.addObject(CMSObjectIdentifiers.envelopedData);
    BERSequenceGenerator localBERSequenceGenerator2 = new BERSequenceGenerator(localBERSequenceGenerator1.getRawOutputStream(), 0, true);
    localBERSequenceGenerator2.addObject(getVersion());
    if (originatorInfo != null) {
      localBERSequenceGenerator2.addObject(new DERTaggedObject(false, 0, originatorInfo));
    }
    if (_berEncodeRecipientSet) {
      localBERSequenceGenerator2.getRawOutputStream().write(new BERSet(paramASN1EncodableVector).getEncoded());
    } else {
      localBERSequenceGenerator2.getRawOutputStream().write(new DERSet(paramASN1EncodableVector).getEncoded());
    }
    BERSequenceGenerator localBERSequenceGenerator3 = new BERSequenceGenerator(localBERSequenceGenerator2.getRawOutputStream());
    localBERSequenceGenerator3.addObject(paramASN1ObjectIdentifier);
    AlgorithmIdentifier localAlgorithmIdentifier = paramOutputEncryptor.getAlgorithmIdentifier();
    localBERSequenceGenerator3.getRawOutputStream().write(localAlgorithmIdentifier.getEncoded());
    OutputStream localOutputStream1 = CMSUtils.createBEROctetOutputStream(localBERSequenceGenerator3.getRawOutputStream(), 0, false, _bufferSize);
    OutputStream localOutputStream2 = paramOutputEncryptor.getOutputStream(localOutputStream1);
    return new CmsEnvelopedDataOutputStream(localOutputStream2, localBERSequenceGenerator1, localBERSequenceGenerator2, localBERSequenceGenerator3);
  }
  
  protected OutputStream open(OutputStream paramOutputStream, ASN1EncodableVector paramASN1EncodableVector, OutputEncryptor paramOutputEncryptor)
    throws CMSException
  {
    try
    {
      BERSequenceGenerator localBERSequenceGenerator1 = new BERSequenceGenerator(paramOutputStream);
      localBERSequenceGenerator1.addObject(CMSObjectIdentifiers.envelopedData);
      BERSequenceGenerator localBERSequenceGenerator2 = new BERSequenceGenerator(localBERSequenceGenerator1.getRawOutputStream(), 0, true);
      Object localObject;
      if (_berEncodeRecipientSet) {
        localObject = new BERSet(paramASN1EncodableVector);
      } else {
        localObject = new DERSet(paramASN1EncodableVector);
      }
      localBERSequenceGenerator2.addObject(new ASN1Integer(EnvelopedData.calculateVersion(originatorInfo, (ASN1Set)localObject, _unprotectedAttributes)));
      if (originatorInfo != null) {
        localBERSequenceGenerator2.addObject(new DERTaggedObject(false, 0, originatorInfo));
      }
      localBERSequenceGenerator2.getRawOutputStream().write(((ASN1Set)localObject).getEncoded());
      B
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