org.bouncycastle.pqc.crypto.xmss.XMSSParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on 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.5 to JDK 1.7. Note: this package includes the IDEA and NTRU encryption algorithms.
package org.bouncycastle.pqc.crypto.xmss;
import org.bouncycastle.crypto.Digest;
/**
* XMSS Parameters.
*/
public final class XMSSParameters
{
private final XMSSOid oid;
private final WOTSPlus wotsPlus;
//private final SecureRandom prng;
private final int height;
private final int k;
/**
* XMSS Constructor...
*
* @param height Height of tree.
* @param digest Digest to use.
*/
public XMSSParameters(int height, Digest digest)
{
super();
if (height < 2)
{
throw new IllegalArgumentException("height must be >= 2");
}
if (digest == null)
{
throw new NullPointerException("digest == null");
}
wotsPlus = new WOTSPlus(new WOTSPlusParameters(digest));
this.height = height;
this.k = determineMinK();
oid = DefaultXMSSOid.lookup(getDigest().getAlgorithmName(), getDigestSize(), getWinternitzParameter(),
wotsPlus.getParams().getLen(), height);
/*
* if (oid == null) { throw new InvalidParameterException(); }
*/
}
private int determineMinK()
{
for (int k = 2; k <= height; k++)
{
if ((height - k) % 2 == 0)
{
return k;
}
}
throw new IllegalStateException("should never happen...");
}
protected Digest getDigest()
{
return wotsPlus.getParams().getDigest();
}
/**
* Getter digest size.
*
* @return Digest size.
*/
public int getDigestSize()
{
return wotsPlus.getParams().getDigestSize();
}
/**
* Getter Winternitz parameter.
*
* @return Winternitz parameter.
*/
public int getWinternitzParameter()
{
return wotsPlus.getParams().getWinternitzParameter();
}
/**
* Getter height.
*
* @return XMSS height.
*/
public int getHeight()
{
return height;
}
WOTSPlus getWOTSPlus()
{
return wotsPlus;
}
int getK()
{
return k;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy