Multi-type algorithm encryption method, device and system
By introducing a controller module into the system-on-a-chip (SoC), the interaction between the CPU and the algorithm module is reduced, enabling efficient processing of encryption for multiple types of algorithms. This solves the problem of high CPU utilization and improves the SoC's working efficiency and encryption efficiency.
Patent Information
- Application Number
- CN202410989236.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-19
AI Technical Summary
In the existing technology, the system-on-a-chip (SoC) connects the algorithm module and the central processing unit (CPU) through the Advanced Microcontroller Bus (AMBA) architecture, which results in high CPU utilization and reduces the SoC's operating efficiency.
By introducing a controller module, the target data is acquired in response to the CPU's control commands and stored in SRAM. The controller module then sends the target data to the algorithm module for encryption and sends the ciphertext back to SRAM, reducing direct interaction between the CPU and the algorithm module and improving encryption efficiency.
It reduces CPU usage, improves the efficiency of the algorithm module, and supports multiple types of encryption algorithms, demonstrating good applicability and versatility.
Smart Images

Figure CN118981776A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of encryption computing technology, and in particular to a method, device and system for multi-type algorithm encryption. Background Art
[0002] As the importance of information security has been widely concerned, the application scenarios of encryption technology are also increasing. Encryption technology is to encrypt data through specific algorithms and secret keys to protect the integrity, confidentiality and availability of data. The current encryption algorithms are mainly divided into three categories: symmetric encryption algorithms, asymmetric algorithms and hash algorithms.
[0003] In the prior art, the system on chip (SOC) generally connects the algorithm module unit and the central processing unit (CPU) through the advanced microcontroller bus architecture (AMBA), and the CPU completes the input, output and other control work of the algorithm. This method leads to a high CPU occupancy rate and a long CPU execution time, which will reduce the working efficiency of the entire SOC. Therefore, how to improve the encryption work efficiency of multiple types of algorithms has become a problem that needs to be solved urgently. Summary of the invention
[0004] Based on the above problems, the present application provides a method, device and system for multi-type algorithm encryption to improve the encryption efficiency of multi-type algorithms.
[0005] The present application discloses a method for multi-type algorithm encryption, which is implemented by a system for multi-type algorithm encryption, the system comprising a central processing unit (CPU), a static random access memory (SRAM), a controller module and an algorithm module; the method for multi-type algorithm encryption comprises:
[0006] The controller module responds to the control instruction from the CPU to obtain the target data; the target data is filled in by the CPU based on the encryption type and stored in the SRAM;
[0007] The controller module sends the target data to the algorithm module according to the control instruction;
[0008] When the algorithm module encrypts the target data to obtain ciphertext, the controller module transmits the ciphertext back to the SRAM.
[0009] Optionally, the target data is filled in by the CPU based on the encryption type, including:
[0010] The CPU fills in the target data in a data frame format based on the encryption type; the target data includes a mode frame, and the mode frame indicates the encryption type of the target data; each frame of the target data includes a frame header and a frame trailer.
[0011] Optionally, sending the target data to an algorithm module according to the control instruction includes:
[0012] Acquire and parse the target data according to the control instruction to obtain the encryption type of the target data;
[0013] The target data is sent to the submodule in the algorithm module corresponding to the encryption type of the target data.
[0014] Optionally, sending the target data to an algorithm module according to the control instruction includes:
[0015] Parsing the target data according to the control instruction to obtain the mode frame;
[0016] Based on the mode frame, obtaining a target encryption type of the target data;
[0017] The target data content is sent to a submodule corresponding to the target encryption type.
[0018] Optionally, when the algorithm module encrypts the target data to obtain ciphertext, the controller module transmits the ciphertext back to the SRAM, including:
[0019] When the algorithm module starts to encrypt the target data frame by frame and obtains the first frame of ciphertext, the controller module adds a ciphertext frame header to the front of the first frame of ciphertext and transmits it back to the SRAM;
[0020] When the algorithm module encrypts, the controller module transmits each frame of ciphertext obtained back to the SRAM;
[0021] When the algorithm module completes encryption and obtains the last frame of ciphertext, the controller module adds a ciphertext frame tail to the end of the last frame of ciphertext and transmits it back to the SRAM.
[0022] Optionally, the CPU searches for the encryption result through the numbers of the ciphertext frame header and the ciphertext frame tail.
[0023] Optionally, the target data includes first data, and after the controller module acquires and parses the target data according to the control instruction, the method further includes:
[0024] The controller module performs verification according to the parsing result of the first data, and when the parsing result does not include a frame header and / or a frame tail, returns error information to the CPU and interrupts the work;
[0025] The CPU processes the remaining encryption work of the first data.
[0026] Based on the above-mentioned method of multi-type algorithm encryption, the present application also discloses a device for multi-type algorithm encryption, including: a response unit, a sending unit and a return unit;
[0027] The response unit is used to respond to the control instruction from the CPU and obtain the target data; the target data is filled in by the CPU based on the encryption type and stored in the SRAM;
[0028] The sending unit is used to send the target data to the algorithm module according to the control instruction;
[0029] The return unit is used to return the ciphertext to the SRAM when the algorithm module encrypts the target data to obtain the ciphertext.
[0030] Optionally, the response unit is used to:
[0031] The CPU fills in the target data in a data frame format based on the encryption type; the target data includes a mode frame, and the mode frame indicates the encryption type of the target data; each frame of the target data includes a frame header and a frame trailer.
[0032] Optionally, the sending unit includes:
[0033] A type acquisition subunit, used to acquire and parse the target data according to the control instruction to obtain the encryption type of the target data;
[0034] The data transmission subunit is used to send the target data to the submodule in the algorithm module corresponding to the encryption type of the target data.
[0035] Optionally, the sending unit includes:
[0036] A frame header acquisition subunit, used for parsing the target data according to the control instruction to obtain the mode frame;
[0037] A type parsing subunit, configured to obtain a target encryption type of the target data based on the mode frame;
[0038] The corresponding transmission subunit is used to send the target data content to the submodule corresponding to the target encryption type.
[0039] Optionally, the returning unit includes:
[0040] The frame header adding subunit is used for, when the algorithm module starts to encrypt the target data frame by frame and obtains the first frame of ciphertext, the controller module adds a ciphertext frame header in front of the first frame of ciphertext and transmits it back to the SRAM;
[0041] A frame-by-frame transmission subunit, used for the controller module to transmit each frame of ciphertext obtained back to the SRAM when the algorithm module encrypts;
[0042] The frame tail adding subunit is used for, when the algorithm module completes encryption and obtains the last frame of ciphertext, the controller module adds the ciphertext frame tail after the last frame of ciphertext and transmits it back to the SRAM.
[0043] Optionally, the CPU searches for the encryption result through the numbers of the ciphertext frame header and the ciphertext frame tail.
[0044] Optionally, the target data includes first data, and the device further includes:
[0045] a verification unit, configured to verify the first data according to the parsing result, and return error information to the CPU and interrupt the work when the parsing result does not include the frame header and / or the frame tail;
[0046] A CPU processing unit is used for the CPU to process the remaining encryption work of the first data.
[0047] The present application also discloses a system for multi-type algorithm encryption, which is used to implement the above method. The system includes: a central processing unit CPU, a static random access memory SRAM, a controller module and an algorithm module.
[0048] Optionally, the algorithm module includes:
[0049] Symmetric algorithm submodule, asymmetric algorithm submodule and hash algorithm submodule; each submodule is connected through an advanced microcontroller bus architecture AMBA to communicate with each other.
[0050] The present application discloses a method, device and system for multi-type algorithm encryption. The method is implemented by the system including a central processing unit (CPU), a static random access memory (SRAM), a controller module and an algorithm module. The controller module responds to the control instruction from the CPU and obtains the target data filled in by the CPU based on the encryption type and stored in the SRAM. Thus, multiple types of encryption algorithms can be implemented, which has good applicability and versatility. Afterwards, the controller module sends the target data to the algorithm module according to the control instruction. When the algorithm module encrypts the target data to obtain the ciphertext, the controller module transmits the ciphertext back to the SRAM to achieve encryption. In the present application, the CPU only completes the SRAM reading and writing and the configuration of the controller module, and has no direct interaction with the algorithm module. The algorithm module works until all data encryption is completed, and there is no need to interact with the CPU. While reducing the CPU occupancy rate, it also improves the encryption efficiency of the algorithm module. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0052] Figure 1a A schematic diagram of the structure of a system for encrypting with multiple algorithms disclosed in an embodiment of the present application;
[0053] Figure 1b A flowchart of a method for encrypting using multiple algorithms disclosed in an embodiment of the present application;
[0054] Figure 1c A schematic diagram of an encoding method disclosed in an embodiment of the present application;
[0055] Figure 2 A flowchart of another multi-type algorithm encryption method disclosed in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of the structure of a device for multi-type algorithm encryption disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] This application discloses a multi-type algorithm encryption system, which is used to implement a multi-type algorithm encryption method disclosed in this application. For details, please refer to Figure 1a The embodiment discloses a multi-type algorithm encryption system including: a central processing unit CPU, a static random access memory SRAM, a controller module and an algorithm module. The algorithm module may further include: a symmetric algorithm submodule, an asymmetric algorithm submodule and a hash algorithm submodule. The submodules are connected through an advanced microcontroller bus architecture AMBA to communicate with each other.
[0059] In the system described in this embodiment, it can be seen that the CPU only needs to interact with the SRAM and the controller module, but not with the algorithm module, which can reduce the CPU occupancy rate. Accordingly, the algorithm module will not interact with the CPU during the process of encrypting the target data, so that it can work until all data encryption is completed, which also improves the working efficiency of the algorithm module.
[0060] As a feasible solution, since different encryption algorithms may require different types of data (such as secret keys and initial vectors, etc.), various algorithm sub-modules in the algorithm module can implement multiple types of encryption and have good applicability and versatility.
[0061] Embodiment 1: This application discloses a method for multi-type algorithm encryption.
[0062] For details, please refer to Figure 1b The present embodiment discloses a method for encrypting with multiple algorithms, including the following steps:
[0063] Step 101: The controller module responds to the control instruction from the CPU and acquires target data.
[0064] In the method described in this embodiment, the target data is filled in by the CPU based on the encryption type and stored in the SRAM.
[0065] In the method described in this embodiment, a coding method is proposed to facilitate the algorithm module to quickly implement various operations. Specifically, the CPU can fill the target data into the SRAM in the format of a data frame based on the encryption type required by the target data. Among them, the target data is composed of a mode frame (indicating the encryption type), a plaintext frame (indicating the content to be encrypted), a key frame (a tool for encryption and decryption), and an initial vector IV frame. Correspondingly, the processing of the ciphertext also adopts the format of the data frame.
[0066] Figure 1c A schematic diagram of an encoding method disclosed in an embodiment of the present application is shown in FIG. Figure 1cAs shown, each frame consists of a frame header, content and frame tail. For example, a mode frame consists of a frame header, mode and frame tail of a mode frame. However, in some types of algorithms, an initial vector IV frame or a key frame is not required, so there is no need to fill in the data at the corresponding position of the IV frame or the key frame, and only the frame header and frame tail are required. Counting data frames is to distinguish and encode each frame of data.
[0067] Step 102: The controller module sends the target data to the algorithm module according to the control instruction.
[0068] In the method described in this embodiment, the controller module obtains and parses the target data according to the control instruction to obtain the encryption type of the target data. The target data is sent to the submodule corresponding to the encryption type of the target data in the algorithm module. As an optional method, the controller module parses the target data according to the control instruction to obtain the mode frame, and obtains the target encryption type of the target data based on the mode frame. The target data content is sent to the submodule corresponding to the target encryption type for encryption.
[0069] In the method described in this embodiment, the control instruction may include the first address of the data frame, the ciphertext write-back address and the enable signal. The controller module parses the target data frame by frame according to the first address and starts counting the data frames. Figure 1c As shown, when the first pattern frame is parsed, the counter starts counting, indicating that the current frame is the first frame. The controller module also removes the frame header of the pattern frame, extracts the pattern, and sends it to the algorithm module. When the controller module parses the frame tail of the pattern frame, it indicates that the parsing of this pattern frame is completed. After the encryption and decryption operations are completed, the controller module starts parsing the second frame. Plaintext frames, secret key frames and other frames are parsed and counted in the same way. In this way, it can be ensured that the plaintext, secret key and pattern input each time are a combination of the same format, that is, they are all encoded according to the encoding method disclosed in this application, thereby ensuring the correctness of the encrypted data.
[0070] In the method described in this embodiment, after the controller module starts parsing the target data, it can also perform verification based on the parsing result of the target data. When the parsing result does not include a frame header and / or a frame tail, that is, when the encoding is not performed according to the encoding method disclosed in the present application, an error message is returned to the CPU and the parsing work is interrupted. At this time, the CPU takes over the remaining encryption work of the target data with the error message to ensure the security of the encryption.
[0071] Step 103: When the algorithm module encrypts the target data to obtain ciphertext, the controller module transmits the ciphertext back to the SRAM.
[0072] In the method described in this embodiment, when the algorithm module starts to encrypt the target data frame by frame and obtains the first frame of ciphertext, the controller module adds a ciphertext frame header in front of the first frame of ciphertext and returns it to the ciphertext write-back address of the SRAM. Afterwards, when the algorithm module encrypts, the controller module returns each frame of ciphertext obtained to the SRAM. When the algorithm module completes encryption and obtains the last frame of ciphertext, the controller module adds a ciphertext frame tail after the last frame of ciphertext, indicating that a complete set of encryption operations is completed at this time and is returned to the SRAM. For the remaining data frames, the same is true until all encryption work is completed.
[0073] In the method described in this embodiment, when the CPU wants to access the ciphertext, it can access the encryption result of any algorithm through the numbers of the ciphertext frame header and the ciphertext frame tail, that is, the counter value of the data frame.
[0074] In the method described in this embodiment, since the CPU only completes the initial reading and writing of the SRAM and the configuration of the controller module, and has no interaction with the algorithm unit, the CPU occupancy rate is greatly reduced and the CPU work efficiency is improved. During the working process of the algorithm module, there is no need to interact with the CPU, and it will work until all data encryption is completed, which also greatly improves the work efficiency of the algorithm unit. And the method described in this embodiment supports multiple types of encryption algorithms, and encodes the target data according to the data types required by different encryption algorithms. The encoding method described in this embodiment has good applicability and versatility.
[0075] Embodiment 2: This application discloses another method for multi-type algorithm encryption, please refer to Figure 2 The method described in this embodiment introduces the entire process of multi-type algorithm encryption.
[0076] Step 201: The CPU fills in the target data based on the encryption type and sends it to the SRAM.
[0077] Step 202: When the target data needs to be encrypted, the CPU sends a control instruction to the controller module.
[0078] Step 203: The controller module responds to the control instruction and obtains target data from the SRAM.
[0079] Step 204: The controller module parses the target data to determine whether each frame of the target data includes a frame header and a frame footer. If yes, proceed to step 205. If no, proceed to step 206.
[0080] Step 205: The controller module sends the target data to the submodule corresponding to the encryption type in the algorithm module according to the encryption type of the target data obtained by parsing.
[0081] Step 206: The controller module stops parsing the target data and sends the target data to the CPU for encryption. After the CPU obtains the ciphertext through encryption, the ciphertext is added to the ciphertext frame header and the ciphertext frame footer, and sent to the SRAM for storage.
[0082] Step 207: The submodule encrypts the target data and transmits the ciphertext back to the controller module.
[0083] Step 208: The controller module adds a ciphertext frame header and a ciphertext frame trailer to the ciphertext, and sends it to the SRAM for storage.
[0084] Based on the method for multi-type algorithm encryption disclosed in the above embodiment, this embodiment correspondingly discloses a device for multi-type algorithm encryption. Figure 3 , the device for multi-type algorithm encryption includes: a response unit 301, a sending unit 302 and a return unit 303;
[0085] The response unit 301 is used to respond to the control instruction from the CPU and obtain the target data; the target data is filled in by the CPU based on the encryption type and stored in the SRAM;
[0086] The sending unit 302 is used to send the target data to the algorithm module according to the control instruction;
[0087] The return unit 303 is used to return the ciphertext to the SRAM when the algorithm module encrypts the target data to obtain the ciphertext.
[0088] Optionally, the response unit 301 is used to:
[0089] The CPU fills in the target data in a data frame format based on the encryption type; the target data includes a mode frame, and the mode frame indicates the encryption type of the target data; each frame of the target data includes a frame header and a frame trailer.
[0090] Optionally, the sending unit 302 includes:
[0091] A type acquisition subunit, used to acquire and parse the target data according to the control instruction to obtain the encryption type of the target data;
[0092] The data transmission subunit is used to send the target data to the submodule in the algorithm module corresponding to the encryption type of the target data.
[0093] Optionally, the sending unit 302 includes:
[0094] A frame header acquisition subunit, used for parsing the target data according to the control instruction to obtain the mode frame;
[0095] A type parsing subunit, configured to obtain a target encryption type of the target data based on the mode frame;
[0096] The corresponding transmission subunit is used to send the target data content to the submodule corresponding to the target encryption type.
[0097] Optionally, the returning unit 303 includes:
[0098] The frame header adding subunit is used for, when the algorithm module starts to encrypt the target data frame by frame and obtains the first frame of ciphertext, the controller module adds a ciphertext frame header in front of the first frame of ciphertext and transmits it back to the SRAM;
[0099] A frame-by-frame transmission subunit, used for the controller module to transmit each frame of ciphertext obtained back to the SRAM when the algorithm module encrypts;
[0100] The frame tail adding subunit is used for, when the algorithm module completes encryption and obtains the last frame of ciphertext, the controller module adds the ciphertext frame tail after the last frame of ciphertext and transmits it back to the SRAM.
[0101] Optionally, the CPU searches for the encryption result through the numbers of the ciphertext frame header and the ciphertext frame tail.
[0102] Optionally, the target data includes first data, and the device further includes:
[0103] a verification unit, configured to verify the first data according to the parsing result, and return error information to the CPU and interrupt the work when the parsing result does not include the frame header and / or the frame tail;
[0104] A CPU processing unit is used for the CPU to process the remaining encryption work of the first data.
[0105] The embodiments in this specification are described in a progressive manner. As for the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the methods.
[0106] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0107] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0108] The features described in the embodiments of this specification can be replaced or combined with each other, so that professional and technical personnel in this field can implement or use the present application.
[0109] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for multi-type algorithm encryption, characterized in that: It is implemented by a system of multi-type algorithm encryption, the system includes a central processing unit CPU, a static random access memory SRAM, a controller module and an algorithm module; the multi-type algorithm encryption method includes: The controller module responds to the control instruction from the CPU to obtain the target data; the target data is filled in by the CPU based on the encryption type and stored in the SRAM; The controller module sends the target data to the algorithm module according to the control instruction; When the algorithm module encrypts the target data to obtain ciphertext, the controller module transmits the ciphertext back to the SRAM.
2. The method according to claim 1, characterized in that The target data is filled in by the CPU based on the encryption type, including: The CPU fills in the target data in a data frame format based on the encryption type; the target data includes a mode frame, and the mode frame indicates the encryption type of the target data; each frame of the target data includes a frame header and a frame trailer.
3. The method according to claim 1, characterized in that The step of sending the target data to an algorithm module according to the control instruction comprises: Acquire and parse the target data according to the control instruction to obtain the encryption type of the target data; The target data is sent to the submodule in the algorithm module corresponding to the encryption type of the target data.
4. The method according to claim 2 or 3, characterized in that: The step of sending the target data to an algorithm module according to the control instruction comprises: Parsing the target data according to the control instruction to obtain the mode frame; Based on the mode frame, obtaining a target encryption type of the target data; The target data content is sent to a submodule corresponding to the target encryption type.
5. The method according to claim 1, characterized in that When the algorithm module encrypts the target data to obtain ciphertext, the controller module transmits the ciphertext back to the SRAM, including: When the algorithm module starts to encrypt the target data frame by frame and obtains the first frame of ciphertext, the controller module adds a ciphertext frame header to the front of the first frame of ciphertext and transmits it back to the SRAM; When the algorithm module encrypts, the controller module transmits each frame of ciphertext obtained back to the SRAM; When the algorithm module completes encryption and obtains the last frame of ciphertext, the controller module adds a ciphertext frame tail to the end of the last frame of ciphertext and transmits it back to the SRAM.
6. The method according to claim 5, characterized in that The CPU searches for the encryption result through the numbers of the ciphertext frame header and the ciphertext frame tail.
7. The method according to claim 2, characterized in that The target data includes first data. After the controller module acquires and parses the target data according to the control instruction, the method further includes: The controller module performs verification according to the parsing result of the first data, and when the parsing result does not include a frame header and / or a frame tail, returns error information to the CPU and interrupts the work; The CPU processes the remaining encryption work of the first data.
8. A device for multi-type algorithm encryption, characterized in that: include: Response unit, sending unit and return unit; The response unit is used to respond to the control instruction from the CPU and obtain the target data; The target data is filled in by the CPU based on the encryption type and stored in the SRAM; The sending unit is used to send the target data to the algorithm module according to the control instruction; The return unit is used to return the ciphertext to the SRAM when the algorithm module encrypts the target data to obtain the ciphertext.
9. A multi-type algorithm encryption system, characterized in that: Used to implement the method described in claims 1-7, the system includes: a central processing unit CPU, a static random access memory SRAM, a controller module and an algorithm module.
10. The system according to claim 9, characterized in that The algorithm module includes: Symmetric algorithm submodule, asymmetric algorithm submodule and hash algorithm submodule; each submodule is connected through an advanced microcontroller bus architecture AMBA to communicate with each other.
Citation Information
Cited By
PLC behavior measurement method, device and equipment based on trusted 3.0 and national cryptographic algorithms
CN120871729A
PLC behavior measurement method, device and equipment based on trusted 3.0 and national secret algorithm
CN120871729B
