All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gatling.recorder.internal.bouncycastle.cms.jcajce.JceKEMRecipientInfoGenerator Maven / Gradle / Ivy

There is a newer version: 1.78.1
Show newest version
package io.gatling.recorder.internal.bouncycastle.cms.jcajce;

import java.security.Provider;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;

import io.gatling.recorder.internal.bouncycastle.asn1.ASN1ObjectIdentifier;
import io.gatling.recorder.internal.bouncycastle.asn1.cms.IssuerAndSerialNumber;
import io.gatling.recorder.internal.bouncycastle.asn1.x509.AlgorithmIdentifier;
import io.gatling.recorder.internal.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import io.gatling.recorder.internal.bouncycastle.cms.KEMRecipientInfoGenerator;

public class JceKEMRecipientInfoGenerator
    extends KEMRecipientInfoGenerator
{
    public JceKEMRecipientInfoGenerator(X509Certificate recipientCert, ASN1ObjectIdentifier symWrapAlgorithm)
        throws CertificateEncodingException
    {
        super(new IssuerAndSerialNumber(new JcaX509CertificateHolder(recipientCert).toASN1Structure()), new JceCMSKEMKeyWrapper(recipientCert.getPublicKey(), symWrapAlgorithm));
    }

    public JceKEMRecipientInfoGenerator(byte[] subjectKeyIdentifier, PublicKey publicKey, ASN1ObjectIdentifier symWrapAlgorithm)
    {
        super(subjectKeyIdentifier, new JceCMSKEMKeyWrapper(publicKey, symWrapAlgorithm));
    }

    public JceKEMRecipientInfoGenerator setProvider(String providerName)
    {
        ((JceCMSKEMKeyWrapper)this.wrapper).setProvider(providerName);

        return this;
    }

    public JceKEMRecipientInfoGenerator setProvider(Provider provider)
    {
        ((JceCMSKEMKeyWrapper)this.wrapper).setProvider(provider);

        return this;
    }

    public JceKEMRecipientInfoGenerator setSecureRandom(SecureRandom random)
    {
        ((JceCMSKEMKeyWrapper)this.wrapper).setSecureRandom(random);

        return this;
    }

    public JceKEMRecipientInfoGenerator setKDF(AlgorithmIdentifier kdfAlgorithm)
    {
        ((JceCMSKEMKeyWrapper)this.wrapper).setKDF(kdfAlgorithm);

        return this;
    }

    /**
     * Internally algorithm ids are converted into cipher names using a lookup table. For some providers
     * the standard lookup table won't work. Use this method to establish a specific mapping from an
     * algorithm identifier to a specific algorithm.
     * 

* For example: *

     *     unwrapper.setAlgorithmMapping(PKCSObjectIdentifiers.rsaEncryption, "RSA");
     * 
* @param algorithm OID of algorithm in recipient. * @param algorithmName JCE algorithm name to use. * @return the current RecipientInfoGenerator. */ public JceKEMRecipientInfoGenerator setAlgorithmMapping(ASN1ObjectIdentifier algorithm, String algorithmName) { ((JceCMSKEMKeyWrapper)this.wrapper).setAlgorithmMapping(algorithm, algorithmName); return this; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy