You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.3 KiB

using System;
namespace Org.BouncyCastle.Crypto.Tls
{
internal class DtlsEpoch
{
private readonly DtlsReplayWindow mReplayWindow = new DtlsReplayWindow();
private readonly int mEpoch;
private readonly TlsCipher mCipher;
private long mSequenceNumber = 0;
internal DtlsEpoch(int epoch, TlsCipher cipher)
{
if (epoch < 0)
throw new ArgumentException("must be >= 0", "epoch");
if (cipher == null)
throw new ArgumentNullException("cipher");
this.mEpoch = epoch;
this.mCipher = cipher;
}
internal long AllocateSequenceNumber()
{
lock (this)
{
if (mSequenceNumber >= (1L << 48))
throw new TlsFatalAlert(AlertDescription.internal_error);
return mSequenceNumber++;
}
}
internal TlsCipher Cipher
{
get { return mCipher; }
}
internal int Epoch
{
get { return mEpoch; }
}
internal DtlsReplayWindow ReplayWindow
{
get { return mReplayWindow; }
}
internal long SequenceNumber
{
get { lock(this) return mSequenceNumber; }
}
}
}