Commit 6b11c6ec authored by schmitting's avatar schmitting
Browse files

IKE stuff added

parent 6dab452f
Loading
Loading
Loading
Loading
+94 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
	//LibIpv6
	import from LibIpv6_CommonRfcs_TypesAndValues { type all };
	import from LibIpv6_Interface_TypesAndValues all;
	import from LibIpv6_Rfc4306Ikev2_TypesAndValues all;

	/* @desc    This external function calculates the payload length
	 *			of a IPv6 packet
@@ -135,4 +136,96 @@
	*/
	external function fx_authHeaderPayloadLength(in template AuthHeader p_authHeader) return UInt8;

	/* @desc    This external function calculates the length of an IKE message
	 *			based on the length of the payload(s), length of message is 
	 *          length of payload(s) plus length of IKE header which is 28
	 * @param   p_ikepayload payload portion of IKE message
	 * @return  length of IKE message in bytes
	*/
	external function fx_ikepayloadLength( in template IkePayloadList p_ikepayload ) 
	return UInt32;
	
	/* @desc	This external function calculates the checksum for any
	 *         	UDP packet which contains an IKE message.
	 * @param  p_ikemessage IKE message 
	 * @return checksum value 
	*/
	external function fx_udpikeChecksum( in template IkeMsg p_ikemessage) 
	return Oct2;

	/* @desc	This external function implements the negotiated
	 *         	pseudo random function and calcutes pseudo random value
	 *			based on the two input strings.
	 * @param   p_prf negotiated PseudoRandomFunction
	 *			choice is:
	 *			e_prfHmacMd5(1),
	 *			e_prfHmacSha1(2),
	 *			e_prfHmacTiger(3),
	 *			e_prfAes128Xcbc(4)
	 * @param   p_first, p_second input values to pseudo random function
	 * @return  pseudo random value 
	*/
	external function fx_pseudoRandom( in IkePseudoRandomFunction p_prf,
									   in octetstring p_first,
									   in octetstring p_second ) 
	return octetstring;

	/* @desc	This external function implements the negotiated
	 *         	pseudo random function and calcutes the seven secrets
	 *			based on the two input strings.
	 *			SK_d  = prf (p_first, S | 0x01)
   	 *			SK_ai = prf (p_first, SK_d  | p_second | 0x02)
   	 *			SK_ar = prf (p_first, SK_ai | p_second | 0x03)
  	 *			SK_ei = prf (p_first, SK_ar | p_second | 0x04)
  	 *			SK_er = prf (p_first, SK_ei | p_second | 0x05)
  	 *			SK_pi = prf (p_first, SK_er | p_second | 0x06)
  	 *			SK_pr = prf (p_first, SK_pi | p_second | 0x07)
	 * @param   p_prf negotiated PseudoRandomFunction
	 *			choice is:
	 *			e_prfHmacMd5(1),
	 *			e_prfHmacSha1(2),
	 *			e_prfHmacTiger(3),
	 *			e_prfAes128Xcbc(4)
	 * @param   p_first, p_second input values to pseudo random function
	 * @return  pseudo random value 
	*/
	external function fx_pseudoRandomPlus( in IkePseudoRandomFunction p_prf,
									  	   in octetstring p_first,
									   	   in octetstring p_second ) 
	return SevenSecrets;
	
	/* @desc	This external function implements the Diffie-Hellman procedure
	 *         	and calculates the key for the Key Exchange payload to be sent to the 
	 *			peer based on the private key and the number of the Diffie-Hellman group.
	 *			Prime and generator for the Diffie-Hellman groups are found in:
	 *			Group 1 and 2: RFC4306 Appendix B
	 *			Group 5, 14, 15, 16, 17 and 18: RFC3526
	 * @param   p_diffieHellmanGroup chosen Diffie-Hellman group
	 * @param   p_diffieHellmanPrivKey private key taken from PIXIT value
	*/
	external function fx_dHKeyToSend( in DiffieHellmanGroup p_diffieHellmanGroup,
									  in octetstring p_diffieHellmanPrivKey ) 
	return octetstring;

	/* @desc	This external function implements the Diffie-Hellman procedure
	 *         	and calculates the shared secret based on the private key,
	 *			the received key from the Key Exchange payload and the number
	 *			of the Diffie-Hellman group.
	 *			Prime and generator for the Diffie-Hellman groups are found in:
	 *			Group 1 and 2: RFC4306 Appendix B
	 *			Group 5, 14, 15, 16, 17 and 18: RFC3526
	 * @param   p_diffieHellmanGroup chosen Diffie-Hellman group
	 * @param   p_diffieHellmanPrivKey private key taken from PIXIT value
	 * @return  p_receivedKey received key taken from Key Exchange payload 
	*/
	external function fx_dHSharedSecret( in DiffieHellmanGroup p_diffieHellmanGroup,
									     in octetstring p_diffieHellmanPrivKey,
									     in octetstring p_receivedKey) 
	return octetstring;


	
	external function fx_setIkeSecurityParameters(in IkeSa p_ikeSa)
	return FncRetCode;

}// end module LibIpv6_ExternalFunctions
+96 −0
Original line number Diff line number Diff line
@@ -1233,6 +1233,102 @@ module LibIpv6_Interface_TypesAndValues {

	} // end group mobileSecurity

	group ikeSecurity
	{
		type enumerated IkeEncryptionAlgo {
			e_reserved(0),
			e_encrAlgoDesIv64(1),
			e_encrAlgoDes(2),
			e_encrAlgo3Des(3),
			e_encrAlgoRc5(4),
			e_encrAlgoIdea(5),
			e_encrAlgoCast(6),
			e_encrAlgoBlowfish(7),
			e_encrAlgo3Idea(8),
			e_encrAlgoDesIv32(9),
			e_encrAlgoNull(11),
			e_encrAlgoAesCbc(12),
			e_encrAlgoAesCtr(13)
		}
		with {
			encode "TODO";
		}

		type enumerated IkePseudoRandomFunction {
			e_reserved(0),
			e_prfHmacMd5(1),
			e_prfHmacSha1(2),
			e_prfHmacTiger(3),
			e_prfAes128Xcbc(4)
		}
		with {
			encode "TODO";
		}

		type enumerated IkeIntegrityAlgo {
			e_none(0),
			e_integAlgoHmacMd596(1),
			e_integAlgoHmacSha196(2),
			e_integAlgoDesMac(3),
			e_integAlgoKpdkMd5(4),
			e_integAlgoAesXcbc96(5)
		}
		with {
			encode "TODO";
		}

			type enumerated DiffieHellmanGroup {
			e_none(0),
			e_group1ModP768Bit(1),
			e_group2ModP1024Bit(2),
			e_group5ModP1536Bit(5),
			e_group14ModP2044Bit(14),
			e_group15ModP3072Bit(15),
			e_group16ModP4096Bit(16),
			e_group17ModP6144Bit(17),
			e_group18ModP8192Bit(18)
		}
		with {
			encode "TODO";
		}

			type record SevenSecrets {
			octetstring sK_d,
			octetstring sK_ai,
			octetstring sK_ar,
			octetstring sK_ei,
			octetstring sK_er,
			octetstring sK_pi,
			octetstring sK_pr
		}
		with {
			encode "TODO";
		}

	//IKE Security Association Database
		type record length (1 .. c_maxNrIkeDa) of IkeSa IkeSad;
		const UInt8 c_maxNrIkeDa := 8;


		//IKE Security Association
		type record IkeSa {
			Oct8 spiInitiator,
			Oct8 spiResponder,
			UInt32 messageID,
			IkeEncryptionAlgo ikeEncryptionAlgo,
			octetstring	ikeEncryptionKey,
			IkePseudoRandomFunction ikePseudoRandomFunction,
			IkeIntegrityAlgo ikeIntegrityAlgo,
			octetstring	ikeIntegrityKey,
			DiffieHellmanGroup diffieHellmanGroup,
			octetstring diffieHellmanPrivKey,
			octetstring diffieHellmanSharedSecret,
			SevenSecrets sevenSecrets
		}
		with {
			variant "TODO";
		}
	}//end group ikeSecurity
	}//end group cryptoTypes


+34 −0
Original line number Diff line number Diff line
@@ -75,6 +75,40 @@ module LibIpv6_ModuleParameters {
	*/
	modulepar {octetstring PX_COMBINED_MODE_KEY := 'B1B2B3B4'O}

	group ikeSecurity
	{
	/*
	 * @desc Which SPI shall be used for testing IKE?
	*/
	modulepar {Oct8 PX_IKE_SPI := '0000000000000001'O;}  

	/*
	 * @desc Which encryption algorithm shall be used for testing IKE?
	*/
	modulepar {IkeEncryptionAlgo PX_IKE_ENCALGO := e_encrAlgoDesIv64;} 

	/*
	 * @desc Which pseudo random function shall be used for testing IKE?
	*/
	modulepar {IkePseudoRandomFunction PX_IKE_PSEUDORANDOM_FCT := e_prfHmacMd5;} 

	/*
	 * @desc Which integrity algorithm shall be used for testing IKE?
	*/
	modulepar {IkeIntegrityAlgo PX_IKE_INTALGO := e_integAlgoHmacMd596;} 

	/*
	 * @desc Which Diffie-Hellman group shall be used for testing IKE?
	*/
	modulepar {DiffieHellmanGroup PX_IKE_DIFFIEHELLMAN_GROUP := e_group1ModP768Bit;} 

	/*
	 * @desc Which private key for the Diffie-Hellman exchange shall be used for testing IKE?
	*/
	modulepar {octetstring PX_IKE_DIFFIEHELLMAN_PRIVKEY := '0123456789ABCDEF'O;} 

	} // end group ikeSecurity

	
	
} // end module LibIpv6_ModuleParameters