org.bouncycastle.pqc.jcajce.spec.LMSKeyGenParameterSpec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk18on Show documentation
Show all versions of bcprov-jdk18on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.8 and up.
package org.bouncycastle.pqc.jcajce.spec;
import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
import java.util.Map;
import org.bouncycastle.pqc.crypto.lms.LMOtsParameters;
import org.bouncycastle.pqc.crypto.lms.LMSigParameters;
/**
* ParameterSpec for the Leighton-Micali Hash-Based Signature (LMS) scheme.
*/
public class LMSKeyGenParameterSpec
implements AlgorithmParameterSpec
{
private static final Map sigParameters = new HashMap();
private static final Map otsParameters = new HashMap();
static
{
sigParameters.put("lms-sha256-n32-h5", LMSigParameters.lms_sha256_n32_h5);
sigParameters.put("lms-sha256-n32-h10", LMSigParameters.lms_sha256_n32_h10);
sigParameters.put("lms-sha256-n32-h15", LMSigParameters.lms_sha256_n32_h15);
sigParameters.put("lms-sha256-n32-h20", LMSigParameters.lms_sha256_n32_h20);
sigParameters.put("lms-sha256-n32-h25", LMSigParameters.lms_sha256_n32_h25);
otsParameters.put("sha256-n32-w1", LMOtsParameters.sha256_n32_w1);
otsParameters.put("sha256-n32-w2", LMOtsParameters.sha256_n32_w2);
otsParameters.put("sha256-n32-w4", LMOtsParameters.sha256_n32_w4);
otsParameters.put("sha256-n32-w8", LMOtsParameters.sha256_n32_w8);
}
private final LMSigParameters lmSigParams;
private final LMOtsParameters lmOtsParameters;
/**
* Base constructor.
*
* @param lmSigParams the LMS system signature parameters to use.
* @param lmOtsParameters the LM OTS parameters to use for the underlying one-time signature keys.
*/
public LMSKeyGenParameterSpec(LMSigParameters lmSigParams, LMOtsParameters lmOtsParameters)
{
this.lmSigParams = lmSigParams;
this.lmOtsParameters = lmOtsParameters;
}
/**
* Return the LMS system signature parameters.
*
* @return the LMS system signature parameters.
*/
public LMSigParameters getSigParams()
{
return lmSigParams;
}
/**
* Return the LM OTS parameters to use for the underlying one-time signature keys.
*
* @return the LM OTS parameters.
*/
public LMOtsParameters getOtsParams()
{
return lmOtsParameters;
}
public static LMSKeyGenParameterSpec fromNames(String sigParams, String otsParams)
{
if (!sigParameters.containsKey(sigParams))
{
throw new IllegalArgumentException("LM signature parameter name " + sigParams + " not recognized");
}
if (!otsParameters.containsKey(otsParams))
{
throw new IllegalArgumentException("LM OTS parameter name " + otsParams + " not recognized");
}
return new LMSKeyGenParameterSpec(sigParameters.get(sigParams), otsParameters.get(otsParams));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy