Skip to content

Commit 696b373

Browse files
committed
Some error messages in tls
1 parent f1e2937 commit 696b373

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,8 @@ protected void sendClientHello()
19131913
this.clientExtensions.remove(TlsExtensionsUtils.EXT_extended_master_secret);
19141914
}
19151915

1916+
boolean hasRenegSCSV = Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
1917+
19161918
if (securityParameters.isRenegotiating())
19171919
{
19181920
/*
@@ -1922,13 +1924,19 @@ protected void sendClientHello()
19221924
*/
19231925
if (!securityParameters.isSecureRenegotiation())
19241926
{
1925-
throw new TlsFatalAlert(AlertDescription.internal_error);
1927+
throw new TlsFatalAlert(AlertDescription.internal_error, "Renegotiation requires secure_renegotiation");
19261928
}
19271929

19281930
/*
19291931
* The client MUST include the "renegotiation_info" extension in the ClientHello,
19301932
* containing the saved client_verify_data. The SCSV MUST NOT be included.
19311933
*/
1934+
if (hasRenegSCSV)
1935+
{
1936+
throw new TlsFatalAlert(AlertDescription.internal_error,
1937+
"Renegotiation cannot use TLS_EMPTY_RENEGOTIATION_INFO_SCSV");
1938+
}
1939+
19321940
SecurityParameters saved = tlsClientContext.getSecurityParametersConnection();
19331941

19341942
this.clientExtensions.put(EXT_RenegotiationInfo, createRenegotiationInfo(saved.getLocalVerifyData()));
@@ -1945,7 +1953,7 @@ protected void sendClientHello()
19451953
* Including both is NOT RECOMMENDED.
19461954
*/
19471955
boolean noRenegExt = (null == TlsUtils.getExtensionData(clientExtensions, EXT_RenegotiationInfo));
1948-
boolean noRenegSCSV = !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV);
1956+
boolean noRenegSCSV = !hasRenegSCSV;
19491957

19501958
if (noRenegExt && noRenegSCSV)
19511959
{

0 commit comments

Comments
 (0)