Processor, computer system, key management method, and data encryption and decryption method

By sharing the key encryption register and the initial working key processing module in the processor's physical core, a consistent initial working key is generated, and the operating system participation is reduced, the problem of time-consuming key packaging is solved, and the key management efficiency and system security are improved.

CN120498649APending Publication Date: 2025-08-15HYGON INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510782198.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing key packaging technology takes a long time, resulting in low key management efficiency, and the operating system frequently participates in IWKEY loading and synchronization operations to increase complexity.

Method used

In each physical core of the processor, a key encryption register is shared to store the initial value, and the initial working key is generated through the initial working key processing module, and the key encapsulation is used to reduce the participation of the operating system.

Benefits of technology

It improves the efficiency of key encapsulation, reduces the complexity and loading time of the key encryption process, ensures the consistency of the initial working key generated by the logical core, and improves the security and flexibility of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120498649A_ABST
    Figure CN120498649A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a processor, a computer system, a key management method and a data encryption and decryption method, and the processor comprises at least one physical core; each physical core comprises at least one logic core and a register shared by each logic core; the shared register comprises a key encryption register, and an initial value used for generating an initial working key is stored in the key encryption register; and each logic core comprises an initial working key processing module which is used for generating an initial working key based on the initial value provided by the key encryption register and packaging the input initial key by using the initial working key to form a handle. According to the technical scheme provided by the embodiment of the invention, the key packaging efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and specifically to a processor, a computer system, a key management method, and a data encryption and decryption method. Background Art

[0002] With the rapid development of computer and network technologies, data security has become increasingly important, and key management is a core component of data security. Key encapsulation technology has emerged to address the security and efficiency challenges of key management. By encapsulating keys into encrypted handles, key encapsulation ensures that the keys remain encrypted during transmission and storage, significantly reducing the risk of key leakage.

[0003] However, the implementation of key encapsulation technology takes a long time. Therefore, how to provide a technical solution to improve the efficiency of key encapsulation has become a technical problem that those skilled in the art need to solve urgently. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a processor, a computer system, a key management method, and a data encryption and decryption method to improve the efficiency of key encapsulation.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions.

[0006] In a first aspect, an embodiment of the present invention provides a processor, comprising: at least one physical core; each physical core comprising at least one logical core and a register shared by each logical core;

[0007] The shared register includes a key encryption register, wherein the key encryption register stores an initial value for generating an initial working key;

[0008] Each logical core includes:

[0009] The initial working key processing module is configured to generate an initial working key based on at least an initial value provided by the key encryption register, and to encapsulate an input initial key using at least the initial working key to form a handle.

[0010] In a second aspect, an embodiment of the present invention provides a computer system, comprising the processor as described in the first aspect.

[0011] In a third aspect, an embodiment of the present invention provides a key management method, applied to the processor described in the first aspect, comprising:

[0012] Obtaining a pre-stored initial value; the initial value is shared by each logical core of each physical core on the processor;

[0013] generating an initial working key based at least on the initial value;

[0014] The input initial key is encapsulated using at least the initial working key to generate a handle.

[0015] In a fourth aspect, an embodiment of the present invention provides a data encryption and decryption method, comprising:

[0016] Obtaining an input initial key, where the input initial key is obtained by decrypting the initial working key and the handle; the initial working key and the handle are obtained based on the key management method described in the third aspect;

[0017] Executing a key expansion instruction to expand the input initial key to generate a round key;

[0018] The data is encrypted or decrypted using the round key.

[0019] A processor provided by an embodiment of the present invention includes: at least one physical core; each physical core includes at least one logical core and a register shared by each logical core; the shared register includes a key encryption register, and the key encryption register stores an initial value for generating an initial working key; each logical core includes: an initial working key processing module, which is used to generate an initial working key based on at least the initial value provided by the key encryption register, and at least use the initial working key to encapsulate the input initial key to form a handle.

[0020] It can be seen that the technical solution provided by the embodiment of the present invention is to add a key encryption register for storing the initial value used to generate the initial working key in each physical core, for the register shared by each logical core included in the physical core; since each logical core shares a register, the initial value stored in the key encryption register in the shared register can also be shared by each logical core; and then each logical core can generate the same initial working key in real time based on the same initial value using the initial working key processing module; using the same initial value can ensure the consistency of the initial working keys generated by each logical core; to ensure that all physical cores and logical cores use the same initial working key, the operating system is usually responsible for managing the loading and distribution of the initial working key. Therefore, based on the added key encryption register and initial working key processing module in the embodiment of the present invention, the consistency of the initial working keys generated by each logical core can be ensured while avoiding the frequent operation of the operating system, reducing the complexity of the key encryption process and the time-consuming loading and distribution of the initial working key; therefore, the purpose of improving the efficiency of key encapsulation can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0022] Figure 1a is a schematic structural diagram of a processor provided by an embodiment of the present invention;

[0023] Figure 1b yes Figure 1a A schematic structural diagram of an initial working key processing module in the provided processor;

[0024] Figure 2 1 is a schematic structural diagram of a random initial working key generation circuit provided by an embodiment of the present invention;

[0025] Figure 3 1 is a schematic diagram of the structure of a handle encryption circuit provided by an embodiment of the present invention;

[0026] Figure 4 1 is a schematic diagram of a working process of a handle decryption circuit provided by an embodiment of the present invention;

[0027] Figure 5a This is a structural diagram of a data encryption and decryption module provided by an embodiment of the present invention;

[0028] Figure 5b This is a schematic diagram of a data encryption and decryption process provided by an embodiment of the present invention;

[0029] Figure 6 is a schematic structural diagram of a computer system provided by an embodiment of the present invention;

[0030] Figure 7 This is a flowchart of a key management method provided by an embodiment of the present invention;

[0031] Figure 8 is another flowchart of the key management method provided by an embodiment of the present invention;

[0032] Figure 9 The figure is a flow chart of a data encryption and decryption method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0033] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.

[0034] Key encapsulation technology uses an Initial Working Key (IWKEY) to encapsulate the input initial key into a handle. By encapsulating the input initial key (provided by the user and located in the data encryption or decryption instructions), it effectively protects the security of the input initial key during transmission and storage, reduces the risk of input initial key leakage, simplifies the management process of the input initial key, and improves the overall performance and flexibility of the system.

[0035] However, when using key encapsulation technology to encapsulate the input initial key, to ensure system security and consistency, the IWKEY used by each logical core on each physical core of the processor must be consistent when executing the LOADIWKEY (initial working key load instruction) to load the IWKEY. This IWKEY consistency is guaranteed by the operating system.

[0036] The operating system manages resource allocation and synchronization across multiple logical cores. To ensure that all logical cores use the same IWKEY, the operating system frequently loads and synchronizes IWKEYs. For example, when one logical core loads a new IWKEY, the operating system must ensure that other logical cores also load the same IWKEY, or synchronize the IWKEY state between logical cores. This complicates the key encapsulation process and results in a longer time-consuming process.

[0037] Based on this, an embodiment of the present invention provides a processor to improve the efficiency of key encapsulation.

[0038] Please refer to Figure 1a , Figure 1a It is a structural diagram of a processor provided by an embodiment of the present invention.

[0039] like Figure 1a As shown, the processor 1 includes:

[0040] At least one physical core 11 i (i=1, ..., M);

[0041] 11 per physical core i Includes: at least one logical core 12 j (j=1, ..., N) and a logic core 12j Shared register 13;

[0042] The shared register 13 includes a key encryption register 131, wherein the key encryption register 131 stores an initial value for generating an initial working key;

[0043] 12 per logical core j include:

[0044] Initial working key processing module 121 j , used to generate an initial working key based on at least the initial value provided by the key encryption register 131, and to encapsulate the input initial key using at least the initial working key to form a handle.

[0045] The key encryption register (global key encryption register) 131 is located in the shared register 13, so each logic core 12 j The initial value in the key encryption register 131 can be shared. The initial value can be provided by the user and pre-stored in the key encryption register 131, so that when key encapsulation is required, each logical core 12 j Can share an initial value to ensure that each logical core 12 j Initial working key processing module 121 j The consistency of the generated initial working key.

[0046] Based on the above content, it can be seen that in order to ensure the logical core 12 j The initial working key used is consistent, and the operating system is usually responsible for managing the initial working key in each logical core. j Loading and distribution on the cores to ensure that all physical and logical cores use the same IWKEY. The specific steps are as follows:

[0047] (1) Generate or obtain IWKEY

[0048] The operating system can generate IWKEY using a hardware random number generator (RNG) or a software pseudo-random number generator (PRNG).

[0049] The operating system can obtain IWKEY from a hardware security module (HSM) or other secure storage.

[0050] (2) Distributing IWKEY

[0051] The operating system distributes the generated or obtained IWKEY to all physical cores.

[0052] Each physical core then distributes IWKEY to all logical cores on it.

[0053] (3) Load IWKEY

[0054] The operating system loads IWKEY into a dedicated register or secure memory area of each logical core by executing the LOADIWKEY instruction.

[0055] It can be seen that the above method of ensuring the consistency of the initial working key increases the involvement and complexity of the operating system and affects the key encryption (encapsulation) process.

[0056] Therefore, in the embodiment of the present invention, a key encryption register 131 and an initial working key processing module 121 are added. j , realize each logical core 12 j The consistency of the initial working key used avoids the involvement of the operating system and improves the efficiency of the key (the input initial key for data encryption and decryption) packaging process.

[0057] It can be seen that the technical solution provided by the embodiment of the present invention is that in each physical core 11 i In the physical core 11 i Included logical cores 12 j The shared register 13 is additionally provided with a key encryption register 131 for storing an initial value for generating an initial working key; j Share a register, so the initial value stored in the key encryption register 131 in the shared register 13 can also be used by each logical core 12 j Shared; and then each logical core 12 j Based on the same initial value, the initial working key processing module 121 can be used j Generate the same initial working key in real time; using the same initial value can ensure that each logical core 12 j To ensure that all physical cores and logical cores use the same initial working key, the operating system is usually responsible for managing the loading and distribution of the initial working key. j , which can ensure that each logical core 12 j While ensuring the consistency of the generated initial working key, it avoids frequent operation of the operating system, reduces the complexity of the key encryption process and the time consumption of loading and distributing the initial working key; therefore, it can achieve the purpose of improving the key encapsulation efficiency.

[0058] In order to support reliable generation and use of the initial working key, in one embodiment, the initial working key processing module 121j The initial working key random generation circuit 122 may be included j , handle encryption circuit 123 j For its structure, please refer to Figure 1b , Figure 1b yes Figure 1a A structural diagram of an initial working key processing module in a processor is provided.

[0059] like Figure 1b As shown:

[0060] The initial working key random generation circuit 122 j , used to generate an initial working key based on at least an initial value provided by the key encryption register;

[0061] The handle encryption circuit 123 j , used to encapsulate the input initial key based on at least the initial working key to generate a handle.

[0062] The initial working key is generated based on a random number (random initial value), and each logical core 12 j If the generated initial working keys are the same, the random numbers used are also the same. The same random numbers can be determined based on the initial value stored in the key encryption register 131.

[0063] Each logical core 12 j Initial working key random generation circuit 122 j Based on the same random initial value, the consistency of the generated initial working key can be ensured, meeting the security requirements of the system. After the initial working key is generated, key encapsulation technology can be implemented, that is, the input initial key is encapsulated with the initial working key to generate a handle to protect the security of the input initial key.

[0064] Please refer to Figure 2 , Figure 2 The figure is a schematic structural diagram of a random initial working key generation circuit provided by an embodiment of the present invention.

[0065] like Figure 2 As shown, the initial working key random generation circuit 122 j include:

[0066] The random initial value determination module 1221 is used to determine the initial value stored in the key encryption register 131 and the logic core 12 j The built-in initial value determines the random initial value;

[0067] The random generator 1222 is used to generate an initial working key according to the random initial value.

[0068] Logical core 12j The built-in initial value refers to the logical core 12 j The default state at reset or startup typically includes:

[0069] Initial values of registers: For example, general registers (such as the extended accumulator register and the extended base register) and status registers (such as the extended flag register) are set to default values at reset.

[0070] Memory map: The initial memory map state of the logical core, including the stack pointer, program counter, etc.

[0071] Hardware status: for example, interrupt enable status, cache status, etc.

[0072] The purpose of these built-in initial values is to ensure that the logical core 12 j In a consistent and predictable state at startup so that programs can execute correctly.

[0073] Logical core 12 j The built-in initial value ensures that all logical cores 12 j The state is consistent when reset or started. This consistency provides a reliable starting point for subsequent operations (including random number generation and IWKEY generation). Therefore, when determining the random initial value, it is determined based on the built-in initial value and the initial value stored in the key encryption register 131, which fully ensures that each logical core 12 j Furthermore, when the random generator 1222 generates the initial working key based on the random initial value, each logical core 12 j Use the same initial working key.

[0074] Please refer to Figure 3 , Figure 3 It is a structural diagram of a handle encryption circuit provided by an embodiment of the present invention.

[0075] like Figure 3 As shown, the handle encryption circuit 123 j include:

[0076] An encryption information acquisition module 1231 is configured to acquire the initial working key generated by the random generator 1222, the data processing instructions stored in the memory, and the control information stored in the key encryption register 131, wherein the data processing instructions include the authorization code and the input initial key;

[0077] The handle encryption module 1232 is used to encapsulate the input initial key using the initial working key, the control information and the authorization code to generate a handle.

[0078] The authorization code and the input initial key are carried by a data processing instruction, and the data processing instruction may be a data encryption instruction or a data decryption instruction.

[0079] The authorization code has the following functions:

[0080] Authentication: The authorization code verifies the identity of the requester, ensuring that only authorized entities can access or operate the wrapped key. This prevents unauthorized users or systems from accessing sensitive key information.

[0081] Prevent replay attacks: The authorization code can contain a timestamp or other one-time use token to prevent attackers from obtaining the key through replay attacks.

[0082] Access control: Authorization codes can be used to implement fine-grained access control, ensuring that only specific users or systems can decapsulate keys under specific conditions.

[0083] Control information (user restriction information) has the following functions:

[0084] Key usage restrictions: Control information can specify the usage of the wrapped key, for example, restricting the key to be used only for specific operations or specific data. This can prevent the key from being misused.

[0085] Lifecycle management: Control information can include information such as the validity period and number of uses of the key to help manage the key lifecycle and ensure that the key is used within a safe time frame.

[0086] Audit and tracing: Control information can record the use of keys, facilitate auditing and tracing, and ensure the security and compliance of the system.

[0087] Therefore, when using IWKEY to encapsulate the initial key input, introducing authorization codes and control information can enhance the security and flexibility of computer systems. The authorization code verifies the identity of the requester, preventing unauthorized access and replay attacks; the control information restricts key usage, manages the key lifecycle, and supports flexible key management policies. These mechanisms effectively improve the security and adaptability of computer systems and ensure the safe use of the initial key input.

[0088] To support the complete usage process for the initial working key, in one embodiment, please continue to refer to Figure 1a and Figure 1b .like Figure 1b and Figure 1a As shown, the initial working key processing module 121 j , further comprising: a handle decryption circuit 124 j , the handle decryption circuit 124 j, used to decrypt the handle using the initial working key to obtain the input initial key;

[0089] The logic core 12 j It may also include:

[0090] Data encryption and decryption module 125 j , used to encrypt or decrypt data based on the input initial key obtained after decryption.

[0091] The handle decryption circuit 124 j The working process can be referred to Figure 4 , Figure 4 The figure is a schematic diagram of a working process of a handle decryption circuit provided by an embodiment of the present invention.

[0092] like Figure 4 As shown, the key encryption register 131 is the initial working key random generation circuit 122 j Provides initial value, initial working key random generation circuit 122 j Based on initial value and logic core 12 j The built-in initial value generates an initial working key and provides the initial working key to the handle decryption circuit 124 j At the same time, the handle encryption circuit provides the generated handle to the handle decryption circuit 124 j , and providing the authorization code to the handle decryption circuit 124 j Handle decryption circuit 124 j The handle is decrypted using the initial working key and the authorization code, and the input initial key encapsulated by the handle is decrypted so that the input initial key obtained after decryption can be used to encrypt or decrypt data later.

[0093] In the symmetric encryption and decryption algorithm, the initial working key used in the encapsulation process (handle encryption) and the decapsulation process (handle decryption) of the input initial key must remain consistent. The encryption and decryption algorithms used in the embodiments of the present invention are mainly the State Migration Symmetric Key Block Cipher algorithm (SM4) or the Advanced Encryption Standard (AES) algorithm, both of which are symmetric encryption algorithms. Therefore, when decrypting the handle, the initial working key used is consistent with the initial working key used in the handle encryption process, and the initial working key in the encryption process can be used to decrypt the handle.

[0094] The initial key obtained after decryption is used in the data encryption and decryption process. In other stages, the initial key can be encapsulated and protected by the handle to prevent leakage of the initial key. Therefore, the initial key can be used as intermediate data and not directly stored, ensuring the security of the initial key.

[0095] Please refer to Figure 5a , Figure 5a It is a structural diagram of a data encryption and decryption module provided by an embodiment of the present invention.

[0096] like Figure 5a As shown, the data encryption and decryption module 125 j include:

[0097] The key expansion module 1251 is used to execute the key expansion instruction to expand the input initial key obtained after decryption to generate round keys;

[0098] The data encryption and decryption circuit 1252 is configured to encrypt or decrypt data using the round key.

[0099] The key expansion module 1251 can receive the key from the handle decryption circuit 124 j The input initial key is obtained after decryption, and then the key expansion instruction is executed for the input initial key to generate the round key used in each round of encryption or decryption process. The round key is used as the key to complete the encryption and decryption of the data.

[0100] In order to further speed up the execution process of data encryption and decryption and improve the execution efficiency of data encryption and decryption, in some implementations, the current handle decryption process can be pre-detected and judged to avoid unnecessary handle decryption operations. Figure 5b , Figure 5b It is a schematic diagram of a process of data encryption and decryption provided by an embodiment of the present invention.

[0101] like Figure 5b As shown, the logic core 12 j It may also include:

[0102] Detection unit 126 j , used in the handle decryption circuit 124 j Before performing a handle decryption operation on the currently received handle using the currently received initial working key and authorization code, determine whether the current handle, the current initial working key, and the current authorization code are the same as the handle, the initial working key, and the authorization code used in the previous handle decryption operation;

[0103] If yes, the handle decryption circuit 124 is controlled jStop executing the current handle decryption operation and control the data encryption / decryption circuit 1252 to use the cached round key to encrypt or decrypt the data; the cached round key is generated after the key expansion instruction is executed last time;

[0104] If not, the handle decryption circuit 124 is controlled j The handle is decrypted using the current initial working key and authorization code to obtain the input initial key.

[0105] Key expansion is the process of converting an initial input key into multiple round keys through a series of algorithms. These round keys are used in each round of encryption or decryption. For example, the SM4 algorithm uses a 128-bit initial input key to generate 32 round keys, each used in one round of encryption or decryption.

[0106] In symmetric encryption algorithms (such as state-transfer symmetric-key block ciphers), multiple data blocks typically use the same extended round key. This is because symmetric encryption algorithms are designed to allow the same round key to be used to encrypt or decrypt multiple data blocks. Since the encryption and decryption processes are reversible, encrypted data can be correctly decrypted using the same round key.

[0107] Using the same expanded round key for multiple data items indicates that the initial key input remains unchanged throughout the encryption or decryption process, and therefore the round key generated after expansion also remains unchanged. Using the same expanded round key also reduces the computational overhead of key expansion and improves encryption or decryption efficiency.

[0108] Therefore, in the case where the same expanded round key can be used for the above-mentioned multiple data, since the same expanded round key indicates that the input initial key has not changed, it also indicates that the handle and initial working key used to encrypt the input initial key have not changed. Therefore, in this case, the round key after the previous expansion can be cached, and the current handle, initial working key, and authorization code can be pre-tested. If it is determined that the handle, initial working key, and authorization code used in the previous handle decryption operation are the same, the round key cached after the previous expansion can be directly used to encrypt and decrypt the data, avoiding the execution of the handle decryption operation and the expansion operation of the input initial key obtained after decryption. This can save time in data encryption or decryption and improve the efficiency of data encryption or decryption.

[0109] In one embodiment, the data encryption and decryption module 125 jThe encryption and decryption algorithms to be run may include the state transition symmetric key block cipher algorithm (SM4) or the advanced encryption standard (AES) algorithm. j The handle encryption algorithm that is run includes: SM4 handle encryption algorithm or AES handle encryption algorithm; the handle decryption algorithm that is run includes: SM4 handle decryption algorithm or AES handle decryption algorithm.

[0110] Compared with the case where the AES algorithm is used directly without using a detection unit, in the embodiment of the present invention, the detection unit 126 is used. j In this case, the performance of data encryption and decryption using the SM4 algorithm can be improved by about 33%. It can be seen that the processor provided by the embodiment of the present invention can not only support the encryption and decryption of handles under the SM4 algorithm, but also improve the overall performance of the processor.

[0111] The embodiment of the present invention also provides a computer system, please refer to Figure 6 , Figure 6 It is a structural diagram of a computer system provided by an embodiment of the present invention.

[0112] like Figure 6 As shown, the computer system may include:

[0113] The processor 1 provided by any of the aforementioned embodiments.

[0114] The processor (Processor) 1 can be a central processing unit (CPU), or a graphics processing unit (GPU) or other processors that can perform data processing tasks.

[0115] Optionally, the computer system may further include:

[0116] The memory 2 is used to store data processing instructions, encrypted data (ciphertext) and decrypted data (plaintext), wherein the data processing instructions include an authorization code and an input initial key.

[0117] The data processing instruction is a data encryption instruction or a data decryption instruction.

[0118] The memory 2 may be, for example, a static random access memory (SRAM), a dynamic random access memory (DRAM), or the like.

[0119] Optionally, the memory 2 may also store a handle to facilitate detection by the detection unit.

[0120] It can be seen that the technical solution provided by the embodiment of the present invention is that, in each physical core of the processor 1, a key encryption register for storing the initial value used to generate the initial working key is added for the register shared by each logical core included in the physical core; since each logical core shares a register, the initial value stored in the key encryption register can also be shared by each logical core; and then each logical core can generate the initial working key in real time based on the same initial value using the initial working key processing module; using the same initial value can ensure the consistency of the initial working keys generated by each logical core; to ensure that all physical cores and logical cores use the same initial working key, the operating system is usually responsible for managing the loading and distribution of the initial working key. Therefore, based on the additional key encryption register and initial working key processing module in the embodiment of the present invention, the consistency of the initial working keys generated by each logical core can be ensured while avoiding the frequent operation of the operating system, reducing the complexity of the key encryption process and the time consumption of loading and distributing the initial working key, thereby achieving the purpose of improving the efficiency of key encapsulation.

[0121] An embodiment of the present invention further provides a key management method, which is applied to the processor described in any of the aforementioned embodiments.

[0122] Please refer to Figure 7 , Figure 7 This is a flowchart of a key management method provided by an embodiment of the present invention.

[0123] like Figure 7 As shown, the method includes the following steps:

[0124] Step S710: Obtain a pre-stored initial value.

[0125] The initial value is shared by each logical core of each physical core on the processor.

[0126] The initial value is pre-stored in a key encryption register of the processor so as to be shared by all logical cores in the physical core of the processor.

[0127] Step S711: Generate an initial working key based at least on the initial value.

[0128] The logical cores share the initial value, so the consistency of the generated initial working keys can be distinguished, meeting the requirements of key encapsulation.

[0129] Step S712: Encapsulate the input initial key using at least the initial working key to generate a handle.

[0130] It can be seen that the technical solution provided by the embodiment of the present invention, since each logical core shares an initial value; thus, each logical core can generate an initial working key in real time based on the same initial value; using the same initial value can ensure the consistency of the initial working keys generated by each logical core; to ensure that all physical cores and logical cores use the same initial working key, the operating system is usually responsible for managing the loading and distribution of the initial working key. Therefore, the embodiment of the present invention can ensure the consistency of the initial working key used by each logical core while avoiding the frequent operation of the operating system, reducing the complexity of the key encryption process and the time consumption of loading and distributing the initial working key, thereby achieving the purpose of improving the efficiency of key encapsulation.

[0131] Please refer to Figure 8 , Figure 8 This is another flowchart of the key management method provided by an embodiment of the present invention.

[0132] like Figure 8 As shown, the method includes the following steps:

[0133] Step S810: Acquire the built-in initial value of the logic core.

[0134] The built-in initial value can provide a reliable implementation basis for the subsequent generation of a unified random initial value and an initial working key.

[0135] Step S811: Obtain a pre-stored initial value.

[0136] Step S812: Determine a random initial value based on the built-in initial value and the initial value.

[0137] Step S813: Generate an initial working key using the random initial value.

[0138] Step S814: Encapsulate the input initial key using the authorization code, pre-stored control information, and the initial working key to generate a handle.

[0139] The authorization code and the input initialization key are located in the data processing instruction. The control information is shared by each logical core of each physical core on the processor.

[0140] The main purpose of introducing authorization codes and control information when using IWKEY to encapsulate keys is to enhance the security and flexibility of computer systems.

[0141] Step S815: When encrypting and decrypting data, the handle is decrypted using the initial working key and the authorization code to obtain the input initial key.

[0142] Since the input initial key is encapsulated and protected by the initial working key, when the input initial key is needed to encrypt or decrypt data, the handle can be decrypted to obtain the input initial key that can be used to encrypt or decrypt data.

[0143] An embodiment of the present invention further provides a data encryption and decryption method for performing data encryption and decryption operations using an input initial key protected by the key management method provided by the aforementioned embodiment.

[0144] Please refer to Figure 9 , Figure 9 The figure is a flow chart of a data encryption and decryption method provided by an embodiment of the present invention.

[0145] like Figure 9 As shown, the method includes the following steps:

[0146] Step S911, obtain and input the initial key.

[0147] The input initial key is obtained by decrypting the initial working key and the handle.

[0148] The initial working key and handle are obtained based on any of the aforementioned key management methods;

[0149] Step S912: Execute the key expansion instruction to expand the input initial key to generate a round key.

[0150] Step S913: encrypt or decrypt the data using the round key.

[0151] Since the input initial key is protected by the initial working key, the security of the input initial key can be ensured. When the input initial key is used to encrypt and decrypt data, the security of the data encryption and decryption process can be enhanced.

[0152] Please continue to refer to Figure 9 , the method may further include:

[0153] Step S908: Obtain the current handle, initial working key and authorization code to perform a decryption operation on the current handle.

[0154] Step S909: Determine whether the current handle, initial working key, and authorization code are the same as the previous handle, initial working key, and authorization code. If yes, proceed to step S914; if not, proceed to step S910.

[0155] Step S910: Decrypt the handle using the current initial working key and the authorization code to obtain the input initial key.

[0156] When it is determined that the handle, initial working key and authorization code used for the current handle decryption are different from the handle, initial working key and authorization code used for the previous handle decryption, the current handle is decrypted using the current initial working key and authorization code to obtain the input initial key, so as to obtain the input initial key when performing data encryption and decryption, that is, step S911.

[0157] Step S914: Obtain the cached round key.

[0158] The cached round key is generated after the key expansion instruction is executed last time, so that the cached round key is used to encrypt or decrypt data.

[0159] When it is determined that the handle, initial working key and authorization code used for the current handle decryption are the same as the handle, initial working key and authorization code used for the previous handle decryption, the round key cached after the previous key expansion can be directly used to execute step S913 for data encryption and decryption, saving the pre-processing time during data encryption and decryption, that is, the time for decrypting and inputting the initial key.

[0160] It can be seen that the technical solution provided by the embodiment of the present invention, since the input initial key is protected by the initial working key, and the initial working key is generated in real time using the initial value shared by each logical core; therefore, it can avoid frequent operation of the operating system, reduce the complexity of the key encryption process and the time consumption of loading and distributing the initial working key, and achieve the purpose of improving the key encapsulation efficiency.

[0161] The above describes multiple embodiment schemes provided by the embodiments of the present invention. The various optional methods introduced in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible embodiment schemes, which can all be considered as embodiment schemes disclosed and open in the embodiments of the present invention.

[0162] Although the embodiments of the present invention are disclosed above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be based on the scope defined by the claims.

Claims

1. A processor, characterized in that: include: At least one physical core; each physical core includes at least one logical core and a register shared by each logical core; The shared register includes a key encryption register, wherein the key encryption register stores an initial value for generating an initial working key; Each logical core includes: The initial working key processing module is configured to generate an initial working key based on at least an initial value provided by the key encryption register, and to encapsulate an input initial key using at least the initial working key to form a handle.

2. The processor according to claim 1, wherein The initial working key processing module includes: an initial working key random generation circuit and a handle encryption circuit; The initial working key random generation circuit is used to generate an initial working key based on at least an initial value provided by the key encryption register; The handle encryption circuit is used to encapsulate the input initial key based on at least the initial working key to generate a handle.

3. The processor according to claim 2, wherein: The initial working key random generation circuit includes: A random initial value determination module, configured to determine a random initial value based on the initial value stored in the key encryption register and the built-in initial value of the logic core; A random generator is used to generate an initial working key according to the random initial value.

4. The processor according to claim 3, wherein: The handle encryption circuit includes: an encryption information acquisition module, configured to acquire an initial working key generated by the random generator, a data processing instruction stored in a memory, and control information stored in the key encryption register, wherein the data processing instruction includes an authorization code and an input initial key; The handle encryption module is used to encapsulate the input initial key using the initial working key, the control information and the authorization code to generate a handle.

5. The processor according to any one of claims 1 to 4, wherein: The initial working key processing module further includes: a handle decryption circuit, the handle decryption circuit being used to decrypt the handle using the initial working key and the authorization code to obtain an input initial key; the logic core further includes: The data encryption and decryption module is used to encrypt or decrypt data based on the input initial key obtained after decryption.

6. The processor according to claim 5, wherein: The data encryption and decryption module includes: The key expansion module is used to execute the key expansion instruction, expand the input initial key obtained after decryption, and generate the round key; The data encryption and decryption circuit is used to encrypt or decrypt data using the round key.

7. The processor according to claim 6, wherein: The logic core further includes: a detection unit, configured to determine, before the handle decryption circuit performs a handle decryption operation on the currently received handle using the currently received initial working key and authorization code, whether the current handle, the current initial working key, and the current authorization code are the same as the handle, the initial working key, and the authorization code used in the previous handle decryption operation; If yes, the handle decryption circuit is controlled to stop executing the current handle decryption operation, and the data encryption / decryption circuit is controlled to use the cached round key obtained to encrypt or decrypt the data using the cached round key; the cached round key is generated after the key expansion instruction is last executed; If not, the handle decryption circuit is controlled to decrypt the handle using the current initial working key and the authorization code to obtain the input initial key.

8. The processor according to claim 7, wherein: The encryption and decryption algorithms run by the data encryption and decryption module include: a state transition symmetric key block cipher algorithm or an advanced encryption standard algorithm; the handle encryption algorithm run by the initial working key processing module includes: a handle encryption algorithm corresponding to the state transition symmetric key block cipher algorithm, or a handle encryption algorithm corresponding to the advanced encryption standard algorithm; the handle decryption algorithm run includes: a handle decryption algorithm corresponding to the state transition symmetric key block cipher algorithm, or a handle decryption algorithm corresponding to the advanced encryption standard algorithm.

9. A computer system, characterized in that: The method comprises a processor according to any one of claims 1 to 8.

10. The computer system according to claim 9, wherein: Also includes: The memory is used to store data processing instructions, encrypted data and decrypted data, wherein the data processing instructions include an authorization code and an input initial key.

11. A key management method, characterized in that: Applied to the processor according to any one of claims 1 to 8, the method comprising: Obtaining a pre-stored initial value; the initial value is shared by each logical core of each physical core on the processor; generating an initial working key based at least on the initial value; The input initial key is encapsulated using at least the initial working key to generate a handle.

12. The key management method according to claim 11, wherein: After the step of obtaining the pre-stored initial value, the method further includes: Get the built-in initial value of the logic core; Generating an initial working key based at least on the initial value comprises: Determine a random initial value based on the built-in initial value and the initial value; An initial working key is generated using the random initial value.

13. The key management method according to claim 12, wherein: The input initial key is provided by a data processing instruction, and the data processing instruction also includes an authorization code; and the step of encapsulating the input initial key using at least the initial working key to generate a handle includes: Encapsulating the input initial key using the authorization code, pre-stored control information, and the initial working key to generate a handle; The control information is shared by each logical core of each physical core on the processor.

14. The key management method according to claim 13, wherein: Also includes: When encrypting and decrypting data, the handle is decrypted using the initial working key and the authorization code to obtain the input initial key.

15. A data encryption and decryption method, characterized in that: include: Obtaining an input initial key, where the input initial key is obtained by decrypting the initial working key and the handle; The initial working key and handle are obtained based on the key management method according to any one of claims 11 to 14; Executing a key expansion instruction to expand the input initial key to generate a round key; The data is encrypted or decrypted using the round key.

16. The data encryption and decryption method according to claim 15, wherein: Before the step of obtaining and inputting the initial key, the method further includes: Obtain the current handle, initial working key, and authorization code to perform the decryption operation of the current handle; Determine whether the current handle, initial working key, and authorization code are the same as the previous handle, initial working key, and authorization code; If yes, obtain the cached round key to encrypt or decrypt the data using the cached round key; the cached round key is generated after the key expansion instruction is executed last time; If not, the handle is decrypted using the current initial working key and the authorization code to obtain the input initial key.