bcpkix-jdk15on-147

Recipient(X509Certificate paramX509Certificate)
    throws CertificateEncodingException
  {
    recipientIDs.add(new KeyAgreeRecipientIdentifier(CMSUtils.getIssuerAndSerialNumber(paramX509Certificate)));
    recipientKeys.add(paramX509Certificate.getPublicKey());
    return this;
  }
  
  public JceKeyAgreeRecipientInfoGenerator addRecipient(byte[] paramArrayOfByte, PublicKey paramPublicKey)
    throws CertificateEncodingException
  {
    recipientIDs.add(new KeyAgreeRecipientIdentifier(new RecipientKeyIdentifier(paramArrayOfByte)));
    recipientKeys.add(paramPublicKey);
    return this;
  }
  
  public ASN1Sequence generateRecipientEncryptedKeys(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, GenericKey paramGenericKey)
    throws CMSException
  {
    init(paramAlgorithmIdentifier1.getAlgorithm());
    Object localObject1 = senderPrivateKey;
    ASN1ObjectIdentifier localASN1ObjectIdentifier = paramAlgorithmIdentifier1.getAlgorithm();
    if (localASN1ObjectIdentifier.getId().equals(CMSEnvelopedGenerator.ECMQV_SHA1KDF)) {
      localObject1 = new MQVPrivateKeySpec((PrivateKey)localObject1, ephemeralKP.getPrivate(), ephemeralKP.getPublic());
    }
    ASN1EncodableVector localASN1EncodableVector = new ASN1EncodableVector();
    for (int i = 0; i != recipientIDs.size(); i++)
    {
      Object localObject2 = (PublicKey)recipientKeys.get(i);
      KeyAgreeRecipientIdentifier localKeyAgreeRecipientIdentifier = (KeyAgreeRecipientIdentifier)recipientIDs.get(i);
      if (localASN1ObjectIdentifier.getId().equals(CMSEnvelopedGenerator.ECMQV_SHA1KDF)) {
        localObject2 = new MQVPublicKeySpec((PublicKey)localObject2, (PublicKey)localObject2);
      }
      try
      {
        KeyAgreement localKeyAgreement = helper.createKeyAgreement(localASN1ObjectIdentifier);
        localKeyAgreement.init((Key)localObject1, random);
        localKeyAgreement.doPhase((Key)localObject2, true);
        SecretKey localSecretKey = localKeyAgreement.generateSecret(paramAlgorithmIdentifier2.getAlgorithm().getId());
        Cipher localCipher = helper.createCipher(paramAlgorithmIdentifier2.getAlgorithm());
        localCipher.init(3, localSecretKey, random);
        byte[] arrayOfByte = localCipher.wrap(helper.getJceKey(paramGenericKey));
        DEROctetString localDEROctetString = new DEROctetString(arrayOfByte);
        localASN1EncodableVector.add(new RecipientEncryptedKey(localKeyAgreeRecipientIdentifier, localDEROctetString));
      }
      catch (GeneralSecurityException localGeneralSecurityException)
      {
        throw new CMSException("cannot perform agreement step: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
      }
    }
    return new DERSequence(localASN1EncodableVector);
  }
  
  protected ASN1Encodable getUserKeyingMaterial(AlgorithmIdentifier paramAlgorithmIdentifier)
    throws CMSException
  {
    init(paramAlgorithmIdentifier.getAlgorithm());
    if (ephemeralKP != null) {
      return new MQVuserKeyingMaterial(createOriginatorPublicKey(SubjectPublicKeyInfo.getInstance(ephemeralKP.getPublic().getEncoded())), null);
    }
    return null;
  }
  
  private void init(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CMSException
  {
    if (random == null) {
      random = new SecureRandom();
    }
    if ((paramASN1ObjectIdentifier.equals(CMSAlgorithm.ECMQV_SHA1KDF)) && (ephemeralKP == null)) {
      try
      {
        ECParameterSpec localECParameterSpec = ((ECPublicKey)senderPublicKey).getParams();
        KeyPairGenerator localKeyPairGenerator = helper.createKeyPairGenerator(paramASN1ObjectIdentifier);
        localKeyPairGenerator.initialize(localECParameterSpec, random);
        ephemeralKP = localKeyPairGenerator.generateKeyPair();
      }
      catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
      {
        throw new CMSException("cannot determine MQV ephemeral key pair parameters from public key: " + localInvalidAlgorithmParameterException);
      }
    }
  }
}

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

import java.io.OutputStream;
import java.security.Key;
import javax.crypto.Mac;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.jcajce.io.MacOutputStream;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.MacCalculator;

class JceKeyTransAuthenticatedRecipient$1
  implements MacCalculator
{
  JceKeyTransAuthenticatedRecipient$1(JceKeyTransAuthenticatedRecipient paramJceKeyTransAuthenticatedRecipient, AlgorithmIdentifier paramAlgorithmIdentifier, Key paramKey, Mac paramMac) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$contentMacAlgorithm;
  }
  
  public GenericKey getKey()
  {
    return new GenericKey(val$secretKey);
  }
  
  public OutputStream getOutputStream()
  {
    return new MacOutputStream(val$dataMac);
  }
  
  public byte[] getMac()
  {
    return val$dataMac.doFinal();
  }
}

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

