/// <summary> /// Send message MSG_NEGO_RESP. /// </summary> /// <param name="isSupportVersion">If it is true, it is support version, if it is false, it is not support version.</param> /// <param name="isWellFormed">If it is true, it is well formed, if it is false, it is not well formed.</param> public void SendMsgNegoResp(bool isSupportVersion, bool isWellFormed) { PccrrNegoResponsePacket pccrrNegoResponsePacket; if (!isSupportVersion && isWellFormed) { pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minErrorSupV, this.maxErrorSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoErrorVer); } else if (isSupportVersion && isWellFormed) { pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minSupV, this.maxSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoVer); } else { pccrrNegoResponsePacket = this.pccrrStackSer.CreateMsgNegoResponse(this.minErrorSupV, this.maxErrorSupV, CryptoAlgoId_Values.AES_128, MsgType_Values.MSG_NEGO_RESP, this.protoErrorVer); MSG_NEGO_RESP msgNegoResp = new MSG_NEGO_RESP(); MESSAGE_HEADER messageHeader = new MESSAGE_HEADER(); messageHeader = pccrrNegoResponsePacket.MessageHeader; msgNegoResp.MinSupporteProtocolVersion.MajorVersion = 0; msgNegoResp.MinSupporteProtocolVersion.MinorVersion = 0; messageHeader.ProtVer.MajorVersion = 1; messageHeader.ProtVer.MinorVersion = 0; msgNegoResp.MaxSupporteProtocolVersion.MajorVersion = 0; msgNegoResp.MaxSupporteProtocolVersion.MinorVersion = 0; pccrrNegoResponsePacket.MsgNegoResp = msgNegoResp; pccrrNegoResponsePacket.MessageHeader = messageHeader; } this.pccrrStackSer.SendPacket(pccrrNegoResponsePacket); }
/// <summary> /// Send message MSG_NEGO_REQ /// </summary> public void SendMsgNegoReq() { PccrrNegoRequestPacket packet = this.pccrrStack.CreateMsgNegoRequest(this.minSupV, this.maxSupV, this.cryptoAlgo, MsgType_Values.MSG_NEGO_REQ, this.protoVer); this.pccrrStack.SendPacket(packet, new TimeSpan(0, 0, this.timeout)); PccrrPacket respMSG = this.pccrrStack.ExpectPacket(); PccrrNegoResponsePacket pccrrNegoResponsePacket = respMSG as PccrrNegoResponsePacket; MSG_NEGO_RESP msgNegoResp = pccrrNegoResponsePacket.MsgNegoResp; MESSAGE_HEADER messageHeader = pccrrNegoResponsePacket.MessageHeader; TRANSPORT_RESPONSE_HEADER transportRespH = pccrrNegoResponsePacket.TransportResponseHeader; RESPONSE_MESSAGE respMessage = new RESPONSE_MESSAGE(); respMessage.MESSAGEBODY = msgNegoResp; respMessage.MESSAGEHEADER = messageHeader; respMessage.TRANSPORTRESPONSEHEADER = transportRespH; this.uiPayload = Marshal.SizeOf(messageHeader) + Marshal.SizeOf(msgNegoResp); this.VerifyHttpResponse(); PccrrBothRoleCaptureCode.CaptureHttpRequirements(); this.VerifyMsgNegoResp(msgNegoResp); this.VerifyMessageHeader(messageHeader); PccrrBothRoleCaptureCode.CaptureMessageHeaderRequirements(messageHeader, this.uiPayload); this.VerifyTransportResponseHeader(transportRespH); PccrrBothRoleCaptureCode.CaptureMessageRequirements(); this.VerifyResponseMessage(respMessage); this.ReceiveMsgNegoResp(); }
/// <summary> /// Capture MSG_NEGO_RESP structure related requirements. /// </summary> /// <param name="msgNegoResp">The msgNegoResp.</param> private void VerifyMsgNegoResp(MSG_NEGO_RESP msgNegoResp) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R132"); bool isVerifyR132 = msgNegoResp.MinSupporteProtocolVersion.GetType() == typeof(ProtoVersion); // Verify MS-PCCRR requirement: MS-PCCRR_R132 Site.CaptureRequirementIfIsTrue( isVerifyR132, 132, @"[In MSG_NEGO_RESP]MinSupportedProtocolVersion (4 bytes): Minimum protocol version supported by the requesting peer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R134"); bool isVerifyR134 = msgNegoResp.MaxSupporteProtocolVersion.GetType() == typeof(ProtoVersion); // Verify MS-PCCRR requirement: MS-PCCRR_R134 Site.CaptureRequirementIfIsTrue( isVerifyR134, 134, @"[In MSG_NEGO_RESP]MaxSupportedProtocolVersion (4 bytes): Maximum protocol version supported by the requesting peer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R131"); bool isVerifyR131 = msgNegoResp.MinSupporteProtocolVersion.GetType() == typeof(ProtoVersion) && msgNegoResp.MaxSupporteProtocolVersion.GetType() == typeof(ProtoVersion); Site.CaptureRequirementIfIsTrue( isVerifyR131, 131, @"[In MSG_NEGO_RESP]The message is sent in response to a Negotiation Request message or to any other request message with a protocol version not supported by the server-role peer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R133"); bool isVerifyR133 = msgNegoResp.MinSupporteProtocolVersion.GetType() == typeof(ProtoVersion); Site.CaptureRequirementIfIsTrue( isVerifyR133, 133, @"[In MSG_NEGO_RESP]The protocol version[Minimum protocol version] is encoded identically to the ProtVer field defined in section 2.2.3."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R135"); bool isVerifyR135 = msgNegoResp.MaxSupporteProtocolVersion.GetType() == typeof(ProtoVersion); Site.CaptureRequirementIfIsTrue( isVerifyR135, 135, @"[In MSG_NEGO_RESP]The protocol version[Maximum protocol version] is encoded identically to the ProtVer field defined in section 2.2.3."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R130"); // Since the R133 and R135 have already contains the logic with R130, and R133 and R135 have been verified, // the following requirement can be verified directly Site.CaptureRequirement( 130, @"[In MSG_NEGO_RESP]The MSG_NEGO_RESP (Negotiation Response) message is the response message containing the minimum and maximum protocol version supported by the responding server-role peer."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-PCCRR_R168"); bool isVerifyR168 = msgNegoResp.MinSupporteProtocolVersion.GetType() == typeof(ProtoVersion) && msgNegoResp.MaxSupporteProtocolVersion.GetType() == typeof(ProtoVersion); // Verify MS-PCCRR requirement: MS-PCCRR_R168 Site.CaptureRequirementIfIsTrue( isVerifyR168, 168, @"[In Protocol Details][Protocol Version Negotiation]The server responds with a Negotiation Response message (MSG_NEGO_RESP (section 2.2.5.1)), declaring the minimum and maximum protocol versions it supports."); }