Skip to content

Commit 7e6e864

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents b425743 + eda52bc commit 7e6e864

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+170
-73
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ configure(subprojects.findAll {it.name != 'bom'}) {
287287
}
288288

289289

290-
test.dependsOn([':core:test', ':prov:test', ':prov:test11', ':prov:test15', ':prov:test21', ':pkix:test', 'pg:test', ':tls:test', 'mls:test', 'mail:test', 'jmail:test'])
290+
test.dependsOn([':core:test', ':prov:test', ':prov:test11', ':prov:test15', ':prov:test17', ':pkix:test', 'pg:test', ':tls:test', 'mls:test', 'mail:test', 'jmail:test'])
291291

292292
apply from: "publish.gradle"
293293

core/src/main/java/org/bouncycastle/crypto/engines/Grain128Engine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private int getOutput()
188188
int s60 = lfsr[1] >>> 28 | lfsr[2] << 4;
189189
int s79 = lfsr[2] >>> 15 | lfsr[3] << 17;
190190
int s93 = lfsr[2] >>> 29 | lfsr[3] << 3;
191-
int s94 = lfsr[2] >>> 31 | lfsr[3] << 1;
191+
int s94 = lfsr[2] >>> 30 | lfsr[3] << 2;
192192

193193
return b12 & s8 ^ s13 & s20 ^ b95 & s42 ^ s60 & s79 ^ b12 & b95 & s94 ^ s93
194194
^ b2 ^ b15 ^ b36 ^ b45 ^ b64 ^ b73 ^ b89;

core/src/main/java/org/bouncycastle/pqc/crypto/xmss/XMSSPrivateKeyParameters.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,7 @@ private XMSSPrivateKeyParameters(Builder builder)
162162
}
163163
else
164164
{
165-
if (builder.index < ((1 << params.getHeight()) - 2) && tmpPublicSeed != null && tmpSecretKeySeed != null)
166-
{
167-
bdsState = new BDS(params, tmpPublicSeed, tmpSecretKeySeed, (OTSHashAddress)new OTSHashAddress.Builder().build(), builder.index);
168-
}
169-
else
170-
{
171-
bdsState = new BDS(params, (1 << params.getHeight()) - 1, builder.index);
172-
}
165+
bdsState = new BDS(params, tmpPublicSeed, tmpSecretKeySeed, (OTSHashAddress)new OTSHashAddress.Builder().build(), builder.index);
173166
}
174167
if (builder.maxIndex >= 0 && builder.maxIndex != bdsState.getMaxIndex())
175168
{
@@ -228,6 +221,7 @@ public XMSSPrivateKeyParameters getNextKey()
228221
* <p>
229222
* Note: this will use the range [index...index + usageCount) for the current key.
230223
* </p>
224+
*
231225
* @param usageCount the number of usages the key should have.
232226
* @return a key based on the current key that can be used usageCount times.
233227
*/
@@ -343,6 +337,10 @@ public Builder withPrivateKey(byte[] privateKeyVal)
343337

344338
public XMSSPrivateKeyParameters build()
345339
{
340+
if (!((privateKey != null) || (publicSeed != null && secretKeySeed != null)))
341+
{
342+
throw new IllegalStateException("publicSeed or secretKeySeed is null");
343+
}
346344
return new XMSSPrivateKeyParameters(this);
347345
}
348346
}

core/src/test/java/org/bouncycastle/crypto/test/Grain128Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class Grain128Test
1515
extends SimpleTest
1616
{
1717

18-
String keyStream1 = "f09b7bf7d7f6b5c2de2ffc73ac21397f";
19-
String keyStream2 = "afb5babfa8de896b4b9c6acaf7c4fbfd";
18+
String keyStream1 = "4bdb20824c5dce6fc63e94456c3281d4";
19+
String keyStream2 = "ba399daf90df8eba103d9ea83c805904";
2020

2121
public String getName()
2222
{

core/src/test/java/org/bouncycastle/pqc/crypto/test/XMSSPrivateKeyTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ private void parsingTest(Digest digest)
3131
{
3232
XMSSParameters params = new XMSSParameters(10, digest);
3333
byte[] root = generateRoot(digest);
34-
XMSSPrivateKeyParameters privateKey = new XMSSPrivateKeyParameters.Builder(params).withRoot(root).build();
34+
XMSSPrivateKeyParameters privateKey = new XMSSPrivateKeyParameters.Builder(params).withRoot(root)
35+
.withPublicSeed(new byte[digest.getDigestSize()]).withSecretKeySeed(new byte[digest.getDigestSize()]).build();
3536

3637
byte[] export = privateKey.toByteArray();
3738

prov/build.gradle

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ sourceSets {
3636
srcDirs = ['src/main/jdk1.15']
3737
}
3838
}
39-
java21 {
39+
java17 {
4040
java {
41-
srcDirs = ['src/main/jdk21']
41+
srcDirs = ['src/main/jdk17']
4242
}
4343
}
4444
java25 {
@@ -68,7 +68,7 @@ dependencies {
6868
builtBy compileJava11Java
6969
}
7070

71-
java21Implementation files([
71+
java17Implementation files([
7272
sourceSets.main.output.classesDirs,
7373
sourceSets.java9.output.classesDirs,
7474
sourceSets.java11.output.classesDirs,
@@ -81,8 +81,8 @@ dependencies {
8181
sourceSets.java9.output.classesDirs,
8282
sourceSets.java11.output.classesDirs,
8383
sourceSets.java15.output.classesDirs,
84-
sourceSets.java21.output.classesDirs]) {
85-
builtBy compileJava21Java
84+
sourceSets.java17.output.classesDirs]) {
85+
builtBy compileJava17Java
8686
}
8787
}
8888

@@ -106,9 +106,10 @@ compileJava15Java {
106106
options.sourcepath = files(['src/main/java', 'src/main/jdk1.15'])
107107
}
108108

109-
compileJava21Java {
110-
options.release = 21
111-
options.sourcepath = files(['src/main/java', 'src/main/jdk21'])
109+
compileJava17Java {
110+
targetCompatibility = 17
111+
sourceCompatibility = 17
112+
options.sourcepath = files(['src/main/java', 'src/main/jdk17'])
112113
}
113114

114115
compileJava25Java {
@@ -132,8 +133,8 @@ task sourcesJar(type: Jar) {
132133
into('META-INF/versions/15') {
133134
from sourceSets.java15.allSource
134135
}
135-
into('META-INF/versions/21') {
136-
from sourceSets.java21.allSource
136+
into('META-INF/versions/17') {
137+
from sourceSets.java17.allSource
137138
}
138139
into('META-INF/versions/25') {
139140
from sourceSets.java25.allSource
@@ -154,8 +155,8 @@ jar {
154155
into('META-INF/versions/15') {
155156
from sourceSets.java15.output
156157
}
157-
into('META-INF/versions/21') {
158-
from sourceSets.java21.output
158+
into('META-INF/versions/17') {
159+
from sourceSets.java17.output
159160
}
160161
into('META-INF/versions/25') {
161162
from sourceSets.java25.output
@@ -208,11 +209,11 @@ sourceSets {
208209
}
209210
}
210211

211-
test21 {
212+
test17 {
212213
java {
213214
compileClasspath += main.output + test.output
214215
runtimeClasspath += test.output
215-
srcDir(files("src/test/jdk21"))
216+
srcDir(files("src/test/jdk17"))
216217
}
217218
}
218219

@@ -229,22 +230,22 @@ dependencies {
229230
java9Implementation project(':core')
230231
java11Implementation project(':core')
231232
java15Implementation project(':core')
232-
java21Implementation project(':core')
233+
java17Implementation project(':core')
233234
java25Implementation project(':core')
234235
}
235236

236237
dependencies {
237238
test11Implementation group: 'junit', name: 'junit', version: '4.13.2'
238239
test15Implementation group: 'junit', name: 'junit', version: '4.13.2'
239-
test21Implementation group: 'junit', name: 'junit', version: '4.13.2'
240+
test17Implementation group: 'junit', name: 'junit', version: '4.13.2'
240241
test25Implementation group: 'junit', name: 'junit', version: '4.13.2'
241242
test11Implementation files('../libs/unboundid-ldapsdk-6.0.8.jar')
242243
test15Implementation files('../libs/unboundid-ldapsdk-6.0.8.jar')
243-
test21Implementation files('../libs/unboundid-ldapsdk-6.0.8.jar')
244+
test17Implementation files('../libs/unboundid-ldapsdk-6.0.8.jar')
244245
test25Implementation files('../libs/unboundid-ldapsdk-6.0.8.jar')
245246
test11Implementation(project(":core"))
246247
test15Implementation(project(":core"))
247-
test21Implementation(project(":core"))
248+
test17Implementation(project(":core"))
248249
test25Implementation(project(":core"))
249250
test25Implementation sourceSets.java25.output
250251

@@ -264,9 +265,10 @@ compileTest15Java {
264265
options.sourcepath = files(['src/test/java', 'src/test/jdk1.15'])
265266
}
266267

267-
compileTest21Java {
268-
options.release = 21
269-
options.sourcepath = files(['src/test/java', 'src/test/jdk21'])
268+
compileTest17Java {
269+
targetCompatibility = 17
270+
sourceCompatibility = 17
271+
options.sourcepath = files(['src/test/java', 'src/test/jdk17'])
270272
}
271273

272274
compileTest25Java {
@@ -291,7 +293,7 @@ publishing {
291293
configurations {
292294
test11Implementation.extendsFrom testImplementation
293295
test15Implementation.extendsFrom testImplementation
294-
test21Implementation.extendsFrom testImplementation
296+
test17Implementation.extendsFrom testImplementation
295297
test25Implementation.extendsFrom testImplementation
296298
}
297299

@@ -396,14 +398,14 @@ task test15(type: Test) {
396398
}
397399
}
398400

399-
task test21(type: Test) {
401+
task test17(type: Test) {
400402

401-
// This is testing the 21 code base
402-
onlyIf {System.getenv("BC_JDK21") != null}
403+
// This is testing the 17 code base
404+
onlyIf {System.getenv("BC_JDK17") != null}
403405
dependsOn jar
404406

405-
testClassesDirs = sourceSets.test21.output.classesDirs
406-
classpath = sourceSets.test21.runtimeClasspath + files(jar.archiveFile)
407+
testClassesDirs = sourceSets.test17.output.classesDirs
408+
classpath = sourceSets.test17.runtimeClasspath + files(jar.archiveFile)
407409

408410
forkEvery = 1;
409411
maxParallelForks = 8;
@@ -413,10 +415,10 @@ task test21(type: Test) {
413415
testLogging.showStandardStreams = false
414416

415417
javaLauncher = javaToolchains.launcherFor {
416-
languageVersion = JavaLanguageVersion.of(21)
418+
languageVersion = JavaLanguageVersion.of(17)
417419
}
418420

419-
jvmArgs = ['-Dtest.java.version.prefix=21']
421+
jvmArgs = ['-Dtest.java.version.prefix=17']
420422

421423

422424
finalizedBy jacocoTestReport
@@ -477,9 +479,9 @@ if (System.getenv("BC_JDK17") != null) {
477479
test.dependsOn("test15")
478480
}
479481

480-
if (System.getenv("BC_JDK21") != null) {
481-
System.out.println("${project.name}: Adding test21 as dependency for test task because BC_JDK21 is defined")
482-
test.dependsOn("test21")
482+
if (System.getenv("BC_JDK17") != null) {
483+
System.out.println("${project.name}: Adding test17 as dependency for test task because BC_JDK17 is defined")
484+
test.dependsOn("test17")
483485
}
484486
if (System.getenv("BC_JDK25") != null) {
485487
System.out.println("${project.name}: Adding test25 as dependency for test task because BC_JDK25 is defined")

prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java renamed to prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/MLKEM.java

File renamed without changes.

prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMDecapsulatorSpi.java renamed to prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMDecapsulatorSpi.java

File renamed without changes.

prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMEncapsulatorSpi.java renamed to prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMEncapsulatorSpi.java

File renamed without changes.

prov/src/main/jdk21/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java renamed to prov/src/main/jdk17/org/bouncycastle/jcajce/provider/asymmetric/mlkem/MLKEMSpi.java

File renamed without changes.

0 commit comments

Comments
 (0)