Newer
Older
/*
* @author STF 276
* @version $Id$
* @desc This module collects external functions available
* to any function implementation in the IPv6 lirbary or
* ATS. Notice that the test case execution is only possible
* if a Platform Adapter with their implementation is used
* by the test system.
*/
module LibIpv6_ExternalFunctions {
//LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
import from LibIpv6_CommonRfcs_TypesAndValues { type all };
import from LibIpv6_Interface_TypesAndValues all;
/* @desc This external function calculates the payload length
* of a IPv6 packet
* @param p_msg Ipv6 packet
* @return payload length in bytes
external function fx_payloadLength( in template Ipv6Packet p_msg )
/* @desc This external function calculates the payload length
* of a IPv6 packet
* @param p_msg Ipv6 packet
* @param p_entry Nr of Tunnelled packet within the IPv6Packet
* @return payload length in bytes
*/
external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry )
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)
external function fx_encodeMessage (in template Ipv6Packet p_msg)
/* @desc This external function calculates the checksum for MIPv6 Header.
* If HomeAddressOption present, then this external function is called with the
* HomeAddress as Source Address
* @param p_srcAddr Source Address to be used for Checksum calculation
tepelmann
committed
* @param p_dstAddr MobileHeader
* @param p_mobileHeader MobileHeader
* @return MIPv6 Header checksum
*/
external function fx_mipHeaderChecksum( in Ipv6Address p_srcAddr,
in Ipv6Address p_dstAddr,
tepelmann
committed
in MobileHeader p_mobileHeader)
return Oct2;
/* @desc This external function calculates the length of MIPv6 Header.
tepelmann
committed
* @param p_mobileHeader MobileHeader
tepelmann
committed
external function fx_mipHeaderLength( in MobileHeader p_mobileHeader)
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.
* If e_sha1_96 is chosen, then the key input shall be ignored.
*
* @param p_integrityAlgo Cryptographic function used to compute MAC
* @param p_key Key used to compute the MAC
tepelmann
committed
external function fx_mac( IntegrityAlgo p_integrityAlgo, in octetstring p_key, in octetstring p_message)
return octetstring;
//p_message := SPI & SEQNr & IV & encrypted data
//* @param p_spi Security parameter Index whihc poinst to the SAD to be used
tepelmann
committed
external function fx_integrity(in UInt31 p_spi, in octetstring p_key, in octetstring p_message)
return octetstring;
tepelmann
committed
/* @desc This external function runs the MobileHeader through Codec and returns
* the octetstring representing the MobileHeader
tepelmann
committed
* @param p_mobileHeader Mip Header to be encoded to octetstring
tepelmann
committed
external function fx_mipHdrToOct(MobileHeader p_mobileHeader)
/* @desc This external function byte aligns the EspPayload (Iv, EspIpDatagram, TfcPadding) + next Header + pad Length
* 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_espPayload EspPayload to be byteAligned
* @return octetstring
*/
// external function fx_generatePadding(in UInt31 p_spi, EspPayload p_espPayload)
// return octetstring;
/* @desc This external function encrypts the EspPayload(except iv) + padding + padLen + nextHeader
*
* @param p_spi Security parameter Index whihc poinst to the SAD to be used
* @param p_espHeader Esp Header to be encoded to octetstring
* @return octetstring Is used for calculating the ICV
*/
// external function fx_encrypt(in UInt31 p_spi, in EspHeader p_espHeader)
// return octetstring;
external function fx_setSecurityParameters(in Sa p_sa)
return FncRetCode;
/* @desc This external function calculates the payload length
* of an IPv6 authentication header
* @param p_authHeader Authentication Header
* @return payload length in 32-bits words
*/
external function fx_authHeaderPayloadLength(in template AuthHeader p_authHeader) return UInt8;
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* @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;