Skip to content

Commit

Permalink
added table lookup for sig/OTS parameters
Browse files Browse the repository at this point in the history
updated properties to 172b06
  • Loading branch information
dghgit committed Nov 5, 2022
1 parent 6810725 commit b37a596
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bc-build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

release.suffix: 173b05
release.name: 1.72b05
release.suffix: 173b06
release.name: 1.73b06
release.version: 1.72.99
release.debug: true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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;
Expand All @@ -11,6 +13,23 @@
public class LMSKeyGenParameterSpec
implements AlgorithmParameterSpec
{
private static final Map<String, LMSigParameters> sigParameters = new HashMap<String, LMSigParameters>();
private static final Map<String, LMOtsParameters> otsParameters = new HashMap<String, LMOtsParameters>();

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;

Expand Down Expand Up @@ -45,4 +64,18 @@ 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));
}
}

0 comments on commit b37a596

Please sign in to comment.