Data encryption and decryption method and device, equipment and medium

By dynamically selecting the encryption and decryption method on the system-level chip and switching the encryption and decryption method according to task priority and load conditions, the problems of unbalanced resource utilization and unreasonable task scheduling in traditional technology are solved, and the encryption and decryption in multi-task environments are improved Efficiency and data security.

CN119167401APending Publication Date: 2024-12-20SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411337138.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Traditional encryption and decryption technology has problems such as unbalanced resource utilization, lack of dynamic adjustment mechanisms and unreasonable task scheduling in multi-task environments, resulting in the central processor being overloaded under high load conditions and the hardware resources being underutilized, making it difficult to optimize performance.

Method used

By dynamically selecting the encryption and decryption method on the system-level chip, creating the target task based on the target data and determining the current task based on priority, calculating the central processor, memory and hardware loads. If the total load exceeds the threshold, switch the encryption and decryption method and reasonably schedule the task. To avoid resource waste and performance bottlenecks.

Benefits of technology

The optimal utilization of resources in a multi-task environment is achieved, resource waste and performance bottlenecks are avoided, and the encryption and decryption efficiency of system-level chip data security transmission is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167401A_ABST
    Figure CN119167401A_ABST
Patent Text Reader

Abstract

The invention discloses a data encryption and decryption method and device, equipment and a medium, is applied to a system-on-chip, and relates to the technical field of computers, the data encryption and decryption method comprises the following steps: determining target data according to a target read-write command, and creating a target task based on the target data; determining a current task from the target tasks through the priority, and performing encryption and decryption processing on target data corresponding to the current task by using an initial encryption and decryption mode; the encryption and decryption modes comprise a software encryption and decryption mode and a hardware encryption and decryption mode, and the hardware load is a hardware load for realizing the hardware encryption and decryption mode; calculating a total load based on the current central processing unit load, the current memory load and the current hardware load, and determining whether to switch an initial encryption and decryption mode according to the total load; if the current encryption and decryption mode is switched, the current encryption and decryption state is stored, and the target data is encrypted and decrypted according to the switched encryption and decryption mode and the current encryption and decryption state, so that resource waste or performance bottleneck can be avoided, and the encryption and decryption efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data encryption and decryption method, device, equipment and medium. Background Art

[0002] With the continuous development of information technology, data security has become a focus of attention in various industries. As a core component of modern electronic devices, the data security of the storage devices of System on Chip (SoC) is particularly important. In order to ensure the security of data transmission and storage, SoC storage devices usually use encryption and decryption technology. In the implementation of encryption and decryption technology, there are usually two main ways: software encryption and decryption and hardware encryption and decryption. Software encryption and decryption is highly flexible, easy to implement, and low cost. However, it may face performance bottlenecks under high load conditions. Hardware encryption and decryption is implemented through dedicated encryption and decryption hardware modules. It has the advantages of high performance and low latency, and can maintain stable performance under high load conditions. However, it has the disadvantages of poor flexibility, high cost, and difficult maintenance.

[0003] For the secure storage of data, using software encryption and decryption and hardware encryption and decryption each has its own advantages and disadvantages. In a multi-tasking environment, traditional encryption and decryption mechanisms face the following problems: (1) Unbalanced resource utilization: Under high load conditions, relying on software encryption and decryption may cause the central processing unit to overload, while the resources of the hardware encryption and decryption module may not be fully utilized; (2) Lack of dynamic adjustment mechanism: Traditional technologies usually use software or hardware encryption and decryption, and cannot optimize performance under different load conditions; (3) Unreasonable task scheduling: In a multi-tasking environment, the encryption and decryption requirements of tasks are different, and traditional technologies are difficult to schedule reasonably.

[0004] Therefore, the above technical problems need to be solved by those skilled in the art urgently. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a data encryption and decryption method, device, equipment and medium, which avoids resource waste or performance bottlenecks and improves encryption and decryption efficiency. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a data encryption and decryption method, which is applied to a system-level chip, comprising:

[0007] Determine the target data according to the target read / write command, and create at least one target task based on the target data; wherein different target tasks correspond to different sequence numbers and priorities;

[0008] Determine the current task from the target tasks by using the priority, and perform encryption and decryption processing on the target data corresponding to the current task by using the initial encryption and decryption method, and determine the current CPU load, the current memory load and the current hardware load; the encryption and decryption method includes a software encryption and decryption method and a hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method;

[0009] Calculating a total load based on the current CPU load, the current memory load, and the current hardware load, and determining whether to switch the initial encryption and decryption mode according to the total load;

[0010] If the initial encryption and decryption method is switched, the current encryption and decryption state corresponding to the target data is saved, and the target data is encrypted and decrypted according to the switched encryption and decryption method and the current encryption and decryption state to obtain encrypted and decrypted data.

[0011] Optionally, after creating at least one target task based on the target data, the method further includes:

[0012] Creating a target message queue, and storing the target task in the target message queue;

[0013] Accordingly, determining the current task from the target tasks according to the priority includes:

[0014] The current task is determined from the target message queue according to the priority.

[0015] Optionally, determining the current CPU load, the current memory load, and the current hardware load includes:

[0016] Determine the CPU usage time and the system startup total time, and determine the current CPU load according to the ratio of the CPU usage time to the system startup total time;

[0017] Determining the used memory and the total system memory, and determining the current memory load according to the ratio of the used memory to the total system memory;

[0018] The hardware usage time is determined, and the current hardware load is determined according to the ratio of the hardware usage time to the total system startup time.

[0019] Optionally, the calculating the total load based on the current CPU load, the current memory load and the current hardware load includes:

[0020] Determine a first load by the current CPU load and the current first weight coefficient, determine a second load by the current memory load and the current second weight coefficient, and determine a third load by the current hardware load and the current third weight coefficient;

[0021] The total load is determined according to the first load, the second load, and the third load.

[0022] Optionally, in the process of calculating the total load based on the current CPU load, the current memory load and the current hardware load, the process further includes:

[0023] Determine a first value according to the product of an initial first weight coefficient and a first adjustment factor and the product of a historical CPU load and a second adjustment factor; wherein the sum of the first adjustment factor and the second adjustment factor is 1;

[0024] determining a second value according to a product of an initial second weight coefficient and the first adjustment factor and a product of a historical memory load and the second adjustment factor;

[0025] Determine a third value according to a product of an initial third weight coefficient and the first adjustment factor and a product of a historical hardware load and the second adjustment factor;

[0026] Determine a fourth value according to the sum of the first value, the second value and the third value;

[0027] Determine a ratio of the first value to the fourth value as the current first weight coefficient;

[0028] Determine a ratio of the second value to the fourth value as the current second weight coefficient;

[0029] The ratio of the third value to the fourth value is determined as the current third weight coefficient; wherein the sum of the current first weight coefficient, the current second weight coefficient and the current third weight coefficient is 1.

[0030] Optionally, determining whether to switch the initial encryption and decryption mode according to the total load includes:

[0031] If the total load is greater than the load threshold, switching the initial encryption and decryption mode;

[0032] If the total load is not greater than the load threshold, there is no need to switch the initial encryption and decryption mode.

[0033] Optionally, in the process of encrypting and decrypting the target data corresponding to the current task by using the initial encryption and decryption method, the process further includes:

[0034] Determine whether the preset fault conditions are met;

[0035] If the preset fault condition is met, the initial encryption and decryption mode is switched.

[0036] In a second aspect, the present application discloses a data encryption and decryption device, which is applied to a system-level chip, comprising:

[0037] A data determination module, used to determine target data according to a target read / write command, and to create at least one target task based on the target data; different target tasks correspond to different sequence numbers and priorities;

[0038] A first encryption and decryption module is used to determine the current task from the target tasks according to the priority, and to perform encryption and decryption processing on the target data corresponding to the current task using an initial encryption and decryption method, and to determine the current CPU load, the current memory load, and the current hardware load; the encryption and decryption methods include software encryption and decryption methods and hardware encryption and decryption methods, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method;

[0039] A switching module, configured to calculate a total load based on the current CPU load, the current memory load and the current hardware load, and determine whether to switch the initial encryption and decryption mode according to the total load;

[0040] The second encryption and decryption module is used to save the current encryption and decryption state corresponding to the target data if the initial encryption and decryption method is switched, and to encrypt and decrypt the target data according to the switched encryption and decryption method and the current encryption and decryption state to obtain encrypted and decrypted data.

[0041] In a third aspect, the present application discloses an electronic device, comprising:

[0042] Memory, used to store computer programs;

[0043] The processor is used to execute the computer program to implement the aforementioned disclosed data encryption and decryption method.

[0044] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed data encryption and decryption method is implemented.

[0045] It can be seen that the present application proposes a data encryption and decryption method, which is applied to a system-level chip, including: determining the target data according to the target read and write command, and creating at least one target task based on the target data; wherein different target tasks correspond to different serial numbers and priorities; determining the current task from the target tasks according to the priority, and using the initial encryption and decryption method to encrypt and decrypt the target data corresponding to the current task, and determining the current central processing unit load, the current memory load and the current hardware load; the encryption and decryption method includes software encryption and decryption method and hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method; calculating the total load based on the current central processing unit load, the current memory load and the current hardware load, and determining whether to switch the initial encryption and decryption method according to the total load; if the initial encryption and decryption method is switched, then saving the current encryption and decryption state corresponding to the target data, and encrypting and decrypting the target data according to the switched encryption and decryption method and the current encryption and decryption state to obtain the encrypted and decrypted data.

[0046] Beneficial effect: Compared with the traditional technology that only uses one encryption and decryption method for encryption and decryption, the present application will dynamically select the encryption and decryption method. Specifically, the present application first encrypts and decrypts the target data corresponding to the current task based on the initial encryption and decryption method. In a multi-task environment, the present application selects the current task based on the task priority, and realizes the reasonable scheduling of multiple tasks. During the encryption and decryption process, the present application will obtain the current CPU load, the current memory load and the current hardware load, and determine whether to switch the encryption and decryption method based on the current CPU load, the current memory load and the current hardware load, and continue to encrypt and decrypt data according to the encryption and decryption method after switching. The above process reasonably utilizes the CPU resources, memory resources and hardware resources, avoids resource waste or performance bottlenecks, and improves the encryption and decryption efficiency of system-level chip data security transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention 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 invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0048] Figure 1 A flow chart of a data encryption and decryption method disclosed in this application;

[0049] Figure 2 A schematic diagram of an encrypted signature disclosed in this application;

[0050] Figure 3A schematic diagram of realizing data encryption and decryption based on a system-level chip disclosed in this application;

[0051] Figure 4 A flowchart of a specific data encryption and decryption method disclosed in this application;

[0052] Figure 5 A schematic diagram of the timeline of a multi-task adjustment software and hardware encryption and decryption method disclosed in this application;

[0053] Figure 6 A flowchart of a specific data encryption and decryption method disclosed in this application;

[0054] Figure 7 This is a schematic diagram of the structure of a data encryption and decryption method device disclosed in this application;

[0055] Figure 8 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] For the secure storage of data, using software encryption and decryption and hardware encryption and decryption each has its own advantages and disadvantages. In a multi-tasking environment, traditional encryption and decryption mechanisms face the following problems: (1) Unbalanced resource utilization: Under high load conditions, relying on software encryption and decryption may cause the central processing unit to overload, while the resources of the hardware encryption and decryption module may not be fully utilized; (2) Lack of dynamic adjustment mechanism: Traditional technologies usually use software or hardware encryption and decryption, and cannot optimize performance under different load conditions; (3) Unreasonable task scheduling: In a multi-tasking environment, the encryption and decryption requirements of tasks are different, and traditional technologies are difficult to schedule reasonably.

[0058] To this end, an embodiment of the present application proposes a data encryption and decryption solution to avoid waste of resources and improve efficiency.

[0059] The present application discloses a method for data encryption and decryption. Figure 1 As shown, the method includes:

[0060] Step S11: determining target data according to the target read / write command, and creating at least one target task based on the target data; wherein different target tasks correspond to different sequence numbers and priorities.

[0061] In order to solve the problem of uneven resource utilization in the data encryption and decryption process of the SoC system, the inability to effectively improve resource utilization, and the inability to process encryption and decryption tasks in a timely manner in multi-task scenarios, resulting in performance degradation, the present application designs a data encryption and decryption method. The core logic of this method is to create a target message queue, which specifically includes an encryption queue EQ (Encryption Queue) and a decryption queue (Decryption Queue) so as to manage multiple tasks separately and dynamically adjust the encryption and decryption method of a single task according to the load conditions, so as to improve system efficiency and resource utilization, and improve SoC system performance.

[0062] The following is the encryption and decryption task node structure defined in this embodiment:

[0063] typedef enum {

[0064] WAITING,

[0065] IN_PROGRESS,

[0066] COMPLETED

[0067] } TaskStatus;

[0068] typedef enum {

[0069] SOFTWARE,

[0070] HARDWARE

[0071] } EncryptionDecryptionType;

[0072] typedef struct Task {

[0073] int task_id;

[0074] int priority; / / 0: low, 1: medium, 2: high

[0075] EncryptionDecryptionType type;

[0076] TaskStatus status;

[0077] struct Task* next;

[0078] } Task;

[0079] The following is the encryption queue and decryption queue data structure defined in this embodiment:

[0080] #define MAX_QUEUE_SIZE 8

[0081] typedef struct EncryptionTaskQueue {

[0082] Task* front;

[0083] Task* rear;

[0084] int size;

[0085] } EncryptionQueue;

[0086] typedef struct DecryptionTaskQueue {

[0087] Task* head;

[0088] Task* tail;

[0089] int size;

[0090] }DecryptionQueue;

[0091] In this embodiment, tasks are managed in an orderly manner through a queue mechanism to ensure that tasks are executed in an orderly and efficient manner.

[0092] Specifically, this embodiment first determines the target data according to the target read and write commands, creates at least one target task based on the target data, and then stores the target task to the target message queue to achieve management of multiple tasks, wherein the target read and write commands include read commands and write commands.

[0093] Step S12: Determine the current task from the target tasks by priority, and use the initial encryption and decryption method to encrypt and decrypt the target data corresponding to the current task, and determine the current CPU load, current memory load and current hardware load; the encryption and decryption method includes software encryption and decryption method and hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method.

[0094] In this embodiment, different target tasks correspond to different sequence numbers and priorities, for example, the priority of task A is high, the priority of task B is low, and the priority of task C is medium. Further, the current task is determined from the target message queue according to the priority, for example, task A is preferentially determined as the current task. For multiple tasks of the same priority, this embodiment can consider combining the processing calculation amount of the task, the current load situation, and the task generation time to further obtain a more accurate processing order to improve processing efficiency.

[0095] After determining the current task, the target data corresponding to the current task is encrypted and decrypted using the initial encryption and decryption method. The initial encryption and decryption method can be a software encryption and decryption method or a hardware encryption and decryption method. The software encryption and decryption method and the hardware encryption and decryption method can be implemented based on the national encryption and decryption algorithm. The software encryption and decryption can use the encryption and decryption algorithm library (gmssl) for encryption and decryption operations, and the hardware encryption and decryption can call the interface of the hardware encryption and decryption module for encryption and decryption operations. Figure 2 Data encryption and signing process: Use the SM4 algorithm (block cipher algorithm) to encrypt the original data to obtain encrypted data, use the SM2 algorithm (elliptic curve public key cryptography algorithm) to sign the encrypted data to obtain the signature value, store the signature value in the data header information, and finally use the SM3 algorithm (cryptographic hash function) to calculate the header information and write the calculation result to the data header information. It should be pointed out that the decryption process is the inverse process of the encryption process.

[0096] At the same time, determine the current CPU load, current memory load and current hardware load, so as to determine whether to switch the encryption and decryption mode based on the current CPU load, current memory load and current hardware load. On the one hand, determine the CPU usage time and the total system startup time, and determine the current CPU load according to the ratio of the CPU usage time and the total system startup time, for example, L1=(CPU usage time / total system startup time)×100%, where L1 is the current CPU load; on the other hand, determine the used memory and the total system memory, and determine the current memory load according to the ratio of the used memory to the total system memory, for example, L2=(used memory / total system memory)×100%, where L2 is the current memory load; on the third hand, determine the hardware usage time, and determine the current hardware load according to the ratio of the hardware usage time to the total system startup time, for example, L3=(hardware usage time / total system startup time)×100%, where L3 is the current hardware load.

[0097] At the same time, this embodiment determines whether the preset fault condition is currently met. If the preset fault condition is met, the initial encryption and decryption method is switched to ensure the continuity and stability of encryption and decryption. Meeting the preset fault condition means that the currently used encryption and decryption method cannot continue to perform encryption and decryption work normally.

[0098] Step S13: Calculate the total load based on the current CPU load, the current memory load and the current hardware load, and determine whether to switch the initial encryption and decryption mode according to the total load.

[0099] In this embodiment, the first load is determined by the current central processing unit load and the current first weight coefficient, the second load is determined by the current memory load and the current second weight coefficient, and the third load is determined by the current hardware load and the current third weight coefficient. Furthermore, the total load is determined based on the sum of the first load, the second load and the third load.

[0100] Specifically, , in the above formula, is the weight coefficient of the CPU (Central Processing Unit / Processor) load, which is also the first weight coefficient. is the weight coefficient of memory load, which is also the second weight coefficient. is the weight coefficient of the hardware load, which is also the third weight coefficient. is the total load. Further, a load threshold is set ,For example It is set to 60%. When the total load is greater than the load threshold, the initial encryption and decryption method is switched. When the total load is not greater than the load threshold, there is no need to switch the initial encryption and decryption method.

[0101] Furthermore, the weight coefficient is dynamically adjusted based on historical performance data and current SoC system status. , , in order to optimize system performance and resource utilization, so that the SoC system can maintain the best performance in encrypting and decrypting data under different load conditions. Specifically, this embodiment determines the first value according to the product of the initial first weight coefficient and the first adjustment factor and the product of the historical CPU load and the second adjustment factor; wherein the sum of the first adjustment factor and the second adjustment factor is 1, and determines the second value according to the product of the initial second weight coefficient and the first adjustment factor and the product of the historical memory load and the second adjustment factor, and determines the third value according to the product of the initial third weight coefficient and the first adjustment factor and the product of the historical hardware load and the second adjustment factor, and determines the fourth value according to the sum of the first value, the second value and the third value, and then determines the ratio of the first value to the fourth value as the current first weight coefficient, the ratio of the second value to the fourth value as the current second weight coefficient, and the ratio of the third value to the fourth value as the current third weight coefficient; wherein the sum of the current first weight coefficient, the current second weight coefficient and the current third weight coefficient is 1.

[0102] Among them, L 1,hist is the average CPU load of the SOC over a period of time determined based on the historical CPU load, L 2,hist is the average memory load of the SoC over a period of time based on historical memory loads, L 3,hist is the average hardware load of the SoC over a period of time, 1-k is the first adjustment factor, and k is the second adjustment factor (between 0 and 1), which is used to control the influence of historical data on weight adjustment. is the initial first weight coefficient, is the initial second weight coefficient, is the initial third weight coefficient, and the first value is ×(1-k)+k×L 1,hist , the second value is ×(1-k)+k×L 2,hist , the third value is ×(1-k)+k×L 3,hist , the fourth value is Normalization_Factor= ×(1-k)+k×L 1,hist + ×(1-k)+k×L 2,hist + ×(1-k)+k×L 3,hist , so the current first weight coefficient is , the calculation of the current second weight coefficient and the calculation of the current third weight coefficient are calculated in the same way.

[0103] Exemplarily, L 1,hist = 65%, L 2,hist = 55%, L 3,hist = 45%, L1 = 70%, L2 = 60%, L3 = 50%, , if k is 0.1, then Normalization_Factor = 1.065, , , , = 0.478×70 + 0.273×60 + 0.191×50 = 59.39%, 59.39% < T = 60%, so in this case, the system does not switch the encryption and decryption method.

[0104] In this way, the SoC system can dynamically select the optimal encryption and decryption method during the process of using encrypted and decrypted data for multiple tasks, so as to ensure the best utilization of performance and resources. It should be noted that switching the encryption and decryption method requires strict security policies to save the encrypted and decrypted data status, public keys and signatures, etc., so as to ensure that there are no security vulnerabilities during the software and hardware switching process.

[0105] Step S14: If the initial encryption and decryption method is switched, save the current encryption and decryption status corresponding to the target data, and perform encryption and decryption processing on the target data according to the switched encryption and decryption method and the current encryption and decryption status to obtain the encrypted and decrypted data.

[0106] As can be seen from the above analysis, if the total load is greater than the load threshold, the initial encryption and decryption method is switched, and the current encryption and decryption status corresponding to the target data is saved, and then the target data is encrypted and decrypted according to the switched encryption and decryption method and the current encryption and decryption status.

[0107] See Figure 3 As shown, the encryption and decryption module in the system-on-chip in this embodiment is used to perform encryption and decryption processing on the data between the host and the Flash (flash) memory. In some embodiments, during the normal operation stage, the system load and data security requirements may change dynamically. According to the current load change, hardware or software encryption and decryption are selected. During the data backup and recovery stage, a large number of data read and write operations need to be performed, and at the same time, data security is ensured, and hardware encryption and decryption will be automatically selected. During the maintenance stage of the system with low load, such as system inspection and log backup, software encryption and decryption are sufficient to meet the requirements and save hardware resources at the same time.

[0108] See Figure 3 and Figure 4As shown, in a specific implementation, data is downloaded to RAM (Random Access Memory) through the host side, and the encryption and decryption module is called to perform encryption and decryption operations on the data, and then the writing of the Flash memory is completed. In another specific implementation, the data is read from the Flash memory to RAM, and the encryption and decryption module is called to perform encryption and decryption operations on the data, and then exported to the host side to complete the reading of the data. In this embodiment, the system may initially select a hardware algorithm with a higher priority for data encryption and decryption. Furthermore, the load monitoring module collects the load data of hardware encryption and decryption and software encryption and decryption in real time, and monitors the load conditions of software and hardware in real time. Specifically, the load monitoring module uses the API (Application Programming Interface) or hardware access interface provided by the RTOS (Real Time Operating System) to obtain CPU usage and memory usage, and uses the timer provided by the operating system to measure data such as the time consumption of the encryption and decryption process. Real-time load monitoring and data collection need to consider the real-time and resource constraints of the SoC, and ensure the real-time nature of the monitoring tasks to avoid affecting the response performance of key tasks. Furthermore, the load monitoring module sends the collected CPU usage, memory usage, and encryption and decryption processing time data to the dynamic switching module after preprocessing. The dynamic switching module calculates the weight of the current system and decides whether to switch the decryption operation according to the formula. The weight adjustment module regularly adjusts the weight coefficient according to the current load conditions and historical performance data. and γ to optimize system performance. The system-level chip in this embodiment may also include a data management module responsible for operations such as data storage, reading, and transmission.

[0109] See also Figure 5 As shown, Figure 5 A timeline diagram of dynamic adjustment of software and hardware encryption and decryption methods for multi-task encryption and decryption is provided. Tasks A, B, and C are all encryption tasks or decryption tasks. The three tasks have different priorities. Tasks A, B, and C are added to EQ or DQ, and the execution order of encryption and decryption tasks is determined according to the task priority. System load monitors the system load at each time point, expressed by CPU load, memory load (MEM) and hardware load (HW) to decide whether to use software encryption and decryption or hardware encryption and decryption. For example, when the hardware load of the encryption and decryption engine is low, hardware encryption and decryption is used first, such as task A. When the hardware load of the encryption and decryption engine is high, it is dynamically switched to software encryption and decryption, such as task C. After the hardware encryption and decryption task is completed, the load is reduced accordingly, the task is removed from the queue, and it is switched to hardware encryption and decryption, such as task B.

[0110] See also Figure 6 As shown, Figure 6 A dynamic switching encryption and decryption process is disclosed. In this embodiment, the load status is continuously obtained, and it is assumed that the hardware encryption and decryption is the initial encryption and decryption mode, and then it is determined whether the hardware encryption and decryption fails. If so, the current encryption and decryption state is saved and switched to the software encryption and decryption mode to continue encryption and decryption. If not, it is determined whether the total load exceeds a threshold. If so, the current encryption and decryption state is saved and switched to the software encryption and decryption mode. If not, encryption and decryption are continued using the current encryption and decryption mode.

[0111] Based on the above process, this application can achieve the following effects: (1) Efficient data encryption and decryption: By dynamically selecting software and hardware for encryption and decryption operations, the encryption and decryption efficiency of the SoC system data security transmission is improved. (2) Optimized encryption and decryption task management: The tasks that need to be encrypted and decrypted are managed in an orderly manner through the queue mechanism to ensure that the tasks are executed in an orderly and efficient manner. (3) Optimized resource utilization: The dynamic load balancing mechanism ensures the optimal utilization of system resources (such as CPU, memory, and hardware) to avoid resource waste or performance bottlenecks. (4) Flexible weight adjustment: According to the system status and historical load data, the weight coefficient is dynamically adjusted to adapt to the SoC encryption and decryption task requirements under different load conditions. (5) Improve system security: Without affecting system performance, the data encryption and decryption operations of the SoC system are guaranteed to improve data security.

[0112] It can be seen that the present application proposes a data encryption and decryption method, which is applied to a system-level chip, including: determining the target data according to the target read and write command, and creating at least one target task based on the target data; wherein different target tasks correspond to different serial numbers and priorities; determining the current task from the target tasks according to the priority, and using the initial encryption and decryption method to encrypt and decrypt the target data corresponding to the current task, and determining the current central processing unit load, the current memory load and the current hardware load; the encryption and decryption method includes software encryption and decryption method and hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method; calculating the total load based on the current central processing unit load, the current memory load and the current hardware load, and determining whether to switch the initial encryption and decryption method according to the total load; if the initial encryption and decryption method is switched, then saving the current encryption and decryption state corresponding to the target data, and encrypting and decrypting the target data according to the switched encryption and decryption method and the current encryption and decryption state to obtain the encrypted and decrypted data.

[0113] Beneficial effect: Compared with the traditional technology that only uses one encryption and decryption method for encryption and decryption, the present application will dynamically select the encryption and decryption method. Specifically, the present application first encrypts and decrypts the target data corresponding to the current task based on the initial encryption and decryption method. In a multi-task environment, the present application selects the current task based on the task priority, and realizes the reasonable scheduling of multiple tasks. During the encryption and decryption process, the present application will obtain the current CPU load, the current memory load and the current hardware load, and determine whether to switch the encryption and decryption method based on the current CPU load, the current memory load and the current hardware load, and continue to encrypt and decrypt data according to the encryption and decryption method after switching. The above process reasonably utilizes the CPU resources, memory resources and hardware resources, avoids resource waste or performance bottlenecks, and improves the encryption and decryption efficiency of system-level chip data security transmission.

[0114] Correspondingly, the embodiment of the present application also discloses a data encryption and decryption device, which is applied to a system-level chip, see Figure 7 As shown, the device comprises:

[0115] The data determination module 11 is used to determine the target data according to the target read / write command, and create at least one target task based on the target data; different target tasks correspond to different sequence numbers and priorities.

[0116] The first encryption and decryption module 12 is used to determine the current task from the target tasks according to the priority, and use the initial encryption and decryption method to encrypt and decrypt the target data corresponding to the current task, and determine the current central processing unit load, the current memory load and the current hardware load; the encryption and decryption method includes software encryption and decryption method and hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method.

[0117] The switching module 13 is used to calculate the total load based on the current CPU load, the current memory load and the current hardware load, and determine whether to switch the initial encryption and decryption mode according to the total load.

[0118] The second encryption / decryption module 14 is used to save the current encryption / decryption state corresponding to the target data if the initial encryption / decryption mode is switched, and to encrypt / decrypt the target data according to the switched encryption / decryption mode and the current encryption / decryption state to obtain the encrypted / decrypted data.

[0119] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0120] It can be seen that the present application proposes a data encryption and decryption method, which is applied to a system-level chip, including: determining the target data according to the target read and write command, and creating at least one target task based on the target data; wherein different target tasks correspond to different serial numbers and priorities; determining the current task from the target tasks according to the priority, and using the initial encryption and decryption method to encrypt and decrypt the target data corresponding to the current task, and determining the current central processing unit load, the current memory load and the current hardware load; the encryption and decryption method includes software encryption and decryption method and hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method; calculating the total load based on the current central processing unit load, the current memory load and the current hardware load, and determining whether to switch the initial encryption and decryption method according to the total load; if the initial encryption and decryption method is switched, then saving the current encryption and decryption state corresponding to the target data, and encrypting and decrypting the target data according to the switched encryption and decryption method and the current encryption and decryption state to obtain the encrypted and decrypted data.

[0121] Beneficial effect: Compared with the traditional technology that only uses one encryption and decryption method for encryption and decryption, the present application will dynamically select the encryption and decryption method. Specifically, the present application first encrypts and decrypts the target data corresponding to the current task based on the initial encryption and decryption method. In a multi-task environment, the present application selects the current task based on the task priority, and realizes the reasonable scheduling of multiple tasks. During the encryption and decryption process, the present application will obtain the current CPU load, the current memory load and the current hardware load, and determine whether to switch the encryption and decryption method based on the current CPU load, the current memory load and the current hardware load, and continue to encrypt and decrypt data according to the encryption and decryption method after switching. The above process reasonably utilizes the CPU resources, memory resources and hardware resources, avoids resource waste or performance bottlenecks, and improves the encryption and decryption efficiency of system-level chip data security transmission.

[0122] Furthermore, an embodiment of the present application also provides an electronic device. Figure 8 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0123] Figure 8The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the data encryption / decryption method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0124] In this embodiment, the power supply 26 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0125] In addition, the memory 22, as a carrier for storing resources, may be a read-only memory, a random access memory, a disk or an optical disk, etc., and the resources stored thereon may include a computer program 221, and the storage method may be temporary storage or permanent storage. In addition to including a computer program that can be used to complete the data encryption and decryption method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 221 may further include a computer program that can be used to complete other specific tasks.

[0126] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed data encryption and decryption method is implemented.

[0127] For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.

[0128] Furthermore, an embodiment of the present application also discloses a computer program product, including a computer program / instruction, which implements the steps of the data encryption and decryption method disclosed above when executed by a processor.

[0129] The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0130] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0131] 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.

[0132] Finally, it should 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.