import java.io.OutputStream;
import java.security.Key;
import java.security.PrivateKey;
import javax.crypto.Mac;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.RecipientOperator;
import org.bouncycastle.jcajce.io.MacOutputStream;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.MacCalculator;

public class JceKeyTransAuthenticatedRecipient
  extends JceKeyTransRecipient
{
  public JceKeyTransAuthenticatedRecipient(PrivateKey paramPrivateKey)
  {
    super(paramPrivateKey);
  }
  
  public RecipientOperator getRecipientOperator(AlgorithmIdentifier paramAlgorithmIdentifier1, final AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CMSException
  {
    final Key localKey = extractSecretKey(paramAlgorithmIdentifier1, paramAlgorithmIdentifier2, paramArrayOfByte);
    final Mac localMac = contentHelper.createContentMac(localKey, paramAlgorithmIdentifier2);
    new RecipientOperator(new MacCalculator()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier2;
      }
      
      public GenericKey getKey()
      {
        return new GenericKey(localKey);
      }
      
      public OutputStream getOutputStream()
      {
        return new MacOutputStream(localMac);
      }
      
      public byte[] getMac()
      {
        return localMac.doFinal();
      }
    });
  }
}

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

import java.io.InputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputDecryptor;

class JceKeyTransEnvelopedRecipient$1
  implements InputDecryptor
{
  JceKeyTransEnvelopedRecipient$1(JceKeyTransEnvelopedRecipient paramJceKeyTransEnvelopedRecipient, AlgorithmIdentifier paramAlgorithmIdentifier, Cipher paramCipher) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$contentEncryptionAlgorithm;
  }
  
  public InputStream getInputStream(InputStream paramInputStream)
  {
    return new CipherInputStream(paramInputStream, val$dataCipher);
  }
}

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

import java.io.InputStream;
import java.security.Key;
import java.security.PrivateKey;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.RecipientOperator;
import org.bouncycastle.operator.InputDecryptor;

public class JceKeyTransEnvelopedRecipient
  extends JceKeyTransRecipient
{
  public JceKeyTransEnvelopedRecipient(PrivateKey paramPrivateKey)
  {
    super(paramPrivateKey);
  }
  
  public RecipientOperator getRecipientOperator(AlgorithmIdentifier paramAlgorithmIdentifier1, final AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CMSException
  {
    Key localKey = extractSecretKey(paramAlgorithmIdentifier1, paramAlgorithmIdentifier2, paramArrayOfByte);
    final Cipher localCipher = contentHelper.createContentCipher(localKey, paramAlgorithmIdentifier2);
    new RecipientOperator(new InputDecryptor()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier2;
      }
      
      public InputStream getInputStream(InputStream paramAnonymousInputStream)
      {
        return new CipherInputStream(paramAnonymousInputStream, localCipher);
      }
    });
  }
}

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

import java.security.Key;
import java.security.PrivateKey;
import java.security.Provider;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.KeyTransRecipient;
import org.bouncycastle.operator.OperatorException;
import org.bouncycastle.operator.jcajce.JceAsymmetricKeyUnwrapper;

public abstract class JceKeyTransRecipient
  implements KeyTransRecipient
{
  private PrivateKey recipientKey;
  protected EnvelopedDataHelper helper = new EnvelopedDataHelper(new DefaultJcaJceExtHelper());
  protected EnvelopedDataHelper contentHelper = helper;
  protected Map extraMappings = new HashMap();
  
  public JceKeyTransRecipient(PrivateKey paramPrivateKey)
  {
    recipientKey = paramPrivateKey;
  }
  
  public JceKeyTransRecipient setProvider(Provider paramProvider)
  {
    helper = new EnvelopedDataHelper(new ProviderJcaJceExtHelper(paramProvider));
    contentHelper = helper;
    return this;
  }
  
  public JceKeyTransRecipient setProvider(String paramString)
  {
    helper = new EnvelopedDataHelper(new NamedJcaJceExtHelper(paramString));
    contentHelper = helper;
    return this;
  }
  
  public JceKeyTransRecipient setAlgorithmMapping(ASN1ObjectIdentifier paramASN1ObjectIdentifier, String paramString)
  {
    extraMappings.put(paramASN1ObjectIdentifier, paramString);
    return this;
  }
  
  public JceKeyTransRecipient setContentProvider(Provider paramProvider)
  {
    contentHelper = CMSUtils.createContentHelper(paramProvider);
    return this;
  }
  
  public JceKeyTransRecipient setContentProvider(String paramString)
  {
    contentHelper = CMSUtils.createContentHelper(paramString);
    return this;
  }
  
  protected Key extractSecretKey(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CMSException
  {
    JceAsymmetricKeyUnwrapper localJceAsymmetricKeyUnwrapper = helper.createAsymmetricUnwrapper(paramAlgorithmIdentifier1, recipientKey);
    if (!extraMappings.isEmpty())
    {
      Iterator localIterator = extraMappings.keySet().iterator();
      while (localIterator.hasNext())
      {
        ASN1ObjectIdentifier localASN1ObjectIdentifier = (ASN1ObjectIdentifier)localIterator.next();
        localJceAsymmetricKeyUnwrapper.setAlgorithmMapping(localASN1ObjectIdentifier, (String)extraMappings.get(localASN1ObjectIdentifier));
      }
    }
    try
    {
      return helper.getJceKey(paramAlgorithmIdentifier2.getAlgorithm(), localJceAsymmetricKeyUnwrapper.generateUnwrappedKey(paramAlgorithmIdentifier2, paramArrayOfByte));
    }
    catch (OperatorException localOperatorException)
    {
      throw new CMSException("exception unwrapping key: " + localOperatorException.getMessage(), localOperatorException);
    }
  }
}

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

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

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

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

import java.security.Provider;
import java.security.PublicKey;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import org.bouncycastle.cms.KeyTransRecipientInfoGenerator;
import org.bouncycastle.operator.jcajce.JceAsymmetricKeyWrapper;

public class JceKeyTransRecipientInfoGenerator
  extends KeyTransRecipientInfoGenerator
{
  public JceKeyTransRecipientInfoGenerator(X509Certificate paramX509Certificate)
    throws CertificateEncodingException
  {
    super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(paramX509Certificate).toASN1Structure()), new JceAsymmetricKeyWrapper(paramX509Certificate.getPublicKey()));
  }
  
  public JceKeyTransRecipientInfoGenerator(byte[] paramArrayOfByte, PublicKey paramPublicKey)
  {
    super(paramArrayOfByte, new JceAsymmetricKeyWrapper(paramPublicKey));
  }
  
  public JceKeyTransRecipientInfoGenerator setProvider(String paramString)
  {
    ((JceAsymmetricKeyWrapper)wrapper).setProvider(paramString);
    return this;
  }
  
  public JceKeyTransRecipientInfoGenerator setProvider(Provider paramProvider)
  {
    ((JceAsymmetricKeyWrapper)wrapper).setProvider(paramProvider);
    return this;
  }
  
  public JceKeyTransRecipientInfoGenerator setAlgorithmMapping(ASN1ObjectIdentifier paramASN1ObjectIdentifier, String paramString)
  {
    ((JceAsymmetricKeyWrapper)wrapper).setAlgorithmMapping(paramASN1ObjectIdentifier, paramString);
    return this;
  }
}

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

import java.io.OutputStream;
import java.security.Key;
import javax.crypto.Mac;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.jcajce.io.MacOutputStream;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.MacCalculator;

class JcePasswordAuthenticatedRecipient$1
  implements MacCalculator
{
  JcePasswordAuthenticatedRecipient$1(JcePasswordAuthenticatedRecipient paramJcePasswordAuthenticatedRecipient, AlgorithmIdentifier paramAlgorithmIdentifier, Key paramKey, Mac paramMac) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$contentMacAlgorithm;
  }
  
  public GenericKey getKey()
  {
    return new GenericKey(val$secretKey);
  }
  
  public OutputStream getOutputStream()
  {
    return new MacOutputStream(val$dataMac);
  }
  
  public byte[] getMac()
  {
    return val$dataMac.doFinal();
  }
}

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

