Skip to content

Commit 2d33a55

Browse files
committed
added initial support for ContextParameterSpec
added support for ContextParameterSpec to SLHDSA
1 parent 408cab0 commit 2d33a55

File tree

8 files changed

+599
-185
lines changed

8 files changed

+599
-185
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.bouncycastle.jcajce.provider.asymmetric;
2+
3+
import java.io.IOException;
4+
import java.security.spec.AlgorithmParameterSpec;
5+
import java.security.spec.InvalidParameterSpecException;
6+
7+
import org.bouncycastle.jcajce.provider.config.ConfigurableProvider;
8+
import org.bouncycastle.jcajce.provider.util.AsymmetricAlgorithmProvider;
9+
import org.bouncycastle.jcajce.spec.ContextParameterSpec;
10+
11+
public class CONTEXT
12+
{
13+
private static final String PREFIX = "org.bouncycastle.jcajce.provider.asymmetric" + ".CONTEXT$";
14+
15+
public static class ContextAlgorithmParametersSpi
16+
extends java.security.AlgorithmParametersSpi
17+
{
18+
private ContextParameterSpec contextParameterSpec;
19+
20+
protected boolean isASN1FormatString(String format)
21+
{
22+
return format == null || format.equals("ASN.1");
23+
}
24+
25+
protected AlgorithmParameterSpec engineGetParameterSpec(
26+
Class paramSpec)
27+
throws InvalidParameterSpecException
28+
{
29+
if (paramSpec == null)
30+
{
31+
throw new NullPointerException("argument to getParameterSpec must not be null");
32+
}
33+
if (paramSpec != ContextParameterSpec.class)
34+
{
35+
throw new IllegalArgumentException("argument to getParameterSpec must be ContextParameterSpec.class");
36+
}
37+
38+
return contextParameterSpec;
39+
}
40+
41+
@Override
42+
protected void engineInit(AlgorithmParameterSpec algorithmParameterSpec)
43+
throws InvalidParameterSpecException
44+
{
45+
if (!(algorithmParameterSpec instanceof ContextParameterSpec))
46+
{
47+
throw new IllegalArgumentException("argument to engineInit must be a ContextParameterSpec");
48+
}
49+
50+
this.contextParameterSpec = (ContextParameterSpec)algorithmParameterSpec;
51+
}
52+
53+
@Override
54+
protected void engineInit(byte[] bytes)
55+
throws IOException
56+
{
57+
throw new IllegalStateException("not implemented");
58+
}
59+
60+
@Override
61+
protected void engineInit(byte[] bytes, String s)
62+
throws IOException
63+
{
64+
throw new IllegalStateException("not implemented");
65+
}
66+
67+
@Override
68+
protected byte[] engineGetEncoded()
69+
throws IOException
70+
{
71+
throw new IllegalStateException("not implemented");
72+
}
73+
74+
@Override
75+
protected byte[] engineGetEncoded(String s)
76+
throws IOException
77+
{
78+
throw new IllegalStateException("not implemented");
79+
}
80+
81+
@Override
82+
protected String engineToString()
83+
{
84+
return "ContextParameterSpec";
85+
}
86+
}
87+
88+
public static class Mappings
89+
extends AsymmetricAlgorithmProvider
90+
{
91+
public Mappings()
92+
{
93+
}
94+
95+
public void configure(ConfigurableProvider provider)
96+
{
97+
provider.addAlgorithm("AlgorithmParameters.CONTEXT", PREFIX + "ContextAlgorithmParametersSpi");
98+
}
99+
}
100+
}

prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/slhdsa/BCSLHDSAPublicKey.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.io.ObjectOutputStream;
66

77
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
8-
import org.bouncycastle.crypto.CipherParameters;
98
import org.bouncycastle.jcajce.interfaces.SLHDSAPublicKey;
109
import org.bouncycastle.jcajce.spec.SLHDSAParameterSpec;
1110
import org.bouncycastle.pqc.crypto.slhdsa.SLHDSAPublicKeyParameters;
@@ -126,7 +125,7 @@ public String toString()
126125
return buf.toString();
127126
}
128127

129-
CipherParameters getKeyParams()
128+
SLHDSAPublicKeyParameters getKeyParams()
130129
{
131130
return params;
132131
}

0 commit comments

Comments
 (0)