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

org.bouncycastle.jcajce.spec.EdDSASigParameterSpec 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.util.Arrays;

/**
 * ParameterSpec for EdDSA signature to allow for context and preHash.
 */
public class EdDSASigParameterSpec
    implements AlgorithmParameterSpec
{
    private final boolean preHash;
    private final byte[] context;

    /**
     * Base constructor.
     *
     * @param preHash whether or not the signature is a preHash one.
     */
    public EdDSASigParameterSpec(boolean preHash)
    {
        if (preHash != false)
        {
            throw new IllegalStateException("only false supported at the moment");
        }
        this.preHash = preHash;
        this.context = null;
    }

    /**
     * Base constructor.
     *
     * @param preHash whether or not the signature is a preHash one.
     * @param context context to be added to the signature calculation.
     */
    public EdDSASigParameterSpec(boolean preHash, byte[] context)
    {
        if (preHash != false)
        {
            throw new IllegalStateException("only false supported at the moment");
        }
        if (context.length > 255)
        {
            throw new IllegalStateException("context length > 255");
        }
        this.preHash = preHash;
        this.context = Arrays.clone(context);
    }

    /**
     * Return the context to be used for the signature.
     *
     * @return the signature context.
     */
    public byte[] getContext()
    {
        return Arrays.clone(context);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy