diff options
Diffstat (limited to '')
-rw-r--r-- | crypto/src/crypto/tls/DtlsEpoch.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/src/crypto/tls/DtlsEpoch.cs b/crypto/src/crypto/tls/DtlsEpoch.cs index 91fffa5e1..af14035ce 100644 --- a/crypto/src/crypto/tls/DtlsEpoch.cs +++ b/crypto/src/crypto/tls/DtlsEpoch.cs @@ -24,8 +24,13 @@ namespace Org.BouncyCastle.Crypto.Tls internal long AllocateSequenceNumber() { - // TODO Check for overflow - return mSequenceNumber++; + lock (this) + { + if (mSequenceNumber >= (1L << 48)) + throw new TlsFatalAlert(AlertDescription.internal_error); + + return mSequenceNumber++; + } } internal TlsCipher Cipher @@ -45,7 +50,7 @@ namespace Org.BouncyCastle.Crypto.Tls internal long SequenceNumber { - get { return mSequenceNumber; } + get { lock(this) return mSequenceNumber; } } } } |