public static Action <BytesView> GetStreamFilterFromIVEncryptor(bool isEncrypt, IIVEncryptor iVEncryptor, bool ivOK) { return((bv) => { if (!ivOK) { ivOK = true; if (isEncrypt) { bv.nextNode = bv.Clone(); bv.Set(iVEncryptor.IV); bv = bv.nextNode; } else { int iVLength = iVEncryptor.IVLength; iVEncryptor.IV = bv.GetBytes(0, iVLength, true); bv.SubSelf(iVLength); } } foreach (var item in bv) { iVEncryptor.Update(new BytesSegment(item)); } }); }
public void ApplyFilterFromEncryptor(IIVEncryptor write, IIVEncryptor read) { AddWriteFilter(GetStreamFilterFromIVEncryptor(true, write)); AddReadFilter(GetStreamFilterFromIVEncryptor(false, read)); }
public static Action <BytesView> GetStreamFilterFromIVEncryptor(bool isEncrypt, IIVEncryptor iVEncryptor) { return(GetStreamFilterFromIVEncryptor(isEncrypt, iVEncryptor, false)); }
public IvEncryptStream(IMyStream baseStream, IIVEncryptor recv, IIVEncryptor send) { BaseStream = baseStream; recvEnc = recv; sendEnc = send; }