internal virtual bool ReadRecord() { byte[] recordHeader = TlsUtilities.ReadAllOrNothing(TLS_HEADER_SIZE, mInput); if (recordHeader == null) { return(false); } byte type = TlsUtilities.ReadUint8(recordHeader, TLS_HEADER_TYPE_OFFSET); /* * RFC 5246 6. If a TLS implementation receives an unexpected record type, it MUST send an * unexpected_message alert. */ CheckType(type, AlertDescription.unexpected_message); if (!mRestrictReadVersion) { int version = TlsUtilities.ReadVersionRaw(recordHeader, TLS_HEADER_VERSION_OFFSET); if ((version & 0xffffff00) != 0x0300) { throw new TlsFatalAlert(AlertDescription.illegal_parameter); } } else { ProtocolVersion version = TlsUtilities.ReadVersion(recordHeader, TLS_HEADER_VERSION_OFFSET); if (mReadVersion == null) { mReadVersion = version; } else if (!version.Equals(mReadVersion)) { throw new TlsFatalAlert(AlertDescription.illegal_parameter); } } int length = TlsUtilities.ReadUint16(recordHeader, TLS_HEADER_LENGTH_OFFSET); byte[] plaintext = DecodeAndVerify(type, mInput, length); mHandler.ProcessRecord(type, plaintext, 0, plaintext.Length); return(true); }
internal virtual bool ReadRecord() { byte[] array = TlsUtilities.ReadAllOrNothing(5, mInput); if (array == null) { return(false); } byte b = TlsUtilities.ReadUint8(array, 0); CheckType(b, 10); if (!mRestrictReadVersion) { int num = TlsUtilities.ReadVersionRaw(array, 1); if ((num & 4294967040u) != 768) { throw new TlsFatalAlert(47); } } else { ProtocolVersion protocolVersion = TlsUtilities.ReadVersion(array, 1); if (mReadVersion == null) { mReadVersion = protocolVersion; } else if (!protocolVersion.Equals(mReadVersion)) { throw new TlsFatalAlert(47); } } int len = TlsUtilities.ReadUint16(array, 3); byte[] array2 = DecodeAndVerify(b, mInput, len); mHandler.ProcessRecord(b, array2, 0, array2.Length); return(true); }