public void ClearTest() { // arrange ByteCircularBuffer target; int expectedSize; int expectedHead; int expectedTail; expectedHead = 0; expectedSize = 0; expectedTail = 0; target = new ByteCircularBuffer(10); target.Put(1); target.Put(2); target.Put(3); // act target.Clear(); // assert target.Head.Should(). Be(expectedHead); target.Tail.Should(). Be(expectedTail); target.Size.Should(). Be(expectedSize); }
public override void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength) { Debug.Assert(_decCircularBuffer != null, "_circularBuffer != null"); _decCircularBuffer.Put(buf, 0, length); if (!_decryptIVReceived) { if (_decCircularBuffer.Size <= ivLen) { // we need more data outlength = 0; return; } // start decryption _decryptIVReceived = true; byte[] iv = _decCircularBuffer.Get(ivLen); initCipher(iv, false); } byte[] cipher = _decCircularBuffer.ToArray(); cipherUpdate(false, cipher.Length, cipher, outbuf); _decCircularBuffer.Clear(); outlength = cipher.Length; // done the decryption }