[0133] The above is a detailed introduction to a data encryption and decryption method, device, equipment, and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data encryption and decryption method, characterized in that: Applications in system-level chips include: Determine the target data according to the target read / write command, and create at least one target task based on the target data; wherein different target tasks correspond to different sequence numbers and priorities; Determine the current task from the target tasks by using the priority, and perform encryption and decryption processing on the target data corresponding to the current task by using the initial encryption and decryption method, and determine the current CPU load, the current memory load and the current hardware load; the encryption and decryption method includes a software encryption and decryption method and a hardware encryption and decryption method, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method; Calculating a total load based on the current CPU load, the current memory load, and the current hardware load, and determining whether to switch the initial encryption and decryption mode according to the total load; If the initial encryption and decryption method is switched, the current encryption and decryption state corresponding to the target data is saved, and the target data is encrypted and decrypted according to the switched encryption and decryption method and the current encryption and decryption state to obtain encrypted and decrypted data.

2. The data encryption and decryption method according to claim 1, characterized in that: After creating at least one target task based on the target data, the method further includes: Creating a target message queue, and storing the target task in the target message queue; Accordingly, determining the current task from the target tasks according to the priority includes: The current task is determined from the target message queue according to the priority.

3. The data encryption and decryption method according to claim 1, characterized in that: The determining of the current CPU load, the current memory load and the current hardware load includes: Determine the CPU usage time and the system startup total time, and determine the current CPU load according to the ratio of the CPU usage time to the system startup total time; Determining the used memory and the total system memory, and determining the current memory load according to the ratio of the used memory to the total system memory; The hardware usage time is determined, and the current hardware load is determined according to the ratio of the hardware usage time to the total system startup time.

4. The data encryption and decryption method according to claim 3, characterized in that: The calculating the total load based on the current CPU load, the current memory load and the current hardware load includes: Determine a first load by the current CPU load and the current first weight coefficient, determine a second load by the current memory load and the current second weight coefficient, and determine a third load by the current hardware load and the current third weight coefficient; The total load is determined according to the first load, the second load, and the third load.

5. The data encryption and decryption method according to claim 4, characterized in that: The process of calculating the total load based on the current CPU load, the current memory load and the current hardware load also includes: Determine a first value according to the product of an initial first weight coefficient and a first adjustment factor and the product of a historical CPU load and a second adjustment factor; wherein the sum of the first adjustment factor and the second adjustment factor is 1; determining a second value according to a product of an initial second weight coefficient and the first adjustment factor and a product of a historical memory load and the second adjustment factor; Determine a third value according to a product of an initial third weight coefficient and the first adjustment factor and a product of a historical hardware load and the second adjustment factor; Determine a fourth value according to the sum of the first value, the second value and the third value; Determine a ratio of the first value to the fourth value as the current first weight coefficient; Determine a ratio of the second value to the fourth value as the current second weight coefficient; The ratio of the third value to the fourth value is determined as the current third weight coefficient; wherein the sum of the current first weight coefficient, the current second weight coefficient and the current third weight coefficient is 1.

6. The data encryption and decryption method according to claim 1, characterized in that: The determining whether to switch the initial encryption and decryption mode according to the total load includes: If the total load is greater than the load threshold, switching the initial encryption and decryption mode; If the total load is not greater than the load threshold, there is no need to switch the initial encryption and decryption mode.

7. The data encryption and decryption method according to any one of claims 1 to 6, characterized in that: In the process of encrypting and decrypting the target data corresponding to the current task using the initial encryption and decryption method, it also includes: Determine whether the preset fault conditions are met; If the preset fault condition is met, the initial encryption and decryption mode is switched.

8. A data encryption and decryption device, characterized in that: Applications in system-level chips include: A data determination module, used to determine target data according to a target read / write command, and to create at least one target task based on the target data; different target tasks correspond to different sequence numbers and priorities; A first encryption and decryption module is used to determine the current task from the target tasks according to the priority, and to perform encryption and decryption processing on the target data corresponding to the current task using an initial encryption and decryption method, and to determine the current CPU load, the current memory load, and the current hardware load; the encryption and decryption methods include software encryption and decryption methods and hardware encryption and decryption methods, and the hardware load is the load of the hardware that implements the hardware encryption and decryption method; A switching module, configured to calculate a total load based on the current CPU load, the current memory load and the current hardware load, and determine whether to switch the initial encryption and decryption mode according to the total load; The second encryption and decryption module is used to save the current encryption and decryption state corresponding to the target data if the initial encryption and decryption method is switched, and to encrypt and decrypt the target data according to the switched encryption and decryption method and the current encryption and decryption state to obtain encrypted and decrypted data.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the data encryption and decryption method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the data encryption and decryption method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Data encryption method and data decryption method

    CN122204409A