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

org.bouncycastle.jcajce.provider.FPEParametersCreator Maven / Gradle / Ivy

Go to download

The FIPS 140-2 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-2 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 1.0.2, FIPS Certificate #3514. Please see certificate for certified platform details.

The newest version!
package org.bouncycastle.jcajce.provider;

import java.security.InvalidAlgorithmParameterException;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;

import org.bouncycastle.crypto.Parameters;
import org.bouncycastle.crypto.ParametersWithIV;
import org.bouncycastle.crypto.fips.FipsAES;
import org.bouncycastle.jcajce.spec.FPEParameterSpec;

class FPEParametersCreator
    implements ParametersCreator
{
    private final FipsAES.FPEParameters baseParameters;

    FPEParametersCreator(FipsAES.FPEParameters baseParameters)
    {
        this.baseParameters = baseParameters;
    }

    public Parameters createParameters(boolean forEncryption, AlgorithmParameterSpec spec, SecureRandom random)
        throws InvalidAlgorithmParameterException
    {
        if (spec instanceof FPEParameterSpec)
        {
            return baseParameters.withRadixConverter(((FPEParameterSpec)spec).getRadixConverter()).withTweak(((FPEParameterSpec)spec).getTweak())
                                    .withUsingInverseFunction(((FPEParameterSpec)spec).isUsingInverseFunction());
        }

        throw new InvalidAlgorithmParameterException("paramspec required");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy