bcpkix-jdk15on-147

eption("exception calculating mac: " + localCRMFException.getMessage(), localCRMFException);
        }
      }
    };
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.crmf.PKMACValue;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.MacCalculator;

class PKMACValueGenerator
{
  private PKMACBuilder builder;
  
  public PKMACValueGenerator(PKMACBuilder paramPKMACBuilder)
  {
    builder = paramPKMACBuilder;
  }
  
  public PKMACValue generate(char[] paramArrayOfChar, SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
    throws CRMFException
  {
    MacCalculator localMacCalculator = builder.build(paramArrayOfChar);
    OutputStream localOutputStream = localMacCalculator.getOutputStream();
    try
    {
      localOutputStream.write(paramSubjectPublicKeyInfo.getEncoded("DER"));
      localOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new CRMFException("exception encoding mac input: " + localIOException.getMessage(), localIOException);
    }
    return new PKMACValue(localMacCalculator.getAlgorithmIdentifier(), new DERBitString(localMacCalculator.getMac()));
  }
}

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

import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.cmp.PBMParameter;
import org.bouncycastle.asn1.crmf.PKMACValue;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.MacCalculator;
import org.bouncycastle.util.Arrays;

class PKMACValueVerifier
{
  private final PKMACBuilder builder;
  
  public PKMACValueVerifier(PKMACBuilder paramPKMACBuilder)
  {
    builder = paramPKMACBuilder;
  }
  
