override protected bool HandleIncoming(MemBlock data, out MemBlock app_data)
{
if(!_active) {
if(_closed == 0) {
UpdateSH(null, null);
}
app_data = null;
return false;
}
SecurityDataMessage sdm = new SecurityDataMessage(data);
if(sdm.SPI != _spi) {
throw new Exception("Invalid SPI!");
}
try {
// try to decrypt the data
lock(_sync) {
_current_sh.DecryptAndVerify(sdm);
}
} catch {
// Maybe this is just a late arriving packet, if it is, we'll just ignore it
if(sdm.Epoch == _last_epoch) {
app_data = null;
return false;
// bad packet, let's throw it away!
} else {
throw;
}
}
app_data = sdm.Data;
return true;
}