Loading ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_ExternalFunctions.ttcn +44 −44 Original line number Original line Diff line number Diff line Loading @@ -44,16 +44,6 @@ external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry ) external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry ) return UInt16; return UInt16; /* @desc This external function calculates the checksum for any * IPv6 packet which contains an ICMP message as its payload. * If ICMP message contains DestOptionHdr with HomeAddress, then checksum is calculated * by using this home address as entry for source address. * @param p_packet ICMPv6 packet * @return checksum value */ //external function fx_icmpv6Checksum( in template Ipv6Packet p_packet) //return Oct2; /* @desc TODO /* @desc TODO * @param TODO * @param TODO * @return checksum value * @return checksum value Loading Loading @@ -86,14 +76,6 @@ external function fx_mipHeaderLength( in MobileHeader p_mobileHeader) external function fx_mipHeaderLength( in MobileHeader p_mobileHeader) return UInt8; return UInt8; /* @desc This external function calculates the length of DstOptHeader . * @param p_extHdr Extension header * @return DstOpt Header length */ // external function fx_dstOptHdrLength( in ExtensionHeader p_extHdr) // return UInt8; /* @desc Apply indicated Integrity algorithm to the message. Message is an octetstring. /* @desc Apply indicated Integrity algorithm to the message. Message is an octetstring. * If e_sha1_96 is chosen, then the key input shall be ignored. * If e_sha1_96 is chosen, then the key input shall be ignored. * * Loading @@ -114,32 +96,23 @@ external function fx_mipHdrToOct(MobileHeader p_mobileHeader) external function fx_mipHdrToOct(MobileHeader p_mobileHeader) return octetstring; return octetstring; /* @desc This external function byte aligns the EspPayload (Iv, EspIpDatagram, TfcPadding) + next Header + pad Length /* @desc This external function sets the test adapter with the relevant security parameters * with padding according to the byteBoundary set by the encryption algo. * The nextHeader is of constant size 1 octet, * and is therefore no input parameter to this external function. * The padLnength is of constant size 1 octet, * and is therefore no input parameter to this external function. * * * @param p_spi Security parameter Index whihc poinst to the SAD to be used * @param p_sa Security Association * @param p_espPayload EspPayload to be byteAligned * @return FncRetCode * @return octetstring */ */ // external function fx_generatePadding(in UInt31 p_spi, EspPayload p_espPayload) external function fx_setSecurityParameters(in Sad p_sa) // return octetstring; return FncRetCode; /* @desc This external function encrypts the EspPayload(except iv) + padding + padLen + nextHeader /* @desc This external function sets the test adapter with the relevant security parameters * * * @param p_spi Security parameter Index whihc poinst to the SAD to be used * @param p_sa Security Association * @param p_espHeader Esp Header to be encoded to octetstring * @return FncRetCode * @return octetstring Is used for calculating the ICV */ */ // external function fx_encrypt(in UInt31 p_spi, in EspHeader p_espHeader) external function fx_setIkeSecurityParameters(in IkeSad p_ikeSad) // return octetstring; external function fx_setSecurityParameters(in Sad p_sa) return FncRetCode; return FncRetCode; /* @desc This external function calculates the payload length /* @desc This external function calculates the payload length * of an IPv6 authentication header * of an IPv6 authentication header * @param p_authHeader Authentication Header * @param p_authHeader Authentication Header Loading Loading @@ -234,11 +207,6 @@ in octetstring p_receivedKey) in octetstring p_receivedKey) return octetstring; return octetstring; external function fx_setIkeSecurityParameters(in IkeSa p_ikeSa) return FncRetCode; external function fx_calcAuth() external function fx_calcAuth() return octetstring; return octetstring; Loading @@ -260,8 +228,40 @@ external function fx_saProposalToOct(SaProposal p_saProposal) external function fx_saProposalToOct(SaProposal p_saProposal) return octetstring; return octetstring; /* @desc This external function runs the Transform through Codec and returns * the octetstring representing the Transform * * @param p_transform Transform to be encoded to octetstring * @return octetstring */ external function fx_saTransformToOct(SaTransform p_saTransform) return octetstring; /* @desc This external function runs the Ikev2Header through Codec and returns * the octetstring representing the Ikev2Header * * @param p_ikev2Header Ikev2Header to be encoded to octetstring * @return octetstring */ external function fx_ikev2HeaderToOct(Ikev2Header p_ikev2Header) return octetstring; /* @desc This external function runs the IkePayloadList through Codec and returns * the octetstring representing the IkePayloadList * * @param p_ikePayloadList IkePayloadList to be encoded to octetstring * @return octetstring */ external function fx_ikePayloadListToOct(IkePayloadList p_ikePayloadList) return octetstring; /* @desc This external function runs the Ipv6Payload through Codec and returns * the octetstring representing the IkePayloadList * * @param p_ipv6Payload Ipv6Payload to be encoded to octetstring * @return octetstring */ external function fx_ipv6PayloadToOct(Ipv6Payload p_ipv6Payload) return octetstring; }// end module LibIpv6_ExternalFunctions }// end module LibIpv6_ExternalFunctions ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_Interface_Functions.ttcn +13 −1 Original line number Original line Diff line number Diff line Loading @@ -86,7 +86,7 @@ group rfc2460Root_Functions { v_pseudoDstAddr := v_activeIpv6Packet.ipv6Hdr.destinationAddress; v_pseudoDstAddr := v_activeIpv6Packet.ipv6Hdr.destinationAddress; v_pseudoSrcAddr := v_activeIpv6Packet.ipv6Hdr.sourceAddress; v_pseudoSrcAddr := v_activeIpv6Packet.ipv6Hdr.sourceAddress; //calc payloadLen //calc payloadLen of IPv6packet if (v_activeIpv6Packet.ipv6Hdr.payloadLength == c_uInt16Zero ) { if (v_activeIpv6Packet.ipv6Hdr.payloadLength == c_uInt16Zero ) { v_activeIpv6Packet.ipv6Hdr.payloadLength := fx_payloadLength (v_activeIpv6Packet); v_activeIpv6Packet.ipv6Hdr.payloadLength := fx_payloadLength (v_activeIpv6Packet); } } Loading Loading @@ -411,6 +411,17 @@ group rfc2460Root_Functions { p_ipv6Payload.otherIcmpv6Msg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); p_ipv6Payload.otherIcmpv6Msg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); } } } } else if(ischosen(p_ipv6Payload.ikeMsg)) { if(p_ipv6Payload.ikeMsg.checksum == c_2ZeroBytes) { //calc checksum p_ipv6Payload.ikeMsg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); } if(p_ipv6Payload.ikeMsg.msgLength == 0) { //calc payloadLen of UDP msg //smu 2007 check that calc is correct p_ipv6Payload.ikeMsg.msgLength := lengthof(fx_ipv6PayloadToOct(p_ipv6Payload)); } } return e_success; return e_success; Loading Loading @@ -1224,6 +1235,7 @@ group rfc4303Esp_ExtHdrFunctions { //TODO chose in function of PX_SPI the SAD to be used for testing //TODO chose in function of PX_SPI the SAD to be used for testing // v_ret := fx_setSecurityParameters(Sad:{vc_sad[c_saOut]}); // v_ret := fx_setSecurityParameters(Sad:{vc_sad[c_saOut]}); //SMU 2007 how is it solved to know when to use which SAD? v_ret := fx_setSecurityParameters(vc_sad); v_ret := fx_setSecurityParameters(vc_sad); if (v_ret != e_success) {log("f_init_ipSecParams: Error when setting security parameters");} if (v_ret != e_success) {log("f_init_ipSecParams: Error when setting security parameters");} Loading ttcn3/EtsiLibrary/LibIpv6/LibCore/LibIpv6_Rfc2461NeighborDiscovery_Functions.ttcn +1 −1 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,7 @@ module LibIpv6_Rfc2461NeighborDiscovery_Functions { var Redirect v_ipPkt; var Redirect v_ipPkt; v_ipPkt := valueof(p_redirect); v_ipPkt := valueof(p_redirect); //calc payloadLen //calc payloadLen //SMU this must be deleted during maintenance v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt); v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt); //set extensionHeaders //set extensionHeaders Loading ttcn3/EtsiLibrary/LibIpv6/LibSec/LibIpv6_Rfc4306Ikev2_Functions.ttcn +70 −75 Original line number Original line Diff line number Diff line Loading @@ -579,27 +579,31 @@ group sendRequests { var IkeSaInitRequest v_ipPkt := valueof(p_ikeSaInitRequest); var IkeSaInitRequest v_ipPkt := valueof(p_ikeSaInitRequest); var FncRetCode v_ret := e_error; var FncRetCode v_ret := e_error; //smu added if (ispresent(v_ipPkt.ipv6Payload)) { if (ispresent(v_ipPkt.ipv6Payload)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { //Length in octets of IKEv2 header + payloads in octets //smu 2007: to be moved to setExtensionHdrs? v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := 0; //For each IkePayload: Length in octets of the current payload, including the generic payload header v_ret := f_calcPList(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes v_ret := f_getSAandCalcLen(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length in octets of IKEv2 header + payloads in octets v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := lengthof(fx_ikev2HeaderToOct(v_ipPkt.ipv6Payload.ikeMsg.ikev2Header)) + lengthof(fx_ikePayloadListToOct(v_ipPkt.ipv6Payload.ikeMsg.payloadList)); //Length in octets of this UDP packet, done in setExtensionHdr //Length in octets of this UDP packet including the header and the data. //Checksum of UDPpacket, done in setExtensionHdr v_ipPkt.ipv6Payload.ikeMsg.msgLength := 0; } v_ipPkt.ipv6Payload.ikeMsg.checksum := 0; } } if(f_setExtensionHeaders( v_ipPkt, v_ipPkt.ipv6Hdr.sourceAddress, v_ipPkt.ipv6Hdr.destinationAddress) != e_success) { log(" **** f_sendIkeSaInitReq: Error when calculating length ****"); return e_error; } } //send //send Loading @@ -611,13 +615,42 @@ group sendRequests { } // end f_sendIkeSaInitReq } // end f_sendIkeSaInitReq function f_sendIkeAuthReq(in template IkeSaInitRequest p_ikeSaInitRequest) function f_sendIkeAuthReq(in template IkeAuthRequest p_ikeAuthRequest) runs on Ipv6Node runs on Ipv6Node return FncRetCode { return FncRetCode { var IkeSaInitRequest v_ipPkt; var IkeAuthRequest v_ipPkt; v_ipPkt := valueof(p_ikeSaInitRequest); v_ipPkt := valueof(p_ikeAuthRequest); var FncRetCode v_ret := e_error; //encryptedPL is to be filled out by test adapter fx_setIkeSecurityParameters(vc_ikeSad); //fx_setSecurityParameters SMU todo if (ispresent(v_ipPkt.ipv6Payload)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { //smu 2007: to be moved to setExtensionHdrs? //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes v_ret := f_getSAandCalcLen(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length in octets of IKEv2 header + payloads in octets v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := lengthof(fx_ikev2HeaderToOct(v_ipPkt.ipv6Payload.ikeMsg.ikev2Header)) + lengthof(fx_ikePayloadListToOct(v_ipPkt.ipv6Payload.ikeMsg.payloadList)); //Length in octets of this UDP packet, done in setExtensionHdr //Checksum of UDPpacket, done in setExtensionHdr } } if(f_setExtensionHeaders( v_ipPkt, v_ipPkt.ipv6Hdr.sourceAddress, v_ipPkt.ipv6Hdr.destinationAddress) != e_success) { log(" **** f_sendIkeAuthReq: Error when calculating length ****"); return e_error; } //send //send ipPort.send(v_ipPkt); ipPort.send(v_ipPkt); Loading Loading @@ -822,89 +855,51 @@ group establishSAFns { group calcIkeFns { group calcIkeFns { function f_calcPList(inout IkePayloadList p_payloadList) function f_getSAandCalcLen(inout IkePayloadList p_payloadList) return FncRetCode { return FncRetCode { var FncRetCode v_ret := e_success; var FncRetCode v_ret := e_success; var UInt8 i := 0; var UInt8 i := 0; for(i:=0;i<sizeof(p_payloadList) and v_ret == e_success; i := i+1) { for(i:=0;i<sizeof(p_payloadList) and v_ret == e_success; i := i+1) { v_ret := f_calcIkePLLen(p_payloadList[i]); if (ischosen(p_payloadList[i].securityAssociation)) { v_ret := f_calcLenSecurityAssociation(p_payloadList[i]); } } } return v_ret; return v_ret; }//end f_calcPList }//end f_getSAandCalcLen function f_calcIkePLLen(inout IkePayload p_payload) //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes function f_calcLenSecurityAssociation(inout IkePayload p_payload) return FncRetCode { return FncRetCode { var FncRetCode v_ret := e_success; var FncRetCode v_ret := e_success; var UInt8 i := 0; var UInt8 i := 0; var UInt8 j := 0; var UInt8 j := 0; if (ischosen(p_payload.securityAssociation)) { if (ischosen(p_payload.securityAssociation)) { //SA payload length p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); for(i:=0;i<sizeof(p_payload.securityAssociation.saProposalList[i]); i := i+1) { for(i:=0;i<sizeof(p_payload.securityAssociation.saProposalList); i := i+1) { //smu add transforms here //Proposal length p_payload.securityAssociation.saProposalList[i].proposalLength := lengthof(fx_saProposalToOct(p_payload.securityAssociation.saProposalList[i])); p_payload.securityAssociation.saProposalList[i].proposalLength := lengthof(fx_saProposalToOct(p_payload.securityAssociation.saProposalList[i])); for(j:=0;j<sizeof(p_payload.securityAssociation.saProposalList[j]); j := j+1) { for(j:=0;j<sizeof(p_payload.securityAssociation.saProposalList[i].saTransformList); j := j+1) { //Transform length } p_payload.securityAssociation.saProposalList[i].saTransformList[j].transformLength := lengthof(fx_saTransformToOct(p_payload.securityAssociation.saProposalList[i].saTransformList[j])); } } else if (ischosen(p_payload.keyExchange)) { p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.idInitiator)) { p_payload.keyExchange.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.idResponder)) { p_payload.idResponder.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.certificate)) { p_payload.certificate.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.certificateRequest)) { p_payload.certificateRequest.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.authentication)) { p_payload.authentication.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.nonce)) { p_payload.nonce.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.notify)) { p_payload.notify.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } //else if (ischosen(p_payload.delete)) { // p_payload.delete.payloadLength := lengthof(fx_ikePLToOct(p_payload)); //} else if (ischosen(p_payload.vendorId)) { p_payload.vendorId.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.tsInitiator)) { p_payload.tsInitiator.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.tsResponder)) { p_payload.tsResponder.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.encrypted)) { p_payload.encrypted.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else if (ischosen(p_payload.configuration)) { p_payload.configuration.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else if (ischosen(p_payload.extensibleAuth)) { p_payload.extensibleAuth.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else { else { v_ret := e_error; v_ret := e_error; log("**** f_calcPL: Error: IkePayload contains unknown element. IkePayload length cannot be calculated ****") log("**** f_calcLenSecurityAssociation: Error: IkePayload contains unknown element. IkePayload length is only calculated for SecurityAssociation ****") log(p_payload); log(p_payload); } } return v_ret; return v_ret; }//end f_calcIkePLLen }//end f_calcLenSecurityAssociation }//end group calcIkeFns }//end group calcIkeFns Loading ttcn3/EtsiLibrary/LibIpv6/LibSec/LibIpv6_Rfc4306Ikev2_Templates.ttcn +9 −9 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -146,7 +146,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -190,7 +190,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -419,7 +419,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := (lengthof(p_data) + 4), payloadLength := (lengthof(p_data) + 8), dhGroup := p_dhGroup, dhGroup := p_dhGroup, reserved2 := c_uInt8Zero, reserved2 := c_uInt8Zero, data := p_data data := p_data Loading @@ -446,7 +446,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved := c_uInt7Zero, reserved := c_uInt7Zero, payloadLength := lengthof(p_data), payloadLength := lengthof(p_data) + 4, data := p_data data := p_data } } } } Loading Loading @@ -488,7 +488,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := lengthof(valueof(p_data)), payloadLength := lengthof(valueof(p_data)) + 8, idType := c_identificationIpv6Addr, idType := c_identificationIpv6Addr, reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, data := p_data data := p_data Loading @@ -506,7 +506,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := lengthof(p_data), payloadLength := lengthof(p_data) + 8, authMethod := c_authenticationSharedKeyMsgIntegrityCode, authMethod := c_authenticationSharedKeyMsgIntegrityCode, reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, data := p_data data := p_data Loading @@ -524,7 +524,7 @@ group trafficSelectionPLTmplts { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := 0, payloadLength := sizeof(valueof(p_trafficSelectorList)) * 40, numberOfTs := sizeof(valueof(p_trafficSelectorList)), numberOfTs := sizeof(valueof(p_trafficSelectorList)), reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, trafficSelectorList := p_trafficSelectorList trafficSelectorList := p_trafficSelectorList Loading @@ -546,7 +546,7 @@ group trafficSelectionPLTmplts { tsIpv6TrafficSelector := { tsIpv6TrafficSelector := { tsType := c_tsIpv6AddrRange, tsType := c_tsIpv6AddrRange, ipProtocolId := p_ipProtocolId, ipProtocolId := p_ipProtocolId, tsLength := 0, tsLength := 40, startPort := c_uInt16Zero, startPort := c_uInt16Zero, endPort := c_uInt16Zero, endPort := c_uInt16Zero, startAddress := p_startAddress, startAddress := p_startAddress, Loading Loading
ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_ExternalFunctions.ttcn +44 −44 Original line number Original line Diff line number Diff line Loading @@ -44,16 +44,6 @@ external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry ) external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry ) return UInt16; return UInt16; /* @desc This external function calculates the checksum for any * IPv6 packet which contains an ICMP message as its payload. * If ICMP message contains DestOptionHdr with HomeAddress, then checksum is calculated * by using this home address as entry for source address. * @param p_packet ICMPv6 packet * @return checksum value */ //external function fx_icmpv6Checksum( in template Ipv6Packet p_packet) //return Oct2; /* @desc TODO /* @desc TODO * @param TODO * @param TODO * @return checksum value * @return checksum value Loading Loading @@ -86,14 +76,6 @@ external function fx_mipHeaderLength( in MobileHeader p_mobileHeader) external function fx_mipHeaderLength( in MobileHeader p_mobileHeader) return UInt8; return UInt8; /* @desc This external function calculates the length of DstOptHeader . * @param p_extHdr Extension header * @return DstOpt Header length */ // external function fx_dstOptHdrLength( in ExtensionHeader p_extHdr) // return UInt8; /* @desc Apply indicated Integrity algorithm to the message. Message is an octetstring. /* @desc Apply indicated Integrity algorithm to the message. Message is an octetstring. * If e_sha1_96 is chosen, then the key input shall be ignored. * If e_sha1_96 is chosen, then the key input shall be ignored. * * Loading @@ -114,32 +96,23 @@ external function fx_mipHdrToOct(MobileHeader p_mobileHeader) external function fx_mipHdrToOct(MobileHeader p_mobileHeader) return octetstring; return octetstring; /* @desc This external function byte aligns the EspPayload (Iv, EspIpDatagram, TfcPadding) + next Header + pad Length /* @desc This external function sets the test adapter with the relevant security parameters * with padding according to the byteBoundary set by the encryption algo. * The nextHeader is of constant size 1 octet, * and is therefore no input parameter to this external function. * The padLnength is of constant size 1 octet, * and is therefore no input parameter to this external function. * * * @param p_spi Security parameter Index whihc poinst to the SAD to be used * @param p_sa Security Association * @param p_espPayload EspPayload to be byteAligned * @return FncRetCode * @return octetstring */ */ // external function fx_generatePadding(in UInt31 p_spi, EspPayload p_espPayload) external function fx_setSecurityParameters(in Sad p_sa) // return octetstring; return FncRetCode; /* @desc This external function encrypts the EspPayload(except iv) + padding + padLen + nextHeader /* @desc This external function sets the test adapter with the relevant security parameters * * * @param p_spi Security parameter Index whihc poinst to the SAD to be used * @param p_sa Security Association * @param p_espHeader Esp Header to be encoded to octetstring * @return FncRetCode * @return octetstring Is used for calculating the ICV */ */ // external function fx_encrypt(in UInt31 p_spi, in EspHeader p_espHeader) external function fx_setIkeSecurityParameters(in IkeSad p_ikeSad) // return octetstring; external function fx_setSecurityParameters(in Sad p_sa) return FncRetCode; return FncRetCode; /* @desc This external function calculates the payload length /* @desc This external function calculates the payload length * of an IPv6 authentication header * of an IPv6 authentication header * @param p_authHeader Authentication Header * @param p_authHeader Authentication Header Loading Loading @@ -234,11 +207,6 @@ in octetstring p_receivedKey) in octetstring p_receivedKey) return octetstring; return octetstring; external function fx_setIkeSecurityParameters(in IkeSa p_ikeSa) return FncRetCode; external function fx_calcAuth() external function fx_calcAuth() return octetstring; return octetstring; Loading @@ -260,8 +228,40 @@ external function fx_saProposalToOct(SaProposal p_saProposal) external function fx_saProposalToOct(SaProposal p_saProposal) return octetstring; return octetstring; /* @desc This external function runs the Transform through Codec and returns * the octetstring representing the Transform * * @param p_transform Transform to be encoded to octetstring * @return octetstring */ external function fx_saTransformToOct(SaTransform p_saTransform) return octetstring; /* @desc This external function runs the Ikev2Header through Codec and returns * the octetstring representing the Ikev2Header * * @param p_ikev2Header Ikev2Header to be encoded to octetstring * @return octetstring */ external function fx_ikev2HeaderToOct(Ikev2Header p_ikev2Header) return octetstring; /* @desc This external function runs the IkePayloadList through Codec and returns * the octetstring representing the IkePayloadList * * @param p_ikePayloadList IkePayloadList to be encoded to octetstring * @return octetstring */ external function fx_ikePayloadListToOct(IkePayloadList p_ikePayloadList) return octetstring; /* @desc This external function runs the Ipv6Payload through Codec and returns * the octetstring representing the IkePayloadList * * @param p_ipv6Payload Ipv6Payload to be encoded to octetstring * @return octetstring */ external function fx_ipv6PayloadToOct(Ipv6Payload p_ipv6Payload) return octetstring; }// end module LibIpv6_ExternalFunctions }// end module LibIpv6_ExternalFunctions
ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_Interface_Functions.ttcn +13 −1 Original line number Original line Diff line number Diff line Loading @@ -86,7 +86,7 @@ group rfc2460Root_Functions { v_pseudoDstAddr := v_activeIpv6Packet.ipv6Hdr.destinationAddress; v_pseudoDstAddr := v_activeIpv6Packet.ipv6Hdr.destinationAddress; v_pseudoSrcAddr := v_activeIpv6Packet.ipv6Hdr.sourceAddress; v_pseudoSrcAddr := v_activeIpv6Packet.ipv6Hdr.sourceAddress; //calc payloadLen //calc payloadLen of IPv6packet if (v_activeIpv6Packet.ipv6Hdr.payloadLength == c_uInt16Zero ) { if (v_activeIpv6Packet.ipv6Hdr.payloadLength == c_uInt16Zero ) { v_activeIpv6Packet.ipv6Hdr.payloadLength := fx_payloadLength (v_activeIpv6Packet); v_activeIpv6Packet.ipv6Hdr.payloadLength := fx_payloadLength (v_activeIpv6Packet); } } Loading Loading @@ -411,6 +411,17 @@ group rfc2460Root_Functions { p_ipv6Payload.otherIcmpv6Msg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); p_ipv6Payload.otherIcmpv6Msg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); } } } } else if(ischosen(p_ipv6Payload.ikeMsg)) { if(p_ipv6Payload.ikeMsg.checksum == c_2ZeroBytes) { //calc checksum p_ipv6Payload.ikeMsg.checksum := fx_calcPayloadChecksum (p_srcAddr, p_dstAddr, p_ipv6Payload); } if(p_ipv6Payload.ikeMsg.msgLength == 0) { //calc payloadLen of UDP msg //smu 2007 check that calc is correct p_ipv6Payload.ikeMsg.msgLength := lengthof(fx_ipv6PayloadToOct(p_ipv6Payload)); } } return e_success; return e_success; Loading Loading @@ -1224,6 +1235,7 @@ group rfc4303Esp_ExtHdrFunctions { //TODO chose in function of PX_SPI the SAD to be used for testing //TODO chose in function of PX_SPI the SAD to be used for testing // v_ret := fx_setSecurityParameters(Sad:{vc_sad[c_saOut]}); // v_ret := fx_setSecurityParameters(Sad:{vc_sad[c_saOut]}); //SMU 2007 how is it solved to know when to use which SAD? v_ret := fx_setSecurityParameters(vc_sad); v_ret := fx_setSecurityParameters(vc_sad); if (v_ret != e_success) {log("f_init_ipSecParams: Error when setting security parameters");} if (v_ret != e_success) {log("f_init_ipSecParams: Error when setting security parameters");} Loading
ttcn3/EtsiLibrary/LibIpv6/LibCore/LibIpv6_Rfc2461NeighborDiscovery_Functions.ttcn +1 −1 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,7 @@ module LibIpv6_Rfc2461NeighborDiscovery_Functions { var Redirect v_ipPkt; var Redirect v_ipPkt; v_ipPkt := valueof(p_redirect); v_ipPkt := valueof(p_redirect); //calc payloadLen //calc payloadLen //SMU this must be deleted during maintenance v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt); v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt); //set extensionHeaders //set extensionHeaders Loading
ttcn3/EtsiLibrary/LibIpv6/LibSec/LibIpv6_Rfc4306Ikev2_Functions.ttcn +70 −75 Original line number Original line Diff line number Diff line Loading @@ -579,27 +579,31 @@ group sendRequests { var IkeSaInitRequest v_ipPkt := valueof(p_ikeSaInitRequest); var IkeSaInitRequest v_ipPkt := valueof(p_ikeSaInitRequest); var FncRetCode v_ret := e_error; var FncRetCode v_ret := e_error; //smu added if (ispresent(v_ipPkt.ipv6Payload)) { if (ispresent(v_ipPkt.ipv6Payload)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { //Length in octets of IKEv2 header + payloads in octets //smu 2007: to be moved to setExtensionHdrs? v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := 0; //For each IkePayload: Length in octets of the current payload, including the generic payload header v_ret := f_calcPList(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes v_ret := f_getSAandCalcLen(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length in octets of IKEv2 header + payloads in octets v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := lengthof(fx_ikev2HeaderToOct(v_ipPkt.ipv6Payload.ikeMsg.ikev2Header)) + lengthof(fx_ikePayloadListToOct(v_ipPkt.ipv6Payload.ikeMsg.payloadList)); //Length in octets of this UDP packet, done in setExtensionHdr //Length in octets of this UDP packet including the header and the data. //Checksum of UDPpacket, done in setExtensionHdr v_ipPkt.ipv6Payload.ikeMsg.msgLength := 0; } v_ipPkt.ipv6Payload.ikeMsg.checksum := 0; } } if(f_setExtensionHeaders( v_ipPkt, v_ipPkt.ipv6Hdr.sourceAddress, v_ipPkt.ipv6Hdr.destinationAddress) != e_success) { log(" **** f_sendIkeSaInitReq: Error when calculating length ****"); return e_error; } } //send //send Loading @@ -611,13 +615,42 @@ group sendRequests { } // end f_sendIkeSaInitReq } // end f_sendIkeSaInitReq function f_sendIkeAuthReq(in template IkeSaInitRequest p_ikeSaInitRequest) function f_sendIkeAuthReq(in template IkeAuthRequest p_ikeAuthRequest) runs on Ipv6Node runs on Ipv6Node return FncRetCode { return FncRetCode { var IkeSaInitRequest v_ipPkt; var IkeAuthRequest v_ipPkt; v_ipPkt := valueof(p_ikeSaInitRequest); v_ipPkt := valueof(p_ikeAuthRequest); var FncRetCode v_ret := e_error; //encryptedPL is to be filled out by test adapter fx_setIkeSecurityParameters(vc_ikeSad); //fx_setSecurityParameters SMU todo if (ispresent(v_ipPkt.ipv6Payload)) { if (ischosen(v_ipPkt.ipv6Payload.ikeMsg)) { //smu 2007: to be moved to setExtensionHdrs? //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes v_ret := f_getSAandCalcLen(v_ipPkt.ipv6Payload.ikeMsg.payloadList); //Length in octets of IKEv2 header + payloads in octets v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := lengthof(fx_ikev2HeaderToOct(v_ipPkt.ipv6Payload.ikeMsg.ikev2Header)) + lengthof(fx_ikePayloadListToOct(v_ipPkt.ipv6Payload.ikeMsg.payloadList)); //Length in octets of this UDP packet, done in setExtensionHdr //Checksum of UDPpacket, done in setExtensionHdr } } if(f_setExtensionHeaders( v_ipPkt, v_ipPkt.ipv6Hdr.sourceAddress, v_ipPkt.ipv6Hdr.destinationAddress) != e_success) { log(" **** f_sendIkeAuthReq: Error when calculating length ****"); return e_error; } //send //send ipPort.send(v_ipPkt); ipPort.send(v_ipPkt); Loading Loading @@ -822,89 +855,51 @@ group establishSAFns { group calcIkeFns { group calcIkeFns { function f_calcPList(inout IkePayloadList p_payloadList) function f_getSAandCalcLen(inout IkePayloadList p_payloadList) return FncRetCode { return FncRetCode { var FncRetCode v_ret := e_success; var FncRetCode v_ret := e_success; var UInt8 i := 0; var UInt8 i := 0; for(i:=0;i<sizeof(p_payloadList) and v_ret == e_success; i := i+1) { for(i:=0;i<sizeof(p_payloadList) and v_ret == e_success; i := i+1) { v_ret := f_calcIkePLLen(p_payloadList[i]); if (ischosen(p_payloadList[i].securityAssociation)) { v_ret := f_calcLenSecurityAssociation(p_payloadList[i]); } } } return v_ret; return v_ret; }//end f_calcPList }//end f_getSAandCalcLen function f_calcIkePLLen(inout IkePayload p_payload) //Length of SA in octets //Length in octets of this proposal, including all transforms and attributes that follow. //Length in octets of the Transform including Header and Attributes function f_calcLenSecurityAssociation(inout IkePayload p_payload) return FncRetCode { return FncRetCode { var FncRetCode v_ret := e_success; var FncRetCode v_ret := e_success; var UInt8 i := 0; var UInt8 i := 0; var UInt8 j := 0; var UInt8 j := 0; if (ischosen(p_payload.securityAssociation)) { if (ischosen(p_payload.securityAssociation)) { //SA payload length p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); for(i:=0;i<sizeof(p_payload.securityAssociation.saProposalList[i]); i := i+1) { for(i:=0;i<sizeof(p_payload.securityAssociation.saProposalList); i := i+1) { //smu add transforms here //Proposal length p_payload.securityAssociation.saProposalList[i].proposalLength := lengthof(fx_saProposalToOct(p_payload.securityAssociation.saProposalList[i])); p_payload.securityAssociation.saProposalList[i].proposalLength := lengthof(fx_saProposalToOct(p_payload.securityAssociation.saProposalList[i])); for(j:=0;j<sizeof(p_payload.securityAssociation.saProposalList[j]); j := j+1) { for(j:=0;j<sizeof(p_payload.securityAssociation.saProposalList[i].saTransformList); j := j+1) { //Transform length } p_payload.securityAssociation.saProposalList[i].saTransformList[j].transformLength := lengthof(fx_saTransformToOct(p_payload.securityAssociation.saProposalList[i].saTransformList[j])); } } else if (ischosen(p_payload.keyExchange)) { p_payload.securityAssociation.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.idInitiator)) { p_payload.keyExchange.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.idResponder)) { p_payload.idResponder.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.certificate)) { p_payload.certificate.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.certificateRequest)) { p_payload.certificateRequest.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.authentication)) { p_payload.authentication.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.nonce)) { p_payload.nonce.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.notify)) { p_payload.notify.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } //else if (ischosen(p_payload.delete)) { // p_payload.delete.payloadLength := lengthof(fx_ikePLToOct(p_payload)); //} else if (ischosen(p_payload.vendorId)) { p_payload.vendorId.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.tsInitiator)) { p_payload.tsInitiator.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.tsResponder)) { p_payload.tsResponder.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } else if (ischosen(p_payload.encrypted)) { p_payload.encrypted.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else if (ischosen(p_payload.configuration)) { p_payload.configuration.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else if (ischosen(p_payload.extensibleAuth)) { p_payload.extensibleAuth.payloadLength := lengthof(fx_ikePLToOct(p_payload)); } } else { else { v_ret := e_error; v_ret := e_error; log("**** f_calcPL: Error: IkePayload contains unknown element. IkePayload length cannot be calculated ****") log("**** f_calcLenSecurityAssociation: Error: IkePayload contains unknown element. IkePayload length is only calculated for SecurityAssociation ****") log(p_payload); log(p_payload); } } return v_ret; return v_ret; }//end f_calcIkePLLen }//end f_calcLenSecurityAssociation }//end group calcIkeFns }//end group calcIkeFns Loading
ttcn3/EtsiLibrary/LibIpv6/LibSec/LibIpv6_Rfc4306Ikev2_Templates.ttcn +9 −9 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -146,7 +146,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -190,7 +190,7 @@ sourcePort := p_udpsourcePort, sourcePort := p_udpsourcePort, destPort := p_udpdestPort, destPort := p_udpdestPort, msgLength := c_uInt16Zero, msgLength := c_uInt16Zero, checksum := c_uInt16Zero, checksum := c_2ZeroBytes, padding := omit, padding := omit, // IKEv2 Header // IKEv2 Header ikev2Header := { ikev2Header := { Loading Loading @@ -419,7 +419,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := (lengthof(p_data) + 4), payloadLength := (lengthof(p_data) + 8), dhGroup := p_dhGroup, dhGroup := p_dhGroup, reserved2 := c_uInt8Zero, reserved2 := c_uInt8Zero, data := p_data data := p_data Loading @@ -446,7 +446,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved := c_uInt7Zero, reserved := c_uInt7Zero, payloadLength := lengthof(p_data), payloadLength := lengthof(p_data) + 4, data := p_data data := p_data } } } } Loading Loading @@ -488,7 +488,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := lengthof(valueof(p_data)), payloadLength := lengthof(valueof(p_data)) + 8, idType := c_identificationIpv6Addr, idType := c_identificationIpv6Addr, reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, data := p_data data := p_data Loading @@ -506,7 +506,7 @@ group payloadTemplates { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := lengthof(p_data), payloadLength := lengthof(p_data) + 8, authMethod := c_authenticationSharedKeyMsgIntegrityCode, authMethod := c_authenticationSharedKeyMsgIntegrityCode, reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, data := p_data data := p_data Loading @@ -524,7 +524,7 @@ group trafficSelectionPLTmplts { nextPayload := p_nextPayload, nextPayload := p_nextPayload, criticalFlag := 0, criticalFlag := 0, reserved1 := c_uInt7Zero, reserved1 := c_uInt7Zero, payloadLength := 0, payloadLength := sizeof(valueof(p_trafficSelectorList)) * 40, numberOfTs := sizeof(valueof(p_trafficSelectorList)), numberOfTs := sizeof(valueof(p_trafficSelectorList)), reserved2 := c_uInt24Zero, reserved2 := c_uInt24Zero, trafficSelectorList := p_trafficSelectorList trafficSelectorList := p_trafficSelectorList Loading @@ -546,7 +546,7 @@ group trafficSelectionPLTmplts { tsIpv6TrafficSelector := { tsIpv6TrafficSelector := { tsType := c_tsIpv6AddrRange, tsType := c_tsIpv6AddrRange, ipProtocolId := p_ipProtocolId, ipProtocolId := p_ipProtocolId, tsLength := 0, tsLength := 40, startPort := c_uInt16Zero, startPort := c_uInt16Zero, endPort := c_uInt16Zero, endPort := c_uInt16Zero, startAddress := p_startAddress, startAddress := p_startAddress, Loading