import java.io.OutputStream;
import java.security.Key;
import javax.crypto.Mac;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.RecipientOperator;
import org.bouncycastle.jcajce.io.MacOutputStream;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.MacCalculator;

public class JcePasswordAuthenticatedRecipient
  extends JcePasswordRecipient
{
  public JcePasswordAuthenticatedRecipient(char[] paramArrayOfChar)
  {
    super(paramArrayOfChar);
  }
  
  public RecipientOperator getRecipientOperator(AlgorithmIdentifier paramAlgorithmIdentifier1, final AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws CMSException
  {
    final Key localKey = extractSecretKey(paramAlgorithmIdentifier1, paramAlgorithmIdentifier2, paramArrayOfByte1, paramArrayOfByte2);
    final Mac localMac = helper.createContentMac(localKey, paramAlgorithmIdentifier2);
    new RecipientOperator(new MacCalculator()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier2;
      }
      
      public GenericKey getKey()
      {
        return new GenericKey(localKey);
      }
      
      public OutputStream getOutputStream()
      {
        return new MacOutputStream(localMac);
      }
      
      public byte[] getMac()
      {
        return localMac.doFinal();
      }
    });
  }
}

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

import java.io.InputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputDecryptor;

class JcePasswordEnvelopedRecipient$1
  implements InputDecryptor
{
  JcePasswordEnvelopedRecipient$1(JcePasswordEnvelopedRecipient paramJcePasswordEnvelopedRecipient, AlgorithmIdentifier paramAlgorithmIdentifier, Cipher paramCipher) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$contentEncryptionAlgorithm;
  }
  
  public InputStream getInputStream(InputStream paramInputStream)
  {
    return new CipherInputStream(paramInputStream, val$dataCipher);
  }
}

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

import java.io.InputStream;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.RecipientOperator;
import org.bouncycastle.operator.InputDecryptor;

public class JcePasswordEnvelopedRecipient
  extends JcePasswordRecipient
{
  public JcePasswordEnvelopedRecipient(char[] paramArrayOfChar)
  {
    super(paramArrayOfChar);
  }
  
  public RecipientOperator getRecipientOperator(AlgorithmIdentifier paramAlgorithmIdentifier1, final AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws CMSException
  {
    Key localKey = extractSecretKey(paramAlgorithmIdentifier1, paramAlgorithmIdentifier2, paramArrayOfByte1, paramArrayOfByte2);
    final Cipher localCipher = helper.createContentCipher(localKey, paramAlgorithmIdentifier2);
    new RecipientOperator(new InputDecryptor()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier2;
      }
      
      public InputStream getInputStream(InputStream paramAnonymousInputStream)
      {
        return new CipherInputStream(paramAnonymousInputStream, localCipher);
      }
    });
  }
}

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

import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.Provider;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.PasswordRecipient;

public abstract class JcePasswordRecipient
  implements PasswordRecipient
{
  private int schemeID = 1;
  protected EnvelopedDataHelper helper = new EnvelopedDataHelper(new DefaultJcaJceExtHelper());
  private char[] password;
  
  JcePasswordRecipient(char[] paramArrayOfChar)
  {
    password = paramArrayOfChar;
  }
  
  public JcePasswordRecipient setPasswordConversionScheme(int paramInt)
  {
    schemeID = paramInt;
    return this;
  }
  
  public JcePasswordRecipient setProvider(Provider paramProvider)
  {
    helper = new EnvelopedDataHelper(new ProviderJcaJceExtHelper(paramProvider));
    return this;
  }
  
  public JcePasswordRecipient setProvider(String paramString)
  {
    helper = new EnvelopedDataHelper(new NamedJcaJceExtHelper(paramString));
    return this;
  }
  
  protected Key extractSecretKey(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws CMSException
  {
    Cipher localCipher = helper.createRFC3211Wrapper(paramAlgorithmIdentifier1.getAlgorithm());
    try
    {
      IvParameterSpec localIvParameterSpec = new IvParameterSpec(ASN1OctetString.getInstance(paramAlgorithmIdentifier1.getParameters()).getOctets());
      localCipher.init(4, new SecretKeySpec(paramArrayOfByte1, localCipher.getAlgorithm()), localIvParameterSpec);
      return localCipher.unwrap(paramArrayOfByte2, paramAlgorithmIdentifier2.getAlgorithm().getId(), 3);
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot process content encryption key: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  public int getPasswordConversionScheme()
  {
    return schemeID;
  }
  
  public char[] getPassword()
  {
    return password;
  }
}

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

import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.Provider;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cms.CMSException;
import org.bouncycastle.cms.PasswordRecipientInfoGenerator;
import org.bouncycastle.operator.GenericKey;

public class JcePasswordRecipientInfoGenerator
  extends PasswordRecipientInfoGenerator
{
  private EnvelopedDataHelper helper = new EnvelopedDataHelper(new DefaultJcaJceExtHelper());
  
  public JcePasswordRecipientInfoGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier, char[] paramArrayOfChar)
  {
    super(paramASN1ObjectIdentifier, paramArrayOfChar);
  }
  
  public JcePasswordRecipientInfoGenerator setProvider(Provider paramProvider)
  {
    helper = new EnvelopedDataHelper(new ProviderJcaJceExtHelper(paramProvider));
    return this;
  }
  
  public JcePasswordRecipientInfoGenerator setProvider(String paramString)
  {
    helper = new EnvelopedDataHelper(new NamedJcaJceExtHelper(paramString));
    return this;
  }
  
  public byte[] generateEncryptedBytes(AlgorithmIdentifier paramAlgorithmIdentifier, byte[] paramArrayOfByte, GenericKey paramGenericKey)
    throws CMSException
  {
    Key localKey = helper.getJceKey(paramGenericKey);
    Cipher localCipher = helper.createRFC3211Wrapper(paramAlgorithmIdentifier.getAlgorithm());
    try
    {
      IvParameterSpec localIvParameterSpec = new IvParameterSpec(ASN1OctetString.getInstance(paramAlgorithmIdentifier.getParameters()).getOctets());
      localCipher.init(3, new SecretKeySpec(paramArrayOfByte, localCipher.getAlgorithm()), localIvParameterSpec);
      return localCipher.wrap(localKey);
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CMSException("cannot process content encryption key: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
}

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

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

class NamedJcaJceExtHelper
  extends NamedJcaJceHelper
  implements JcaJceExtHelper
{
  public NamedJcaJceExtHelper(String paramString)
  {
    super(paramString);
  }
  
  public JceAsymmetricKeyUnwrapper createAsymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, PrivateKey paramPrivateKey)
  {
    return new JceAsymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramPrivateKey).setProvider(providerName);
  }
  
  public SymmetricKeyUnwrapper createSymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, SecretKey paramSecretKey)
  {
    return new JceSymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramSecretKey).setProvider(providerName);
  }
}

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

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

class ProviderJcaJceExtHelper
  extends ProviderJcaJceHelper
  implements JcaJceExtHelper
{
  public ProviderJcaJceExtHelper(Provider paramProvider)
  {
    super(paramProvider);
  }
  
  public JceAsymmetricKeyUnwrapper createAsymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, PrivateKey paramPrivateKey)
  {
    return new JceAsymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramPrivateKey).setProvider(provider);
  }
  
  public SymmetricKeyUnwrapper createSymmetricUnwrapper(AlgorithmIdentifier paramAlgorithmIdentifier, SecretKey paramSecretKey)
  {
    return new JceSymmetricKeyUnwrapper(paramAlgorithmIdentifier, paramSecretKey).setProvider(provider);
  }
}

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

import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.OutputCompressor;

public class ZlibCompressor
  implements OutputCompressor
{
  private static final String ZLIB = "1.2.840.113549.1.9.16.3.8";
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return new AlgorithmIdentifier(new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.3.8"));
  }
  
  public OutputStream getOutputStream(OutputStream paramOutputStream)
  {
    return new DeflaterOutputStream(paramOutputStream);
  }
}

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

import java.io.InputStream;
import java.util.zip.InflaterInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputExpander;

class ZlibExpanderProvider$1
  implements InputExpander
{
  ZlibExpanderProvider$1(ZlibExpanderProvider paramZlibExpanderProvider, AlgorithmIdentifier paramAlgorithmIdentifier) {}
  
  public AlgorithmIdentifier getAlgorithmIdentifier()
  {
    return val$algorithm;
  }
  
  public InputStream getInputStream(InputStream paramInputStream)
  {
    Object localObject = new InflaterInputStream(paramInputStream);
    if (ZlibExpanderProvider.access$000(this$0) >= 0L) {
      localObject = new ZlibExpanderProvider.LimitedInputStream((InputStream)localObject, ZlibExpanderProvider.access$000(this$0));
    }
    return (InputStream)localObject;
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.bouncycastle.util.io.StreamOverflowException;

class ZlibExpanderProvider$LimitedInputStream
  extends FilterInputStream
{
  private long remaining;
  
  public ZlibExpanderProvider$LimitedInputStream(InputStream paramInputStream, long paramLong)
  {
    super(paramInputStream);
    remaining = paramLong;
  }
  
  public int read()
    throws IOException
  {
    if (remaining >= 0L)
    {
      int i = in.read();
      if ((i < 0) || (--remaining >= 0L)) {
        return i;
      }
    }
    throw new StreamOverflowException("expanded byte limit exceeded");
  }
  
  public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    if (paramInt2 < 1) {
      return super.read(paramArrayOfByte, paramInt1, paramInt2);
    }
    if (remaining < 1L)
    {
      read();
      return -1;
    }
    int i = remaining > paramInt2 ? paramInt2 : (int)remaining;
    int j = in.read(paramArrayOfByte, paramInt1, i);
    if (j > 0) {
      remaining -= j;
    }
    return j;
  }
}

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

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.InflaterInputStream;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputExpander;
import org.bouncycastle.operator.InputExpanderProvider;
import org.bouncycastle.util.io.StreamOverflowException;

public class ZlibExpanderProvider
  implements InputExpanderProvider
{
  private final long limit;
  
  public ZlibExpanderProvider()
  {
    limit = -1L;
  }
  
  public ZlibExpanderProvider(long paramLong)
  {
    limit = paramLong;
  }
  
  public InputExpander get(final AlgorithmIdentifier paramAlgorithmIdentifier)
  {
    new InputExpander()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier;
      }
      
      public InputStream getInputStream(InputStream paramAnonymousInputStream)
      {
        Object localObject = new InflaterInputStream(paramAnonymousInputStream);
        if (limit >= 0L) {
          localObject = new ZlibExpanderProvider.LimitedInputStream((InputStream)localObject, limit);
        }
        return (InputStream)localObject;
      }
    };
  }
  
  private static class LimitedInputStream
    extends FilterInputStream
  {
    private long remaining;
    
    public LimitedInputStream(InputStream paramInputStream, long paramLong)
    {
      super();
      remaining = paramLong;
    }
    
    public int read()
      throws IOException
    {
      if (remaining >= 0L)
      {
        int i = in.read();
        if ((i < 0) || (--remaining >= 0L)) {
          return i;
        }
      }
      throw new StreamOverflowException("expanded byte limit exceeded");
    }
    
    public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
      throws IOException
    {
      if (paramInt2 < 1) {
        return super.read(paramArrayOfByte, paramInt1, paramInt2);
      }
      if (remaining < 1L)
      {
        read();
        return -1;
      }
      int i = remaining > paramInt2 ? paramInt2 : (int)remaining;
      int j = in.read(paramArrayOfByte, paramInt1, i);
      if (j > 0) {
        remaining -= j;
      }
      return j;
    }
  }
}

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

import java.io.OutputStream;
import org.bouncycastle.asn1.DERApplicationSpecific;
import org.bouncycastle.asn1.eac.CVCertificate;
import org.bouncycastle.asn1.eac.CertificateBody;
import org.bouncycastle.asn1.eac.CertificateHolderAuthorization;
import org.bouncycastle.asn1.eac.CertificateHolderReference;
import org.bouncycastle.asn1.eac.CertificationAuthorityReference;
import org.bouncycastle.asn1.eac.PackedDate;
import org.bouncycastle.asn1.eac.PublicKeyDataObject;
import org.bouncycastle.eac.operator.EACSigner;

public class EACCertificateBuilder
{
  private static final byte[] ZeroArray = { 0 };
  private PublicKeyDataObject publicKey;
  private CertificateHolderAuthorization certificateHolderAuthorization;
  private PackedDate certificateEffectiveDate;
  private PackedDate certificateExpirationDate;
  private CertificateHolderReference certificateHolderReference;
  private CertificationAuthorityReference certificationAuthorityReference;
  
