diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-15 17:21:18 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-15 17:21:18 +0700 |
commit | 6eac5db2161d1766650f951608a1df41b19c6719 (patch) | |
tree | ded2353edd6d725b4f013ebda76f0ad656428518 | |
parent | make initial DTLS handshake resend time configurable (diff) | |
download | BouncyCastle.NET-ed25519-6eac5db2161d1766650f951608a1df41b19c6719.tar.xz |
Minor fixups for github_445
-rw-r--r-- | crypto/src/tls/DtlsClientProtocol.cs | 3 | ||||
-rw-r--r-- | crypto/src/tls/DtlsRecordLayer.cs | 4 | ||||
-rw-r--r-- | crypto/src/tls/DtlsReliableHandshake.cs | 4 | ||||
-rw-r--r-- | crypto/src/tls/DtlsServerProtocol.cs | 3 | ||||
-rw-r--r-- | crypto/src/tls/TlsPeer.cs | 3 | ||||
-rw-r--r-- | crypto/src/tls/TlsUtilities.cs | 9 |
6 files changed, 19 insertions, 7 deletions
diff --git a/crypto/src/tls/DtlsClientProtocol.cs b/crypto/src/tls/DtlsClientProtocol.cs index 4a96eed23..72484e178 100644 --- a/crypto/src/tls/DtlsClientProtocol.cs +++ b/crypto/src/tls/DtlsClientProtocol.cs @@ -100,7 +100,8 @@ namespace Org.BouncyCastle.Tls SecurityParameters securityParameters = state.clientContext.SecurityParameters; DtlsReliableHandshake handshake = new DtlsReliableHandshake(state.clientContext, recordLayer, - state.client.GetHandshakeTimeoutMillis(), state.client.GetHandshakeResendTimeMillis(), null); + state.client.GetHandshakeTimeoutMillis(), TlsUtilities.GetHandshakeResendTimeMillis(state.client), + null); byte[] clientHelloBody = GenerateClientHello(state); diff --git a/crypto/src/tls/DtlsRecordLayer.cs b/crypto/src/tls/DtlsRecordLayer.cs index ab35c49b1..a18210de2 100644 --- a/crypto/src/tls/DtlsRecordLayer.cs +++ b/crypto/src/tls/DtlsRecordLayer.cs @@ -306,7 +306,7 @@ namespace Org.BouncyCastle.Tls HeartbeatMessageType.heartbeat_request, m_heartbeat.GeneratePayload()); this.m_heartbeatTimeout = new Timeout(m_heartbeat.TimeoutMillis, currentTimeMillis); - this.m_heartbeatResendMillis = m_peer.GetHandshakeResendTimeMillis(); + this.m_heartbeatResendMillis = TlsUtilities.GetHandshakeResendTimeMillis(m_peer); this.m_heartbeatResendTimeout = new Timeout(m_heartbeatResendMillis, currentTimeMillis); SendHeartbeatMessage(m_heartbeatInFlight); @@ -405,7 +405,7 @@ namespace Org.BouncyCastle.Tls HeartbeatMessageType.heartbeat_request, m_heartbeat.GeneratePayload()); this.m_heartbeatTimeout = new Timeout(m_heartbeat.TimeoutMillis, currentTimeMillis); - this.m_heartbeatResendMillis = m_peer.GetHandshakeResendTimeMillis(); + this.m_heartbeatResendMillis = TlsUtilities.GetHandshakeResendTimeMillis(m_peer); this.m_heartbeatResendTimeout = new Timeout(m_heartbeatResendMillis, currentTimeMillis); SendHeartbeatMessage(m_heartbeatInFlight); diff --git a/crypto/src/tls/DtlsReliableHandshake.cs b/crypto/src/tls/DtlsReliableHandshake.cs index 90fa17580..42a98a991 100644 --- a/crypto/src/tls/DtlsReliableHandshake.cs +++ b/crypto/src/tls/DtlsReliableHandshake.cs @@ -90,8 +90,8 @@ namespace Org.BouncyCastle.Tls private int m_next_send_seq = 0, m_next_receive_seq = 0; - internal DtlsReliableHandshake(TlsContext context, DtlsRecordLayer transport, int timeoutMillis, int initialResendMillis, - DtlsRequest request) + internal DtlsReliableHandshake(TlsContext context, DtlsRecordLayer transport, int timeoutMillis, + int initialResendMillis, DtlsRequest request) { this.m_recordLayer = transport; this.m_handshakeHash = new DeferredHash(context); diff --git a/crypto/src/tls/DtlsServerProtocol.cs b/crypto/src/tls/DtlsServerProtocol.cs index 974eed2de..a4f8f4bc5 100644 --- a/crypto/src/tls/DtlsServerProtocol.cs +++ b/crypto/src/tls/DtlsServerProtocol.cs @@ -89,7 +89,8 @@ namespace Org.BouncyCastle.Tls SecurityParameters securityParameters = state.serverContext.SecurityParameters; DtlsReliableHandshake handshake = new DtlsReliableHandshake(state.serverContext, recordLayer, - state.server.GetHandshakeTimeoutMillis(), state.server.GetHandshakeResendTimeMillis(), request); + state.server.GetHandshakeTimeoutMillis(), TlsUtilities.GetHandshakeResendTimeMillis(state.server), + request); DtlsReliableHandshake.Message clientMessage = null; diff --git a/crypto/src/tls/TlsPeer.cs b/crypto/src/tls/TlsPeer.cs index f5266f0c9..4f16978d9 100644 --- a/crypto/src/tls/TlsPeer.cs +++ b/crypto/src/tls/TlsPeer.cs @@ -36,7 +36,8 @@ namespace Org.BouncyCastle.Tls /// NOTE: Currently only respected by DTLS protocols. /// </remarks> /// <returns>the handshake resend time, in milliseconds.</returns> - int GetHandshakeResendTimeMillis(); + // TODO[api] + //int GetHandshakeResendTimeMillis(); bool AllowLegacyResumption(); diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs index a2ee82f9e..69a458a5a 100644 --- a/crypto/src/tls/TlsUtilities.cs +++ b/crypto/src/tls/TlsUtilities.cs @@ -5721,5 +5721,14 @@ namespace Org.BouncyCastle.Tls } return v; } + + // TODO[api] Not needed once GetHandshakeResendTimeMillis() has been added to TlsPeer + internal static int GetHandshakeResendTimeMillis(TlsPeer tlsPeer) + { + if (tlsPeer is AbstractTlsPeer abstractTlsPeer) + return abstractTlsPeer.GetHandshakeResendTimeMillis(); + + return 1000; + } } } |