  public boolean isValid(PKMACValue paramPKMACValue, char[] paramArrayOfChar, SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
    throws CRMFException
  {
    builder.setParameters(PBMParameter.getInstance(paramPKMACValue.getAlgId().getParameters()));
    MacCalculator localMacCalculator = builder.build(paramArrayOfChar);
    OutputStream localOutputStream = localMacCalculator.getOutputStream();
    try
    {
      localOutputStream.write(paramSubjectPublicKeyInfo.getEncoded("DER"));
      localOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new CRMFException("exception encoding mac input: " + localIOException.getMessage(), localIOException);
    }
    return Arrays.areEqual(localMacCalculator.getMac(), paramPKMACValue.getValue().getBytes());
  }
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;

public abstract interface PKMACValuesCalculator
{
  public abstract void setup(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2)
    throws CRMFException;
  
  public abstract byte[] calculateDigest(byte[] paramArrayOfByte)
    throws CRMFException;
  
  public abstract byte[] calculateMac(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
    throws CRMFException;
}

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

import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.crmf.CertRequest;
import org.bouncycastle.asn1.crmf.PKMACValue;
import org.bouncycastle.asn1.crmf.POPOSigningKey;
import org.bouncycastle.asn1.crmf.POPOSigningKeyInput;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.operator.ContentSigner;

public class ProofOfPossessionSigningKeyBuilder
{
  private CertRequest certRequest;
  private SubjectPublicKeyInfo pubKeyInfo;
  private GeneralName name;
  private PKMACValue publicKeyMAC;
  
  public ProofOfPossessionSigningKeyBuilder(CertRequest paramCertRequest)
  {
    certRequest = paramCertRequest;
  }
  
  public ProofOfPossessionSigningKeyBuilder(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
  {
    pubKeyInfo = paramSubjectPublicKeyInfo;
  }
  
  public ProofOfPossessionSigningKeyBuilder setSender(GeneralName paramGeneralName)
  {
    name = paramGeneralName;
    return this;
  }
  
  public ProofOfPossessionSigningKeyBuilder setPublicKeyMac(PKMACValueGenerator paramPKMACValueGenerator, char[] paramArrayOfChar)
    throws CRMFException
  {
    publicKeyMAC = paramPKMACValueGenerator.generate(paramArrayOfChar, pubKeyInfo);
    return this;
  }
  
  public POPOSigningKey build(ContentSigner paramContentSigner)
  {
    if ((name != null) && (publicKeyMAC != null)) {
      throw new IllegalStateException("name and publicKeyMAC cannot both be set.");
    }
    POPOSigningKeyInput localPOPOSigningKeyInput;
    if (certRequest != null)
    {
      localPOPOSigningKeyInput = null;
      CRMFUtil.derEncodeToStream(certRequest, paramContentSigner.getOutputStream());
    }
    else if (name != null)
    {
      localPOPOSigningKeyInput = new POPOSigningKeyInput(name, pubKeyInfo);
      CRMFUtil.derEncodeToStream(localPOPOSigningKeyInput, paramContentSigner.getOutputStream());
    }
    else
    {
      localPOPOSigningKeyInput = new POPOSigningKeyInput(publicKeyMAC, pubKeyInfo);
      CRMFUtil.derEncodeToStream(localPOPOSigningKeyInput, paramContentSigner.getOutputStream());
    }
    return new POPOSigningKey(localPOPOSigningKeyInput, paramContentSigner.getAlgorithmIdentifier(), new DERBitString(paramContentSigner.getSignature()));
  }
}

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

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERUTF8String;
import org.bouncycastle.asn1.crmf.CRMFObjectIdentifiers;

public class RegTokenControl
  implements Control
{
  private static final ASN1ObjectIdentifier type = CRMFObjectIdentifiers.id_regCtrl_regToken;
  private final DERUTF8String token;
  
  public RegTokenControl(DERUTF8String paramDERUTF8String)
  {
    token = paramDERUTF8String;
  }
  
  public RegTokenControl(String paramString)
  {
    token = new DERUTF8String(paramString);
  }
  
  public ASN1ObjectIdentifier getType()
  {
    return type;
  }
  
  public ASN1Encodable getValue()
  {
    return token;
  }
}

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

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.InputDecryptor;

public abstract interface ValueDecryptorGenerator
{
  public abstract InputDecryptor getValueDecryptor(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CRMFException;
}

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

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

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

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

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.spec.InvalidParameterSpecException;
import javax.crypto.NoSuchPaddingException;
import org.bouncycastle.cert.crmf.CRMFException;

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

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

import java.io.IOException;
import java.security.AlgorithmParameterGenerator;
import java.security.AlgorithmParameters;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.InvalidParameterSpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.RC2ParameterSpec;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Null;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.iana.IANAObjectIdentifiers;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.cms.CMSAlgorithm;
import org.bouncycastle.cms.CMSEnvelopedDataGenerator;
import org.bouncycastle.jcajce.JcaJceHelper;

class CRMFHelper
{
  protected static final Map BASE_CIPHER_NAMES = new HashMap();
  protected static final Map CIPHER_ALG_NAMES = new HashMap();
  protected static final Map DIGEST_ALG_NAMES = new HashMap();
  protected static final Map KEY_ALG_NAMES = new HashMap();
  protected static final Map MAC_ALG_NAMES = new HashMap();
  private JcaJceHelper helper;
  
  CRMFHelper(JcaJceHelper paramJcaJceHelper)
  {
    helper = paramJcaJceHelper;
  }
  
  PublicKey toPublicKey(SubjectPublicKeyInfo paramSubjectPublicKeyInfo)
    throws CRMFException
  {
    X509EncodedKeySpec localX509EncodedKeySpec = new X509EncodedKeySpec(new DERBitString(paramSubjectPublicKeyInfo).getBytes());
    AlgorithmIdentifier localAlgorithmIdentifier = paramSubjectPublicKeyInfo.getAlgorithmId();
    try
    {
      return createKeyFactory(localAlgorithmIdentifier.getAlgorithm()).generatePublic(localX509EncodedKeySpec);
    }
    catch (InvalidKeySpecException localInvalidKeySpecException)
    {
      throw new CRMFException("invalid key: " + localInvalidKeySpecException.getMessage(), localInvalidKeySpecException);
    }
  }
  
  Cipher createCipher(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CRMFException
  {
    try
    {
      String str = (String)CIPHER_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createCipher(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createCipher(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("cannot create cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  public KeyGenerator createKeyGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CRMFException
  {
    try
    {
      String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyGenerator(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyGenerator(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("cannot create key generator: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  Cipher createContentCipher(final Key paramKey, final AlgorithmIdentifier paramAlgorithmIdentifier)
    throws CRMFException
  {
    (Cipher)execute(new JCECallback()
    {
      public Object doInJCE()
        throws CRMFException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException
      {
        Cipher localCipher = createCipher(paramAlgorithmIdentifier.getAlgorithm());
        ASN1Primitive localASN1Primitive = (ASN1Primitive)paramAlgorithmIdentifier.getParameters();
        String str = paramAlgorithmIdentifier.getAlgorithm().getId();
        if ((localASN1Primitive != null) && (!(localASN1Primitive instanceof ASN1Null))) {
          try
          {
            AlgorithmParameters localAlgorithmParameters = createAlgorithmParameters(paramAlgorithmIdentifier.getAlgorithm());
            try
            {
              localAlgorithmParameters.init(localASN1Primitive.getEncoded(), "ASN.1");
            }
            catch (IOException localIOException)
            {
              throw new CRMFException("error decoding algorithm parameters.", localIOException);
            }
            localCipher.init(2, paramKey, localAlgorithmParameters);
          }
          catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
          {
            if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals(CMSEnvelopedDataGenerator.AES128_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES192_CBC)) || (str.equals(CMSEnvelopedDataGenerator.AES256_CBC))) {
              localCipher.init(2, paramKey, new IvParameterSpec(ASN1OctetString.getInstance(localASN1Primitive).getOctets()));
            } else {
              throw localNoSuchAlgorithmException;
            }
          }
        } else if ((str.equals(CMSEnvelopedDataGenerator.DES_EDE3_CBC)) || (str.equals("1.3.6.1.4.1.188.7.1.1.2")) || (str.equals("1.2.840.113533.7.66.10"))) {
          localCipher.init(2, paramKey, new IvParameterSpec(new byte[8]));
        } else {
          localCipher.init(2, paramKey);
        }
        return localCipher;
      }
    });
  }
  
  AlgorithmParameters createAlgorithmParameters(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws NoSuchAlgorithmException, NoSuchProviderException
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str != null) {
      try
      {
        return helper.createAlgorithmParameters(str);
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
    }
    return helper.createAlgorithmParameters(paramASN1ObjectIdentifier.getId());
  }
  
  KeyFactory createKeyFactory(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CRMFException
  {
    try
    {
      String str = (String)KEY_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createKeyFactory(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createKeyFactory(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("cannot create cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  MessageDigest createDigest(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CRMFException
  {
    try
    {
      String str = (String)DIGEST_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createDigest(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createDigest(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("cannot create cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  Mac createMac(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws CRMFException
  {
    try
    {
      String str = (String)MAC_ALG_NAMES.get(paramASN1ObjectIdentifier);
      if (str != null) {
        try
        {
          return helper.createMac(str);
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
      }
      return helper.createMac(paramASN1ObjectIdentifier.getId());
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("cannot create mac: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
  }
  
  AlgorithmParameterGenerator createAlgorithmParameterGenerator(ASN1ObjectIdentifier paramASN1ObjectIdentifier)
    throws GeneralSecurityException
  {
    String str = (String)BASE_CIPHER_NAMES.get(paramASN1ObjectIdentifier);
    if (str != null) {
      try
      {
        return helper.createAlgorithmParameterGenerator(str);
      }
      catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {}
    }
    return helper.createAlgorithmParameterGenerator(paramASN1ObjectIdentifier.getId());
  }
  
  AlgorithmParameters generateParameters(ASN1ObjectIdentifier paramASN1ObjectIdentifier, SecretKey paramSecretKey, SecureRandom paramSecureRandom)
    throws CRMFException
  {
    try
    {
      AlgorithmParameterGenerator localAlgorithmParameterGenerator = createAlgorithmParameterGenerator(paramASN1ObjectIdentifier);
      if (paramASN1ObjectIdentifier.equals(CMSEnvelopedDataGenerator.RC2_CBC))
      {
        byte[] arrayOfByte = new byte[8];
        paramSecureRandom.nextBytes(arrayOfByte);
        try
        {
          localAlgorithmParameterGenerator.init(new RC2ParameterSpec(paramSecretKey.getEncoded().length * 8, arrayOfByte), paramSecureRandom);
        }
        catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
        {
          throw new CRMFException("parameters generation error: " + localInvalidAlgorithmParameterException, localInvalidAlgorithmParameterException);
        }
      }
      return localAlgorithmParameterGenerator.generateParameters();
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      return null;
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("exception creating algorithm parameter generator: " + localGeneralSecurityException, localGeneralSecurityException);
    }
  }
  
  AlgorithmIdentifier getAlgorithmIdentifier(ASN1ObjectIdentifier paramASN1ObjectIdentifier, AlgorithmParameters paramAlgorithmParameters)
    throws CRMFException
  {
    Object localObject;
    if (paramAlgorithmParameters != null) {
      try
      {
        localObject = ASN1Primitive.fromByteArray(paramAlgorithmParameters.getEncoded("ASN.1"));
      }
      catch (IOException localIOException)
      {
        throw new CRMFException("cannot encode parameters: " + localIOException.getMessage(), localIOException);
      }
    } else {
      localObject = DERNull.INSTANCE;
    }
    return new AlgorithmIdentifier(paramASN1ObjectIdentifier, (ASN1Encodable)localObject);
  }
  
  static Object execute(JCECallback paramJCECallback)
    throws CRMFException
  {
    try
    {
      return paramJCECallback.doInJCE();
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      throw new CRMFException("can't find algorithm.", localNoSuchAlgorithmException);
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
      throw new CRMFException("key invalid in message.", localInvalidKeyException);
    }
    catch (NoSuchProviderException localNoSuchProviderException)
    {
      throw new CRMFException("can't find provider.", localNoSuchProviderException);
    }
    catch (NoSuchPaddingException localNoSuchPaddingException)
    {
      throw new CRMFException("required padding not supported.", localNoSuchPaddingException);
    }
    catch (InvalidAlgorithmParameterException localInvalidAlgorithmParameterException)
    {
      throw new CRMFException("algorithm parameters invalid.", localInvalidAlgorithmParameterException);
    }
    catch (InvalidParameterSpecException localInvalidParameterSpecException)
    {
      throw new CRMFException("MAC algorithm parameter spec invalid.", localInvalidParameterSpecException);
    }
  }
  
  static
  {
    BASE_CIPHER_NAMES.put(PKCSObjectIdentifiers.des_EDE3_CBC, "DESEDE");
    BASE_CIPHER_NAMES.put(NISTObjectIdentifiers.id_aes128_CBC, "AES");
    BASE_CIPHER_NAMES.put(NISTObjectIdentifiers.id_aes192_CBC, "AES");
    BASE_CIPHER_NAMES.put(NISTObjectIdentifiers.id_aes256_CBC, "AES");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.DES_EDE3_CBC, "DESEDE/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES128_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES192_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(CMSAlgorithm.AES256_CBC, "AES/CBC/PKCS5Padding");
    CIPHER_ALG_NAMES.put(new ASN1ObjectIdentifier(PKCSObjectIdentifiers.rsaEncryption.getId()), "RSA/ECB/PKCS1Padding");
    DIGEST_ALG_NAMES.put(OIWObjectIdentifiers.idSHA1, "SHA1");
    DIGEST_ALG_NAMES.put(NISTObjectIdentifiers.id_sha224, "SHA224");
    DIGEST_ALG_NAMES.put(NISTObjectIdentifiers.id_sha256, "SHA256");
    DIGEST_ALG_NAMES.put(NISTObjectIdentifiers.id_sha384, "SHA384");
    DIGEST_ALG_NAMES.put(NISTObjectIdentifiers.id_sha512, "SHA512");
    MAC_ALG_NAMES.put(IANAObjectIdentifiers.hmacSHA1, "HMACSHA1");
    MAC_ALG_NAMES.put(PKCSObjectIdentifiers.id_hmacWithSHA1, "HMACSHA1");
    MAC_ALG_NAMES.put(PKCSObjectIdentifiers.id_hmacWithSHA224, "HMACSHA224");
    MAC_ALG_NAMES.put(PKCSObjectIdentifiers.id_hmacWithSHA256, "HMACSHA256");
    MAC_ALG_NAMES.put(PKCSObjectIdentifiers.id_hmacWithSHA384, "HMACSHA384");
    MAC_ALG_NAMES.put(PKCSObjectIdentifiers.id_hmacWithSHA512, "HMACSHA512");
    KEY_ALG_NAMES.put(PKCSObjectIdentifiers.rsaEncryption, "RSA");
    KEY_ALG_NAMES.put(X9ObjectIdentifiers.id_dsa, "DSA");
  }
  
  static abstract interface JCECallback
  {
    public abstract Object doInJCE()
      throws CRMFException, InvalidAlgorithmParameterException, InvalidKeyException, InvalidParameterSpecException, NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException;
  }
}

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

import java.io.IOException;
import java.security.Provider;
import java.security.PublicKey;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.crmf.CertReqMsg;
import org.bouncycastle.asn1.crmf.CertTemplate;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.cert.crmf.CertificateRequestMessage;
import org.bouncycastle.jcajce.DefaultJcaJceHelper;
import org.bouncycastle.jcajce.NamedJcaJceHelper;
import org.bouncycastle.jcajce.ProviderJcaJceHelper;

public class JcaCertificateRequestMessage
  extends CertificateRequestMessage
{
  private CRMFHelper helper = new CRMFHelper(new DefaultJcaJceHelper());
  
  public JcaCertificateRequestMessage(CertificateRequestMessage paramCertificateRequestMessage)
  {
    this(paramCertificateRequestMessage.toASN1Structure());
  }
  
  public JcaCertificateRequestMessage(CertReqMsg paramCertReqMsg)
  {
    super(paramCertReqMsg);
  }
  
  public JcaCertificateRequestMessage setProvider(String paramString)
  {
    helper = new CRMFHelper(new NamedJcaJceHelper(paramString));
    return this;
  }
  
  public JcaCertificateRequestMessage setProvider(Provider paramProvider)
  {
    helper = new CRMFHelper(new ProviderJcaJceHelper(paramProvider));
    return this;
  }
  
  public X500Principal getSubjectX500Principal()
  {
    X500Name localX500Name = getCertTemplate().getSubject();
    if (localX500Name != null) {
      try
      {
        return new X500Principal(localX500Name.getEncoded("DER"));
      }
      catch (IOException localIOException)
      {
        throw new IllegalStateException("unable to construct DER encoding of name: " + localIOException.getMessage());
      }
    }
    return null;
  }
  
  public PublicKey getPublicKey()
    throws CRMFException
  {
    SubjectPublicKeyInfo localSubjectPublicKeyInfo = getCertTemplate().getPublicKey();
    if (localSubjectPublicKeyInfo != null) {
      return helper.toPublicKey(localSubjectPublicKeyInfo);
    }
    return null;
  }
}

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

import java.math.BigInteger;
import java.security.PublicKey;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.cert.crmf.CertificateRequestMessageBuilder;

public class JcaCertificateRequestMessageBuilder
  extends CertificateRequestMessageBuilder
{
  public JcaCertificateRequestMessageBuilder(BigInteger paramBigInteger)
  {
    super(paramBigInteger);
  }
  
  public JcaCertificateRequestMessageBuilder setIssuer(X500Principal paramX500Principal)
  {
    if (paramX500Principal != null) {
      setIssuer(X500Name.getInstance(paramX500Principal.getEncoded()));
    }
    return this;
  }
  
  public JcaCertificateRequestMessageBuilder setSubject(X500Principal paramX500Principal)
  {
    if (paramX500Principal != null) {
      setSubject(X500Name.getInstance(paramX500Principal.getEncoded()));
    }
    return this;
  }
  
  public JcaCertificateRequestMessageBuilder setAuthInfoSender(X500Principal paramX500Principal)
  {
    if (paramX500Principal != null) {
      setAuthInfoSender(new GeneralName(X500Name.getInstance(paramX500Principal.getEncoded())));
    }
    return this;
  }
  
  public JcaCertificateRequestMessageBuilder setPublicKey(PublicKey paramPublicKey)
  {
    setPublicKey(SubjectPublicKeyInfo.getInstance(paramPublicKey.getEncoded()));
    return this;
  }
}

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

import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import org.bouncycastle.asn1.crmf.EncryptedValue;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.cert.crmf.EncryptedValueBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import org.bouncycastle.operator.KeyWrapper;
import org.bouncycastle.operator.OutputEncryptor;

public class JcaEncryptedValueBuilder
  extends EncryptedValueBuilder
{
  public JcaEncryptedValueBuilder(KeyWrapper paramKeyWrapper, OutputEncryptor paramOutputEncryptor)
  {
    super(paramKeyWrapper, paramOutputEncryptor);
  }
  
  public EncryptedValue build(X509Certificate paramX509Certificate)
    throws CertificateEncodingException, CRMFException
  {
    return build(new JcaX509CertificateHolder(paramX509Certificate));
  }
}

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

import java.security.PrivateKey;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.cert.crmf.PKIArchiveControlBuilder;

public class JcaPKIArchiveControlBuilder
  extends PKIArchiveControlBuilder
{
  public JcaPKIArchiveControlBuilder(PrivateKey paramPrivateKey, X500Name paramX500Name)
  {
    this(paramPrivateKey, new GeneralName(paramX500Name));
  }
  
  public JcaPKIArchiveControlBuilder(PrivateKey paramPrivateKey, X500Principal paramX500Principal)
  {
    this(paramPrivateKey, X500Name.getInstance(paramX500Principal.getEncoded()));
  }
  
  public JcaPKIArchiveControlBuilder(PrivateKey paramPrivateKey, GeneralName paramGeneralName)
  {
    super(PrivateKeyInfo.getInstance(paramPrivateKey.getEncoded()), paramGeneralName);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.cert.crmf.jcajce.JcaPKIArchiveControlBuilder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert.crmf.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 JceAsymmetricValueDecryptorGenerator$1
  implements InputDecryptor
{
  JceAsymmetricValueDecryptorGenerator$1(JceAsymmetricValueDecryptorGenerator paramJceAsymmetricValueDecryptorGenerator, 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.cert.crmf.jcajce.JceAsymmetricValueDecryptorGenerator.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.cert.crmf.jcajce;

import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.ProviderException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.cert.crmf.ValueDecryptorGenerator;
import org.bouncycastle.jcajce.DefaultJcaJceHelper;
import org.bouncycastle.jcajce.NamedJcaJceHelper;
import org.bouncycastle.jcajce.ProviderJcaJceHelper;
import org.bouncycastle.operator.InputDecryptor;

public class JceAsymmetricValueDecryptorGenerator
  implements ValueDecryptorGenerator
{
  private PrivateKey recipientKey;
  private CRMFHelper helper = new CRMFHelper(new DefaultJcaJceHelper());
  
  public JceAsymmetricValueDecryptorGenerator(PrivateKey paramPrivateKey)
  {
    recipientKey = paramPrivateKey;
  }
  
  public JceAsymmetricValueDecryptorGenerator setProvider(Provider paramProvider)
  {
    helper = new CRMFHelper(new ProviderJcaJceHelper(paramProvider));
    return this;
  }
  
  public JceAsymmetricValueDecryptorGenerator setProvider(String paramString)
  {
    helper = new CRMFHelper(new NamedJcaJceHelper(paramString));
    return this;
  }
  
  private Key extractSecretKey(AlgorithmIdentifier paramAlgorithmIdentifier1, AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CRMFException
  {
    try
    {
      Object localObject = null;
      Cipher localCipher = helper.createCipher(paramAlgorithmIdentifier1.getAlgorithm());
      try
      {
        localCipher.init(4, recipientKey);
        localObject = localCipher.unwrap(paramArrayOfByte, paramAlgorithmIdentifier2.getAlgorithm().getId(), 3);
      }
      catch (GeneralSecurityException localGeneralSecurityException) {}catch (IllegalStateException localIllegalStateException) {}catch (UnsupportedOperationException localUnsupportedOperationException) {}catch (ProviderException localProviderException) {}
      if (localObject == null)
      {
        localCipher.init(2, recipientKey);
        localObject = new SecretKeySpec(localCipher.doFinal(paramArrayOfByte), paramAlgorithmIdentifier2.getAlgorithm().getId());
      }
      return (Key)localObject;
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
      throw new CRMFException("key invalid in message.", localInvalidKeyException);
    }
    catch (IllegalBlockSizeException localIllegalBlockSizeException)
    {
      throw new CRMFException("illegal blocksize in message.", localIllegalBlockSizeException);
    }
    catch (BadPaddingException localBadPaddingException)
    {
      throw new CRMFException("bad padding in message.", localBadPaddingException);
    }
  }
  
  public InputDecryptor getValueDecryptor(AlgorithmIdentifier paramAlgorithmIdentifier1, final AlgorithmIdentifier paramAlgorithmIdentifier2, byte[] paramArrayOfByte)
    throws CRMFException
  {
    Key localKey = extractSecretKey(paramAlgorithmIdentifier1, paramAlgorithmIdentifier2, paramArrayOfByte);
    final Cipher localCipher = helper.createContentCipher(localKey, paramAlgorithmIdentifier2);
    new InputDecryptor()
    {
      public AlgorithmIdentifier getAlgorithmIdentifier()
      {
        return paramAlgorithmIdentifier2;
      }
      
      public InputStream getInputStream(InputStream paramAnonymousInputStream)
      {
        return new CipherInputStream(paramAnonymousInputStream, localCipher);
      }
    };
  }
}

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

import java.io.OutputStream;
import java.security.AlgorithmParameters;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.operator.GenericKey;
import org.bouncycastle.operator.OutputEncryptor;

class JceCRMFEncryptorBuilder$CRMFOutputEncryptor
  implements OutputEncryptor
{
  private SecretKey encKey;
  private AlgorithmIdentifier algorithmIdentifier;
  private Cipher cipher;
  
  JceCRMFEncryptorBuilder$CRMFOutputEncryptor(JceCRMFEncryptorBuilder paramJceCRMFEncryptorBuilder, ASN1ObjectIdentifier paramASN1ObjectIdentifier, int paramInt, SecureRandom paramSecureRandom)
    throws CRMFException
  {
    KeyGenerator localKeyGenerator = JceCRMFEncryptorBuilder.access$000(paramJceCRMFEncryptorBuilder).createKeyGenerator(paramASN1ObjectIdentifier);
    if (paramSecureRandom == null) {
      paramSecureRandom = new SecureRandom();
    }
    if (paramInt < 0) {
      localKeyGenerator.init(paramSecureRandom);
    } else {
      localKeyGenerator.init(paramInt, paramSecureRandom);
    }
    cipher = JceCRMFEncryptorBuilder.access$000(paramJceCRMFEncryptorBuilder).createCipher(paramASN1ObjectIdentifier);
    encKey = localKeyGenerator.generateKey();
    AlgorithmParameters localAlgorithmParameters = JceCRMFEncryptorBuilder.access$000(paramJceCRMFEncryptorBuilder).generateParameters(paramASN1ObjectIdentifier, encKey, paramSecureRandom);
    try
    {
      cipher.init(1, encKey, localAlgorithmParameters, paramSecureRandom);
    }
    catch (GeneralSecurityException localGeneralSecurityException)
    {
      throw new CRMFException("unable to initialize cipher: " + localGeneralSecurityException.getMessage(), localGeneralSecurityException);
    }
    if (localAlgorithmParameters == null) {
      localAlgorithmParameters = cipher.getParameters();
    }
    algorithmIdentifier = JceCRMFEncryptorBuilder.access$000(paramJceCRMFEncryptorBuilder).getAlgorithmIdentifier(paramASN1Objec
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