Commit fe5b1b08 authored by mullers's avatar mullers
Browse files

ready for 1.test

parent afc9b61a
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -678,6 +678,67 @@ group ipSecFns {
} // end group fillIkeSa


	function f_getLenSaProposalList(in template SaProposalList p_saProposalList)
	return UInt8 {
		var UInt8 v_len := 0;
		var UInt8 i := 0;
		var SaProposalList v_saProposalList := valueof(p_saProposalList);

		for (i:=0;i<sizeof(v_saProposalList);i:=i+1) {
			v_len := v_len + v_saProposalList[i].proposalLength;
		}	
		
		return v_len;
		
	}

	function f_getLenSaTransformList(in UInt8 p_numberOfTransforms, in template SaTransformList p_saTransformList)
	return UInt8 {
		var UInt8 v_len := 0;
		var UInt8 i := 0;
		var SaTransformList v_saTransformList := valueof(p_saTransformList);

		if (p_numberOfTransforms != sizeof(v_saTransformList)) {
			log("f_getLenSaTransformList: Error : Wrong parametrization of Proposal template: NumberOfTransforms does not correspond to SaTransformList ");	
		}

		for (i:=0;i<sizeof(v_saTransformList);i:=i+1) {
			v_len := v_len + v_saTransformList[i].transformLength;
		}	
		
		return v_len;
		
	}

	function f_getLenSaTransformAttributeList (in template SaTransformAttributeList p_saTransformAttributeList)
	return UInt8 {
		var UInt8 v_len := 0;
		
		if ( match(p_saTransformAttributeList, SaTransformAttributeList:omit)) {
			log("**** SaTransformAttributeList omitted ****");
		}
		else {
			log("**** SaTransformAttributeList not omitted ****");
			v_len := 4;
		}

		return v_len;
		
	}

	function f_getLenPadding(IkeMsg p_ikeMsg)
	return UInt8 {
		var UInt8 v_len := 0;

		if(ispresent(p_ikeMsg.padding)) {
			v_len := 4;	
		}

		return v_len;
		
	}

	
	
}//end ipSecFns

+24 −24
Original line number Diff line number Diff line
@@ -206,8 +206,8 @@
	 * @return 	octetstring
	*/
	//SMU 2007 to be deleted
	external function fx_ikePLToOct(IkePayload p_ikePayload)
	return octetstring;
//	external function fx_ikePLToOct(IkePayload p_ikePayload)
//	return octetstring;

	/* @desc 	This external function runs the SaProposal through Codec and returns 
	 *			the octetstring representing the SaProposal
@@ -216,8 +216,8 @@
	 * @return 	octetstring
	*/
	//SMU 2007 to be deleted
	external function fx_saProposalToOct(SaProposal p_saProposal)
	return octetstring;
//	external function fx_saProposalToOct(SaProposal p_saProposal)
//	return octetstring;

	/* @desc 	This external function runs the Transform through Codec and returns 
	 *			the octetstring representing the Transform
@@ -226,26 +226,8 @@
	 * @return 	octetstring
	*/
	//SMU 2007 to be deleted
	external function fx_saTransformToOct(SaTransform p_saTransform)
	return octetstring;

	/* @desc 	This external function runs the Ipv6Payload through Codec and returns 
	 *			the octetstring representing the Ipv6Payload
	 *			
	 * @param 	p_ipv6Payload Ipv6Payload to be encoded to octetstring
	 * @return 	octetstring
	*/
	//SMU 2007 to be deleted
	external function fx_ipv6PayloadToOct(Ipv6Payload p_ipv6Payload)
	return octetstring;

	/* @desc    This external function calculates the payload length
	 *			of the IKE encrypted payload. Before calculating the lenght, the payload is encrypted in the test adapter.
	 * @param   p_msg Ipv6 packet
	 * @return  payload length in bytes
	*/
	external function fx_ikeEncPayloadLength( in template EncryptedPayload p_msg ) 
	return UInt16;
//	external function fx_saTransformToOct(SaTransform p_saTransform)
//	return octetstring;

	/* @desc    This external function calculates the length of an IKE message
	 *			based on the length of the payload(s), length of message is 
@@ -275,4 +257,22 @@
	external function fx_ikev2HeaderToOct(Ikev2Header p_ikev2Header)
	return octetstring;

	/* @desc    This external function calculates the payload length
	 *			of the IKE encrypted payload. Before calculating the lenght, the payload is encrypted in the test adapter.
	 * @param   p_msg Ipv6 packet
	 * @return  payload length in bytes
	*/
	external function fx_ikeEncPayloadLength( in template EncryptedPayload p_msg ) 
	return UInt16;

	/* @desc 	This external function runs the Ipv6Payload through Codec and returns 
	 *			the octetstring representing the Ipv6Payload
	 *			
	 * @param 	p_ipv6Payload Ipv6Payload to be encoded to octetstring
	 * @return 	octetstring
	*/
	//SMU 2007 to be deleted
//	external function fx_ipv6PayloadToOct(Ipv6Payload p_ipv6Payload)
//	return octetstring;

}// end module LibIpv6_ExternalFunctions
+3 −2
Original line number Diff line number Diff line
@@ -418,8 +418,9 @@ group rfc2460Root_Functions {
			}
			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));
				p_ipv6Payload.ikeMsg.msgLength := 	8 + f_getLenPadding(p_ipv6Payload.ikeMsg) +
													lengthof(fx_ikev2HeaderToOct(p_ipv6Payload.ikeMsg.ikev2Header))
													+ lengthof(fx_ikePayloadListToOct(p_ipv6Payload.ikeMsg.payloadList));
			}
		}
		
+87 −73
Original line number Diff line number Diff line
@@ -764,14 +764,15 @@ group sendRequests {

				//smu 2007: to be moved to setExtensionHdrs?

				//Done in templates
				//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);
				//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));
				//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
@@ -813,7 +814,9 @@ group sendRequests {
				//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);
				//v_ret := f_getSAandCalcLen(v_ipPkt.ipv6Payload.ikeMsg.payloadList);

				//use fx_ikeEncPayloadLength
			
				//Length in octets of IKEv2 header + payloads in octets
				v_ipPkt.ipv6Payload.ikeMsg.ikev2Header.messageLength := 
@@ -880,16 +883,20 @@ group sendRequests {
group establishSAFns {
	
	function f_ikeSaUp(
		in template Ipv6Address p_src,
		in template Ipv6Address p_dst)
		template Ipv6Address p_addrTn,
		template Ipv6Address p_addrIut,
		template Ipv6Address p_addrTunnelStart,
		template Ipv6Address p_addrTunnelEnd)
	runs on LibIpv6Node
	return FncRetCode {
		var FncRetCode v_ret := e_error;

		if (vc_sad[c_saOut].ipSecProtocolMode == e_transportMode) {
														
			v_ret := f_sendIkeSaInitReq (
				m_ikeSaInitReq (
				p_src,
				p_dst,
					p_addrTn,
					p_addrIut,
					PX_UDP_PORT_HS02,
					PX_UDP_PORT_IUT_1,
					vc_ikeSad[0].spiInitiator,
@@ -935,7 +942,7 @@ group establishSAFns {
						),
						m_keyExchangePL (
							c_noncePL,
						vc_ikeSad[0].diffieHellmanGroup,
							vc_ikeSad[c_saOut].diffieHellmanGroup,
							fx_dHKeyToSend( 
								vc_ikeSad[0].diffieHellmanGroup,
								vc_ikeSad[0].diffieHellmanPrivKey
@@ -948,6 +955,11 @@ group establishSAFns {
					)
				)
			);
		}
		else {
			
		//TODO tunnel mode	
		}
		
		return v_ret;
														
@@ -1037,7 +1049,9 @@ group establishSAFns {

group calcIkeFns {

	function f_getSAandCalcLen(inout IkePayloadList p_payloadList)


/*	function f_getSAandCalcLen(inout IkePayloadList p_payloadList)
	return FncRetCode {
		var FncRetCode v_ret := e_success;
		var UInt8 i := 0;
@@ -1048,14 +1062,14 @@ group calcIkeFns {
			}
		}

		return v_ret;
		return v_ret;  */

	}//end f_getSAandCalcLen
//	}//end f_getSAandCalcLen

	//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)
/*	function f_calcLenSecurityAssociation(inout IkePayload p_payload)
	return FncRetCode {
		var FncRetCode v_ret := e_success;
		var UInt8 i := 0;
@@ -1079,9 +1093,9 @@ group calcIkeFns {
			log(p_payload);
		}

		return v_ret;
		return v_ret;   */

	}//end f_calcLenSecurityAssociation
//	}//end f_calcLenSecurityAssociation



+6 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
	import from LibIpv6_ModuleParameters all ;
	import from LibIpv6_Rfc2463Icmpv6_TypesAndValues all;
	import from LibIpv6_Rfc4306Ikev2_TypesAndValues all;
	import from LibIpv6_CommonRfcs_Functions all;
	
	group ikeSaInitRequestTemplates {

@@ -85,7 +86,7 @@
						iFlag         := c_iFlagInitiator,
						threeXFlags   := 0,
						messageID     := p_messageID,
						messageLength := c_uInt32Zero
						messageLength := 16 + lengthof(fx_ikePayloadListToOct(valueof(p_ikepayloads)))
					},
					// IKEv2 Payloads
					payloadList   := p_ikepayloads
@@ -288,7 +289,7 @@
				nextPayload    := p_nextPayload,
				criticalFlag   := 0,
				reserved       := c_uInt7Zero,
				payloadLength  := c_uInt16Zero,
				payloadLength  := 4 + f_getLenSaProposalList({p_saProposal}),
				saProposalList := {p_saProposal}
			}
		}
@@ -308,7 +309,7 @@
		) := {
			lastProposal:= p_lastProposal,
			reserved := 0,
			proposalLength := 0,
			proposalLength := 8 + p_spiSize + f_getLenSaTransformList(p_numberOfTransforms, p_saTransformList) ,
			proposalNumber := p_proposalNumber,
			protocolId := p_protocolId,
			spiSize := p_spiSize,
@@ -381,7 +382,7 @@ group transformTmplts {
	) := {
		lastTransform 				:= p_lastTransform,
		reserved1 					:= 0,
		transformLength 			:= 0,
		transformLength 			:= 8 + f_getLenSaTransformAttributeList(p_saTransformAttributeList),
		transformType				:= p_transformType,
		reserved2 					:= 0,
		transformId					:= p_transformId,