Skip to content

Commit fa5572a

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents 4b9f1c8 + afad0ba commit fa5572a

File tree

5 files changed

+125
-22
lines changed

5 files changed

+125
-22
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.bouncycastle.openpgp.test;
2+
3+
import java.security.Security;
4+
5+
import junit.extensions.TestSetup;
6+
import junit.framework.Test;
7+
import junit.framework.TestCase;
8+
import junit.framework.TestSuite;
9+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
10+
import org.bouncycastle.test.PrintTestResult;
11+
import org.bouncycastle.util.test.SimpleTestResult;
12+
13+
public class AllTests
14+
extends TestCase
15+
{
16+
public void testPGP()
17+
{
18+
Security.addProvider(new BouncyCastleProvider());
19+
20+
org.bouncycastle.util.test.Test[] tests = RegressionTest.tests;
21+
22+
for (int i = 0; i != tests.length; i++)
23+
{
24+
SimpleTestResult result = (SimpleTestResult)tests[i].perform();
25+
26+
if (!result.isSuccessful())
27+
{
28+
fail(tests[i].getClass().getName() + " " + result.toString());
29+
}
30+
}
31+
}
32+
33+
public static void main(String[] args)
34+
{
35+
PrintTestResult.printResult(junit.textui.TestRunner.run(suite()));
36+
}
37+
38+
public static Test suite()
39+
{
40+
TestSuite suite = new TestSuite("OpenPGP Tests");
41+
42+
suite.addTestSuite(AllTests.class);
43+
suite.addTestSuite(DSA2Test.class);
44+
suite.addTestSuite(PGPUnicodeTest.class);
45+
46+
return new BCTestSetup(suite);
47+
}
48+
49+
static class BCTestSetup
50+
extends TestSetup
51+
{
52+
public BCTestSetup(Test test)
53+
{
54+
super(test);
55+
}
56+
57+
protected void setUp()
58+
{
59+
Security.addProvider(new BouncyCastleProvider());
60+
}
61+
62+
protected void tearDown()
63+
{
64+
Security.removeProvider("BC");
65+
}
66+
}
67+
}

prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/util/BaseDeterministicOrRandomSignature.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.bouncycastle.jcajce.spec.ContextParameterSpec;
1919
import org.bouncycastle.jcajce.util.BCJcaJceHelper;
2020
import org.bouncycastle.jcajce.util.JcaJceHelper;
21+
import org.bouncycastle.util.Exceptions;
2122

2223
public abstract class BaseDeterministicOrRandomSignature
2324
extends Signature
@@ -34,14 +35,14 @@ public abstract class BaseDeterministicOrRandomSignature
3435
protected BaseDeterministicOrRandomSignature(String name)
3536
{
3637
super(name);
37-
this.originalSpec = null;
38+
this.originalSpec = ContextParameterSpec.EMPTY_CONTEXT_SPEC;
3839
}
3940

4041
final protected void engineInitVerify(PublicKey publicKey)
4142
throws InvalidKeyException
4243
{
4344
verifyInit(publicKey);
44-
paramSpec = null;
45+
paramSpec = ContextParameterSpec.EMPTY_CONTEXT_SPEC;
4546
isInitState = true;
4647
reInit();
4748
}
@@ -53,7 +54,7 @@ final protected void engineInitSign(
5354
throws InvalidKeyException
5455
{
5556
signInit(privateKey, null);
56-
paramSpec = null;
57+
paramSpec = ContextParameterSpec.EMPTY_CONTEXT_SPEC;
5758
isInitState = true;
5859
reInit();
5960
}
@@ -64,7 +65,7 @@ final protected void engineInitSign(
6465
throws InvalidKeyException
6566
{
6667
signInit(privateKey, random);
67-
paramSpec = null;
68+
paramSpec = ContextParameterSpec.EMPTY_CONTEXT_SPEC;
6869
isInitState = true;
6970
reInit();
7071
}
@@ -170,7 +171,7 @@ protected final AlgorithmParameters engineGetParameters()
170171
}
171172
catch (Exception e)
172173
{
173-
throw new IllegalStateException(e.toString(), e);
174+
throw Exceptions.illegalStateException(e.toString(), e);
174175
}
175176
}
176177
}

prov/src/main/java/org/bouncycastle/jcajce/spec/ContextParameterSpec.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
public class ContextParameterSpec
88
implements AlgorithmParameterSpec
99
{
10+
public static ContextParameterSpec EMPTY_CONTEXT_SPEC = new ContextParameterSpec(new byte[0]);
11+
1012
private final byte[] context;
1113

1214
public ContextParameterSpec(byte[] context)

prov/src/main/jdk1.4/org/bouncycastle/jce/provider/BouncyCastleProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public final class BouncyCastleProvider extends Provider
9696

9797
private static final String[] ASYMMETRIC_CIPHERS =
9898
{
99-
"DSA", "DH", "EC", "RSA", "GOST", "ECGOST", "ElGamal", "DSTU4145", "GM", "EdEC", "SPHINCSPlus", "Dilithium", "Falcon", "NTRU", "SLHDSA", "MLDSA", "MLKEM"
99+
"DSA", "DH", "EC", "RSA", "GOST", "ECGOST", "ElGamal", "DSTU4145", "GM", "EdEC", "SPHINCSPlus", "Dilithium", "Falcon", "NTRU", "CONTEXT", "SLHDSA", "MLDSA", "MLKEM"
100100
};
101101

102102
/*

0 commit comments

Comments
 (0)