protected byte[] trimmedBuffer(byte[] buffer, int length) { var trimmed = new byte[length]; Array.Copy(buffer, trimmed, length); return trimmed; }