override protected bool HandleOutgoing(ICopyable app_data, out ICopyable data)
{
if(!_active) {
if(_closed == 1) {
throw new SendException(false, "SA closed, unable to send!");
}
UpdateSH(null, null);
data = null;
return false;
}
// prepare the packet
SecurityDataMessage sdm = new SecurityDataMessage();
sdm.SPI = _spi;
sdm.Data = app_data as MemBlock;
if(sdm.Data == null) {
byte[] b = new byte[app_data.Length];
app_data.CopyTo(b, 0);
sdm.Data = MemBlock.Reference(b);
}
// Encrypt it!
lock(_sync) {
_current_sh.SignAndEncrypt(sdm);
}
data = new CopyList(PeerSecOverlord.Security, PeerSecOverlord.SecureData, sdm.ICPacket);
return true;
}