  public EACCertificateBuilder(CertificationAuthorityReference paramCertificationAuthorityReference, PublicKeyDataObject paramPublicKeyDataObject, CertificateHolderReference paramCertificateHolderReference, CertificateHolderAuthorization paramCertificateHolderAuthorization, PackedDate paramPackedDate1, PackedDate paramPackedDate2)
  {
    certificationAuthorityReference = paramCertificationAuthorityReference;
    publicKey = paramPublicKeyDataObject;
    certificateHolderReference = paramCertificateHolderReference;
    certificateHolderAuthorization = paramCertificateHolderAuthorization;
    certificateEffectiveDate = paramPackedDate1;
    certificateExpirationDate = paramPackedDate2;
  }
  
  private CertificateBody buildBody()
  {
    DERApplicationSpecific localDERApplicationSpecific = new DERApplicationSpecific(41, ZeroArray);
    CertificateBody localCertificateBody = new CertificateBody(localDERApplicationSpecific, certificationAuthorityReference, publicKey, certificateHolderReference, certificateHolderAuthorization, certificateEffectiveDate, certificateExpirationDate);
    return localCertificateBody;
  }
  
  public EACCertificateHolder build(EACSigner paramEACSigner)
    throws EACException
  {
    try
    {
      CertificateBody localCertificateBody = buildBody();
      OutputStream localOutputStream = paramEACSigner.getOutputStream();
      localOutputStream.write(localCertificateBody.getEncoded("DER"));
      localOutputStream.close();
      return new EACCertificateHolder(new CVCertificate(localCertificateBody, paramEACSigner.getSignature()));
    }
    catch (Exception localException)
    {
      throw new EACException("unable to process signature: " + localException.getMessage(), localException);
    }
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1ParsingException;
import org.bouncycastle.asn1.eac.CVCertificate;
import org.bouncycastle.asn1.eac.CertificateBody;
import org.bouncycastle.asn1.eac.PublicKeyDataObject;
import org.bouncycastle.eac.operator.EACSignatureVerifier;

public class EACCertificateHolder
{
  private CVCertificate cvCertificate;
  
  private static CVCertificate parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return CVCertificate.getInstance(paramArrayOfByte);
    }
    catch (ClassCastException localClassCastException)
    {
      throw new EACIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw new EACIOException("malformed data: " + localIllegalArgumentException.getMessage(), localIllegalArgumentException);
    }
    catch (ASN1ParsingException localASN1ParsingException)
    {
      if ((localASN1ParsingException.getCause() instanceof IOException)) {
        throw ((IOException)localASN1ParsingException.getCause());
      }
      throw new EACIOException("malformed data: " + localASN1ParsingException.getMessage(), localASN1ParsingException);
    }
  }
  
  public EACCertificateHolder(byte[] paramArrayOfByte)
    throws IOException
  {
    this(parseBytes(paramArrayOfByte));
  }
  
  public EACCertificateHolder(CVCertificate paramCVCertificate)
  {
    cvCertificate = paramCVCertificate;
  }
  
  public CVCertificate toASN1Structure()
  {
    return cvCertificate;
  }
  
  public PublicKeyDataObject getPublicKeyDataObject()
  {
    return cvCertificate.getBody().getPublicKey();
  }
  
  public boolean isSignatureValid(EACSignatureVerifier paramEACSignatureVerifier)
    throws EACException
  {
    try
    {
      OutputStream localOutputStream = paramEACSignatureVerifier.getOutputStream();
      localOutputStream.write(cvCertificate.getBody().getEncoded("DER"));
      localOutputStream.close();
      return paramEACSignatureVerifier.verify(cvCertificate.getSignature());
    }
    catch (Exception localException)
    {
      throw new EACException("unable to process signature: " + localException.getMessage(), localException);
    }
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.ASN1ParsingException;
import org.bouncycastle.asn1.eac.CVCertificateRequest;
import org.bouncycastle.asn1.eac.CertificateBody;
import org.bouncycastle.asn1.eac.PublicKeyDataObject;
import org.bouncycastle.eac.operator.EACSignatureVerifier;

public class EACCertificateRequestHolder
{
  private CVCertificateRequest request;
  
  private static CVCertificateRequest parseBytes(byte[] paramArrayOfByte)
    throws IOException
  {
    try
    {
      return CVCertificateRequest.getInstance(paramArrayOfByte);
    }
    catch (ClassCastException localClassCastException)
    {
      throw new EACIOException("malformed data: " + localClassCastException.getMessage(), localClassCastException);
    }
    catch (Ill
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