0

I want to know how to write a CAPL script where I could read the RNG Seed sending response from ECU and send generated key using capl script and send request from the CANOe to the ECU. Since I don't have CDD file is there any solution how could I implement the functionality ?

I have implemented AES128 Seed & key functionality in ECU. I've tested with constant Seed and compared generated key and I defined a capl script for testing purpose and it works as expected. Now I am sending Random Number Generator(RNG) Seed from ECU when I get request 02 27 01. I send response with 8 bytes seed for example 0A 67 01 XX 01 02 03 04 05 06 07 08.

So everytime when this RNG is received in CAONe how to define a CAPL program that can read those 8 bytes of Seed and generate a Key. Please could someone help me to fix this.

Below I have added example check my AES128 Seed and key is working. In the below code I defined Key manually based on fixed Seed for testing. Actually I want to implement CAPL which can generate Key automatically. Since I don't ahve CDD file I assume I can't using funcitons like on DiagStartGenerateKeyFromSeed(). Is there any way that I could include functions and use ? Please your solutions helps me a lot and gain knowledge.

/*@!Encoding:1252*/
includes
{
  
}

variables
{
   //Golbal variables declaration 
  byte checkByte0;  
  message 0x723 msg = { dlc=8};
  message 0x723 msg1 = { dlc=8};
  byte check_byte0;
  message 0x72B sendmsg;
}

on message 0x723
{
  checkByte0 = this.byte(0) & 0x30;  
  //checkByte0 = 0x0F & 0x30; 
  /*Send static key to ECU for testing only*/
  if(checkByte0 == 0x30) //FC frame
  {
    write(" 27 02 Key is requested );
    msg.byte(0) = 0x21; //CF
    msg.byte(1) = 0xc8;
    msg.byte(2) = 0x9d;    //data
    msg.byte(3) = 0x02;
    msg.byte(4) = 0x8d;
    msg.byte(5) = 0xfa;    
    msg.byte(6) = 0x16;
    msg.byte(7) = 0x8a;
    
    
    msg1.byte(0) = 0x22; //CF
    msg1.byte(1) = 0x85;
    msg1.byte(2) = 0x93;    //data
    msg1.byte(3) = 0x3a;
    msg1.byte(4) = 0xef;
    msg1.byte(5) = 0xdd;    
    msg1.byte(6) = 0x00;
    msg1.byte(7) = 0x00;
    output(msg);
    output(msg1);
  }
}

//send Seed Request SID $27 01
on key 'r'
{  
  msg.byte(0) = 0x02; //FF
  msg.byte(1) = 0x27; //length
  msg.byte(2) = 0x01; //security
  msg.byte(3) = 0x00; //Seed 
  msg.byte(4) = 0x00; //
  msg.byte(5) = 0x00; //
  msg.byte(6) = 0x00;
  msg.byte(7) = 0x00;
  output(msg);  
}

/*Send generated Key request based on Seed */
on key 't'
{  
  msg.byte(0) = 0x10; //FF
  msg.byte(1) = 0x12; //length
  msg.byte(2) = 0x27; //write
  msg.byte(3) = 0x02; //write
  msg.byte(4) = 0x18; //did
  msg.byte(5) = 0xc8; //did
  msg.byte(6) = 0xfa; //data
  msg.byte(7) = 0xca;
  output(msg);  
}

  • You could and should create a _Basic Diagnostics Description_. You can then use the complete diagnostics toolset of CANoe without needing to have a CDD. Using the Basic Diagnostics editor, you simply define the services you need (and also a Seed'n'Key DLL) and no longer have to take care of ISO-TP and such. – MSpiller Oct 27 '22 at 09:36
  • @M.Spiller, thank you so much for your reply. I understood Basic Diagnostic Descritpion intially it was disabled in my CANOe. I have configured and enabled it now. I will add all the necessary diagnostic services and update the solution from my end. – Mahesh Reddy Oct 27 '22 at 10:13

0 Answers0