A method, apparatus, device, and readable storage medium for testing the
security layer of an
electronic control system are disclosed, relating to the field of electronic control technology for
new energy vehicles. Specifically, the method includes an
electronic control unit (ECU) receiving a
test data packet from a HIL simulator via a hardware interface. This data packet includes
scenario-based extreme operating condition parameters, encrypted interference signals, encrypted sensor signals corresponding to the hardware to be interacted with, and encrypted abnormal signals. The ECU performs integrity
verification and
signal threshold judgment on the
test data packet to obtain a first result, and generates control commands based on the first result. The ECU encrypts and digitally signs the control commands based on a preset security key to obtain a
target control command, which is then sent to the HIL simulator via a communication
bus. The HIL simulator decrypts the
target control command, timestamps it, and verifies the
digital signature to obtain a second result, and executes the
target control command based on the second result, thereby achieving
security layer testing of the
electronic control system. This application can improve the realism and anti-interference capability of
security layer testing of electronic control systems.