Skip to content

Commit edd3d90

Browse files
committed
(D)TLS: Only offer reneg info with pre-1.3
1 parent 11d7ddd commit edd3d90

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

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
}

0 commit comments

Comments
 (0)