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

org.bouncycastle.jcajce.spec.GOST28147ParameterSpec 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 the debug version JCE provider and low-level API for the BC-FJA version 1.0.2.3, FIPS Certificate #3514. Please note the debug jar is not certified.

There is a newer version: 2.0.0
Show newest version
package org.bouncycastle.jcajce.spec;

import java.security.spec.AlgorithmParameterSpec;

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.crypto.general.GOST28147;
import org.bouncycastle.util.Arrays;

/**
 * A parameter spec for the GOST-28147 cipher.
 */
public class GOST28147ParameterSpec
    implements AlgorithmParameterSpec
{
    private final byte[] iv;
    private final byte[] sBox;

    public GOST28147ParameterSpec(
        byte[] sBox)
    {
        this(sBox, null);
    }

    public GOST28147ParameterSpec(
        byte[] sBox,
        byte[] iv)
    {
        this.sBox = Arrays.clone(sBox);
        this.iv = Arrays.clone(iv);
    }
    
    public GOST28147ParameterSpec(
        String sBoxName)
    {
        this(sBoxName, null);
    }

    public GOST28147ParameterSpec(
        String sBoxName,
        byte[] iv)
    {
        this.sBox = GOST28147.getSBox(sBoxName);
        this.iv = Arrays.clone(iv);
    }

    public GOST28147ParameterSpec(
        ASN1ObjectIdentifier sBoxOID,
        byte[] iv)
    {
        this.sBox = GOST28147.getSBox(sBoxOID);
        this.iv = Arrays.clone(iv);
    }

    public byte[] getSBox()
    {
        return Arrays.clone(sBox);
    }

    /**
     * Returns the IV or null if this parameter set does not contain an IV.
     *
     * @return the IV or null if this parameter set does not contain an IV.
     */
    public byte[] getIV()
    {
        return Arrays.clone(iv);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy