bcpkix-jdk15on-147

tificateHolderSelector;

public class KeyTransRecipientId
  extends RecipientId
{
  private X509CertificateHolderSelector baseSelector;
  
  private KeyTransRecipientId(X509CertificateHolderSelector paramX509CertificateHolderSelector)
  {
    super(0);
    baseSelector = paramX509CertificateHolderSelector;
  }
  
  public KeyTransRecipientId(byte[] paramArrayOfByte)
  {
    this(null, null, paramArrayOfByte);
  }
  
  public KeyTransRecipientId(X500Name paramX500Name, BigInteger paramBigInteger)
  {
    this(paramX500Name, paramBigInteger, null);
  }
  
  public KeyTransRecipientId(X500Name paramX500Name, BigInteger paramBigInteger, byte[] paramArrayOfByte)
  {
    this(new X509CertificateHolderSelector(paramX500Name, paramBigInteger, paramArrayOfByte));
  }
  
  public X500Name getIssuer()
  {
    return baseSelector.getIssuer();
  }
  
  public BigInteger getSerialNumber()
  {
    return baseSelector.getSerialNumber();
  }
  
  public byte[] getSubjectKeyIdentifier()
  {
    return baseSelector.getSubjectKeyIdentifier();
  }
  
  public int hashCode()
  {
    return baseSelector.hashCode();
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof KeyTransRecipientId)) {
      return false;
    }
    KeyTransRecipientId localKeyTransRecipientId = (KeyTransRecipientId)paramObject;
    return baseSelector.equals(baseSelector);
  }
  
  public Object clone()
  {
    return new KeyTransRecipientId(baseSelector);
  }
  
  public boolean match(Object paramObject)
  {
    if ((paramObject instanceof KeyTransRecipientInformation)) {
      return ((KeyTransRecipientInformation)paramObject).getRID().equals(this);
    }
    return baseSelector.match(paramObject);
  }
}

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

import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import org.bouncycastle.asn1.cms.KeyTransRecipientInfo;
import org.bouncycastle.asn1.cms.RecipientIdentifier;
import org.bouncycastle.asn1.cms.RecipientInfo;
import org.bouncycastle.operator.AsymmetricKeyWrapper;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.OperatorException;

public abstract class KeyTransRecipientInfoGenerator
  implements RecipientInfoGenerator
{
  protected final AsymmetricKeyWrapper wrapper;
  private IssuerAndSerialNumber issuerAndSerial;
  private byte[] subjectKeyIdentifier;
  
  protected KeyTransRecipientInfoGenerator(IssuerAndSerialNumber paramIssuerAndSerialNumber, AsymmetricKeyWrapper paramAsymmetricKeyWrapper)
  {
    issuerAndSerial = paramIssuerAndSerialNumber;
    wrapper = paramAsymmetricKeyWrapper;
  }
  
  protected KeyTransRecipientInfoGenerator(byte[] paramArrayOfByte, AsymmetricKeyWrapper paramAsymmetricKeyWrapper)
  {
    subjectKeyIdentifier = paramArrayOfByte;
    wrapper = paramAsymmetricKeyWrapper;
  }
  
  public final RecipientInfo generate(GenericKey paramGenericKey)
    throws CMSException
  {
    byte[] arrayOfByte;
    try
    {
      arrayOfByte = wrapper.generateWrappedKey(paramGenericKey);
    }
    catch (OperatorException localOperatorException)
    {
      throw new CMSException("exception wrapping content key: " + localOperatorException.getMessage(), localOperatorException);
    }
    RecipientIdentifier localRecipientIdentifier;
    if (issuerAndSerial != null) {
      localRecipientIdentifier = new RecipientIdentifier(issuerAndSerial);
    } else {
      localRecipientIdentifier = new RecipientIdentifier(new DEROctetString(subjectKeyIdentifier));
    }
    return new RecipientInfo(new KeyTransRecipientInfo(localRecipientIdentifier, wrapper.getAlgorithmIdentifier(), new DEROctetString(arrayOfByte)));
  }
}

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

import java.io.IOException;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import org.bouncycastle.asn1.cms.KeyTransRecipientInfo;
import org.bouncycastle.asn1.cms.RecipientIdentifier;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceKeyTransAuthenticatedRecipient;
import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient;
import org.bouncycastle.cms.jcajce.JceKeyTransRecipient;

public class KeyTransRecipientInformation
  extends RecipientInformation
{
  private KeyTransRecipientInfo info;
  
  KeyTransRecipientInformation(KeyTransRecipientInfo paramKeyTransRecipientInfo, AlgorithmIdentifier paramAlgorithmIdentifier, CMSSecureReadable paramCMSSecureReadable, AuthAttributesProvider paramAuthAttributesProvider)
  {
    super(paramKeyTransRecipientInfo.getKeyEncryptionAlgorithm(), paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider);
    info = paramKeyTransRecipientInfo;
    RecipientIdentifier localRecipientIdentifier = paramKeyTransRecipientInfo.getRecipientIdentifier();
    Object localObject;
    if (localRecipientIdentifier.isTagged())
    {
      localObject = ASN1OctetString.getInstance(localRecipientIdentifier.getId());
      rid = new KeyTransRecipientId(((ASN1OctetString)localObject).getOctets());
    }
    else
    {
      localObject = IssuerAndSerialNumber.getInstance(localRecipientIdentifier.getId());
      rid = new KeyTransRecipientId(((IssuerAndSerialNumber)localObject).getName(), ((IssuerAndSerialNumber)localObject).getSerialNumber().getValue());
    }
  }
  
  /**
   * @deprecated
   */
  public CMSTypedStream getContentStream(Key paramKey, String paramString)
    throws CMSException, NoSuchProviderException
  {
    return getContentStream(paramKey, CMSUtils.getProvider(paramString));
  }
  
  /**
   * @deprecated
   */
  public CMSTypedStream getContentStream(Key paramKey, Provider paramProvider)
    throws CMSException
  {
    try
    {
      Object localObject;
      if ((secureReadable instanceof CMSEnvelopedHelper.CMSEnvelopedSecureReadable)) {
        localObject = new JceKeyTransEnvelopedRecipient((PrivateKey)paramKey);
      } else {
        localObject = new JceKeyTransAuthenticatedRecipient((PrivateKey)paramKey);
      }
      if (paramProvider != null)
      {
        ((JceKeyTransRecipient)localObject).setProvider(paramProvider);
        if (paramProvider.getName().equalsIgnoreCase("SunJCE")) {
          ((JceKeyTransRecipient)localObject).setContentProvider((String)null);
        }
      }
      return getContentStream((Recipient)localObject);
    }
    catch (IOException localIOException)
    {
      throw new CMSException("encoding error: " + localIOException.getMessage(), localIOException);
    }
  }
  
  protected RecipientOperator getRecipientOperator(Recipient paramRecipient)
    throws CMSException
  {
    return ((KeyTransRecipient)paramRecipient).getRecipientOperator(keyEncAlg, messageAlgorithm, info.getEncryptedKey().getOctets());
  }
}

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

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

class NullOutputStream
  extends OutputStream
{
  public void write(byte[] paramArrayOfByte)
    throws IOException
  {}
  
  public void write(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {}
  
  public void write(int paramInt)
    throws IOException
  {}
}

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

import java.math.BigInteger;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Selector;

class OriginatorId
  implements Selector
{
  private byte[] subjectKeyId;
  private X500Name issuer;
  private BigInteger serialNumber;
  
  public OriginatorId(byte[] paramArrayOfByte)
  {
    setSubjectKeyID(paramArrayOfByte);
  }
  
  private void setSubjectKeyID(byte[] paramArrayOfByte)
  {
    subjectKeyId = paramArrayOfByte;
  }
  
  public OriginatorId(X500Name paramX500Name, BigInteger paramBigInteger)
  {
    setIssuerAndSerial(paramX500Name, paramBigInteger);
  }
  
  private void setIssuerAndSerial(X500Name paramX500Name, BigInteger paramBigInteger)
  {
    issuer = paramX500Name;
    serialNumber = paramBigInteger;
  }
  
  public OriginatorId(X500Name paramX500Name, BigInteger paramBigInteger, byte[] paramArrayOfByte)
  {
    setIssuerAndSerial(paramX500Name, paramBigInteger);
    setSubjectKeyID(paramArrayOfByte);
  }
  
  public X500Name getIssuer()
  {
    return issuer;
  }
  
  public Object clone()
  {
    return new OriginatorId(issuer, serialNumber, subjectKeyId);
  }
  
  public int hashCode()
  {
    int i = Arrays.hashCode(subjectKeyId);
    if (serialNumber != null) {
      i ^= serialNumber.hashCode();
    }
    if (issuer != null) {
      i ^= issuer.hashCode();
    }
    return i;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof OriginatorId)) {
      return false;
    }
    OriginatorId localOriginatorId = (OriginatorId)paramObject;
    return (Arrays.areEqual(subjectKeyId, subjectKeyId)) && (equalsObj(serialNumber, serialNumber)) && (equalsObj(issuer, issuer));
  }
  
  private boolean equalsObj(Object paramObject1, Object paramObject2)
  {
    return paramObject2 == null ? true : paramObject1 != null ? paramObject1.equals(paramObject2) : false;
  }
  
  public boolean match(Object paramObject)
  {
    return false;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.bouncycastle.asn1.cms.OriginatorInfo;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.util.Store;

public class OriginatorInfoGenerator
{
  private final List origCerts;
  private final List origCRLs;
  
  public OriginatorInfoGenerator(X509CertificateHolder paramX509CertificateHolder)
  {
    origCerts = new ArrayList(1);
    origCRLs = null;
    origCerts.add(paramX509CertificateHolder.toASN1Structure());
  }
  
  public OriginatorInfoGenerator(Store paramStore)
    throws CMSException
  {
    this(paramStore, null);
  }
  
  public OriginatorInfoGenerator(Store paramStore1, Store paramStore2)
    throws CMSException
  {
    origCerts = CMSUtils.getCertificatesFromStore(paramStore1);
    if (paramStore2 != null) {
      origCRLs = CMSUtils.getCRLsFromStore(paramStore2);
    } else {
      origCRLs = null;
    }
  }
  
  public OriginatorInformation generate()
  {
    if (origCRLs != null) {
      return new OriginatorInformation(new OriginatorInfo(CMSUtils.createDerSetFromList(origCerts), CMSUtils.createDerSetFromList(origCRLs)));
    }
    return new OriginatorInformation(new OriginatorInfo(CMSUtils.createDerSetFromList(origCerts), null));
  }
}

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

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.cms.OriginatorInfo;
import org.bouncycastle.asn1.x509.Certificate;
import org.bouncycastle.asn1.x509.CertificateList;
import org.bouncycastle.cert.X509CRLHolder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.util.CollectionStore;
import org.bouncycastle.util.Store;

public class OriginatorInformation
{
  private OriginatorInfo originatorInfo;
  
  OriginatorInformation(OriginatorInfo paramOriginatorInfo)
  {
    originatorInfo = paramOriginatorInfo;
  }
  
  public Store getCertificates()
  {
    ASN1Set localASN1Set = originatorInfo.getCertificates();
    if (localASN1Set != null)
    {
      ArrayList localArrayList = new ArrayList(localASN1Set.size());
      Enumeration localEnumeration = localASN1Set.getObjects();
      while (localEnumeration.hasMoreElements())
      {
        ASN1Primitive localASN1Primitive = ((ASN1Encodable)localEnumeration.nextElement()).toASN1Primitive();
        if ((localASN1Primitive instanceof ASN1Sequence)) {
          localArrayList.add(new X509CertificateHolder(Certificate.getInstance(localASN1Primitive)));
        }
      }
      return new CollectionStore(localArrayList);
    }
    return new CollectionStore(new ArrayList());
  }
  
  public Store getCRLs()
  {
    ASN1Set localASN1Set = originatorInfo.getCRLs();
    if (localASN1Set != null)
    {
      ArrayList localArrayList = new ArrayList(localASN1Set.size());
      Enumeration localEnumeration = localASN1Set.getObjects();
      while (localEnumeration.hasMoreElements())
      {
        ASN1Primitive localASN1Primitive = ((ASN1Encodable)localEnumeration.nextElement()).toASN1Primitive();
        if ((localASN1Primitive instanceof ASN1Sequence)) {
          localArrayList.add(new X509CRLHolder(CertificateList.getInstance(localASN1Primitive)));
        }
      }
      return new CollectionStore(localArrayList);
    }
    return new CollectionStore(new ArrayList());
  }
  
  public OriginatorInfo toASN1Structure()
  {
    return originatorInfo;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.OriginatorInformation
 * 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 org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;

public class PKCS5Scheme2PBEKey
  extends CMSPBEKey
{
  public PKCS5Scheme2PBEKey(char[] paramArrayOfChar, byte[] paramArrayOfByte, int paramInt)
  {
    super(paramArrayOfChar, paramArrayOfByte, paramInt);
  }
  
  public PKCS5Scheme2PBEKey(char[] paramArrayOfChar, AlgorithmParameters paramAlgorithmParameters)
    throws InvalidAlgorithmParameterException
  {
    super(paramArrayOfChar, getParamSpec(paramAlgorithmParameters));
  }
  
  byte[] getEncoded(String paramString)
  {
    PKCS5S2ParametersGenerator localPKCS5S2ParametersGenerator = new PKCS5S2ParametersGenerator();
    localPKCS5S2ParametersGenerator.init(PBEParametersGenerator.PKCS5PasswordToBytes(getPassword()), getSalt(), getIterationCount());
    return ((KeyParameter)localPKCS5S2ParametersGenerator.generateDerivedParameters(CMSEnvelopedHelper.INSTANCE.getKeySize(paramString))).getKey();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.PKCS5Scheme2PBEKey
 * 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 org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;

public class PKCS5Scheme2UTF8PBEKey
  extends CMSPBEKey
{
  public PKCS5Scheme2UTF8PBEKey(char[] paramArrayOfChar, byte[] paramArrayOfByte, int paramInt)
  {
    super(paramArrayOfChar, paramArrayOfByte, paramInt);
  }
  
  public PKCS5Scheme2UTF8PBEKey(char[] paramArrayOfChar, AlgorithmParameters paramAlgorithmParameters)
    throws InvalidAlgorithmParameterException
  {
    super(paramArrayOfChar, getParamSpec(paramAlgorithmParameters));
  }
  
  byte[] getEncoded(String paramString)
  {
    PKCS5S2ParametersGenerator localPKCS5S2ParametersGenerator = new PKCS5S2ParametersGenerator();
    localPKCS5S2ParametersGenerator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(getPassword()), getSalt(), getIterationCount());
    return ((KeyParameter)localPKCS5S2ParametersGenerator.generateDerivedParameters(CMSEnvelopedHelper.INSTANCE.getKeySize(paramString))).getKey();
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.PKCS5Scheme2UTF8PBEKey
 * 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 PasswordRecipient
  extends Recipient
{
  public static final int PKCS5_SCHEME2 = 0;
  public static final int PKCS5_SCHEME2_UTF8 = 1;
  
  public abstract RecipientOperator getRecipientOperator(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws CMSException;
  
  public abstract int getPasswordConversionScheme();
  
  public abstract char[] getPassword();
}

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

public class PasswordRecipientId
  extends RecipientId
{
  public PasswordRecipientId()
  {
    super(3);
  }
  
  public int hashCode()
  {
    return 3;
  }
  
  public boolean equals(Object paramObject)
  {
    return (paramObject instanceof PasswordRecipientId);
  }
  
  public Object clone()
  {
    return new PasswordRecipientId();
  }
  
  public boolean match(Object paramObject)
  {
    return (paramObject instanceof PasswordRecipientInformation);
  }
}

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

import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Map;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cms.PasswordRecipientInfo;
import org.bouncycastle.asn1.cms.RecipientInfo;
import org.bouncycastle.asn1.pkcs.PBKDF2Params;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.operator.GenericKey;

public abstract class PasswordRecipientInfoGenerator
  implements RecipientInfoGenerator
{
  private char[] password;
  private AlgorithmIdentifier keyDerivationAlgorithm;
  private ASN1ObjectIdentifier kekAlgorithm;
  private SecureRandom random;
  private int schemeID;
  private int keySize;
  private int blockSize;
  
  protected PasswordRecipientInfoGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier, char[] paramArrayOfChar)
  {
    this(paramASN1ObjectIdentifier, paramArrayOfChar, getKeySize(paramASN1ObjectIdentifier), ((Integer)PasswordRecipientInformation.BLOCKSIZES.get(paramASN1ObjectIdentifier)).intValue());
  }
  
  protected PasswordRecipientInfoGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier, char[] paramArrayOfChar, int paramInt1, int paramInt2)
  {
    password = paramArrayOfChar;
    schemeID = 1;
    kekAlgorithm = paramASN1ObjectIdentifier;
    keySize = paramInt1;
    blockSize = paramInt2;
  }
  
  private static int getKeySize(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
  {
    Integer localInteger = (Integer)PasswordRecipientInformation.KEYSIZES.get(paramASN1ObjectIdentifier);
    if (localInteger == null) {
      throw new IllegalArgumentException("cannot find key size for algorithm: " + paramASN1ObjectIdentifier);
    }
    return localInteger.intValue();
  }
  
  public PasswordRecipientInfoGenerator setPasswordConversionScheme(int paramInt)
  {
    schemeID = paramInt;
    return this;
  }
  
  public PasswordRecipientInfoGenerator setSaltAndIterationCount(byte[] paramArrayOfByte, int paramInt)
  {
    keyDerivationAlgorithm = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_PBKDF2, new PBKDF2Params(paramArrayOfByte, paramInt));
    return this;
  }
  
  public PasswordRecipientInfoGenerator setSecureRandom(SecureRandom paramSecureRandom)
  {
    random = paramSecureRandom;
    return this;
  }
  
  public RecipientInfo generate(GenericKey paramGenericKey)
    throws CMSException
  {
    byte[] arrayOfByte1 = new byte[blockSize];
    if (random == null) {
      random = new SecureRandom();
    }
    random.nextBytes(arrayOfByte1);
    if (keyDerivationAlgorithm == null)
    {
      localObject1 = new byte[20];
      random.nextBytes((byte[])localObject1);
      keyDerivationAlgorithm = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_PBKDF2, new PBKDF2Params((byte[])localObject1, 1024));
    }
    Object localObject1 = PBKDF2Params.getInstance(keyDerivationAlgorithm.getParameters());
    byte[] arrayOfByte2;
    if (schemeID == 0)
    {
      localObject2 = new PKCS5S2ParametersGenerator();
      ((PKCS5S2ParametersGenerator)localObject2).init(PBEParametersGenerator.PKCS5PasswordToBytes(password), ((PBKDF2Params)localObject1).getSalt(), ((PBKDF2Params)localObject1).getIterationCount().intValue());
      arrayOfByte2 = ((KeyParameter)((PKCS5S2ParametersGenerator)localObject2).generateDerivedParameters(keySize)).getKey();
    }
    else
    {
      localObject2 = new PKCS5S2ParametersGenerator();
      ((PKCS5S2ParametersGenerator)localObject2).init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password), ((PBKDF2Params)localObject1).getSalt(), ((PBKDF2Params)localObject1).getIterationCount().intValue());
      arrayOfByte2 = ((KeyParameter)((PKCS5S2ParametersGenerator)localObject2).generateDerivedParameters(keySize)).getKey();
    }
    Object localObject2 = new AlgorithmIdentifier(kekAlgorithm, new DEROctetString(arrayOfByte1));
    byte[] arrayOfByte3 = generateEncryptedBytes((AlgorithmIdentifier)localObject2, arrayOfByte2, paramGenericKey);
    DEROctetString localDEROctetString = new DEROctetString(arrayOfByte3);
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    localASN1EncodableVector.add(kekAlgorithm);
    localASN1EncodableVector.add(new DEROctetString(arrayOfByte1));
    AlgorithmIdentifier localAlgorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_alg_PWRI_KEK, new DERSequence(localASN1EncodableVector));
    return new RecipientInfo(new PasswordRecipientInfo(keyDerivationAlgorithm, localAlgorithmIdentifier, localDEROctetString));
  }
  
  protected abstract byte[] generateEncryptedBytes(AlgorithmIdentifier paramAlgorithmIdentifier, byte[] paramArrayOfByte, GenericKey paramGenericKey)
    throws CMSException;
}

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

import java.io.IOException;
import java.math.BigInteger;
import java.security.AlgorithmParameters;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.util.HashMap;
import java.util.Map;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.cms.PasswordRecipientInfo;
import org.bouncycastle.asn1.pkcs.PBKDF2Params;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceAlgorithmIdentifierConverter;
import org.bouncycastle.cms.jcajce.JcePasswordAuthenticatedRecipient;
import org.bouncycastle.cms.jcajce.JcePasswordEnvelopedRecipient;
import org.bouncycastle.cms.jcajce.JcePasswordRecipient;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;

public class PasswordRecipientInformation
  extends RecipientInformation
{
  static Map KEYSIZES = new HashMap();
  static Map BLOCKSIZES = new HashMap();
  private PasswordRecipientInfo info;
  
  PasswordRecipientInformation(PasswordRecipientInfo paramPasswordRecipientInfo, AlgorithmIdentifier paramAlgorithmIdentifier, CMSSecureReadable paramCMSSecureReadable, AuthAttributesProvider paramAuthAttributesProvider)
  {
    super(paramPasswordRecipientInfo.getKeyEncryptionAlgorithm(), paramAlgorithmIdentifier, paramCMSSecureReadable, paramAuthAttributesProvider);
    info = paramPasswordRecipientInfo;
    rid = new PasswordRecipientId();
  }
  
  public String getKeyDerivationAlgOID()
  {
    if (info.getKeyDerivationAlgorithm() != null) {
      return info.getKeyDerivationAlgorithm().getAlgorithm().getId();
    }
    return null;
  }
  
  public byte[] getKeyDerivationAlgParams()
  {
    try
    {
      if (info.getKeyDerivationAlgorithm() != null)
      {
        ASN1Encodable localASN1Encodable = info.getKeyDerivationAlgorithm().getParameters();
        if (localASN1Encodable != null) {
          return localASN1Encodable.toASN1Primitive().getEncoded();
        }
      }
      return null;
    }
    catch (Exception localException)
    {
      throw new RuntimeException("exception getting encryption parameters " + localException);
    }
  }
  
  public AlgorithmIdentifier getKeyDerivationAlgorithm()
  {
    return info.getKeyDerivationAlgorithm();
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getKeyDerivationAlgParameters(String paramString)
    throws NoSuchProviderException
  {
    return getKeyDerivationAlgParameters(CMSUtils.getProvider(paramString));
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getKeyDerivationAlgParameters(Provider paramProvider)
  {
    try
    {
      return new JceAlgorithmIdentifierConverter().setProvider(paramProvider).getAlgorithmParameters(info.getKeyDerivationAlgorithm());
    }
    catch (Exception localException)
    {
      throw new RuntimeException("exception getting encryption parameters " + localException);
    }
  }
  
  /**
   * @deprecated
   */
  public CMSTypedStream getContentStream(Key paramKey, String paramString)
    throws CMSException, NoSuchProviderException
  {
    return getContentStream(paramKey, CMSUtils.getProvider(paramString));
  }
  
  /**
   * @deprecated
   */
  public CMSTypedStream getContentStream(Key paramKey, Provider paramProvider)
    throws CMSException
  {
    try
    {
      CMSPBEKey localCMSPBEKey = (CMSPBEKey)paramKey;
      Object localObject;
      if ((secureReadable instanceof CMSEnvelopedHelper.CMSEnvelopedSecureReadable)) {
        localObject = new JcePasswordEnvelopedRecipient(localCMSPBEKey.getPassword());
      } else {
        localObject = new JcePasswordAuthenticatedRecipient(localCMSPBEKey.getPassword());
      }
      ((JcePasswordRecipient)localObject).setPasswordConversionScheme((localCMSPBEKey instanceof PKCS5Scheme2UTF8PBEKey) ? 1 : 0);
      if (paramProvider != null) {
        ((JcePasswordRecipient)localObject).setProvider(paramProvider);
      }
      return getContentStream((Recipient)localObject);
    }
    catch (IOException localIOException)
    {
      throw new CMSException("encoding error: " + localIOException.getMessage(), localIOException);
    }
  }
  
  protected RecipientOperator getRecipientOperator(Recipient paramRecipient)
    throws CMSException, IOException
  {
    PasswordRecipient localPasswordRecipient = (PasswordRecipient)paramRecipient;
    AlgorithmIdentifier localAlgorithmIdentifier1 = AlgorithmIdentifier.getInstance(info.getKeyEncryptionAlgorithm());
    AlgorithmIdentifier localAlgorithmIdentifier2 = AlgorithmIdentifier.getInstance(localAlgorithmIdentifier1.getParameters());
    byte[] arrayOfByte1 = getPasswordBytes(localPasswordRecipient.getPasswordConversionScheme(), localPasswordRecipient.getPassword());
    PBKDF2Params localPBKDF2Params = PBKDF2Params.getInstance(info.getKeyDerivationAlgorithm().getParameters());
    PKCS5S2ParametersGenerator localPKCS5S2ParametersGenerator = new PKCS5S2ParametersGenerator();
    localPKCS5S2ParametersGenerator.init(arrayOfByte1, localPBKDF2Params.getSalt(), localPBKDF2Params.getIterationCount().intValue());
    int i = ((Integer)KEYSIZES.get(localAlgorithmIdentifier2.getAlgorithm())).intValue();
    byte[] arrayOfByte2 = ((KeyParameter)localPKCS5S2ParametersGenerator.generateDerivedParameters(i)).getKey();
    return localPasswordRecipient.getRecipientOperator(localAlgorithmIdentifier2, messageAlgorithm, arrayOfByte2, info.getEncryptedKey().getOctets());
  }
  
  protected byte[] getPasswordBytes(int paramInt, char[] paramArrayOfChar)
  {
    if (paramInt == 0) {
      return PBEParametersGenerator.PKCS5PasswordToBytes(paramArrayOfChar);
    }
    return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(paramArrayOfChar);
  }
  
  static
  {
    BLOCKSIZES.put(CMSAlgorithm.DES_EDE3_CBC, new Integer(8));
    BLOCKSIZES.put(CMSAlgorithm.AES128_CBC, new Integer(16));
    BLOCKSIZES.put(CMSAlgorithm.AES192_CBC, new Integer(16));
    BLOCKSIZES.put(CMSAlgorithm.AES256_CBC, new Integer(16));
    KEYSIZES.put(CMSAlgorithm.DES_EDE3_CBC, new Integer(192));
    KEYSIZES.put(CMSAlgorithm.AES128_CBC, new Integer(128));
    KEYSIZES.put(CMSAlgorithm.AES192_CBC, new Integer(192));
    KEYSIZES.put(CMSAlgorithm.AES256_CBC, new Integer(256));
  }
}

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

public abstract interface Recipient {}

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

import org.bouncycastle.util.Selector;

public abstract class RecipientId
  implements Selector
{
  public static final int keyTrans = 0;
  public static final int kek = 1;
  public static final int keyAgree = 2;
  public static final int password = 3;
  private final int type;
  
  protected RecipientId(int paramInt)
  {
    type = paramInt;
  }
  
  public int getType()
  {
    return type;
  }
  
  public abstract Object clone();
}

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

import org.bouncycastle.asn1.cms.RecipientInfo;
import org.bouncycastle.operator.GenericKey;

public abstract interface RecipientInfoGenerator
{
  public abstract RecipientInfo generate(GenericKey paramGenericKey)
    throws CMSException;
}

/* Location:
 * Qualified Name:     org.bouncycastle.cms.RecipientInfoGenerator
 * 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.security.AlgorithmParameters;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.Provider;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.jcajce.JceAlgorithmIdentifierConverter;
import org.bouncycastle.util.io.Streams;

public abstract class RecipientInformation
{
  protected RecipientId rid;
  protected AlgorithmIdentifier keyEncAlg;
  protected AlgorithmIdentifier messageAlgorithm;
  protected CMSSecureReadable secureReadable;
  private AuthAttributesProvider additionalData;
  private byte[] resultMac;
  private RecipientOperator operator;
  
  RecipientInformation(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, CMSSecureReadable paramCMSSecureReadable, AuthAttributesProvider paramAuthAttributesProvider)
  {
    keyEncAlg = paramAlgorithmIdentifier1;
    messageAlgorithm = paramAlgorithmIdentifier2;
    secureReadable = paramCMSSecureReadable;
    additionalData = paramAuthAttributesProvider;
  }
  
  public RecipientId getRID()
  {
    return rid;
  }
  
  private byte[] encodeObj(ASN1Encodable paramASN1Encodable)
    throws IOException
  {
    if (paramASN1Encodable != null) {
      return paramASN1Encodable.toASN1Primitive().getEncoded();
    }
    return null;
  }
  
  public AlgorithmIdentifier getKeyEncryptionAlgorithm()
  {
    return keyEncAlg;
  }
  
  public String getKeyEncryptionAlgOID()
  {
    return keyEncAlg.getObjectId().getId();
  }
  
  public byte[] getKeyEncryptionAlgParams()
  {
    try
    {
      return encodeObj(keyEncAlg.getParameters());
    }
    catch (Exception localException)
    {
      throw new RuntimeException("exception getting encryption parameters " + localException);
    }
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getKeyEncryptionAlgorithmParameters(String paramString)
    throws CMSException, NoSuchProviderException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramString).getAlgorithmParameters(keyEncAlg);
  }
  
  /**
   * @deprecated
   */
  public AlgorithmParameters getKeyEncryptionAlgorithmParameters(Provider paramProvider)
    throws CMSException
  {
    return new JceAlgorithmIdentifierConverter().setProvider(paramProvider).getAlgorithmParameters(keyEncAlg);
  }
  
  /**
   * @deprecated
   */
  public byte[] getContent(Key paramKey, String paramString)
    throws CMSException, NoSuchProviderException
  {
    return getContent(paramKey, CMSUtils.getProvider(paramString));
  }
  
  /**
   * @deprecated
   */
  public byte[] getContent(Key paramKey, Provider paramProvider)
    throws CMSException
  {
    try
    {
      return CMSUtils.streamToByteArray(getContentStream(paramKey, paramProvider).getContentStream());
    }
    catch (IOException localIOException)
    {
      throw new RuntimeException("unable to parse internal stream: " + localIOException);
    }
  }
  
  public byte[] getContentDigest()
  {
    if ((secureReadable instanceof CMSEnvelopedHelper.CMSDigestAuthenticatedSecureReadable)) {
      return ((CMSEnvelopedHelper.CMSDigestAuthenticatedSecureReadable)secureReadable).getDigest();
    }
    return null;
  }
  
  public byte[] getMac()
  {
    if ((resultMac == null) && (operator.isMacBased()))
    {
      if (additionalData != null) {
        try
        {
          Streams.drain(operator.getInputStream(new ByteArrayInputStream(additionalData.getAuthAttributes().getEncoded("DER"))));
        }
        catch (IOException localIOException)
        {
          localIOException.printStackTrace();
        }
      }
      resultMac = operator.getMac();
    }
    return resultMac;
  }
  
  public byte[] getContent(Recipient paramRecipient)
    throws CMSException
  {
    try
    {
      return CMSUtils.streamToByteArray(getContentStream(paramRecipient).getContentStream());
    }
    catch (IOException localIOException)
    {
      throw new CMSException("unable to parse internal stream: " + localIOException.getMessage(), localIOException);
    }
  }
  
  /**
   * @deprecated
   */
  public CMSTypedStream getContentStream(Key paramKey, String paramString)
    throws CMSException, NoSuchProviderException
  {
    return getContentStream(paramKey, CMSUtils.getProvider(paramString));
  }
  
  /**
   * @deprecated
   */
  public abstract CMSTypedStream getContentStream(Key paramKey, Provider paramProvider)
    throws CMSException;
  
  public CMSTypedStream getContentStream(Recipient paramRecipient)
    throws CMSException, IOException
  {
    operator = getRecipientOperator(paramRecipient);
    if (additionalData != null) {
      return new CMSTypedStream(secureReadable.getInputStream());
    }
    return new CMSTypedStream(operator.getInputStream(secureReadable.getInputStream()));
  }
  
  protected abstract RecipientOperator getRecipientOperator(Recipient paramRecipient)
    throws CMSException, IOException;
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class RecipientInformationStore
{
  private final List all;
  private final Map table = new HashMap();
  
  public RecipientInformationStore(Collection paramCollection)
  {
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
    {
      RecipientInformation localRecipientInformation = (RecipientInformation)localIterator.next();
      RecipientId localRecipientId = localRecipientInformation.getRID();
      ArrayList localArrayList = (ArrayList)table.get(localRecipientId);
      if (localArrayList == null)
      {
        localArrayList = new ArrayList(1);
        table.put(localRecipientId, localArrayList);
      }
      localArrayList.add(localRecipientInformation);
    }
    all = new ArrayList(paramCollection);
  }
  
  public RecipientInformation get(RecipientId paramRecipientId)
  {
    Collection localCollection = getRecipients(paramRecipientId);
    return localCollection.size() == 0 ? null : (RecipientInformation)localCollection.iterator().next();
  }
  
  public int size()
  {
    return all.size();
  }
  
  public Collection getRecipients()
  {
    return new ArrayList(all);
  }
  
  public Collection getRecipients(RecipientId paramRecipientId)
  {
    if ((paramRecipientId instanceof KeyTransRecipientId))
    {
      localObject = (KeyTransRecipientId)paramRecipientId;
      byte[] arrayOfByte = ((KeyTransRecipientId)localObject).getSubjectKeyIdentifier();
      if ((((KeyTransRecipientId)localObject).getIssuer() != null) && (arrayOfByte != null))
      {
        localArrayList = new ArrayList();
        Collection localCollection1 = getRecipients(new KeyTransRecipientId(((KeyTransRecipientId)localObject).getIssuer(), ((KeyTransRecipientId)localObject).getSerialNumber()));
        if (localCollection1 != null) {
          localArrayList.addAll(localCollection1);
        }
        Collection localCollection2 = getRecipients(new KeyTransRecipientId(arrayOfByte));
        if (localCollection2 != null) {
          localArrayList.addAll(localCollection2);
        }
        return localArrayList;
      }
      ArrayList localArrayList = (ArrayList)table.get(paramRecipientId);
      return localArrayList == null ? new ArrayList() : new ArrayList(localArrayList);
    }
    Object localObject = (ArrayList)table.get(paramRecipientId);
    return localObject == null ? new ArrayList() : new ArrayList((Collection)localObject);
  }
}

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

import java.io.InputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputDecryptor;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.util.io.TeeInputStream;

public class RecipientOperator
{
  private final AlgorithmIdentifier algorithmIdentifier;
  private final Object operator;
  
  public RecipientOperator(InputDecryptor paramInputDecryptor)
  {
    algorithmIdentifier = paramInputDecryptor.getAlgorithmIdentifier();
    operator = paramInputDecryptor;
  }
  
  public RecipientOperator(MacCalculator paramMacCalculator)
  {
    algorithmIdentifier = paramMacCalculator.getAlgorithmIdentifier();
    operator = paramMacCalculator;
  }
  
  public InputStream getInputStream(InputStrea
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