diff options
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/tls/DtlsRecordLayer.cs | 16 | ||||
-rw-r--r-- | crypto/src/tls/TlsUtilities.cs | 13 |
2 files changed, 18 insertions, 11 deletions
diff --git a/crypto/src/tls/DtlsRecordLayer.cs b/crypto/src/tls/DtlsRecordLayer.cs index e3567aa46..fe3b58d41 100644 --- a/crypto/src/tls/DtlsRecordLayer.cs +++ b/crypto/src/tls/DtlsRecordLayer.cs @@ -715,10 +715,12 @@ namespace Org.BouncyCastle.Tls { recordEpoch = m_readEpoch; } - else if (recordType == ContentType.handshake && null != m_retransmitEpoch - && epoch == m_retransmitEpoch.Epoch) + else if (null != m_retransmitEpoch && epoch == m_retransmitEpoch.Epoch) { - recordEpoch = m_retransmitEpoch; + if (recordType == ContentType.handshake) + { + recordEpoch = m_retransmitEpoch; + } } if (null == recordEpoch) @@ -994,7 +996,6 @@ namespace Org.BouncyCastle.Tls int recordLength = RecordHeaderLength; if (m_recordQueue.Available >= recordLength) { - short recordType = m_recordQueue.ReadUint8(0); int epoch = m_recordQueue.ReadUint16(3); DtlsEpoch recordEpoch = null; @@ -1002,8 +1003,7 @@ namespace Org.BouncyCastle.Tls { recordEpoch = m_readEpoch; } - else if (recordType == ContentType.handshake && null != m_retransmitEpoch - && epoch == m_retransmitEpoch.Epoch) + else if (null != m_retransmitEpoch && epoch == m_retransmitEpoch.Epoch) { recordEpoch = m_retransmitEpoch; } @@ -1038,7 +1038,6 @@ namespace Org.BouncyCastle.Tls { this.m_inConnection = true; - short recordType = TlsUtilities.ReadUint8(buf, off); int epoch = TlsUtilities.ReadUint16(buf, off + 3); DtlsEpoch recordEpoch = null; @@ -1046,8 +1045,7 @@ namespace Org.BouncyCastle.Tls { recordEpoch = m_readEpoch; } - else if (recordType == ContentType.handshake && null != m_retransmitEpoch - && epoch == m_retransmitEpoch.Epoch) + else if (null != m_retransmitEpoch && epoch == m_retransmitEpoch.Epoch) { recordEpoch = m_retransmitEpoch; } diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs index 2887b0df1..67a49e5ef 100644 --- a/crypto/src/tls/TlsUtilities.cs +++ b/crypto/src/tls/TlsUtilities.cs @@ -770,11 +770,20 @@ namespace Org.BouncyCastle.Tls public static int ReadUint16(byte[] buf, int offset) { - int n = (buf[offset] & 0xff) << 8; - n |= (buf[++offset] & 0xff); + int n = buf[offset] << 8; + n |= buf[++offset]; return n; } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public static int ReadUint16(ReadOnlySpan<byte> buffer) + { + int n = buffer[0] << 8; + n |= buffer[1]; + return n; + } +#endif + public static int ReadUint24(Stream input) { int i1 = input.ReadByte(); |