// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.cert.crmf.bc;

import org.bouncycastle.crypto.util.AlgorithmIdentifierFactory;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.util.CipherFactory;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.cert.crmf.CRMFException;
import org.bouncycastle.crypto.util.CipherKeyGeneratorFactory;
import org.bouncycastle.crypto.CipherKeyGenerator;
import java.security.SecureRandom;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;

class CRMFHelper
{
    CipherKeyGenerator createKeyGenerator(final ASN1ObjectIdentifier asn1ObjectIdentifier, final SecureRandom secureRandom) throws CRMFException {
        try {
            return CipherKeyGeneratorFactory.createKeyGenerator(asn1ObjectIdentifier, secureRandom);
        }
        catch (final IllegalArgumentException ex) {
            throw new CRMFException(ex.getMessage(), ex);
        }
    }
    
    static Object createContentCipher(final boolean b, final CipherParameters cipherParameters, final AlgorithmIdentifier algorithmIdentifier) throws CRMFException {
        try {
            return CipherFactory.createContentCipher(b, cipherParameters, algorithmIdentifier);
        }
        catch (final IllegalArgumentException ex) {
            throw new CRMFException(ex.getMessage(), ex);
        }
    }
    
    AlgorithmIdentifier generateEncryptionAlgID(final ASN1ObjectIdentifier asn1ObjectIdentifier, final KeyParameter keyParameter, final SecureRandom secureRandom) throws CRMFException {
        try {
            return AlgorithmIdentifierFactory.generateEncryptionAlgID(asn1ObjectIdentifier, keyParameter.getKey().length * 8, secureRandom);
        }
        catch (final IllegalArgumentException ex) {
            throw new CRMFException(ex.getMessage(), ex);
        }
    }
}
