Skip to content

Commit 29bf82a

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents 65dcde7 + edd3d90 commit 29bf82a

File tree

4 files changed

+38
-18
lines changed

4 files changed

+38
-18
lines changed

tls/src/main/java/org/bouncycastle/jsse/provider/SignatureSchemeInfo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,12 @@ private static int[] createCandidatesDefault()
596596
{
597597
int signatureScheme = values[i].signatureScheme;
598598

599-
/*
600-
* SLH-DSA signing is quite slow; users will most likely be interested in it for the certificate
601-
* chain, so we'll leave it to them to configure signature_algorithms_cert.
602-
*/
603-
if (!SignatureScheme.isSLHDSA(signatureScheme))
599+
if (SignatureScheme.isMLDSA(signatureScheme) ||
600+
SignatureScheme.isSLHDSA(signatureScheme))
601+
{
602+
// For the time being, do not enable stand-alone PQ schemes by default
603+
}
604+
else
604605
{
605606
result[pos++] = signatureScheme;
606607
}

tls/src/main/java/org/bouncycastle/tls/DTLSClientProtocol.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -534,19 +534,27 @@ protected byte[] generateClientHello(ClientHandshakeState state)
534534
state.clientExtensions.remove(TlsExtensionsUtils.EXT_extended_master_secret);
535535
}
536536

537-
// Cipher Suites (and SCSV)
537+
// NOT renegotiating
538+
if (offeringDTLSv12Minus)
538539
{
539540
/*
540-
* RFC 5746 3.4. The client MUST include either an empty "renegotiation_info" extension,
541-
* or the TLS_EMPTY_RENEGOTIATION_INFO_SCSV signaling cipher suite value in the
542-
* ClientHello. Including both is NOT RECOMMENDED.
541+
* RFC 5746 3.4. Client Behavior: Initial Handshake (both full and session-resumption)
542+
*/
543+
544+
/*
545+
* The client MUST include either an empty "renegotiation_info" extension, or the
546+
* TLS_EMPTY_RENEGOTIATION_INFO_SCSV signaling cipher suite value in the ClientHello.
547+
* Including both is NOT RECOMMENDED.
543548
*/
544-
boolean noRenegExt = (null == TlsUtils.getExtensionData(state.clientExtensions, TlsProtocol.EXT_RenegotiationInfo));
545-
boolean noRenegSCSV = !Arrays.contains(state.offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
549+
boolean noRenegExt = (null == TlsUtils.getExtensionData(state.clientExtensions,
550+
TlsProtocol.EXT_RenegotiationInfo));
551+
boolean noRenegSCSV = !Arrays.contains(state.offeredCipherSuites,
552+
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
546553

547554
if (noRenegExt && noRenegSCSV)
548555
{
549-
state.offeredCipherSuites = Arrays.append(state.offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
556+
state.offeredCipherSuites = Arrays.append(state.offeredCipherSuites,
557+
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
550558
}
551559
}
552560

tls/src/main/java/org/bouncycastle/tls/TlsClientProtocol.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,6 @@ protected void sendClientHello()
19021902
this.clientExtensions.remove(TlsExtensionsUtils.EXT_extended_master_secret);
19031903
}
19041904

1905-
boolean hasRenegSCSV = Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
1906-
19071905
if (securityParameters.isRenegotiating())
19081906
{
19091907
/*
@@ -1920,7 +1918,7 @@ protected void sendClientHello()
19201918
* The client MUST include the "renegotiation_info" extension in the ClientHello,
19211919
* containing the saved client_verify_data. The SCSV MUST NOT be included.
19221920
*/
1923-
if (hasRenegSCSV)
1921+
if (Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV))
19241922
{
19251923
throw new TlsFatalAlert(AlertDescription.internal_error,
19261924
"Renegotiation cannot use TLS_EMPTY_RENEGOTIATION_INFO_SCSV");
@@ -1930,7 +1928,7 @@ protected void sendClientHello()
19301928

19311929
this.clientExtensions.put(EXT_RenegotiationInfo, createRenegotiationInfo(saved.getLocalVerifyData()));
19321930
}
1933-
else
1931+
else if (offeringTLSv12Minus)
19341932
{
19351933
/*
19361934
* RFC 5746 3.4. Client Behavior: Initial Handshake (both full and session-resumption)
@@ -1942,11 +1940,10 @@ protected void sendClientHello()
19421940
* Including both is NOT RECOMMENDED.
19431941
*/
19441942
boolean noRenegExt = (null == TlsUtils.getExtensionData(clientExtensions, EXT_RenegotiationInfo));
1945-
boolean noRenegSCSV = !hasRenegSCSV;
1943+
boolean noRenegSCSV = !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
19461944

19471945
if (noRenegExt && noRenegSCSV)
19481946
{
1949-
// TODO[tls13] Probably want to not add this if no pre-TLSv13 versions offered?
19501947
offeredCipherSuites = Arrays.append(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
19511948
}
19521949
}

tls/src/test/java/org/bouncycastle/jsse/provider/test/MLDSACredentialsTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@
2222
public class MLDSACredentialsTest
2323
extends TestCase
2424
{
25+
private static final String PROPERTY_CLIENT_SIGNATURE_SCHEMES = "jdk.tls.client.SignatureSchemes";
26+
private static final String PROPERTY_SERVER_SIGNATURE_SCHEMES = "jdk.tls.server.SignatureSchemes";
27+
2528
protected void setUp()
2629
{
2730
ProviderUtils.setupLowPriority(false);
31+
32+
String signatureSchemes = "mldsa44, mldsa65, mldsa87";
33+
34+
System.setProperty(PROPERTY_CLIENT_SIGNATURE_SCHEMES, signatureSchemes);
35+
System.setProperty(PROPERTY_SERVER_SIGNATURE_SCHEMES, signatureSchemes);
36+
}
37+
38+
protected void tearDown()
39+
{
40+
System.clearProperty(PROPERTY_CLIENT_SIGNATURE_SCHEMES);
41+
System.clearProperty(PROPERTY_SERVER_SIGNATURE_SCHEMES);
2842
}
2943

3044
private static final String HOST = "localhost";

0 commit comments

Comments
 (0)