//returns true if a new packet is obtained to _packet private bool ConstructPacket() { if (_cipher == null) //暗号が確立する前 { if (_buffer.Length < PACKET_LENGTH_FIELD_LEN) { return(false); } int len = SSHUtil.ReadInt32(_buffer.Data, _buffer.Offset); if (_buffer.Length < PACKET_LENGTH_FIELD_LEN + len) { return(false); } ReadPacketFromPlainStream(); } else { if (!_head_is_available) { if (_buffer.Length < _cipher.BlockSize) { return(false); } _cipher.Decrypt(_buffer.Data, _buffer.Offset, _head.Length, _head, 0); _buffer.Consume(_head.Length); _head_is_available = true; } int len = SSHUtil.ReadInt32(_head, 0); if (_buffer.Length < len + PACKET_LENGTH_FIELD_LEN - _head.Length + _mac.Size) { return(false); } ReadPacketWithDecryptedHead(); _head_is_available = false; } _sequence++; return(true); }