/// <summary>First signs the data and then encrypts it.</summary>
/// <param name="UnecryptedData">The data to sign and encrypt.</param>
/// <returns>The signed and encrypted data.</returns>
public void SignAndEncrypt(SecurityDataMessage sdm)
{
if (_closed)
{
throw new Exception("SecurityHandler: closed");
}
// Get the sequence id and increment the counter
int seqid = ++_last_outgoing_seqid;
// We ask for an update at the half life and every 1000 packets thereafter
if (seqid == HALF_LIFE || (seqid > HALF_LIFE && seqid % 1000 == 0))
{
if (Update != null)
{
Update(Epoch, EventArgs.Empty);
}
}
sdm.Seqid = seqid;
sdm.Epoch = Epoch;
sdm.Sign(_outgoing_auth);
sdm.Encrypt(_encryptor);
}