Skip to content

Commit f766767

Browse files
author
gefeili
committed
Remove IDs from SLHDSAParameters
1 parent c0d6922 commit f766767

File tree

1 file changed

+25
-73
lines changed

1 file changed

+25
-73
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/slhdsa/SLHDSAParameters.java

Lines changed: 25 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,116 +17,84 @@ public class SLHDSAParameters
1717
// "Pure" SLH-DSA Parameters
1818
// SHA-2
1919
public static final SLHDSAParameters sha2_128f = new SLHDSAParameters(
20-
Integers.valueOf(0x010201), "sha2-128f", new Sha2EngineProvider(16, 16, 22, 6, 33, 66), TYPE_PURE);
20+
"sha2-128f", new Sha2EngineProvider(16, 16, 22, 6, 33, 66), TYPE_PURE);
2121
public static final SLHDSAParameters sha2_128s = new SLHDSAParameters(
22-
Integers.valueOf(0x010202), "sha2-128s", new Sha2EngineProvider(16, 16, 7, 12, 14, 63), TYPE_PURE);
22+
"sha2-128s", new Sha2EngineProvider(16, 16, 7, 12, 14, 63), TYPE_PURE);
2323

2424
public static final SLHDSAParameters sha2_192f = new SLHDSAParameters(
25-
Integers.valueOf(0x010203), "sha2-192f", new Sha2EngineProvider(24, 16, 22, 8, 33, 66), TYPE_PURE);
25+
"sha2-192f", new Sha2EngineProvider(24, 16, 22, 8, 33, 66), TYPE_PURE);
2626
public static final SLHDSAParameters sha2_192s = new SLHDSAParameters(
27-
Integers.valueOf(0x010204), "sha2-192s", new Sha2EngineProvider(24, 16, 7, 14, 17, 63), TYPE_PURE);
27+
"sha2-192s", new Sha2EngineProvider(24, 16, 7, 14, 17, 63), TYPE_PURE);
2828

2929
public static final SLHDSAParameters sha2_256f = new SLHDSAParameters(
30-
Integers.valueOf(0x010205), "sha2-256f", new Sha2EngineProvider(32, 16, 17, 9, 35, 68), TYPE_PURE);
30+
"sha2-256f", new Sha2EngineProvider(32, 16, 17, 9, 35, 68), TYPE_PURE);
3131
public static final SLHDSAParameters sha2_256s = new SLHDSAParameters(
32-
Integers.valueOf(0x010206), "sha2-256s", new Sha2EngineProvider(32, 16, 8, 14, 22, 64), TYPE_PURE);
32+
"sha2-256s", new Sha2EngineProvider(32, 16, 8, 14, 22, 64), TYPE_PURE);
3333

3434
// SHAKE-256.
3535
public static final SLHDSAParameters shake_128f = new SLHDSAParameters(
36-
Integers.valueOf(0x020201), "shake-128f", new Shake256EngineProvider(16, 16, 22, 6, 33, 66), TYPE_PURE);
36+
"shake-128f", new Shake256EngineProvider(16, 16, 22, 6, 33, 66), TYPE_PURE);
3737
public static final SLHDSAParameters shake_128s = new SLHDSAParameters(
38-
Integers.valueOf(0x020202), "shake-128s", new Shake256EngineProvider(16, 16, 7, 12, 14, 63), TYPE_PURE);
38+
"shake-128s", new Shake256EngineProvider(16, 16, 7, 12, 14, 63), TYPE_PURE);
3939

4040
public static final SLHDSAParameters shake_192f = new SLHDSAParameters(
41-
Integers.valueOf(0x020203), "shake-192f", new Shake256EngineProvider(24, 16, 22, 8, 33, 66), TYPE_PURE);
41+
"shake-192f", new Shake256EngineProvider(24, 16, 22, 8, 33, 66), TYPE_PURE);
4242
public static final SLHDSAParameters shake_192s = new SLHDSAParameters(
43-
Integers.valueOf(0x020204), "shake-192s", new Shake256EngineProvider(24, 16, 7, 14, 17, 63), TYPE_PURE);
43+
"shake-192s", new Shake256EngineProvider(24, 16, 7, 14, 17, 63), TYPE_PURE);
4444

