CPAL脚本自动化测试 | 您所在的位置:网站首页 › 安全模块报错 › CPAL脚本自动化测试 |
第一步:定义参数。包括请求种子的请求(SeedReq_1),发送密钥的请求(KeySend_1),发送时间限制,响应时间限制(上述两个时间参数根据实际项目的不同而设置),种子数组,密钥数组,变量和ipOption等相关重要参数。 此处发现此函数并不适用于获取DID的响应数据,如果有了解的可以深入探讨一下。 第三步:通过CANoe工程中的dll文件计算出密钥。需要使用到函数diagGenerateKeyFromSeed来进行密钥的计算。 具体的结构和格式要求如下: 具体解锁脚本如下: void Diag_SecurityLevel_1_Unlock() { diagRequest HKM_TM.RequestSeed_Request SeedReq_1; diagRequest HKM_TM.SendKey_Send KeySend_1; const dword SENDING_TIMEOUT = 2000; const dword RESPONSE_TIMEROUT = 1500; char TEST_STEP[4] = "000"; dword gTestStep; byte seedArray[8]; byte keyArray[8]; dword actualLevel; char variant[12]; char ipOption[2]; dword KeyActualSize; long status; long retval; int i; diagSetTarget("HKM_TM"); retval = 1; actualLevel = 1; ipOption[0] = 'A'; ipOption[1] = 0; KeyActualSize = 8; //Diag_IncrementTestStep(); //diagSendRequest(Diag_10_03); //testCaseComment("Request Security Level 1 Seed"); diagSendRequest(SeedReq_1); if (testWaitForDiagRequestSent(SeedReq_1, SENDING_TIMEOUT) == 1) { testStepPass(TEST_STEP,"Request Seed Successfully"); } else testStepFail(TEST_STEP,"Request send failed"); if (testWaitForDiagResponse(SeedReq_1, RESPONSE_TIMEROUT) == 1) { status = diagGetLastResponseCode(SeedReq_1); if (status != -1) { testStepFail(TEST_STEP,"Seed request failed"); } for (i = 0; i < elCount(seedArray); i ++) { seedArray[i] = DiagGetRespPrimitiveByte(SeedReq_1,i+2); } } //testCaseComment("Generate security level 1 key"); status = diagGenerateKeyFromSeed(seedArray,elcount(seedArray),actualLevel,variant,ipOption,keyArray,elCount(keyArray),KeyActualSize); if (status != 0) { testStepFail(TEST_STEP, "diagGenerateKeyFromSeed failed"); write("Failed"); } else { testStepPass(TEST_STEP,"diagGenerateKeyFromSeed success"); write("Success"); } //testCaseComment("send key"); diagSetParameterRaw(KeySend_1,"SecurityKey",keyArray,elCount(keyArray)); diagSendRequest(KeySend_1); } |
CopyRight 2018-2019 实验室设备网 版权所有 |