UVM-based symmetric key algorithm verification method and platform for three algorithm cores
Through the symmetric key algorithm verification platform based on UVM's three algorithm cores, the verification problem of the SKA algorithm on the chip is solved, an efficient and complete verification process is achieved, and the security performance and area control of the chip are ensured.
Patent Information
- Application Number
- CN202410740216.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-27
AI Technical Summary
There is a lack of systematic verification methods for the new symmetric key algorithm SKA integrated on the chip, and it is difficult to accurately simulate its operation mode and communication process with other modules, which affects the security performance and area control of the chip.
A symmetric key algorithm verification platform based on three algorithm cores based on UVM, including the top layer, test cases and verification environment, accessing verification environment components, AHB system environment components, sub-verification environment components and registers of the symmetric key algorithm core through the APB bus Models and adapters simulate and verify the functions of the SKA algorithm to compare expected results with real calculation results.
It improves the flexibility and efficiency of verification, realizes the synchronization of the module under test and the verification environment, enhances the randomness and completeness of verification, and ensures the functional integrity of the SKA algorithm.
Smart Images

Figure CN118713834A
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip verification technology, and in particular to a symmetric key algorithm verification method and platform based on three algorithm cores of UVM. Background Art
[0002] According to Moore's Law, the number of transistors on an integrated circuit will double every 18 to 24 months, making the performance of the chip grow exponentially. With the rapid growth of chip performance, the amount of data interaction generated inside and outside the chip is also increasing. In order to ensure the security and reliability of data interaction, cryptography has emerged. In the development of cryptography, symmetric algorithms such as DES (Data Encryption Standard), AES (Advanced Encryption Standard) and the national secret SM4 algorithm have been born. They all have the advantages of fast speed, low memory requirements and good security. However, when the three algorithms are independently integrated into the chip, they all have to deploy their own communication interfaces, which leads to an increase in the algorithm area occupied by the chip. In order to meet the requirements of chip security performance and control chip area at the same time, a symmetric key algorithm (Symmetric_keyalgorithm) that integrates the above three symmetric encryption algorithms is proposed, hereinafter referred to as the SKA algorithm. The three algorithms share a set of communication interfaces, which can effectively reduce the area occupied by the algorithm.
[0003] Compared with the mature DES, AES and SM4 algorithms that already have complete verification methods, the SKA algorithm was proposed later and currently lacks systematic verification of its solution. Therefore, how to build a complete SKA algorithm verification platform, accurately simulate the operation of the three algorithms and the communication process with other modules, and ensure the completeness of its functions through a large number of incentives, is an urgent problem that verifiers need to solve. Summary of the invention
[0004] Based on this, it is necessary to provide a symmetric key algorithm verification method and platform for three algorithm cores based on UVM to address the above technical problems.
[0005] A UVM-based symmetric key algorithm verification platform for three algorithm cores, comprising: a top layer, test cases and a verification environment.
[0006] The top layer includes the SKA algorithm module.
[0007] The verification environment includes: APB bus access verification environment component, AHB system environment component, sub-verification environment components of three symmetric key algorithm cores, register model reg_model and adapter adapter; among them, the AHB system environment component includes a slave agent component; the slave agent component includes virtual memory and AHB bus interface monitoring.
[0008] The APB bus access verification environment component is used to simulate the APB bus function and pass the preset configuration information to the SKA algorithm module.
[0009] The AHB system environment component is used to simulate the AHB bus function, communicate with the SKA algorithm module via AHB, and simulate the actual data transmission situation.
[0010] The sub-verification environment component of the symmetric key algorithm core is used to simulate the symmetric key algorithm function, output the expected result of the symmetric key algorithm, collect the actual calculation results output by the corresponding algorithm core in the SKA algorithm module, and compare the expected results with the actual calculation results.
[0011] The register model reg_model is used to access the verification environment components through the APB bus in the verification environment to deploy all registers of the SKA algorithm module.
[0012] The adapter is used to convert the register data types in the verification environment and the SKA algorithm module to facilitate data intercommunication.
[0013] Test cases are used to create a verification environment, declare environment variables, configure information, and create various functions for test cases to call.
[0014] Create a test case, select the function to be tested by changing the register configuration, access the verification environment component through the register model reg_model and the APB bus to synchronize the SKA algorithm module and the verification environment configuration; generate algorithm incentives according to the function to be tested, and initialize the virtual memory through the AHB system environment component; select the corresponding symmetric key algorithm core in the SKA algorithm module according to the configuration information selected by the test case, and then trigger the sub-verification environment component of the corresponding symmetric key algorithm core in the verification environment, and compare the expected result output by the sub-verification environment component of the symmetric key algorithm core with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module. If the comparison fails, print the data comparison failure simulation log and end the simulation; if the comparison passes, output the simulation log and end the simulation.
[0015] In one embodiment, the APB bus access verification environment component includes: component system environment configuration, and a complete set of APB hosts; the APB host includes: an APB driver, an APB sequencer, and an APB interface monitor.
[0016] The APB driver is used to apply to the APB sequence generator for the transaction data required for verification, and transmit the transaction data to the SKA algorithm module and reference model component through the interface.
[0017] The APB sequence generator is used to store and package the sequence and send it out. When the APB driver needs sequence data, the APB sequence generator checks whether there is a sequence to be sent. If so, it is sent directly, otherwise a sequence is generated and sent.
[0018] The APB interface monitor is used to continuously monitor whether the access initiated by the SKA algorithm module during data transmission complies with the APB protocol.
[0019] In one of the embodiments, the sub-verification environment components of the three symmetric key algorithm cores are: the sub-verification environment component of the aes algorithm core, the sub-verification environment component of the sm4 algorithm core, and the sub-verification environment component of the des algorithm core.
[0020] The sub-verification environment components of the AES algorithm core include: an AES reference model component used to simulate the functions of the AES algorithm core and output the expected results of the AES algorithm core, an AES monitoring component used to collect the actual calculation results output by the AES algorithm core in the SKA algorithm module, and an AES comparison component used to compare the expected results with the actual calculation results.
[0021] The sub-verification environment components of the SM4 algorithm core include: an SM4 reference model component used to simulate the functions of the SM4 algorithm core and output the expected results of the SM4 algorithm core, an SM4 monitoring component used to collect the actual calculation results output by the SM4 algorithm core in the SKA algorithm module, and an SM4 comparison component used to compare the expected results with the actual calculation results.
[0022] The sub-verification environment components of the DES algorithm core include: a DES reference model component used to simulate the functions of the DES algorithm core and output the expected results of the DES algorithm core, a DES monitoring component used to collect the actual calculation results output by the DES algorithm core in the SKA algorithm module, and a DES comparison component used to compare the expected results with the actual calculation results.
[0023] In one of the embodiments, environment variables are used to control the clock frequency of the SKA algorithm module and the verification environment; the backdoor write function is used to initialize the virtual memory; the register configuration function is used to call the register model to configure the registers in the SKA algorithm module, and the configuration information will be randomized.
[0024] In one embodiment, the algorithm core of the SKA algorithm module includes: aes algorithm core, sm4 algorithm core and des algorithm core.
[0025] In one embodiment, the platform also includes a coverage collection component; the complete coverage ensures that the SKA algorithm module selects each symmetric key algorithm core and the corresponding working mode.
[0026] In one of the embodiments, the working modes include: electronic code book, ciphertext block connection, ciphertext feedback, output feedback mode, counter and message authentication code based on symmetric key block encryption algorithm, encryption and decryption algorithm, whether to enable pseudo-round calculation and random seed, whether to enable mask calculation, algorithm length and randomly configure the key used for encryption and decryption.
[0027] In one of the embodiments, the data of each component in the verification environment is transmitted via TLM, and each component interacts with data through ports and export ports, and the data is the actual calculation result output by the SKA algorithm module.
[0028] A symmetric key algorithm verification method based on three algorithm cores of UVM, the verification method is applied to the above-mentioned symmetric key algorithm verification platform based on three algorithm cores of UVM, the verification method comprises the following steps:
[0029] Create the top-level simulation file, initialize the verification platform top-level file, and start the test case.
[0030] Based on the verification environment, create AHB system environment components, APB bus access verification environment components, register model reg_model, adapter adapter and sub-verification environment components of three symmetric key algorithm cores.
[0031] Create a test case and modify the configuration information according to the test case function.
[0032] Transfer configuration information to the SKA algorithm module and verification environment, and initialize virtual memory.
[0033] According to the configuration information, the corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then the sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment. The expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module.
[0034] If the comparison fails, the simulation log of data comparison failure is printed and the simulation ends.
[0035] If the comparison passes, the simulation log is output and the simulation ends.
[0036] In one of the embodiments, the sub-verification environment components of the three symmetric key algorithm cores are respectively the sub-verification environment component of the AES algorithm core, the sub-verification environment component of the SM4 algorithm core, and the sub-verification environment component of the DES algorithm core.
[0037] According to the configuration information, the corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then the sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment, and the expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module, including:
[0038] When the sub-verification environment component of the aes algorithm core is triggered in the verification environment, the aes reference model component obtains the initial data from the virtual memory through the slave agent component in the aHB system environment component, processes and encrypts and decrypts the data according to the configuration information, obtains the expected data, and transmits it to the aes comparison component. When the SKA algorithm module completes the data processing, the aes monitoring component obtains the actual calculation result from the virtual memory of the slave agent component in the aHB system environment component, and transmits it to the aes comparison component. The aes comparison component compares the expected data with the actual calculation result.
[0039] The above-mentioned symmetric key algorithm verification method and platform for the three algorithm cores based on UVM adopt the UVM verification environment to divide the SKA module functions into three sub-verification environments for verification, thereby improving the flexibility of verification, achieving synchronization between the module to be tested and the verification environment with low configuration cost, and improving the efficiency of verification; at the same time, the high degree of freedom of configuration options also improves the randomness of verification, making the verification more complete. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a block diagram of a symmetric key algorithm verification platform based on three algorithm cores of UVM in one embodiment;
[0041] Figure 2 A schematic flow chart of a symmetric key algorithm verification method based on three algorithm cores of UVM in one embodiment;
[0042] Figure 3 is a workflow diagram of a reference model component in an algorithm sub-environment (aes_env / des_env / sm4_env) in another embodiment;
[0043] Figure 4 The following is a workflow diagram of the monitoring component in the algorithm sub-environment (aes_env / des_env / sm4_env) in another embodiment. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] In one embodiment, Figure 1 As shown, a symmetric key algorithm verification platform for three algorithm cores based on UVM is provided, which includes: top-level TB, test cases and verification environment ska_env. Figure 1 The interface bus connecting the SKA algorithm module (i.e., the module to be tested) and the verification environment is represented by a double arrow.
[0046] Top-level TB, including the SKA algorithm module.
[0047] The verification environment ska_env includes: APB bus access verification environment component apb_env, AHB system environment component ahb_env, three symmetric key algorithm core sub-verification environment components, register model reg_model and adapter adapter; wherein, the AHB system environment component ahb_env includes a slave agent component slave_agent; the slave agent component slave_agent includes a virtual memory slave_mem and an AHB bus interface monitor slave_monitor. Specifically, in the verification environment ska_env, the components are connected, the data of each component in the verification environment ska_env is transmitted in TLM, and each component interacts with data through port and export port, and the data is the calculation result output by the SKA algorithm.
[0048] The APB bus access verification environment component apb_env is used to simulate the APB bus function and pass the preset configuration information to the SKA algorithm module.
[0049] The AHB system environment component ahb_env is used to simulate the AHB bus function, communicate with the SKA algorithm module via AHB, and simulate the actual data transmission situation.
[0050] The sub-verification environment component of the symmetric key algorithm core is used to simulate the symmetric key algorithm function, output the expected result of the symmetric key algorithm, collect the actual calculation results output by the corresponding algorithm core in the SKA algorithm module, and compare the expected results with the actual calculation results.
[0051] The register model reg_model is used to access the verification environment component apb_env through the APB bus in the verification environment ska_env to deploy all registers of the SKA algorithm module.
[0052] The adapter is used to convert the register data types in the verification environment ska_env and the SKA algorithm module to facilitate data intercommunication.
[0053] Test cases are used to create the verification environment ska_env, declare environment variables, configuration information, and create various functions for test cases to call.
[0054] Specifically, create a test case, and when selecting the test function, change the register configuration to implement different functions, such as working in one of the three algorithm cores mentioned above, and the working mode or encryption and decryption corresponding to each algorithm. The SKA algorithm module and the verification environment ska_env configuration synchronization can be achieved through the register model reg_model and the APB bus access verification environment component apb_env. Generate algorithm stimulus according to the function to be tested, and initialize the virtual memory slave_mem through the AHB system environment component ahb_env.
[0055] Create a test case, select the function to be tested by changing the register configuration, and synchronize the SKA algorithm module and the verification environment configuration through the register model reg_model and the APB bus access verification environment component apb_env; generate algorithm stimulus according to the function to be tested, and initialize the virtual memory slave_mem through the AHB system environment component ahb_env; select the corresponding symmetric key algorithm core in the SKA algorithm module according to the configuration information selected by the test case, and then trigger the corresponding symmetric key algorithm core sub-verification environment component in the verification environment, and compare the expected result output by the sub-verification environment component of the symmetric key algorithm core with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module. If the comparison fails, print the data comparison failure simulation log and end the simulation; if the comparison passes, output the simulation log and end the simulation.
[0056] In the above-mentioned symmetric key algorithm verification platform of the three algorithm cores based on UVM, the UVM verification environment is adopted to divide the SKA module functions into three sub-verification environments for verification, which improves the flexibility of verification, realizes the synchronization of the module to be tested and the verification environment with low configuration cost, and improves the efficiency of verification; at the same time, the high degree of freedom of configuration options also improves the randomness of verification, making the verification more complete.
[0057] In one embodiment, the APB bus access verification environment component apb_env includes: component system environment configuration, and a complete set of APB hosts; the APB host includes: APB driver apb_drv, APB sequencer apb_sequencer and APB interface monitor apb_mon.
[0058] The APB driver apb_drv is used to apply to the APB sequencer apb_sequencer for the transaction data required for verification, and transmit the transaction data to the SKA algorithm module and reference model component through the interface.
[0059] The APB sequence generator apb_sequencer is used to store the sequence and package it for sending. When the APB driver apb_drv needs sequence data, the APB sequence generator apb_sequencer checks whether there is a sequence to be sent. If so, it is sent directly, otherwise a sequence is generated and sent.
[0060] The APB interface monitor apb_mon is used to continuously monitor whether the access initiated by the SKA algorithm module during data transmission complies with the APB protocol.
[0061] In one of the embodiments, the sub-authentication environment components of the three symmetric key algorithm cores are: the sub-authentication environment component aes_subenv of the aes algorithm core, the sub-authentication environment component sm4_subenv of the sm4 algorithm core, and the sub-authentication environment component des_subenv of the des algorithm core.
[0062] The sub-verification environment components of the aes algorithm core include: the aes reference model component aes_refm used to simulate the aes algorithm core function in the SKA algorithm module and output the expected results of the aes algorithm core, the aes monitoring component aes_mon used to collect the actual calculation results output by the aes algorithm core in the SKA algorithm module, and the aes comparison component aes_scb used to compare the expected results with the actual calculation results.
[0063] The sub-verification environment components of the sm4 algorithm core include: the sm4 reference model component sm4_refm used to simulate the sm4 algorithm core function in the SKA algorithm module and output the expected results of the sm4 algorithm core, the sm4 monitoring component sm4_mon used to collect the actual calculation results output by the sm4 algorithm core in the SKA algorithm module, and the sm4 comparison component sm4_scb used to compare the expected results with the actual calculation results.
[0064] The sub-verification environment components of the des algorithm core include: a des reference model component des_refm used to simulate the functions of the des and tdes algorithm cores in the SKA algorithm module and output the expected results of the des and tdes algorithm cores; a des monitoring component des_mon used to collect the actual calculation results output by the des algorithm core in the SKA algorithm module; and a des comparison component des_scb used to compare the expected results with the actual calculation results.
[0065] In one of the embodiments, environment variables are used to control the clock frequency of the SKA algorithm module and the verification environment; the backdoor write function is used to initialize the virtual memory slave_mem; the register configuration function is used to call the register model to configure the registers in the SKA algorithm module, and the configuration information will be randomized.
[0066] In one embodiment, the algorithm core of the SKA algorithm module includes: aes algorithm core, sm4 algorithm core and des algorithm core.
[0067] In one embodiment, the platform also includes a coverage collection component; the complete coverage ensures that the SKA algorithm module selects each symmetric key algorithm core and the corresponding working mode.
[0068] In one of the embodiments, the working modes include: electronic code book, ciphertext block connection, ciphertext feedback, output feedback mode, counter and message authentication code based on symmetric key block encryption algorithm, encryption and decryption algorithm, whether to enable pseudo-round calculation and random seed, whether to enable mask calculation, algorithm length and randomly configure the key used for encryption and decryption.
[0069] Specifically, a coverage collection component cov is set up for all possible algorithm cores and corresponding working modes of the SKA algorithm module. Complete coverage needs to ensure that the SKA algorithm can select aes, sm4 and des algorithm cores; the working mode can be selected as ecb (electronic codebook), cbc (cipher block chaining), cfb (cipher feedback), ofb (output feedback), ctr (counter) and cmac (cipher block chaining-message authentication code based on symmetric key block encryption algorithm); the encryption and decryption algorithm can be selected; whether to turn on pseudo-round calculation and random seed; whether to turn on mask calculation; the algorithm length and randomly configure the key used for encryption and decryption can be selected.
[0070] In one of the embodiments, the data of each component in the verification environment is transmitted via TLM, and each component interacts with data through ports and export ports, and the data is the actual calculation result output by the SKA algorithm module.
[0071] In one embodiment, Figure 2As shown, a symmetric key algorithm verification method for three algorithm cores based on UVM is provided, and the verification method is applied to the symmetric key algorithm verification platform for the three algorithm cores based on UVM, and the verification method comprises the following steps:
[0072] Create the top-level simulation file, initialize the verification platform top-level file, and start the test case.
[0073] Based on the verification environment, create AHB system environment components, APB bus access verification environment components, register model reg_model, adapter adapter and sub-verification environment components of three symmetric key algorithm cores.
[0074] Specifically, an AHB system environment component ahb_env is created based on the verification environment ska_env. The environment includes the component system environment configuration ahb_sys_cfg, the ahb slave agent component slave_agent, and a virtual memory slave_mem is also created in the slave agent component slave_agent. Each slave agent component slave_agent includes an AHB bus interface and an AHB bus interface monitor slave_monitor. The AHB system environment component ahb_env will communicate with the SKA algorithm module via AHB to simulate the actual data transmission. Its AHB bus interface monitor slave_monitor will continuously monitor whether the access initiated by the SKA algorithm module complies with the AHB protocol during the data transmission process.
[0075] Based on the verification environment ska_env, the APB system environment component apb_env was created. The component contains the component system environment configuration apb_sys_cfg and a complete set of APB hosts to simulate the APB bus function and pass the preset configuration information to the SKA algorithm module.
[0076] Based on the verification environment ska_env, create the register model reg_model and adapter adapter. The register model reg_model is used to deploy all registers of the algorithm module through the APB system environment component apb_env in the verification environment; the adapter adapter is responsible for converting the register data types in the verification environment and the SKA algorithm module to facilitate data intercommunication.
[0077] Based on the verification environment ska_env, three sub-environments of the algorithm core, aes_subenv, sm4_subenv and des_subenv, were created. In aes_subenv, a reference model component aes_refm that simulates the complete algorithm function of aes was created, which is used to output the expected results of the algorithm; a monitoring component aes_mon was created to collect the actual calculation results output by the aes algorithm core selected in the SKA algorithm; and a comparison component aes_scb was created to compare the expected results with the actual results. In sm4_subenv, a reference model component sm4_refm that simulates the complete algorithm function of sm4 was created, which is used for the algorithm to output the expected results; a monitoring component aes_mon was created to collect the actual calculation results output by the sm4 algorithm core selected in the SKA algorithm; and a comparison component sm4_scb was created to compare the expected results with the actual results. In des_subenv, a reference model component des_refm is created to simulate the complete algorithm functions of des and tdes, which is used to output the expected results of the algorithm; a monitoring component des_mon is created to collect the actual calculation results output by the des or tdes algorithm core selected in the SKA algorithm; and a comparison component des_scb is created to compare the expected results with the actual results.
[0078] Create a test case and modify the configuration information according to the test case function.
[0079] Specifically, create a basic test component base_test (test case base class) to create a verification environment ska_env, declare environment variables, configuration information, and create various functions for test cases to call. The environment variables can control the clock frequency of the SKA algorithm and verification environment, the backdoor write function can initialize the virtual memory slave_mem, and the register configuration function can call the register model to configure the registers in the SKA algorithm module. In order to meet the coverage of different functions, the configuration information will be randomized.
[0080] Transfer configuration information to the SKA algorithm module and verification environment, and initialize the virtual memory slave_mem.
[0081] According to the configuration information, the corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then the sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment. The expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module.
[0082] If the comparison fails, the simulation log of data comparison failure is printed and the simulation ends.
[0083] If the comparison passes, the simulation log is output and the simulation ends.
[0084] In the above-mentioned symmetric key algorithm verification method of the three algorithm cores based on UVM, an advanced UVM verification platform integrating software implementation, collection and comparison of the SKA algorithm module is built through the SystemVerilog language; the integrated sub-environment guarantee of the three algorithm cores and the random test data and random register configuration ensure the completeness and accuracy of the verification.
[0085] In one of the embodiments, the sub-verification environment components of the three symmetric key algorithm cores are respectively the sub-verification environment component of the AES algorithm core, the sub-verification environment component of the SM4 algorithm core, and the sub-verification environment component of the DES algorithm core.
[0086] According to the configuration information, the corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then the sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment, and the expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module, including:
[0087] When the sub-verification environment component of the aes algorithm core is triggered in the verification environment, the aes reference model component obtains the initial data from the virtual memory through the slave agent component in the aHB system environment component, processes and encrypts and decrypts the data according to the configuration information, obtains the expected data, and transmits it to the aes comparison component. When the SKA algorithm module completes the data processing, the aes monitoring component obtains the actual calculation result from the virtual memory of the slave agent component in the aHB system environment component, and transmits it to the aes comparison component. The aes comparison component compares the expected data with the actual calculation result.
[0088] Specifically, if the configuration selected by the test case is aes, the SKA algorithm module selects aes as the algorithm core, and the aes_subenv in the verification environment is triggered. The aes_refm obtains the initial data from the virtual memory through the AHB proxy component, and processes and encrypts and decrypts the data according to the configuration information to obtain the expected data, and transmits it to the aes_scb component. After waiting for the SKA algorithm module to complete the data processing, aes_mon obtains the actual data from the virtual memory through the AHB proxy component and transmits it to the aes_scb component. The workflow is as follows: Figure 4 As shown, aes_scb will compare the real data with the expected data. If the comparison fails, the simulation log of data comparison failure will be printed and the simulation will end. If the comparison passes, the simulation log will be output and the simulation will end. The above process is configured as the aes algorithm core. Similarly, when the configuration information selects the above des and sm4 algorithm cores, the corresponding environment components will be triggered.
[0089] In a specific embodiment, if the working mode selected by the test case is CMAC mode, due to the particularity of this mode (the length of a single algorithm data changes from 128 bits to 8 bits in CMAC mode), different branches will be selected in the verification environment to process the CMAC algorithm. The workflow is as follows: Figure 3 shown.
[0090] Write the makefile file, select the compilation tool, connect the flielist of the SKA algorithm module and the filelist of the verification environment, add compilation macros, coverage collection items, etc. Through this file, you can also realize the automatic running of the test case for a specified number of times.
[0091] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0092] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0093] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A symmetric key algorithm verification platform based on three algorithm cores of UVM, It is characterized in that The platform includes: a top layer, test cases and a verification environment; The top layer includes an SKA algorithm module; The verification environment includes: an APB bus access verification environment component, an AHB system environment component, three sub-verification environment components of symmetric key algorithm cores, a register model reg_model and an adapter adapter; wherein the AHB system environment component includes a slave agent component; the slave agent component includes virtual memory and AHB bus interface monitoring; The APB bus access verification environment component is used to simulate the APB bus function and pass the preset configuration information to the SKA algorithm module; The AHB system environment component is used to simulate the AHB bus function, perform AHB communication with the SKA algorithm module, and simulate the actual data transmission situation; The sub-verification environment component of the symmetric key algorithm core is used to simulate the symmetric key algorithm function, output the expected result of the symmetric key algorithm, collect the actual calculation results output by the corresponding algorithm core in the SKA algorithm module, and compare the expected results with the actual calculation results; The register model reg_model is used to access the verification environment component through the APB bus in the verification environment to deploy all registers of the SKA algorithm module; The adapter is used to convert the register data types in the verification environment and the SKA algorithm module to facilitate data intercommunication; The test case is used to create the verification environment, declare environment variables, configuration information, and create various functions for the test case to call; Create a test case, select the function to be tested by changing the register configuration, access the verification environment component through the register model reg_model and the APB bus to synchronize the SKA algorithm module and the verification environment configuration; generate an algorithm stimulus according to the function to be tested, and initialize the virtual memory through the AHB system environment component; select the corresponding symmetric key algorithm core in the SKA algorithm module according to the configuration information selected by the test case, and then trigger the sub-verification environment component of the corresponding symmetric key algorithm core in the verification environment, compare the expected result output by the sub-verification environment component of the symmetric key algorithm core with the actual calculation result of the symmetric key algorithm core in the SKA algorithm module, if the comparison fails, print the data comparison failure simulation log, and end the simulation; if the comparison passes, output the simulation log, and end the simulation.
2. The platform according to claim 1, It is characterized in that The APB bus access verification environment component includes: component system environment configuration, and a complete set of APB hosts; the APB host includes: APB driver, APB sequence generator and APB interface monitor; The APB driver is used to apply to the APB sequence generator to obtain the transaction data required for verification, and transmit the transaction data to the SKA algorithm module and the reference model component through the interface; The APB sequence generator is used to store and package the sequence and send it out. When the APB driver needs sequence data, the APB sequence generator checks whether there is a sequence to be sent. If so, it is sent directly, otherwise it generates a sequence and sends it; The APB interface monitor is used to continuously monitor whether the access initiated by the SKA algorithm module during data transmission complies with the APB protocol.
3. The platform according to claim 1, It is characterized in that The sub-verification environment components of the three symmetric key algorithm cores are: the sub-verification environment component of the aes algorithm core, the sub-verification environment component of the sm4 algorithm core, and the sub-verification environment component of the des algorithm core; The sub-verification environment components of the AES algorithm core include: an AES reference model component for simulating the function of the AES algorithm core and outputting the expected results of the AES algorithm core, an AES monitoring component for collecting the actual calculation results output by the AES algorithm core in the SKA algorithm module, and an AES comparison component for comparing the expected results with the actual calculation results; The sub-verification environment components of the SM4 algorithm core include: an SM4 reference model component for simulating the function of the SM4 algorithm core and outputting the expected result of the SM4 algorithm core, an SM4 monitoring component for collecting the actual calculation results output by the SM4 algorithm core in the SKA algorithm module, and an SM4 comparison component for comparing the expected result with the actual calculation result; The sub-verification environment components of the DES algorithm core include: a DES reference model component for simulating the function of the DES algorithm core and outputting the expected results of the DES algorithm core, a DES monitoring component for collecting the actual calculation results output by the DES algorithm core in the SKA algorithm module, and a DES comparison component for comparing the expected results with the actual calculation results.
4. The platform according to claim 1, It is characterized in that The environment variables are used to control the clock frequency of the SKA algorithm module and the verification environment; the backdoor write function is used to initialize the virtual memory; the register configuration function is used to call the register model to configure the registers in the SKA algorithm module, and the configuration information will be randomized.
5. The platform according to claim 1, It is characterized in that The algorithm core of the SKA algorithm module includes: aes algorithm core, sm4 algorithm core and des algorithm core.
6. The platform according to claim 1, It is characterized in that The platform also includes a coverage collection component; complete coverage ensures that the SKA algorithm module selects each symmetric key algorithm core and the corresponding working mode.
7. The platform according to claim 6, It is characterized in that The working modes include: electronic code book, ciphertext block connection, ciphertext feedback, output feedback mode, counter and message authentication code based on symmetric key block encryption algorithm, encryption and decryption algorithm, whether to enable pseudo-round calculation and random seed, whether to enable mask calculation, algorithm length and randomly configure the key used for encryption and decryption.
8. The method according to claim 1, It is characterized in that The data of each component in the verification environment is transmitted using TLM, and each component interacts with data through ports and export ports. The data is the actual calculation result output by the SKA algorithm module.
9. A symmetric key algorithm verification method based on three algorithm cores of UVM, It is characterized in that The verification method is applied to the verification platform according to claim 1, and the verification method comprises the following steps: Create the top-level simulation file, initialize the top-level verification platform file, and start the test case; Based on the verification environment, create AHB system environment components, APB bus access verification environment components, register model reg_model, adapter adapter, and sub-verification environment components of three symmetric key algorithm cores; Create a test case and modify the configuration information according to the test case function; Transmit the configuration information to the SKA algorithm module and verification environment, and initialize the virtual memory; According to the configuration information, a corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then a sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment, and an expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with an actual calculation result of the symmetric key algorithm core in the SKA algorithm module; If the comparison fails, the simulation log of data comparison failure is printed and the simulation ends; If the comparison passes, the simulation log is output and the simulation ends.
10. The method according to claim 9, It is characterized in that The sub-verification environment components of the three symmetric key algorithm cores are the sub-verification environment component of the aes algorithm core, the sub-verification environment component of the sm4 algorithm core, and the sub-verification environment component of the des algorithm core; According to the configuration information, a corresponding symmetric key algorithm core is selected in the SKA algorithm module, and then a sub-verification environment component of the corresponding symmetric key algorithm core is triggered in the verification environment, and an expected result output by the sub-verification environment component of the symmetric key algorithm core is compared with an actual calculation result of the symmetric key algorithm core in the SKA algorithm module, including: When the sub-verification environment component of the aes algorithm core in the verification environment is triggered, the aes reference model component obtains the initial data from the virtual memory through the slave agent component in the aHB system environment component, processes and encrypts and decrypts the data according to the configuration information, obtains the expected data, and transmits it to the aes comparison component. When the SKA algorithm module completes the data processing, the aes monitoring component obtains the actual calculation result from the virtual memory of the slave agent component in the aHB system environment component, and transmits it to the aes comparison component. The aes comparison component compares the expected data with the actual calculation result.