4545
public static final SLHDSAParameters shake_256f = new SLHDSAParameters(
46-
Integers.valueOf(0x020205), "shake-256f", new Shake256EngineProvider(32, 16, 17, 9, 35, 68), TYPE_PURE);
46+
"shake-256f", new Shake256EngineProvider(32, 16, 17, 9, 35, 68), TYPE_PURE);
4747
public static final SLHDSAParameters shake_256s = new SLHDSAParameters(
48-
Integers.valueOf(0x020206), "shake-256s", new Shake256EngineProvider(32, 16, 8, 14, 22, 64), TYPE_PURE);
48+
"shake-256s", new Shake256EngineProvider(32, 16, 8, 14, 22, 64), TYPE_PURE);
4949

5050

5151
// "Pre-hash" SLH-DSA Parameters
5252
// SHA-2
5353
public static final SLHDSAParameters sha2_128f_with_sha256 = new SLHDSAParameters(
54-
Integers.valueOf(0x010201), "sha2-128f-with-sha256", new Sha2EngineProvider(16, 16, 22, 6, 33, 66), TYPE_SHA2_256);
54+
"sha2-128f-with-sha256", new Sha2EngineProvider(16, 16, 22, 6, 33, 66), TYPE_SHA2_256);
5555
public static final SLHDSAParameters sha2_128s_with_sha256 = new SLHDSAParameters(
56-
Integers.valueOf(0x010202), "sha2-128s-with-sha256", new Sha2EngineProvider(16, 16, 7, 12, 14, 63), TYPE_SHA2_256);
56+
"sha2-128s-with-sha256", new Sha2EngineProvider(16, 16, 7, 12, 14, 63), TYPE_SHA2_256);
5757

5858
public static final SLHDSAParameters sha2_192f_with_sha512 = new SLHDSAParameters(
59-
Integers.valueOf(0x010203), "sha2-192f-with-sha512", new Sha2EngineProvider(24, 16, 22, 8, 33, 66), TYPE_SHA2_512);
59+
"sha2-192f-with-sha512", new Sha2EngineProvider(24, 16, 22, 8, 33, 66), TYPE_SHA2_512);
6060
public static final SLHDSAParameters sha2_192s_with_sha512 = new SLHDSAParameters(
61-
Integers.valueOf(0x010204), "sha2-192s-with-sha512", new Sha2EngineProvider(24, 16, 7, 14, 17, 63), TYPE_SHA2_512);
61+
"sha2-192s-with-sha512", new Sha2EngineProvider(24, 16, 7, 14, 17, 63), TYPE_SHA2_512);
6262

6363
public static final SLHDSAParameters sha2_256f_with_sha512 = new SLHDSAParameters(
64-
Integers.valueOf(0x010205), "sha2-256f-with-sha512", new Sha2EngineProvider(32, 16, 17, 9, 35, 68), TYPE_SHA2_512);
64+
"sha2-256f-with-sha512", new Sha2EngineProvider(32, 16, 17, 9, 35, 68), TYPE_SHA2_512);
6565
public static final SLHDSAParameters sha2_256s_with_sha512 = new SLHDSAParameters(
66-
Integers.valueOf(0x010206), "sha2-256s-with-sha512", new Sha2EngineProvider(32, 16, 8, 14, 22, 64), TYPE_SHA2_512);
66+
"sha2-256s-with-sha512", new Sha2EngineProvider(32, 16, 8, 14, 22, 64), TYPE_SHA2_512);
6767

6868
// SHAKE-256.
6969
public static final SLHDSAParameters shake_128f_with_shake128 = new SLHDSAParameters(
70-
Integers.valueOf(0x020201), "shake-128f-with-shake128", new Shake256EngineProvider(16, 16, 22, 6, 33, 66), TYPE_SHAKE128);
70+
"shake-128f-with-shake128", new Shake256EngineProvider(16, 16, 22, 6, 33, 66), TYPE_SHAKE128);
7171
public static final SLHDSAParameters shake_128s_with_shake128 = new SLHDSAParameters(
72-
Integers.valueOf(0x020202), "shake-128s-with-shake128", new Shake256EngineProvider(16, 16, 7, 12, 14, 63), TYPE_SHAKE128);
72+
"shake-128s-with-shake128", new Shake256EngineProvider(16, 16, 7, 12, 14, 63), TYPE_SHAKE128);
7373

7474
public static final SLHDSAParameters shake_192f_with_shake256 = new SLHDSAParameters(
75-
Integers.valueOf(0x020203), "shake-192f-with-shake256", new Shake256EngineProvider(24, 16, 22, 8, 33, 66), TYPE_SHAKE256);
75+
"shake-192f-with-shake256", new Shake256EngineProvider(24, 16, 22, 8, 33, 66), TYPE_SHAKE256);
7676
public static final SLHDSAParameters shake_192s_with_shake256 = new SLHDSAParameters(
77-
Integers.valueOf(0x020204), "shake-192s-with-shake256", new Shake256EngineProvider(24, 16, 7, 14, 17, 63), TYPE_SHAKE256);
77+
"shake-192s-with-shake256", new Shake256EngineProvider(24, 16, 7, 14, 17, 63), TYPE_SHAKE256);
7878

7979
public static final SLHDSAParameters shake_256f_with_shake256 = new SLHDSAParameters(
80-
Integers.valueOf(0x020205), "shake-256f-with-shake256", new Shake256EngineProvider(32, 16, 17, 9, 35, 68), TYPE_SHAKE256);
80+
"shake-256f-with-shake256", new Shake256EngineProvider(32, 16, 17, 9, 35, 68), TYPE_SHAKE256);
8181
public static final SLHDSAParameters shake_256s_with_shake256 = new SLHDSAParameters(
82-
Integers.valueOf(0x020206), "shake-256s-with-shake256", new Shake256EngineProvider(32, 16, 8, 14, 22, 64), TYPE_SHAKE256);
82+
"shake-256s-with-shake256", new Shake256EngineProvider(32, 16, 8, 14, 22, 64), TYPE_SHAKE256);
8383

8484

8585
private static final Map<Integer, SLHDSAParameters> ID_TO_PARAMS = new HashMap<Integer, SLHDSAParameters>();
8686

87-
static
88-
{
89-
SLHDSAParameters[] all = new SLHDSAParameters[]{
90-
SLHDSAParameters.sha2_128f, SLHDSAParameters.sha2_128s,
91-
SLHDSAParameters.sha2_192f, SLHDSAParameters.sha2_192s,
92-
SLHDSAParameters.sha2_256f, SLHDSAParameters.sha2_256s,
93-
SLHDSAParameters.shake_128f, SLHDSAParameters.shake_128s,
94-
SLHDSAParameters.shake_192f, SLHDSAParameters.shake_192s,
95-
SLHDSAParameters.shake_256f, SLHDSAParameters.shake_256s,
96-
97-
SLHDSAParameters.sha2_128f_with_sha256, SLHDSAParameters.sha2_128s_with_sha256,
98-
SLHDSAParameters.sha2_192f_with_sha512, SLHDSAParameters.sha2_192s_with_sha512,
99-
SLHDSAParameters.sha2_256f_with_sha512, SLHDSAParameters.sha2_256s_with_sha512,
100-
SLHDSAParameters.shake_128f_with_shake128, SLHDSAParameters.shake_128s_with_shake128,
101-
SLHDSAParameters.shake_192f_with_shake256, SLHDSAParameters.shake_192s_with_shake256,
102-
SLHDSAParameters.shake_256f_with_shake256, SLHDSAParameters.shake_256s_with_shake256,
103-
};
104-
105-
for (int i = 0; i < all.length; ++i)
106-
{
107-
SLHDSAParameters parameters = all[i];
108-
ID_TO_PARAMS.put(parameters.getID(), parameters);
109-
}
110-
}
111-
112-
private final Integer id;
11387
private final String name;
11488
private final SLHDSAEngineProvider engineProvider;
11589
private final int preHashDigest;
11690

117-
private SLHDSAParameters(Integer id, String name, SLHDSAEngineProvider engineProvider, int preHashDigest)
91+
private SLHDSAParameters(String name, SLHDSAEngineProvider engineProvider, int preHashDigest)
11892
{
119-
this.id = id;
12093
this.name = name;
12194
this.engineProvider = engineProvider;
12295
this.preHashDigest = preHashDigest;
12396
}
12497

125-
public Integer getID()
126-
{
127-
return id;
128-
}
129-
13098
public String getName()
13199
{
132100
return name;
@@ -152,22 +120,6 @@ public boolean isPreHash()
152120
return preHashDigest != TYPE_PURE;
153121
}
154122

155-
/**
156-
* Return the SLH-DSA parameters that map to the passed in parameter ID.
157-
*
158-
* @param id the oid of interest.
159-
* @return the parameter set.
160-
*/
161-
public static SLHDSAParameters getParams(Integer id)
162-
{
163-
return (SLHDSAParameters)ID_TO_PARAMS.get(id);
164-
}
165-
166-
public byte[] getEncoded()
167-
{
168-
return Pack.intToBigEndian(getID().intValue());
169-
}
170-
171123
private static class Sha2EngineProvider
172124
implements SLHDSAEngineProvider
173125
{

0 commit comments

Comments
 (0)