Data encryption method, device, and server based on lightweight encryption algorithm

By starting the P replacement accelerator in resource-constrained devices to process data in parallel, the P replacement operation of lightweight encryption algorithms is accelerated, solving the problem of low encryption efficiency and achieving efficient data encryption in products such as embedded devices and smart cards. .

CN118381602BActive Publication Date: 2024-08-27SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410818232.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-08-27
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

The efficiency of encrypting data based on lightweight encryption algorithms in the existing technology is low, and it is difficult to achieve efficient data encryption in products such as resource-limited embedded devices and smart cards.

Method used

By starting the P replacement accelerator after receiving the replacement instruction, loading the data in N registers in parallel, and performing parallel P replacement operations based on encryption parameters, N sets of P replacement operation results are obtained, and the data to be encrypted is encrypted based on the operation results to achieve the goal. Generation of ciphertext.

Benefits of technology

It improves the speed of data encryption, solves the problem of low efficiency of lightweight encryption algorithms, and can achieve efficient data encryption in resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118381602B
    Figure CN118381602B
Patent Text Reader

Abstract

The present application relates to the field of computers. The present embodiment provides a data encryption method, device, and server based on a lightweight encryption algorithm, wherein the method includes: when it is determined that the received substitution instruction includes a P substitution instruction in the lightweight encryption algorithm, starting a P substitution accelerator; loading N groups of data in N registers in parallel through the P substitution accelerator; loading encryption parameters through the P substitution accelerator, and performing parallel P substitution operations on the data to be subjected to P substitution operations in the N groups of data based on the encryption parameters to obtain N groups of P substitution operation results; encrypting the data to be encrypted based on the N groups of P substitution operation results to obtain a target ciphertext. Through the present application, the problem of low efficiency of encrypting data based on a lightweight encryption algorithm in the related art is solved, and the effect of improving the data encryption speed is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the computer field, and specifically, to a data encryption method, device, and server based on a lightweight encryption algorithm. Background Art

[0002] With the continuous development and popularization of Internet of Things technology, more and more embedded devices, smart cards, security chips and other products are connected to the Internet and exchange and collaborate with each other. These devices usually have low-power processors, small memory capacity and storage space, etc. These resource-constrained factors require embedded devices and smart cards to consider how to achieve sufficient functions and performance under limited resources when designing and implementing them. How to protect these data from being stolen and tampered with under the premise of limited resources has received more and more attention. The demand for efficient encryption of resources and energy is also increasing. The symmetric encryption method in the existing technology cannot achieve efficient encryption of data. Summary of the invention

[0003] The embodiments of the present application provide a data encryption method, device, and server based on a lightweight encryption algorithm, so as to at least solve the problem of low efficiency of encrypting data based on a lightweight encryption algorithm in the related art.

[0004] According to one embodiment of the present application, a data encryption method based on a lightweight encryption algorithm is provided, comprising: in a case where it is determined that a received substitution instruction includes a P substitution instruction in the lightweight encryption algorithm, starting a P substitution accelerator, wherein the P substitution instruction includes encryption parameters of the lightweight encryption algorithm; loading N groups of data in N registers in parallel through the P substitution accelerator, wherein the N groups of data include data to be subjected to P substitution operation in the data to be encrypted, and the N is a natural number greater than 1; loading the encryption parameters through the P substitution accelerator, and performing parallel P substitution operation on the data to be subjected to P substitution operation in the N groups of data based on the encryption parameters to obtain N groups of P substitution operation results; encrypting the data to be encrypted based on the N groups of P substitution operation results to obtain a target ciphertext.

[0005] In an exemplary embodiment, when it is determined that the received replacement instruction includes the P replacement instruction in the lightweight encryption algorithm, before starting the P replacement accelerator, the method further includes: initializing the loaded original parameters to obtain an initial data block, wherein the original parameters include the encryption parameters, and the encryption parameters include at least one of the following: a key, a random number, an initial vector; and storing the initial data block in a computer system.

[0006] In an exemplary embodiment, the loaded original parameters are initialized to obtain an initial data block, including: performing XOR processing on the key, random number and initial vector in the above encryption parameters to obtain a first data block; performing multiple rounds of P permutation operations on the above first data block, and performing XOR processing on multiple of the above operation results with the above key to obtain the above initial data block.

[0007] In an exemplary embodiment, before reading N groups of data in parallel from N registers through the P permutation accelerator, the method further includes: grouping the data to be encrypted according to a preset data length to obtain N groups of the data, wherein the data to be encrypted includes associated information and data text, and the associated information is used to represent user information associated with the data text; and loading the N groups of data into the N registers respectively according to the associated information and the data text.

[0008] In an exemplary embodiment, when it is determined that the received replacement instruction includes a P replacement instruction in a lightweight encryption algorithm, a P replacement accelerator is started, including: adding the above replacement instruction to an operation code space in a computer system to store the above replacement instruction in the above operation code space; decoding the above replacement instruction to obtain the above P replacement instruction from the above replacement instruction; triggering the connection between the above P replacement accelerator and the N above registers to start the above P replacement accelerator.

[0009] In an exemplary embodiment, N groups of data in N registers are loaded in parallel through the P permutation accelerator, including: transmitting the N groups of data in parallel to the P permutation accelerator through M channels; or, controlling the P permutation accelerator to load the N groups of data in parallel through M channels; wherein the M channels are grouped and connected to the N registers, and M is a natural number less than or equal to N.

[0010] In an exemplary embodiment, the encryption parameters are loaded through the P permutation accelerator, and the data to be subjected to the P permutation operation in the N groups of the data are subjected to parallel P permutation operation based on the encryption parameters to obtain N groups of P permutation operation results, including: loading the encryption parameters from the operation code space of the computer system through the P permutation accelerator; performing the P permutation operation on the data to be subjected to the P permutation operation in the associated information through the P permutation accelerator and based on the encryption parameters to obtain a first P permutation operation result; performing the P permutation operation on the data to be subjected to the P permutation operation in the data text through the P permutation accelerator and based on the encryption parameters to obtain a second P permutation operation result; determining the first P permutation operation result and the second P permutation operation result as N groups of the P permutation operation results; wherein the data to be encrypted includes the associated information and the data text, and the associated information is used to represent user information associated with the data text.

[0011] In an exemplary embodiment, before encrypting the data to be encrypted based on N groups of the P permutation operation results to obtain the target ciphertext, the method further includes: storing the N groups of the P permutation operation results in the N registers; and reading the N groups of the P permutation operation results in parallel from the N registers through the P permutation accelerator.

[0012] In an exemplary embodiment, after the data to be encrypted is encrypted based on N groups of the P permutation operation results to obtain the target ciphertext, the method further includes: loading N groups of ciphertext data in the N registers in parallel through the P permutation accelerator, wherein the N groups of ciphertext data include data to be subjected to inverse P permutation operation in the target ciphertext; performing inverse P permutation operation on the N groups of ciphertext data in parallel based on decryption parameters through the P permutation accelerator to obtain N groups of inverse P permutation operation results; and decrypting the target ciphertext based on the N groups of inverse P permutation operation results.

[0013] According to another embodiment of the present application, a data encryption device based on a lightweight encryption algorithm is also provided, including: a processor, a P permutation accelerator and N registers, wherein the processor is used to trigger the start of the P permutation accelerator when it is determined that the received permutation instruction includes the P permutation instruction in the lightweight encryption algorithm, wherein the P permutation instruction includes the encryption parameters of the lightweight encryption algorithm; the P permutation accelerator is used to load N groups of data in N registers in parallel, and perform P permutation operations on the N groups of data in parallel based on the encryption parameters to obtain N groups of P permutation operation results, wherein the N groups of data include data to be subjected to P permutation operations in the data to be encrypted, and the N is a natural number greater than 1; the processor is also used to encrypt the data to be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext.

[0014] In an exemplary embodiment, the device further comprises: an opcode space, wherein the opcode space is used to store the permutation instruction, wherein the opcode space is arranged in a computer system and connected to the processor and the P permutation accelerator.

[0015] In an exemplary embodiment, the device further comprises a decoder, wherein the decoder is connected to the opcode space, and is used to read the replacement instruction from the opcode space, and decode the replacement instruction to obtain the P replacement instruction from the replacement instruction.

[0016] In an exemplary embodiment, the device further includes M channels, wherein the M channels are grouped and connected to the N registers for transmitting the N groups of data in parallel to the P permutation accelerator, and the M is a natural number less than or equal to the N.

[0017] In an exemplary embodiment, the device further includes a general register, wherein the general register and the N registers are both arranged in a computer system, and the general register is used to store the target ciphertext.

[0018] According to another embodiment of the present application, a server is also provided, including the above-mentioned data encryption device based on the lightweight encryption algorithm, wherein the above-mentioned data encryption device based on the lightweight encryption algorithm is used to implement the steps of the above-mentioned method.

[0019] According to another embodiment of the present application, a data encryption device based on a lightweight encryption algorithm is also provided, including: a first startup module, used to start a P permutation accelerator when it is determined that the received permutation instruction includes a P permutation instruction in the lightweight encryption algorithm, wherein the above-mentioned P permutation instruction includes the encryption parameters of the above-mentioned lightweight encryption algorithm; a first loading module, used to load N groups of data in N registers in parallel through the above-mentioned P permutation accelerator, wherein the N groups of the above-mentioned data include data to be subjected to P permutation operation in the data to be encrypted, and the above-mentioned N is a natural number greater than 1; a first operation module, used to perform P permutation operation on the N groups of the above-mentioned data in parallel through the above-mentioned P permutation accelerator and based on the above-mentioned encryption parameters, to obtain N groups of P permutation operation results; a first encryption module, used to encrypt the above-mentioned data to be encrypted based on the N groups of the above-mentioned P permutation operation results to obtain a target ciphertext.

[0020] In an exemplary embodiment, the above-mentioned device also includes: a first processing module, which is used to initialize the loaded original parameters before starting the P replacement accelerator to obtain an initial data block when it is determined that the received replacement instruction includes the P replacement instruction in the lightweight encryption algorithm, wherein the above-mentioned original parameters include the above-mentioned encryption parameters, and the above-mentioned encryption parameters include at least one of the following: a key, a random number, an initial vector; a first storage module, which is used to store the above-mentioned initial data block in a computer system.

[0021] In an exemplary embodiment, the above-mentioned first processing module includes: a first processing unit, used to perform XOR processing on the key, random number and initial vector in the above-mentioned encryption parameters to obtain a first data block; a second processing unit, used to perform multiple rounds of P permutation operations on the above-mentioned first data block, and perform XOR processing on multiple of the above-mentioned operation results with the above-mentioned key to obtain the above-mentioned initial data block.

[0022] In an exemplary embodiment, the above-mentioned device also includes: a second processing module, which is used to group the data to be encrypted according to the preset data length before reading N groups of data in parallel from N registers through the above-mentioned P permutation accelerator to obtain N groups of the above-mentioned data, wherein the above-mentioned data to be encrypted includes associated information and data text, and the above-mentioned associated information is used to represent user information associated with the above-mentioned data text; a second loading module, which is used to load the N groups of the above-mentioned data into the N above-mentioned registers according to the above-mentioned associated information and the above-mentioned data text respectively.

[0023] In an exemplary embodiment, the above-mentioned first startup module includes: a first adding unit, used to add the above-mentioned replacement instruction to the operation code space in the computer system to store the above-mentioned replacement instruction in the above-mentioned operation code space; a first decoding unit, used to decode the above-mentioned replacement instruction to obtain the above-mentioned P replacement instruction from the above-mentioned replacement instruction; a first triggering unit, used to trigger the connection between the above-mentioned P replacement accelerator and the N above-mentioned registers to start the above-mentioned P replacement accelerator.

[0024] In an exemplary embodiment, the first loading module includes: a first transmission unit, used to transmit the N groups of the data in parallel to the P permutation accelerator through M channels; or, a first control unit, used to control the P permutation accelerator to load the N groups of the data in parallel through M channels; wherein the M channels are grouped and connected to the N registers, and M is a natural number less than or equal to N.

[0025] In an exemplary embodiment, the above-mentioned first operation module includes: a first loading unit, used to load the above-mentioned encryption parameters from the operation code space of the computer system through the above-mentioned P permutation accelerator; a first operation unit, used to perform a P permutation operation on the data to be subjected to the P permutation operation in the associated information through the above-mentioned P permutation accelerator and based on the above-mentioned encryption parameters, to obtain a first P permutation operation result; a second operation unit, used to perform a P permutation operation on the data to be subjected to the P permutation operation in the data text through the above-mentioned P permutation accelerator and based on the above-mentioned encryption parameters, to obtain a second P permutation operation result; a first determination unit, used to determine the above-mentioned first P permutation operation result and the second P permutation operation result as N groups of the above-mentioned P permutation operation results; wherein the above-mentioned data to be encrypted includes the above-mentioned associated information and the above-mentioned data text, and the above-mentioned associated information is used to represent user information associated with the above-mentioned data text.

[0026] In an exemplary embodiment, the above-mentioned device also includes: a second storage module, used to encrypt the above-mentioned data to be encrypted based on the N groups of the above-mentioned P permutation operation results, and before obtaining the target ciphertext, the N groups of the above-mentioned P permutation operation results are stored in the N above-mentioned registers; a first reading module, used to read the N groups of the above-mentioned P permutation operation results in parallel from the N above-mentioned registers through the above-mentioned P permutation accelerator.

[0027] In an exemplary embodiment, the above-mentioned device also includes: a third loading module, used to encrypt the above-mentioned data to be encrypted based on the N groups of the above-mentioned P permutation operation results, and after obtaining the target ciphertext, load the N groups of ciphertext data in the N above-mentioned registers in parallel through the above-mentioned P permutation accelerator, wherein the N groups of the above-mentioned ciphertext data include the data to be subjected to inverse P permutation operation in the above-mentioned target ciphertext; a second operation module, used to perform inverse P permutation operation on the N groups of the above-mentioned ciphertext data in parallel through the above-mentioned P permutation accelerator and based on decryption parameters to obtain N groups of inverse P permutation operation results; a first decryption module, used to decrypt the above-mentioned target ciphertext based on the N groups of inverse P permutation operation results.

[0028] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0029] Through the present application, after receiving the P permutation instruction, the P permutation accelerator can be started, and N groups of data in N registers can be loaded in parallel through the P permutation accelerator, and the data to be subjected to the P permutation operation in the N groups of data can be subjected to the P permutation operation in parallel based on the encryption parameters to obtain N groups of P permutation operation results; the data to be encrypted can be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext. And multiple data can be operated at the same time, which speeds up the speed of performing the P permutation operation on the data to be subjected to the P permutation operation. Therefore, the problem of low efficiency of encrypting data based on lightweight encryption algorithms in the related art can be solved, and the effect of improving the data encryption speed can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a hardware structure block diagram of a mobile terminal of a data encryption method based on a lightweight encryption algorithm according to an embodiment of the present application;

[0031] Figure 2 is a flow chart of a data encryption method based on a lightweight encryption algorithm according to an embodiment of the present application;

[0032] Figure 3 is a schematic diagram of the connection between the P permutation accelerator and the register according to an embodiment of the present application;

[0033] Figure 4 is a flow chart of starting a P replacement accelerator according to an embodiment of the present application;

[0034] Figure 5 is a schematic diagram of a data encryption device based on a lightweight encryption algorithm according to an embodiment of the present application;

[0035] Figure 6 It is a structural block diagram of a data encryption device based on a lightweight encryption algorithm according to an embodiment of the present application. DETAILED DESCRIPTION

[0036] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0037] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0038] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 1 is a hardware structure block diagram of a mobile terminal of a data encryption method based on a lightweight encryption algorithm in an embodiment of the present application. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0039] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data encryption method based on the lightweight encryption algorithm in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0040] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0041] In this embodiment, a data encryption method based on a lightweight encryption algorithm is provided. Figure 2 is a flow chart of a data encryption method based on a lightweight encryption algorithm according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0042] Step S202, when it is determined that the received replacement instruction includes a P replacement instruction in the lightweight encryption algorithm, starting a P replacement accelerator, wherein the P replacement instruction includes encryption parameters of the lightweight encryption algorithm;

[0043] Step S204, loading N groups of data in N registers in parallel through a P permutation accelerator, wherein the N groups of data include data to be subjected to P permutation operation in the data to be encrypted, and N is a natural number greater than 1;

[0044] Step S206, loading encryption parameters through the P permutation accelerator, and performing parallel P permutation operations on the data to be subjected to P permutation operations in the N groups of data based on the encryption parameters, to obtain N groups of P permutation operation results;

[0045] Step S208, encrypt the data to be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext.

[0046] The execution subject of the above steps may be a terminal, a server, a specific processor provided in the terminal or the server, or a processor or processing device provided relatively independently from the terminal or the server, but is not limited thereto.

[0047] Through the above steps, after receiving the P permutation instruction, the P permutation accelerator can be started, and the N groups of data in the N registers can be loaded in parallel through the P permutation accelerator, and the data to be subjected to the P permutation operation in the N groups of data can be subjected to the P permutation operation in parallel based on the encryption parameters to obtain N groups of P permutation operation results; the data to be encrypted can be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext. In addition, multiple data can be operated at the same time, which speeds up the P permutation operation of the data to be subjected to the P permutation operation. Therefore, the problem of low efficiency of encrypting data based on the lightweight encryption algorithm in the related art can be solved, and the effect of improving the data encryption speed can be achieved.

[0048] Optionally, this embodiment includes but is not limited to being applied to embedded devices that require data encryption, such as solid state drives (SSDs), smart cards, and other devices that require efficient encryption and decryption under limited hardware resources. It can also be applied to smart homes, smart cities, smart medical care, and other fields, such as modern micro devices such as smart home devices, smart wearable devices, and smart medical devices, which all have the characteristics of small size, low power consumption, and easy portability, and are connected and communicated with other devices through wireless communication technologies (such as mobile hotspots Wi-Fi, Bluetooth, near-field communication NFC, etc.). The method in this embodiment has good portability and flexibility, and can be quickly integrated into the above-mentioned devices to enhance their authentication, communication, upgrade security, and other requirements.

[0049] Optionally, a lightweight encryption algorithm is a type of cryptographic algorithm that runs in a resource-constrained environment. Its main feature is that it occupies less computing resources and memory to protect the security and integrity of its data. For example, the ASCON algorithm is a lightweight permutation cipher based on a sponge-structured substitution-permutation network (SPN). Its encryption benchmark is AEAD, which can provide confidentiality, integrity, and authenticity at the same time. AEAD is an algorithm that implements encryption and authentication within the algorithm at the same time. It is an encryption form that has confidentiality, integrity, and authenticity at the same time. It is a solution that takes into account both performance and resources and can be applied in scenarios of efficient and low-power data encryption and identity authentication. The ASCON algorithm includes many types, such as ASCON-128r and ASCON-128a. The selection of the state size, arrangement, and operation mode of the ASCON algorithm ensures that the algorithm can achieve fast data diffusion with less resources to achieve good cryptographic performance. It also has high security and confidentiality, and has the characteristics of fast software running speed, high hardware efficiency, and high throughput. In this embodiment, the ASCON algorithm uses the P permutation instruction to confuse data. The P permutation instruction is an operation used in an encryption algorithm. It permutes the input data according to a predetermined rule, thereby changing the order and structure of the data, making it difficult to understand and crack. In the ASCON algorithm, the P permutation instruction is used to encrypt and decrypt data to ensure the security and confidentiality of the data. Through continuous permutation operations, the ASCON algorithm can effectively confuse data, making it difficult to crack and decrypt. Therefore, the P permutation instruction plays a vital role in the ASCON algorithm and is one of the key operations to achieve data encryption and protection.

[0050] Optionally, the P permutation accelerator is used to accelerate permutation operations in cryptography. High-speed permutation operations can be provided in cryptographic algorithms, thereby accelerating the encryption and decryption process of data. Through the P permutation accelerator, more efficient cryptographic operations can be obtained, thereby improving the security and performance of the system. The P permutation accelerator is tightly coupled with the processor and the N registers. The P permutation accelerator accesses the N register files to obtain the necessary input data or write the results back to the N registers. Therefore, close coordination and communication are required between the accelerator and the processor register file to ensure the correct transfer and processing of data.

[0051] Optionally, the P permutation operation is an operation used to change or adjust the order of data. The P permutation operation is represented as a permutation containing different elements. That is, the P permutation operation is to rearrange the elements in a sequence without changing the elements themselves. For example, for the sequence {1, 2, 3, 4}, performing a P permutation operation will obtain a new sequence such as {4, 3, 1, 2}. That is, the order of elements in the original sequence is changed, but the elements themselves have not changed. By performing a P permutation operation on the data, the order of the data can be made more random or compact, thereby increasing the security of the data and reducing the storage space.

[0052] In an exemplary embodiment, when it is determined that the received replacement instruction includes a P replacement instruction in a lightweight encryption algorithm, before starting the P replacement accelerator, the method further includes: initializing the loaded original parameters to obtain an initial data block, wherein the original parameters include encryption parameters, and the encryption parameters include at least one of the following: a key, a random number, and an initial vector; and storing the initial data block in a computer system.

[0053] Optionally, a key is a secret code used to encrypt and decrypt data. Lightweight encryption algorithms usually use a shorter key length, generally less than 128 bits, to ensure algorithm efficiency and low power consumption.

[0054] Random numbers are usually used to increase security and prevent guessing or cracking. Random numbers are generated by a random number generator and can be a combination of numbers, letters, or symbols. During the encryption process, random numbers are used to generate keys or initialization vectors to ensure that the results of each encryption are different. This can increase the difficulty for attackers to crack ciphertext and improve the security of encryption algorithms.

[0055] Initialization vector (IV): Some lightweight encryption algorithms require the use of an initialization vector to enhance encryption security and provide more advanced cryptographic protection. The initialization vector IV can be a random number of fixed length, which is used together with the key to initialize the encryption algorithm during the encryption process. The selection of the initialization vector IV has an important impact on the security and performance of the encryption algorithm, so it is necessary to ensure its randomness and uniqueness. In an encryption session, the initialization vector IV is usually used only once to ensure that the encryption result is different each time.

[0056] Optionally, the encryption parameters may also include encryption mode, padding method, encryption algorithm parameters, etc.

[0057] Encryption mode: Encryption algorithms usually support multiple encryption modes, such as Electronic Codebook Mode (ECB), Cipher Block Chaining Mode (CBC), Counter Mode (CTR), etc. You can choose the appropriate encryption mode to meet specific security requirements.

[0058] Padding method: During the encryption process, data needs to be padded to meet the block size requirements of the encryption algorithm, for example, zero padding, PKCS#7 padding, etc.

[0059] Encryption algorithm parameters: Different lightweight encryption algorithms require different algorithm parameters, such as the number of rounds, S-boxes, permutation tables, etc., to affect the security and performance of the encryption algorithm.

[0060] It should be noted that the encryption parameters of the lightweight encryption algorithm can be selected and configured according to specific application scenarios and security requirements to ensure the security and efficiency of encryption.

[0061] Optionally, the loaded original parameters are initialized to obtain an initial data block, including: performing XOR processing on the key, random number and initial vector in the encryption parameters to obtain a first data block; performing multiple rounds of P permutation operations on the first data block, and performing XOR processing on multiple operation results and the key to obtain an initial data block.

[0062] In this embodiment, the initial data block can be a 320-bit data block. For example, during the initialization process, the initial vector IV needs to be calculated in advance and stored inside the computer. After the original parameters are input, the key K, the random number N, and the initial vector IV are first XORed to obtain the first data block S1, which is then XORed with the key K after 12 rounds of P permutation operations to generate the 320-bit initial data block S in the initialization phase.

[0063] In addition, if the P permutation operation is implemented inside the chip (for example, embedded in FPGA or transplanted to ASIC in the form of IP core), the associated data information AD (Associated Data) and the key K (managed by the key management unit) can be preset to omit the initialization processing acceleration. After the associated data is processed, each block ADi is added to the secret state. The key management unit in the chip stores the key support key separately, controls the generation, use, deletion, etc. of the key, and can calculate the relevant operation intermediate data of K in advance. The secret state of the associated data ADi and the key K of the key management unit are calculated and stored in advance, and are only called when used, which can ensure the security of the data and speed up the operation.

[0064] Optionally, if the implementation is done in software and hardware collaboration (for example, a system-on-chip Soc such as the Zynq7000 platform that integrates ARM+FPGA), the associated data AD processing can be implemented in the software, and the user IP / email address, etc. can be used as the associated data AD, which can be processed in the software module and then transmitted to the hardware. This embodiment has greater flexibility in transplantation and application.

[0065] This embodiment processes the original parameters into data blocks, and can integrate the original parameters into the data blocks for easy storage in the computer system. In the process of encrypting data, the encryption parameters can be directly loaded, thereby speeding up the encryption speed of the data and improving the efficiency of data encryption.

[0066] In an exemplary embodiment, before reading N groups of data in parallel from N registers through a P permutation accelerator, the method further includes: grouping the data to be encrypted according to a preset data length to obtain N groups of data, wherein the data to be encrypted includes associated information and data text, and the associated information is used to represent user information associated with the data text; and loading the N groups of data into the N registers respectively according to the associated information and the data text.

[0067] Optionally, the associated information mainly includes user information, which includes objects or devices whose data need to be encrypted. In the case of a device, the user information includes device information, such as the device number, etc. This information may not need to be encrypted, but must be ensured not to be arbitrarily changed by attackers.

[0068] In this embodiment, the associated information may also be associated data AD (Active Directory), which is a directory service for managing and organizing users, computers, and other resources in a network. AD needs to use a key K to encrypt the data stored therein to protect the privacy and security of the user. AD may use the key K to encrypt the user's password, personal information, or other sensitive data to prevent unauthorized access. The association between AD and the key K is that the key K can be used to protect the data stored in the AD, thereby enhancing network security and user privacy protection.

[0069] Furthermore, the grouping processing of the associated data AD mainly includes: grouping the associated data AD according to the grouping data length r (for example, ASCON-128r is 64 bits, and ASCON-128a r is 128 bits). When it cannot be divided completely, splicing processing can be performed at the last bit to ensure that the associated data AD can be divided completely. Grouping the associated data (ADi) is XORed into the intermediate state Sr of the upper half of the process, and then 6 rounds of operations are performed before introducing the next group of associated data (ADi+1). After all the associated data are introduced, the intermediate state Sc of the lower half of the process is XORed (0...1) to complete the introduction of the associated data part.

[0070] Optionally, the data text is a message plaintext that needs to be encrypted (for example, account information, login password, etc.). In the encryption stage, each message plaintext (P) is grouped according to the group data length r (r is 64 bits for ASCON-128 and 128 bits for ASCON-128ar), and the grouped message plaintext (Pi) is XORed into the intermediate state Sr in the upper half of the process, and the corresponding grouped message ciphertext (Ci) is directly output. Then, b rounds (b is 6 for ASCON-128 and 8 for ASCON-128ab) of P permutation operations are performed before introducing the next group of grouped message plaintexts (Pi+1). After all message plaintexts are introduced, the encryption of the message plaintexts is completed.

[0071] This embodiment groups the associated information and data text, and loads the data into N registers in groups, so that the P permutation accelerator can load data from the N registers for calculation at the same time, thereby speeding up the data encryption.

[0072] In an exemplary embodiment, when it is determined that the received permutation instruction includes a P permutation instruction in a lightweight encryption algorithm, a P permutation accelerator is started, including: adding the permutation instruction to an opcode space in a computer system to store the permutation instruction in the opcode space; decoding the permutation instruction to obtain the P permutation instruction from the permutation instruction; and triggering the connection between the P permutation accelerator and N registers to start the P permutation accelerator.

[0073] Optionally, opcode space refers to the space used to store opcodes (i.e., P permutation instructions) in a computer system. The size of the opcode space depends on the computer's architecture and instruction set architecture. Different computer architectures and instruction set architectures will have different sizes of opcode spaces. The size of the opcode space determines the number of instructions that the computer can support, which affects the computer's functions and performance. A larger opcode space means that the computer can support more instructions, and therefore has richer functions and higher performance.

[0074] Optionally, after adding the permute instruction to the opcode space in the computer system, the permute instruction needs to be added to the decode stage of the hardware, and then the P permute accelerator is connected to the registers. To store the full 320-bit state of the P permute operation, 10 fixed 32-bit registers are required, and 2 registers can be combined to store a channel of ASCON state and can be passed directly to the accelerator, as shown in Figure 3 shown.

[0075] The decoding stage of hardware refers to the process of processing data obtained from the input device and converting it into a usable format in a computer or other electronic device. At this stage, the hardware usually performs the following steps: Data reception: The hardware receives the raw data obtained from the input device; Data parsing: The hardware parses the received raw data and converts it into a recognizable format. Data processing: The hardware processes the parsed data and may perform some specific calculations or operations for subsequent use. Data output: The hardware outputs the processed data to a specified device or system for subsequent processing or display. The decoding stage of hardware usually requires efficient processing power and specialized decoders or processors to ensure that large amounts of data can be processed quickly and accurately.

[0076] Optionally, when a permutation instruction is decoded as a P permutation instruction (e.g., an ASCON-P permutation instruction), a P permutation accelerator (e.g., an ASCON-P permutation accelerator) is enabled, and a multiplexer of a fixed register set is switched to perform the operation. For example, taking RISC-V as an example, the permutation instruction is first designed according to the application (e.g., 0xXXX0300B, where bits 20-27 are round constants, bits 28-30 are round numbers, and bit 31 is a big-endian selection), then added to the opcode space, and then added to the decoding stage of the hardware, and then the p permutation accelerator is connected to the register file. Therefore, when an instruction is decoded as an ASCON-P permutation instruction, the signal enables the ASCON-P permutation accelerator, and switches to a multiplexer of a fixed register set to perform the operation.

[0077] RISC-V is an open instruction set architecture (ISA) designed to be used in a variety of different processor implementations. The design goal of RISC-V is to provide a concise, flexible and scalable ISA to meet various applications and market needs. RISC-V is designed with a streamlined instruction set and supports optional extended instruction sets, which makes it suitable for a variety of different application scenarios. RISC-V also provides a variety of privilege levels to meet the needs of different operating systems and applications.

[0078] A multiplexer (MUX) is an electronic device used to combine multiple input signals into one output signal. It can transmit multiple signals on one communication channel, thereby improving communication efficiency. Multiplexers are commonly used in telecommunication and data communication systems to transmit multiple signals on limited communication channels. It can be a multiplexer for digital or analog signals, and the specific application depends on the requirements of the communication system. Multiplexers play an important role in modern communication technology. They can effectively utilize limited communication resources and improve the efficiency of data transmission.

[0079] This embodiment adds a replacement instruction to the operation code space of the computer system, so that the P replacement instruction can be quickly obtained, thereby speeding up the startup of the P replacement accelerator.

[0080] In an exemplary embodiment, N groups of data in N registers are loaded in parallel through a P permutation accelerator, including: transmitting the N groups of data in parallel to the P permutation accelerator through M channels; or controlling the P permutation accelerator to load the N groups of data in parallel through M channels; wherein the M channels are grouped and connected to the N registers, and M is a natural number less than or equal to N.

[0081] Alternatively, if Figure 3 As shown, when N is 10, 10 registers correspond to 5 channels, that is, 2 registers are combined to store one channel of ASCON state, which can be directly passed to the P permutation accelerator.

[0082] This embodiment connects M channels and P permutation accelerators to speed up the loading of data from N registers and improve the efficiency of encrypting data.

[0083] In an exemplary embodiment, encryption parameters are loaded through a P permutation accelerator, and parallel P permutation operations are performed on data to be subjected to P permutation operations in N groups of data based on the encryption parameters to obtain N groups of P permutation operation results, including: loading encryption parameters from the operation code space of the computer system through the P permutation accelerator; performing P permutation operations on data to be subjected to P permutation operations in associated information based on the encryption parameters to obtain a first P permutation operation result; performing P permutation operations on data to be subjected to P permutation operations in a data text based on the encryption parameters to obtain a second P permutation operation result; determining the first P permutation operation result and the second P permutation operation result as N groups of P permutation operation results; wherein the data to be encrypted includes associated information and data text, and the associated information is used to represent user information associated with the data text.

[0084] Optionally, the parallel execution of the P permutation operation in this embodiment is to perform 12 rounds of P permutation at a uniform speed after the intermediate state Sc in the lower half of the process is XORed with the key (filled with 0 to the full position), take out the first 128 bits of the intermediate state S and the first 128 bits of the key, and then XOR them as a label, and concatenate the previously grouped ciphertexts and output a 128-bit tag T together. With this tag, modifications to the ciphertext and related data can be detected during decryption (verification).

[0085] Furthermore, due to the low complexity of the ASCON round function, the P permutation accelerator only needs to use pipeline design to separate the associated modules of the P permutation operation, store the intermediate results in registers, and wait for the next clock cycle to process the data, and then it can be successfully accelerated. Among them, the P permutation accelerator is tightly coupled with the register to reuse the register file to save the password state, thereby realizing the instruction extension of the P permutation operation and improving the access speed of the accelerator.

[0086] This embodiment divides the P permutation operation into parts and executes them in the form of a pipeline, stores the intermediate results in registers, and waits for the next clock cycle to process the data, thereby improving the operation speed.

[0087] In an exemplary embodiment, before encrypting the data to be encrypted based on N groups of P permutation operation results to obtain the target ciphertext, the method further includes: storing the N groups of P permutation operation results in N registers; and reading the N groups of P permutation operation results in parallel from the N registers through a P permutation accelerator. This embodiment improves the speed of operation and accelerates the speed of data encryption by storing the N groups of P permutation operation results in N registers and reading the N groups of P permutation operation results in parallel from the N registers through a P permutation accelerator.

[0088] In an exemplary embodiment, after encrypting the data to be encrypted based on N groups of P permutation operation results to obtain the target ciphertext, the method further includes: loading N groups of ciphertext data in N registers in parallel through a P permutation accelerator, wherein the N groups of ciphertext data include data to be subjected to an inverse P permutation operation in the target ciphertext; performing an inverse P permutation operation on the N groups of ciphertext data in parallel based on a decryption parameter through a P permutation accelerator to obtain N groups of inverse P permutation operation results; and decrypting the target ciphertext based on the N groups of inverse P permutation operation results. The decryption process in this embodiment is very similar to the encryption process, except that ciphertext is processed instead of plaintext, and will not be described in detail here.

[0089] In a specific embodiment, the process of executing the ASCON-P replacement instruction in this embodiment is as follows: Figure 4 As shown, the following steps are included:

[0090] S401, extracting a replacement instruction. The replacement instruction (for example, 0xXXX0300B, where bits 20-27 are round constants, bits 28-30 are round numbers, and bit 31 is an endian selection) is designed according to the application. The replacement instruction is stored in the opcode space.

[0091] S402, decoding a replacement instruction;

[0092] S403, determining that they are all ASCON-P replacement instructions, and calling the LSU unit to load the data to be encrypted;

[0093] S404, when an instruction is decoded as an ASCON-P permutation instruction, a signal enables the ASCON-P permutation accelerator and switches to a multiplexer of a fixed register set to perform a P permutation operation;

[0094] S405, writing the calculated P permutation operation result back to the register, and then performing the encryption operation.

[0095] In addition, the P permutation accelerator of this embodiment is coupled with the registers in the processor, and the idea of ​​extending instructions to speed up the operation speed of the ASCON algorithm can also further refine the parameters. For example, the round constant and the number of rounds are stored inside the device and represented by only one bit. The other bits can be used for other encryption algorithms or other business logics to improve the overall operation speed.

[0096] In summary, the present embodiment accelerates the core element P replacement accelerator in the data processing process using an accelerator with a pipeline design to improve the operation speed, and it is tightly coupled with the processor register file, does not require any special registers, and can use this instruction to realize all encryption calculations on high-performance embedded devices. It has the advantages of high security, strong practicality, fast speed, excellent performance, easy transplantation, low power consumption, and easy expansion, and can efficiently realize the lightweight encryption algorithm ASCON. In addition, the present embodiment uses a pipeline accelerator to accelerate the core operation of data processing, which can greatly improve the operation performance of ASCON. Compared with the traditional ASCON dedicated coprocessor, the dedicated coprocessor needs to use its own register to save the password state, and the data transfer between the coprocessors takes a long time and is costly. The present embodiment is tightly coupled with the processor register file, does not require any special registers, and can also expand this instruction to realize all encryption calculations on high-performance embedded devices, with low cost, high flexibility, and low power consumption.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0098] According to another embodiment of the present application, a data encryption device based on a lightweight encryption algorithm is also provided. Figure 5 As shown, including:

[0099] A processor, a P permutation accelerator and N registers, wherein the processor is used to trigger the start of the P permutation accelerator when it is determined that the received permutation instruction includes the P permutation instruction in the lightweight encryption algorithm, wherein the P permutation instruction includes the encryption parameters of the lightweight encryption algorithm; the P permutation accelerator is used to load N groups of data in the N registers in parallel, and perform P permutation operations on the N groups of data in parallel based on the encryption parameters to obtain N groups of P permutation operation results, wherein the N groups of data include data to be subjected to P permutation operations in the data to be encrypted, and the N is a natural number greater than 1; the processor is also used to encrypt the data to be encrypted based on the N groups of P permutation operation results to obtain a target ciphertext.

[0100] Through the above device, after receiving the P permutation instruction, the processor can start the P permutation accelerator, the P permutation accelerator loads N groups of data in N registers in parallel, and the P permutation accelerator performs parallel P permutation operations on the data to be subjected to P permutation operations in the N groups of data based on the encryption parameters to obtain N groups of P permutation operation results; the processor encrypts the data to be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext. And multiple data can be operated at the same time, which speeds up the speed of performing P permutation operations on the data to be subjected to P permutation operations. Therefore, the problem of low efficiency of encrypting data based on lightweight encryption algorithms in related technologies can be solved, and the effect of improving the data encryption speed can be achieved.

[0101] In an exemplary embodiment, the device further comprises: an opcode space, wherein the opcode space is used to store the permutation instruction, wherein the opcode space is arranged in a computer system and connected to the processor and the P permutation accelerator.

[0102] In an exemplary embodiment, the device further comprises a decoder, wherein the decoder is connected to the opcode space, and is used to read the replacement instruction from the opcode space, and decode the replacement instruction to obtain the P replacement instruction from the replacement instruction.

[0103] In an exemplary embodiment, the device further includes M channels, wherein the M channels are grouped and connected to the N registers for transmitting the N groups of data in parallel to the P permutation accelerator, and the M is a natural number less than or equal to the N.

[0104] In an exemplary embodiment, the device further includes a general register, wherein the general register and the N registers are both arranged in a computer system, and the general register is used to store the target ciphertext.

[0105] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0106] According to another embodiment of the present application, a server is also provided, including the above-mentioned data encryption device based on the lightweight encryption algorithm, wherein the above-mentioned data encryption device based on the lightweight encryption algorithm is used to implement the steps of the above-mentioned method.

[0107] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0108] In this embodiment, a data encryption device based on a lightweight encryption algorithm is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0109] Figure 6 is a structural block diagram of a data encryption device based on a lightweight encryption algorithm according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:

[0110] A first starting module 62, configured to start a P replacement accelerator when it is determined that the received replacement instruction includes a P replacement instruction in a lightweight encryption algorithm, wherein the P replacement instruction includes encryption parameters of the lightweight encryption algorithm;

[0111] A first loading module 64, configured to load N groups of data in N registers in parallel through the P permutation accelerator, wherein the N groups of data include data to be subjected to P permutation operation in the data to be encrypted, and the N is a natural number greater than 1;

[0112] A first operation module 66, configured to perform P permutation operations on the N groups of the data in parallel through the P permutation accelerator and based on the encryption parameters, to obtain N groups of P permutation operation results;

[0113] The first encryption module 68 is used to encrypt the data to be encrypted based on the N groups of P permutation operation results to obtain a target ciphertext.

[0114] Through the above device, after receiving the P permutation instruction, the P permutation accelerator can be started, the P permutation accelerator loads N groups of data in N registers in parallel, and the P permutation accelerator performs parallel P permutation operations on the data to be subjected to P permutation operations in the N groups of data based on the encryption parameters to obtain N groups of P permutation operation results; based on the N groups of P permutation operation results, the data to be encrypted is encrypted to obtain the target ciphertext. And multiple data can be operated at the same time, which speeds up the speed of performing P permutation operations on the data to be subjected to P permutation operations. Therefore, the problem of low efficiency of encrypting data based on lightweight encryption algorithms in related technologies can be solved, and the effect of improving the data encryption speed can be achieved.

[0115] In an exemplary embodiment, the above-mentioned device also includes: a first processing module, which is used to initialize the loaded original parameters before starting the P replacement accelerator to obtain an initial data block when it is determined that the received replacement instruction includes the P replacement instruction in the lightweight encryption algorithm, wherein the above-mentioned original parameters include the above-mentioned encryption parameters, and the above-mentioned encryption parameters include at least one of the following: a key, a random number, an initial vector; a first storage module, which is used to store the above-mentioned initial data block in a computer system.

[0116] In an exemplary embodiment, the above-mentioned first processing module includes: a first processing unit, used to perform XOR processing on the key, random number and initial vector in the above-mentioned encryption parameters to obtain a first data block; a second processing unit, used to perform multiple rounds of P permutation operations on the above-mentioned first data block, and perform XOR processing on multiple of the above-mentioned operation results with the above-mentioned key to obtain the above-mentioned initial data block.

[0117] In an exemplary embodiment, the above-mentioned device also includes: a second processing module, which is used to group the data to be encrypted according to the preset data length before reading N groups of data in parallel from N registers through the above-mentioned P permutation accelerator to obtain N groups of the above-mentioned data, wherein the above-mentioned data to be encrypted includes associated information and data text, and the above-mentioned associated information is used to represent user information associated with the above-mentioned data text; a second loading module, which is used to load the N groups of the above-mentioned data into the N above-mentioned registers according to the above-mentioned associated information and the above-mentioned data text respectively.

[0118] In an exemplary embodiment, the above-mentioned first startup module includes: a first adding unit, used to add the above-mentioned replacement instruction to the operation code space in the computer system to store the above-mentioned replacement instruction in the above-mentioned operation code space; a first decoding unit, used to decode the above-mentioned replacement instruction to obtain the above-mentioned P replacement instruction from the above-mentioned replacement instruction; a first triggering unit, used to trigger the connection between the above-mentioned P replacement accelerator and the N above-mentioned registers to start the above-mentioned P replacement accelerator.

[0119] In an exemplary embodiment, the first loading module includes: a first transmission unit, used to transmit the N groups of the data in parallel to the P permutation accelerator through M channels; or, a first control unit, used to control the P permutation accelerator to load the N groups of the data in parallel through M channels; wherein the M channels are grouped and connected to the N registers, and M is a natural number less than or equal to N.

[0120] In an exemplary embodiment, the above-mentioned first operation module includes: a first loading unit, used to load the above-mentioned encryption parameters from the operation code space of the computer system through the above-mentioned P permutation accelerator; a first operation unit, used to perform a P permutation operation on the data to be subjected to the P permutation operation in the associated information through the above-mentioned P permutation accelerator and based on the above-mentioned encryption parameters, to obtain a first P permutation operation result; a second operation unit, used to perform a P permutation operation on the data to be subjected to the P permutation operation in the data text through the above-mentioned P permutation accelerator and based on the above-mentioned encryption parameters, to obtain a second P permutation operation result; a first determination unit, used to determine the above-mentioned first P permutation operation result and the second P permutation operation result as N groups of the above-mentioned P permutation operation results; wherein the above-mentioned data to be encrypted includes the above-mentioned associated information and the above-mentioned data text, and the above-mentioned associated information is used to represent user information associated with the above-mentioned data text.

[0121] In an exemplary embodiment, the above-mentioned device also includes: a second storage module, used to encrypt the above-mentioned data to be encrypted based on the N groups of the above-mentioned P permutation operation results, and before obtaining the target ciphertext, the N groups of the above-mentioned P permutation operation results are stored in the N above-mentioned registers; a first reading module, used to read the N groups of the above-mentioned P permutation operation results in parallel from the N above-mentioned registers through the above-mentioned P permutation accelerator.

[0122] In an exemplary embodiment, the above-mentioned device also includes: a third loading module, used to encrypt the above-mentioned data to be encrypted based on the N groups of the above-mentioned P permutation operation results, and after obtaining the target ciphertext, load the N groups of ciphertext data in the N above-mentioned registers in parallel through the above-mentioned P permutation accelerator, wherein the N groups of the above-mentioned ciphertext data include the data to be subjected to inverse P permutation operation in the above-mentioned target ciphertext; a second operation module, used to perform inverse P permutation operation on the N groups of the above-mentioned ciphertext data in parallel through the above-mentioned P permutation accelerator and based on decryption parameters to obtain N groups of inverse P permutation operation results; a first decryption module, used to decrypt the above-mentioned target ciphertext based on the N groups of inverse P permutation operation results.

[0123] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0124] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0125] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0126] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0127] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0128] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0129] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0130] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data encryption method based on a lightweight encryption algorithm, It is characterized in that include: In the case of determining that the received replacement instruction includes a P replacement instruction in a lightweight encryption algorithm, starting a P replacement accelerator, wherein the P replacement instruction includes encryption parameters of the lightweight encryption algorithm; Loading N groups of data in N registers in parallel through the P permutation accelerator, wherein the N groups of data include data to be subjected to P permutation operation in the data to be encrypted, and N is a natural number greater than 1; The encryption parameters are loaded through the P permutation accelerator, and based on the encryption parameters, a parallel P permutation operation is performed on the data to be subjected to the P permutation operation in the N groups of data to obtain N groups of P permutation operation results; The data to be encrypted is encrypted based on the N groups of P permutation operation results to obtain a target ciphertext.

2. The method according to claim 1, It is characterized in that In the case where it is determined that the received replacement instruction includes a P replacement instruction in the lightweight encryption algorithm, before starting the P replacement accelerator, the method further includes: Initializing the loaded original parameters to obtain an initial data block, wherein the original parameters include the encryption parameters, and the encryption parameters include at least one of the following: a key, a random number, and an initial vector; The initial data block is stored in a computer system.

3. The method according to claim 2, It is characterized in that Initialize the loaded original parameters to obtain the initial data block, including: Performing XOR processing on the key, random number and initial vector in the encryption parameter to obtain a first data block; Perform multiple rounds of P permutation operations on the first data block, and perform XOR processing on multiple operation results and the key to obtain the initial data block.

4. The method according to claim 1, It is characterized in that Before reading N groups of data in parallel from N registers through the P permutation accelerator, the method further includes: The data to be encrypted are grouped according to a preset data length to obtain N groups of the data, wherein the data to be encrypted includes associated information and data text, and the associated information is used to represent user information associated with the data text; The N groups of data are loaded into the N registers respectively according to the association information and the data text.

5. The method according to claim 1, It is characterized in that When it is determined that the received replacement instruction includes a P replacement instruction in the lightweight encryption algorithm, starting a P replacement accelerator includes: adding the permutation instruction to an opcode space in a computer system to store the permutation instruction in the opcode space; decoding the replacement instruction to obtain the P replacement instruction from the replacement instruction; The connection between the P permutation accelerator and the N registers is triggered to start the P permutation accelerator.

6. The method according to claim 1, It is characterized in that Loading N groups of data in N registers in parallel through the P permutation accelerator includes: Transmitting N groups of the data in parallel to the P permutation accelerator via M channels; or, Control the P permutation accelerator to load N groups of data in parallel through M channels; Wherein, M channel groups are connected to N registers, and M is a natural number less than or equal to N.

7. The method according to claim 1, It is characterized in that The encryption parameters are loaded through the P permutation accelerator, and based on the encryption parameters, a parallel P permutation operation is performed on the data to be subjected to the P permutation operation in the N groups of data to obtain N groups of P permutation operation results, including: Loading the encryption parameters from an operation code space of a computer system via the P permutation accelerator; Performing a P permutation operation on the data to be subjected to the P permutation operation in the associated information based on the encryption parameter by the P permutation accelerator to obtain a first P permutation operation result; Performing a P permutation operation on the data to be subjected to the P permutation operation in the data text based on the encryption parameter by the P permutation accelerator to obtain a second P permutation operation result; Determine the first P permutation operation result and the second P permutation operation result as N groups of the P permutation operation results; The data to be encrypted includes the associated information and the data text, and the associated information is used to represent user information associated with the data text.

8. The method according to claim 1, It is characterized in that Before encrypting the data to be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext, the method further includes: Storing N groups of P permutation operation results into N registers; The P permutation accelerator reads N groups of the P permutation operation results in parallel from the N registers.

9. The method according to claim 1, It is characterized in that After encrypting the data to be encrypted based on the N groups of P permutation operation results to obtain the target ciphertext, the method further includes: Loading N groups of ciphertext data in N registers in parallel through the P permutation accelerator, wherein the N groups of ciphertext data include data to be subjected to inverse P permutation operation in the target ciphertext; Performing inverse P permutation operations on N groups of ciphertext data in parallel based on decryption parameters by using the P permutation accelerator to obtain N groups of inverse P permutation operation results; The target ciphertext is decrypted based on N groups of inverse P permutation operation results.

10. A data encryption device based on a lightweight encryption algorithm, It is characterized in that include: processor, P permutation accelerator, and N registers, where: The processor is configured to trigger the start of the P permutation accelerator when it is determined that the received permutation instruction includes a P permutation instruction in a lightweight encryption algorithm, wherein the P permutation instruction includes encryption parameters of the lightweight encryption algorithm; The P permutation accelerator is used to load N groups of data in N registers in parallel, and perform P permutation operations on the N groups of data in parallel based on the encryption parameters to obtain N groups of P permutation operation results, wherein the N groups of data include data to be subjected to P permutation operations in the data to be encrypted, and N is a natural number greater than 1; The processor is further configured to encrypt the data to be encrypted based on N groups of P permutation operation results to obtain a target ciphertext.

11. The device according to claim 10, It is characterized in that The device also includes: an operation code space, wherein: The operation code space is used to store the permutation instruction, wherein the operation code space is set in a computer system and connected to the processor and the P permutation accelerator.

12. The device according to claim 11, It is characterized in that The device further comprises a decoder, wherein The decoder is connected to the operation code space, and is used to read the replacement instruction from the operation code space and decode the replacement instruction to obtain the P replacement instruction from the replacement instruction.

13. The device according to claim 10, It is characterized in that The device also includes M channels, wherein: The M channels are connected to the N registers in groups, and are used to transmit the N groups of data in parallel to the P permutation accelerator, where M is a natural number less than or equal to N.

14. The device according to claim 10, It is characterized in that The device also includes a general register, wherein The general register and the N registers are both set in a computer system, and the general register is used to store the target ciphertext.

15. A server, It is characterized in that A data encryption device based on a lightweight encryption algorithm comprising the data encryption device described in any one of claims 10-14.

16. A data encryption device based on a lightweight encryption algorithm, It is characterized in that include: A first starting module, configured to start a P replacement accelerator when it is determined that the received replacement instruction includes a P replacement instruction in a lightweight encryption algorithm, wherein the P replacement instruction includes encryption parameters of the lightweight encryption algorithm; A first loading module, configured to load N groups of data in N registers in parallel through the P permutation accelerator, wherein the N groups of data include data to be subjected to P permutation operation in the data to be encrypted, and N is a natural number greater than 1; A first operation module, configured to perform a P permutation operation on N groups of the data in parallel through the P permutation accelerator and based on the encryption parameter, to obtain N groups of P permutation operation results; The first encryption module is used to encrypt the data to be encrypted based on N groups of P permutation operation results to obtain a target ciphertext.

17. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 9 when executed by a processor.