Commit 90f8c909 authored by berge's avatar berge
Browse files

Added support for secured BU/BA and secured HoT/HoTI.

Support for secured MPS/MPA still needs to be added.
parent ab83dc52
Loading
Loading
Loading
Loading
+46 −1
Original line number Diff line number Diff line
@@ -1133,8 +1133,53 @@ group rfc4303Esp_ExtHdrFunctions {
			ipSecProtocolMode := PX_IP_SEC_PROTOCOL_MODE
		}

		// SAD-OUT
		vc_sad[c_saRrpOut] := {
			spi := c_saRrpOut/*f_createSpi()*/,
			seqNr := c_uInt32Zero,
			// AH Integrity
			ahIntegrityAlgo := PX_INTEGRITY_ALGO,
			ahIntegrityKey := PX_INTEGRITY_KEY/*f_createSecretKey()*/,
			icvLen := f_getIcvLen(PX_INTEGRITY_ALGO),
			icvPadLen := f_getIcvPadLen(PX_INTEGRITY_ALGO),
			// ESP encryption
			espEncryptionAlgo := PX_ENCRYPTION_ALGO,
			espEncryptionKey := PX_ESP_ENCR_KEY/*f_createSecretKey()*/,
			// ESP integrity
			espIntegrityAlgo := PX_INTEGRITY_ALGO,
			espIntegrityKey := PX_INTEGRITY_KEY/*f_createSecretKey()*/,
			// Combined mode
			espCombinedModeAlgo := PX_COMBINED_MODE_ALGO,
			espCombinedModeKey := PX_COMBINED_MODE_KEY/*f_createSecretKey()*/,
			// Protocol mode
			ipSecProtocolMode := PX_IP_SEC_PROTOCOL_MODE
		}

		// SAD-IN
		vc_sad[c_saRrpIn] := {
			spi := c_saRrpIn/*f_createSpi()*/,
			seqNr := c_uInt32Zero,
			// AH Integrity
			ahIntegrityAlgo := PX_INTEGRITY_ALGO,
			ahIntegrityKey := PX_INTEGRITY_KEY/*f_createSecretKey()*/,
			icvLen := f_getIcvLen(PX_INTEGRITY_ALGO),
			icvPadLen := f_getIcvPadLen(PX_INTEGRITY_ALGO),
			// ESP encryption
			espEncryptionAlgo := PX_ENCRYPTION_ALGO,
			espEncryptionKey := PX_ESP_ENCR_KEY/*f_createSecretKey()*/,
			// ESP integrity
			espIntegrityAlgo := PX_INTEGRITY_ALGO,
			espIntegrityKey := PX_INTEGRITY_KEY/*f_createSecretKey()*/,
			// Combined mode
			espCombinedModeAlgo := PX_COMBINED_MODE_ALGO,
			espCombinedModeKey := PX_COMBINED_MODE_KEY/*f_createSecretKey()*/,
			// Protocol mode
			ipSecProtocolMode := PX_IP_SEC_PROTOCOL_MODE
		}

		//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]});
		v_ret := fx_setSecurityParameters(vc_sad);
		if (v_ret != e_success) {log("f_init_ipSecParams: Error when setting security parameters");}
		
		return v_ret;
+3 −1
Original line number Diff line number Diff line
@@ -1154,6 +1154,8 @@ module LibIpv6_Interface_TypesAndValues {
		const UInt8 c_maxNrDa := 8;
		const UInt8 c_saOut := 0;
		const UInt8 c_saIn := 1;
		const UInt8 c_saRrpOut := 2;
		const UInt8 c_saRrpIn := 3; 
		

		//Security Association
+294 −89
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
		var FncRetCode v_ret;
		var NeighborSolicitation v_nbrSol;

		if(PX_IP_SEC == e_securityOff) {
			v_ret := f_sendBU(
						m_bindingUpdate(
							c_mobileHdr,
@@ -121,10 +122,40 @@ module LibIpv6_Rfc3775Mipv6_Functions {
										m_mobileOptList_2Elem(
											m_mobileOpt_padN(m_optPad2),
											m_mobileOpt_altCoa(m_altCoA(p_mnHoaTn))))))));
		} else { //e_securityOn
			v_ret := f_sendBU(
						m_bindingUpdate(
							c_espHdr,
							p_mnHoaTn,
							p_haGlaNut,
							m_extHdrList_1Elem(
								m_extHdr_espHeader(
									vc_sad[c_saOut].spi,
									vc_sad[c_saOut].seqNr + 1,
									m_espIpDatagram(
										m_extHdrList_1Elem(
											m_extHdr_mobileHeader (
												c_noNextHdr,
												c_bindingUpdate,
												m_bindingUpdateMsg(
													p_seqNr,
													c_aFlag1,
													c_hFlag1,
													c_lFlag0,
													c_kFlag0,
													p_timeUnits,
													m_mobileOptList_2Elem(
														m_mobileOpt_padN(m_optPad2),
														m_mobileOpt_altCoa(m_altCoA(p_mnHoaTn)))))),
										omit),
									c_mobileHdr))));
			
		}

		if ( v_ret != e_success ) {return v_ret;}
		tc_ac.start;
		alt {
			[]	ipPort.receive(mw_bindingAck(	c_mobileHdr,
			[PX_IP_SEC == e_securityOff]	ipPort.receive(mw_bindingAck(	c_mobileHdr,
													p_haGlaNut,
													p_mnHoaTn,
													m_extHdrList_1Elem(
@@ -134,6 +165,25 @@ module LibIpv6_Rfc3775Mipv6_Functions {
					tc_ac.stop;	
					v_ret := e_success ;
				}
			[PX_IP_SEC == e_securityOn]	ipPort.receive(mw_bindingAck(
													c_espHdr,
													p_haGlaNut,
													p_mnHoaTn,
													m_extHdrList_1Elem(
														mw_extHdr_espHeader(
															?,
															?,
															m_espIpDatagram(			
																m_extHdrList_1Elem(
																	mw_extHdr_mobileHeader (	
																		c_noNextHdr,
																		c_bindingAck,
																		mw_bindingAckMsg(p_seqNr))),
																omit),
															c_mobileHdr)))) {
					tc_ac.stop;	
					v_ret := e_success ;
				}
				
			[]	ipPort.receive(mw_nbrSol) -> value v_nbrSol{
					f_sendNbrAdv (m_nbrAdv_noExtHdr( 	p_paramsMn.lla,
@@ -174,6 +224,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
	return FncRetCode {
		var FncRetCode v_ret;
	
		if(PX_IP_SEC == e_securityOff){
			v_ret := f_sendBU(
						m_bindingUpdate(
							c_dstHdr,
@@ -199,11 +250,44 @@ module LibIpv6_Rfc3775Mipv6_Functions {
										m_mobileOptList_2Elem(
											m_mobileOpt_padN(m_optPad2),
											m_mobileOpt_altCoa(m_altCoA(p_mnCoaTn))))))));
										
		} else { //e_securityOn									
			v_ret := f_sendBU(
						m_bindingUpdate(
							c_dstHdr,
							p_mnCoaTn,
							p_haGlaNut,
							m_extHdrList_2Elem(
								m_extHdr_dstOptHeader(	
									c_espHdr,
									c_optLen2,
									m_dstOptList_2Elem(
										m_dstOpt_padN(m_optPad4),
										m_dstOpt_homeAddr(p_mnHoaTn))),
								m_extHdr_espHeader(
									vc_sad[c_saOut].spi,
									vc_sad[c_saOut].seqNr,
									m_espIpDatagram	(
										m_extHdrList_1Elem(	
											m_extHdr_mobileHeader (
												c_noNextHdr,
												c_bindingUpdate,
												m_bindingUpdateMsg(
													p_seqNr,
													c_aFlag1,
													c_hFlag1,
													p_lFlag,
													c_kFlag0,
													p_timeUnits,
													m_mobileOptList_2Elem(
														m_mobileOpt_padN(m_optPad2),
														m_mobileOpt_altCoa(m_altCoA(p_mnCoaTn)))))),
										omit),
									c_mobileHdr))));
		}		
		if ( v_ret != e_success ) {return v_ret;}
		tc_ac.start;
		alt {
			[]	ipPort.receive(
			[PX_IP_SEC == e_securityOff]	ipPort.receive(
					mw_bindingAck_noData(	
						c_routeHdr,
						p_haGlaNut,
@@ -222,6 +306,33 @@ module LibIpv6_Rfc3775Mipv6_Functions {
					tc_ac.stop;	
					v_ret := e_success ;
				}
			[PX_IP_SEC == e_securityOn]	ipPort.receive(
					mw_bindingAck_noData(	
						c_routeHdr,
						p_haGlaNut,
						p_mnCoaTn,
						m_extHdrList_2Elem(
							mw_extHdr_routingHeader(	
								c_espHdr,
								c_routeHdrLen2,
								c_routeHdrType2,
								c_routeHdrSegmentsLeft1,
								m_routingHeaderData_homeAddress(p_mnHoaTn)),
							mw_extHdr_espHeader(
								vc_sad[c_saIn].spi,
								?, //vc_sad[c_saIn].seqNr,
								m_espIpDatagram	(
									m_extHdrList_1Elem(								
										mw_extHdr_mobileHeader (	
											c_noNextHdr,
											c_bindingAck,
											mw_bindingAckMsg(p_seqNr))),
									omit),
								c_mobileHdr)))) {
					tc_ac.stop;	
					v_ret := e_success ;
				}
			
			[]	tc_ac.timeout{
					v_ret :=  e_timeout;
					log("**** f_mnSendBindUpToHaAndWaitForBindAckOffHome: ERROR: tc_ac.timeout **** ");
@@ -1271,6 +1382,7 @@ group mobileSecurityFns {
	return FncRetCode {
		var FncRetCode v_ret;
		
		if (PX_IP_SEC == e_securityOff)	{
			v_ret := f_sendMipPrefixSol(m_mobilePrefixSol(
											c_dstHdr,
											p_mnCoaTn,
@@ -1283,10 +1395,32 @@ group mobileSecurityFns {
														m_dstOpt_padN(m_optPad4),
														m_dstOpt_homeAddr(p_mnHoaTn)))),
											c_defId));
		} else {
			v_ret := f_sendMipPrefixSol(m_mobilePrefixSol(
											c_espHdr,
											p_mnCoaTn,
											p_haGlaNut,
											m_extHdrList_1Elem(
												m_extHdr_espHeader(
													vc_sad[c_saOut].spi,
													vc_sad[c_saOut].seqNr + 1,
													m_espIpDatagram(
														m_extHdrList_1Elem(
															m_extHdr_dstOptHeader(	
																c_icmpHdr,
																c_optLen2,
																m_dstOptList_2Elem(
																	m_dstOpt_padN(m_optPad4),
																	m_dstOpt_homeAddr(p_mnHoaTn)))),
														omit ),
													c_dstHdr ) ),
											c_defId));

		}
		if ( v_ret != e_success ) {return v_ret;}
		tc_ac.start;
		alt {
			[]	ipPort.receive(mw_mobilePrefixAdv_extHdr(
			[PX_IP_SEC == e_securityOff]	ipPort.receive(mw_mobilePrefixAdv_extHdr(
									c_routeHdr,
									p_haGlaNut,
									p_mnCoaTn,
@@ -1300,6 +1434,27 @@ group mobileSecurityFns {
					tc_ac.stop;
					v_ret := e_success ;
				}
			[PX_IP_SEC == e_securityOn]	ipPort.receive(mw_mobilePrefixAdv_extHdr(
									c_espHdr,
									p_haGlaNut,
									p_mnCoaTn,
									m_extHdrList_1Elem(
										m_extHdr_espHeader(
											?,//vc_sad[c_saIn].spi,
											?,//vc_sad[c_saOut].seqNr + 1,
											m_espIpDatagram(									
												m_extHdrList_1Elem(
													mw_extHdr_routingHeader(	
														c_icmpHdr,
														c_routeHdrLen2,
														c_routeHdrType2,
														c_routeHdrSegmentsLeft1,
														m_routingHeaderData_homeAddress(p_mnHoaTn))),
												omit),
											c_routeHdr)))) {
					tc_ac.stop;
					v_ret := e_success ;
				}
			[]	tc_ac.timeout{
					v_ret :=  e_timeout;
					log("**** f_sendMipPrefixSolAndWaitForReply: ERROR: tc_ac.timeout **** ");
@@ -1323,6 +1478,7 @@ group mobileSecurityFns {
	return FncRetCode {
		var FncRetCode v_ret;
			
		if (PX_IP_SEC == e_securityOff)	{
			v_ret := f_sendMipPrefixSol(m_mobilePrefixSol(
											c_dstHdr,
											p_mnCoaTn,
@@ -1335,6 +1491,28 @@ group mobileSecurityFns {
														m_dstOpt_padN(m_optPad4),
														m_dstOpt_homeAddr(p_mnHoaTn)))),
											c_defId));
		} else {
			v_ret := f_sendMipPrefixSol(m_mobilePrefixSol(
											c_espHdr,
											p_mnCoaTn,
											p_haGla,
											m_extHdrList_1Elem(
												m_extHdr_espHeader(
													vc_sad[c_saOut].spi,
													vc_sad[c_saOut].seqNr + 1,
													m_espIpDatagram(
														m_extHdrList_1Elem(
															m_extHdr_dstOptHeader(	
																c_icmpHdr,
																c_optLen2,
																m_dstOptList_2Elem(
																	m_dstOpt_padN(m_optPad4),
																	m_dstOpt_homeAddr(p_mnHoaTn)))),
														omit ),
													c_dstHdr ) ),
											c_defId));

		}
		if ( v_ret != e_success ) {return v_ret;}
		tc_ac.start;
		alt {
@@ -2783,30 +2961,29 @@ group mobileSecurityFns {
		//Variables
		var Ipv6Packet v_ipv6Packet;
		
		// FIXME Alex
		[/*PX_IP_SEC == e_securityOn*/]	ipPort.receive ( 
		[PX_IP_SEC == e_securityOn]	ipPort.receive ( 
			mw_homeTestInit_noData (
				c_tunneledIpHdr,
				c_espHdr,
				p_paramsIut.mnCoa,
				p_paramsHa.gla,
				m_extHdrList_1Elem (					
					mw_extHdr_espHeader(
						vc_sad[c_saRrpIn].spi,//vc_sad[c_saOut].spi, //FIXME
						?,//vc_sad[c_saOut].seqNr + 1, //FIXME
						m_espIpDatagram (
							m_extHdrList_2Elem(
								mw_extHdr_tunneledHeader (
						c_espHdr, 
									c_mobileHdr, 
									p_paramsIut.mnHoa,
									p_paramsCn.gla ),
					mw_extHdr_espHeader(
						vc_sad[c_saOut].spi,
						vc_sad[c_saOut].seqNr + 1,
						m_espIpDatagram (
							m_extHdrList_1Elem(
								mw_extHdr_mobileHeader (
									c_noNextHdr,
									c_homeTestInit,
									mw_hoti)),
							omit ),
						c_mobileHdr ) ) ) ) -> value v_ipv6Packet {
						c_tunneledIpHdr ) ) ) ) -> value v_ipv6Packet {
			vc_mobileSec.cnSimuParams.receivedHomeInitCookie := 
				v_ipv6Packet.extHdrList[0].mobileHeader.mobileMessage.homeTestInitMsg.homeInitCookie;
				v_ipv6Packet.extHdrList[0].espHeader.espPayload.espIpDatagram.extHdrList[1].mobileHeader.mobileMessage.homeTestInitMsg.homeInitCookie;
			vc_mobileSec.cnSimuParams.homeKeygenToken := 
				f_createHomeKeygenToken(	
					vc_mobileSec.cnSimuParams.kcnList[vc_mobileSec.cnSimuParams.nonceIndex],
@@ -2815,8 +2992,7 @@ group mobileSecurityFns {

		}		
		
		//	FIXME Alex
		[/*PX_IP_SEC == e_securityOff*/]	ipPort.receive ( 
		[PX_IP_SEC == e_securityOff]	ipPort.receive ( 
			mw_homeTestInit_noData (
				c_tunneledIpHdr,
				p_paramsIut.mnCoa,
@@ -2857,7 +3033,35 @@ group mobileSecurityFns {
		//Variables
		var Ipv6Packet v_ipv6Packet;
		
		[] a_cnReceiveHoTiViaHaOffHome(p_paramsCn, p_paramsHa, p_paramsIut) {
		[PX_IP_SEC == e_securityOn] a_cnReceiveHoTiViaHaOffHome(p_paramsCn, p_paramsHa, p_paramsIut) {
			f_sendHot (
				m_homeTest (
					c_espHdr,
					p_paramsHa.gla,
					p_paramsIut.mnCoa,
					m_extHdrList_1Elem (					
						m_extHdr_espHeader(
							vc_sad[c_saRrpOut].spi,
							vc_sad[c_saRrpOut].seqNr + 1, 
							m_espIpDatagram (
								m_extHdrList_2Elem(
									m_extHdr_tunneledHeader (
										c_mobileHdr, 
										p_paramsCn.gla,
										p_paramsIut.mnHoa ),
									m_extHdr_mobileHeader (
										c_noNextHdr,
										c_homeTest,
										m_hot (
											vc_mobileSec.cnSimuParams.nonceIndex,
											vc_mobileSec.cnSimuParams.receivedHomeInitCookie,
											vc_mobileSec.cnSimuParams.homeKeygenToken ) ) ),
								omit ),
							c_tunneledIpHdr ) ) ) );

		}		

		[PX_IP_SEC == e_securityOff] a_cnReceiveHoTiViaHaOffHome(p_paramsCn, p_paramsHa, p_paramsIut) {
			f_sendHot (
				m_homeTest (
					c_tunneledIpHdr,
@@ -2878,6 +3082,7 @@ group mobileSecurityFns {

		}		

						
	}//end a_cnReceiveHoTiAndReplyViaHaOffHome

	/*
+3 −2
Original line number Diff line number Diff line
@@ -119,7 +119,8 @@
		}}
	}

	template MobilePrefixSolicitation mw_mobilePrefixSol (	template Ipv6Address p_src,
	template MobilePrefixSolicitation mw_mobilePrefixSol (	
															template Ipv6Address p_src,
															template Ipv6Address p_dst	):= {
		ipv6Hdr :=  mw_ipHdr_srcDst(p_src, p_dst),
		extHdrList := *,