Loading ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_Interface_Functions.ttcn +73 −0 Original line number Diff line number Diff line Loading @@ -1071,6 +1071,24 @@ group rfc4303Esp_ExtHdrFunctions { var FncRetCode v_ret := e_error; if( (f_getEncryptionIvLen(PX_ENCRYPTION_ALGO) != 0) and (f_getEncryptionIvLen(PX_ENCRYPTION_ALGO) != lengthof(PX_IV))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect IV length for the selected encryption algorithm ****"); return; } if( f_checkEncryptionKeyLen(PX_ENCRYPTION_ALGO,lengthof(PX_ESP_ENCR_KEY))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect key length for the selected encryption algorithm ****"); return; } if( f_checkIntegrityKeyLen(PX_INTEGRITY_ALGO, lengthof(PX_INTEGRITY_KEY))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect key length for the selected integrity algorithm ****"); return; } vc_sad[0] := { spi := PX_SPI/*f_createSpi()*/, seqNr := c_uInt32Zero, Loading Loading @@ -1133,6 +1151,61 @@ group rfc4303Esp_ExtHdrFunctions { return 0; } //in units of octets function f_checkIntegrityKeyLen(IntegrityAlgo p_integrityAlgo, UInt8 p_keyLen) runs on LibIpv6Node return boolean { if((p_integrityAlgo == e_sha1) and (p_keyLen != 20)) { return false; } else if ((p_integrityAlgo == e_hmac_sha1_64) and (p_keyLen != 20)){ return false; } else if((p_integrityAlgo == e_hmac_md5_96) and (p_keyLen != 16)) { return false; } return true; } //in units of octets function f_getEncryptionIvLen(EncryptionAlgo p_encryptionAlgo) runs on LibIpv6Node return UInt8 { if(p_encryptionAlgo == e_tripleDes_cbc) { return 8; } else if (p_encryptionAlgo == e_aes_cbc){ return 16; } else if(p_encryptionAlgo == e_aes_ctr) { return 8; } else if(p_encryptionAlgo == e_des_cbc) { return 8; } return 0; } //in units of octets function f_checkEncryptionKeyLen(EncryptionAlgo p_encryptionAlgo, UInt8 p_keyLen) runs on LibIpv6Node return boolean { if((p_encryptionAlgo == e_tripleDes_cbc) and (p_keyLen != 24)){ return false; } else if ((p_encryptionAlgo == e_aes_cbc) and ((p_keyLen < 0) or (p_keyLen > 8))){ return false; } else if((p_encryptionAlgo == e_aes_ctr) and (p_keyLen != 20) and (p_keyLen != 28) and (p_keyLen != 36)){ return false; } else if((p_encryptionAlgo == e_des_cbc) and (p_keyLen != 8)){ return false; } return true; } /* * @desc This generates Security Parameters Index Loading Loading
ttcn3/EtsiLibrary/LibIpv6/LibCommonRfcs/LibIpv6_Interface_Functions.ttcn +73 −0 Original line number Diff line number Diff line Loading @@ -1071,6 +1071,24 @@ group rfc4303Esp_ExtHdrFunctions { var FncRetCode v_ret := e_error; if( (f_getEncryptionIvLen(PX_ENCRYPTION_ALGO) != 0) and (f_getEncryptionIvLen(PX_ENCRYPTION_ALGO) != lengthof(PX_IV))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect IV length for the selected encryption algorithm ****"); return; } if( f_checkEncryptionKeyLen(PX_ENCRYPTION_ALGO,lengthof(PX_ESP_ENCR_KEY))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect key length for the selected encryption algorithm ****"); return; } if( f_checkIntegrityKeyLen(PX_INTEGRITY_ALGO, lengthof(PX_INTEGRITY_KEY))) { v_ret := e_error; log("**** fx_setSecurityParameters: ERROR: Incorrect key length for the selected integrity algorithm ****"); return; } vc_sad[0] := { spi := PX_SPI/*f_createSpi()*/, seqNr := c_uInt32Zero, Loading Loading @@ -1133,6 +1151,61 @@ group rfc4303Esp_ExtHdrFunctions { return 0; } //in units of octets function f_checkIntegrityKeyLen(IntegrityAlgo p_integrityAlgo, UInt8 p_keyLen) runs on LibIpv6Node return boolean { if((p_integrityAlgo == e_sha1) and (p_keyLen != 20)) { return false; } else if ((p_integrityAlgo == e_hmac_sha1_64) and (p_keyLen != 20)){ return false; } else if((p_integrityAlgo == e_hmac_md5_96) and (p_keyLen != 16)) { return false; } return true; } //in units of octets function f_getEncryptionIvLen(EncryptionAlgo p_encryptionAlgo) runs on LibIpv6Node return UInt8 { if(p_encryptionAlgo == e_tripleDes_cbc) { return 8; } else if (p_encryptionAlgo == e_aes_cbc){ return 16; } else if(p_encryptionAlgo == e_aes_ctr) { return 8; } else if(p_encryptionAlgo == e_des_cbc) { return 8; } return 0; } //in units of octets function f_checkEncryptionKeyLen(EncryptionAlgo p_encryptionAlgo, UInt8 p_keyLen) runs on LibIpv6Node return boolean { if((p_encryptionAlgo == e_tripleDes_cbc) and (p_keyLen != 24)){ return false; } else if ((p_encryptionAlgo == e_aes_cbc) and ((p_keyLen < 0) or (p_keyLen > 8))){ return false; } else if((p_encryptionAlgo == e_aes_ctr) and (p_keyLen != 20) and (p_keyLen != 28) and (p_keyLen != 36)){ return false; } else if((p_encryptionAlgo == e_des_cbc) and (p_keyLen != 8)){ return false; } return true; } /* * @desc This generates Security Parameters Index Loading