Data encryption method and device

By decoupling the working mode module and the encryption and decryption module in the chip, any working mode is applied to all encryption algorithms, and the problem of low maintenance efficiency of various working modes of encryption algorithms in the prior art is solved, and cost reduction and maintenance efficiency improvement are achieved .

CN119299076APending Publication Date: 2025-01-10BEIJING CEC HUADA ELECTRONIC DESIGN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411353447.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

The codes between the various operating modes of different encryption algorithms in existing chips are independent of each other, resulting in the need to be updated and maintained separately during maintenance and update, increasing costs and reducing efficiency.

Method used

The encryption algorithm and working mode are decoupled through the working mode module and the basic encryption and decryption module, so that any working mode can be applied to all encryption algorithms, reducing the need for separate updates and maintenance of multiple working modes for each encryption algorithm.

Benefits of technology

The chip cost is reduced and the efficiency of update and maintenance is improved, so that the same working mode of multiple encryption algorithms only requires one update and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119299076A_ABST
    Figure CN119299076A_ABST
Patent Text Reader

Abstract

The invention discloses a data encryption method and device. And obtaining the to-be-encrypted data, the symmetric key and the target working mode received by the user interface module corresponding to the target encryption algorithm. And then, inputting the to-be-encrypted data, the symmetric key and the target working mode into a working mode module, so that the working mode module divides the to-be-encrypted data based on a preset grouping length corresponding to a target encryption algorithm to obtain at least one group of grouped data, and obtains at least one group of grouped data based on the target working mode and the symmetric key. And calling a target basic encryption and decryption module corresponding to the target encryption algorithm, and performing encryption processing on the at least one group of grouped data to obtain target encrypted data. And the encryption algorithm and the working mode are decoupled through the working mode module and the basic encryption and decryption module. Therefore, various working modes of each encryption algorithm are prevented from being independently updated and maintained, the cost of a chip is reduced, and the updating and maintaining efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of information technology, data has become an indispensable and valuable resource in modern society, and data encryption is a key means to ensure data security. The encryption algorithm for encrypting data provides a variety of working modes to meet different security requirements, such as Electronic Codebook (ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB) and Output Feedback (OFB).

[0003] At present, multiple working modes of different encryption algorithms are integrated inside the chip, but the codes between the multiple working modes of different encryption algorithms are independent of each other. For example, the chip integrates the ECB mode, CBC mode, CFB mode and OFB mode of encryption algorithm A, and the ECB mode and CBC mode of encryption algorithm B. In the subsequent maintenance and update process, the multiple working modes of each encryption algorithm integrated inside the chip need to be updated and maintained separately, which not only increases the cost of the chip, but also reduces the efficiency of update and maintenance. Summary of the invention

[0004] The present specification provides a data encryption method, device, storage medium and electronic device to reduce the cost of chips and improve the efficiency of updating and maintenance.

[0005] This manual adopts the following technical solutions:

[0006] This specification provides a method for data encryption, which is applied to an encryption device, wherein the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm, and the method includes:

[0007] Obtaining the data to be encrypted, the symmetric key, and the target working mode received by the user interface module corresponding to the target encryption algorithm;

[0008] The data to be encrypted, the symmetric key and the target working mode are input into the working mode module, so that the working mode module divides the data to be encrypted based on a preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain target encrypted data.

[0009] Optionally, the target working mode includes a basic working mode;

[0010] Based on the target working mode and the symmetric key, calling a basic encryption and decryption module corresponding to the target encryption algorithm, encrypting the at least one group of packet data to obtain target encrypted data, including:

[0011] If the target operating mode is determined to be the basic operating mode, the at least one group of grouped data and the symmetric key are input into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module encrypts the at least one group of grouped data in sequence based on the symmetric key to obtain at least one group of grouped encrypted data, and concatenates the at least one group of grouped encrypted data to obtain the target encrypted data.

[0012] Optionally, the target operating mode includes an advanced operating mode;

[0013] Based on the target working mode and the symmetric key, calling a basic encryption and decryption module corresponding to the target encryption algorithm, encrypting the at least one group of packet data to obtain target encrypted data, including:

[0014] If it is determined that the target operating mode is the advanced operating mode, obtaining an initialization vector corresponding to the data to be encrypted, inputting the at least one group of grouped data, the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector and the symmetric key;

[0015] The at least one group of grouped encrypted data is concatenated to obtain target encrypted data.

[0016] Optionally, the advanced working mode includes: CBC working mode;

[0017] Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including:

[0018] If it is determined that the target working mode is the CBC working mode, an XOR operation is performed on the first grouped data in the at least one group of grouped data and the initialization vector to obtain first grouped data after the XOR operation, and the first grouped data after the XOR operation and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first grouped data after the XOR operation based on the symmetric key to obtain first grouped encrypted data;

[0019] An XOR operation is performed on the first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain the second grouped data after the XOR operation, and the second grouped data after the XOR operation and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the second grouped data after the XOR operation based on the symmetric key to obtain the second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data.

[0020] Optionally, the advanced working mode includes: CFB working mode;

[0021] Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including:

[0022] If it is determined that the target working mode is the CFB working mode, inputting the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain an encrypted initialization vector;

[0023] performing an XOR operation on a first group of data in the at least one group of data and the encrypted initialization vector to obtain first group of encrypted data, and inputting the first group of encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group of encrypted data based on the symmetric key to obtain encrypted first group of encrypted data;

[0024] An XOR operation is performed on the encrypted first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain the second grouped encrypted data, and so on and so forth until the last group of grouped data to obtain at least one group of grouped encrypted data.

[0025] Optionally, the advanced working mode includes: OFB working mode;

[0026] Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including:

[0027] If it is determined that the target working mode is the OFB working mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain a first encrypted initialization vector, and performs an XOR operation on a first group of data in the at least one group of data and the first encrypted initialization vector to obtain a first group of encrypted data;

[0028] The once-encrypted initialization vector and the symmetric key are continuously input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain a twice-encrypted initialization vector, and performs an XOR operation on the second grouped data in the at least one group of grouped data and the twice-encrypted initialization vector to obtain second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data.

[0029] Optionally, the advanced working mode includes: CTR working mode;

[0030] Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including:

[0031] If it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped data to obtain a counter value corresponding to the at least one group of grouped data;

[0032] Inputting the counter value corresponding to the at least one group of packet data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of packet data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of packet data;

[0033] An XOR operation is performed on the encrypted counter value corresponding to the at least one group of grouped data and the at least one group of grouped data to obtain at least one group of encrypted grouped data.

[0034] Optionally, the method further comprises:

[0035] Acquire encrypted data received by a user interface module corresponding to a target decryption algorithm, a symmetric key corresponding to the encrypted data, and a target operating mode;

[0036] The encrypted data, the symmetric key corresponding to the encrypted data, and the target working mode are input into the working mode module, so that the working mode module divides the encrypted data based on a preset group length corresponding to the target decryption algorithm to obtain at least one group of grouped encrypted data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target decryption algorithm to decrypt the at least one group of grouped encrypted data to obtain target decrypted data.

[0037] Optionally, the target working mode includes a basic working mode;

[0038] Based on the target working mode and the symmetric key, calling a target basic encryption and decryption module corresponding to the target decryption algorithm, decrypting the at least one group of block encrypted data to obtain target decrypted data, including:

[0039] If the target operating mode is determined to be the basic operating mode, the at least one group of grouped encrypted data and the symmetric key are input into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module decrypts the at least one group of grouped encrypted data in sequence based on the symmetric key to obtain at least one group of grouped decrypted data, and concatenates the at least one group of grouped decrypted data to obtain target decrypted data.

[0040] Optionally, the target operating mode includes an advanced operating mode;

[0041] Based on the target working mode and the symmetric key, calling a target basic encryption and decryption module corresponding to the target decryption algorithm, decrypting the at least one group of block encrypted data to obtain target decrypted data, including:

[0042] If it is determined that the target operating mode is the advanced operating mode, obtaining an initialization vector corresponding to the encrypted data, inputting the at least one set of grouped encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one set of grouped decrypted data based on the at least one set of grouped encrypted data, the initialization vector, and the symmetric key;

[0043] The at least one group of grouped decrypted data is concatenated to obtain target encrypted data.

[0044] Optionally, the advanced working mode includes: CBC working mode;

[0045] Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including:

[0046] If it is determined that the target operating mode is the CBC operating mode, inputting the first block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the first block encrypted data based on the symmetric key to obtain the decrypted first block encrypted data;

[0047] Performing an XOR operation on the decrypted first group encrypted data and the initialization vector to obtain first group decrypted data;

[0048] Inputting the second block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the second block encrypted data based on the symmetric key to obtain the decrypted second block encrypted data;

[0049] An XOR operation is performed on the decrypted second group encrypted data and the first group encrypted data to obtain second group decrypted data, and so on until the last group of group encrypted data, to obtain at least one group of group decrypted data.

[0050] Optionally, the advanced working mode includes: CFB working mode;

[0051] Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including:

[0052] If it is determined that the target working mode is the CFB working mode, inputting the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain an encrypted initialization vector;

[0053] Performing an XOR operation on the first group encrypted data in the at least one group of group data and the encrypted initialization vector to obtain first group decrypted data;

[0054] Inputting the first block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first block encrypted data based on the symmetric key to obtain the encrypted first block encrypted data;

[0055] An XOR operation is performed on the second grouped encrypted data in the at least one group of grouped data and the encrypted first grouped encrypted data to obtain second grouped decrypted data, and so on until the last group of grouped encrypted data to obtain at least one group of grouped decrypted data.

[0056] Optionally, the advanced working mode includes: OFB working mode;

[0057] If it is determined that the target working mode is the OFB working mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain a first encrypted initialization vector, and performs an XOR operation on a first group of data in the at least one group of data and the first encrypted initialization vector to obtain a first group of encrypted data;

[0058] The once-encrypted initialization vector and the symmetric key are continuously input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain a twice-encrypted initialization vector, and performs an XOR operation on the second grouped data in the at least one group of grouped data and the twice-encrypted initialization vector to obtain second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data.

[0059] Optionally, the advanced working mode includes: CTR working mode;

[0060] Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including:

[0061] If it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped data to obtain a counter value corresponding to the at least one group of grouped data;

[0062] Inputting the counter value corresponding to the at least one group of packet data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of packet data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of packet data;

[0063] An XOR operation is performed on the encrypted counter value corresponding to the at least one group of grouped data and the at least one group of grouped data to obtain at least one group of encrypted grouped data.

[0064] Optionally, the basic operating mode is an ECB operating mode.

[0065] This specification provides a data encryption device, which is applied to an encryption device, wherein the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm; the device includes:

[0066] An acquisition module, used to acquire the data to be encrypted, the symmetric key and the target working mode received by the user interface module corresponding to the target encryption algorithm;

[0067] An encryption module is used to input the data to be encrypted, the symmetric key and the target working mode into the working mode module, so that the working mode module divides the data to be encrypted based on a preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain target encrypted data.

[0068] This specification provides an electronic device, including a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus;

[0069] The memory stores machine-readable instructions, and the processor executes the above-mentioned data encryption method by calling the machine-readable instructions.

[0070] The present specification provides a machine-readable storage medium, wherein the machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, a method for encrypting data is implemented.

[0071] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:

[0072] In this specification, the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm. The encryption device obtains the data to be encrypted, the symmetric key, and the target working mode received by the user interface module corresponding to the target encryption algorithm. Then, the data to be encrypted, the symmetric key, and the target working mode are input into the working mode module, so that the working mode module divides the data to be encrypted based on the preset packet length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt at least one group of grouped data to obtain the target encrypted data.

[0073] Through the working mode module and the basic encryption and decryption module, the encryption algorithm and the working mode are decoupled, so that any working mode in the working mode module can be applied to all encryption algorithms. Thus, it is avoided to update and maintain the multiple working modes of each encryption algorithm separately, which not only reduces the cost of the chip, but also improves the efficiency of update and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:

[0075] Figure 1 is a flow chart of a data encryption method shown in an exemplary embodiment;

[0076] Figure 2 is a schematic diagram of an encryption process of a basic working mode shown in an exemplary embodiment;

[0077] Figure 3 It is a schematic diagram of an encryption process of a CBC working mode shown in an exemplary embodiment;

[0078] Figure 4It is a schematic diagram of an encryption process of a CFB working mode shown in an exemplary embodiment;

[0079] Figure 5 It is a schematic diagram of an encryption process of an OFB working mode shown in an exemplary embodiment;

[0080] Figure 6 is a schematic diagram of an encryption process of a CTR working mode shown in an exemplary embodiment;

[0081] Figure 7 is a schematic diagram of a decryption process of a basic working mode shown in an exemplary embodiment;

[0082] Figure 8 It is a schematic diagram of a decryption process of a CBC working mode shown in an exemplary embodiment;

[0083] Fig. 9 is a schematic diagram of a decryption process of a CFB working mode shown in an exemplary embodiment;

[0084] Fig.10 is a schematic diagram of a decryption process of an OFB working mode shown in an exemplary embodiment;

[0085] Fig.11 is a schematic diagram of a decryption process of a CTR working mode shown in an exemplary embodiment;

[0086] Fig.12 An encryption device is shown in an exemplary embodiment;

[0087] Fig.13 It is a structural diagram of an electronic device in which a data encryption device is located, shown in an exemplary embodiment;

[0088] Fig.14 It is a structural diagram of a data encryption device shown in an exemplary embodiment. DETAILED DESCRIPTION

[0089] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0090] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0091] At present, multiple working modes of different encryption algorithms are integrated inside the chip, but the codes between the multiple working modes of different encryption algorithms are independent of each other. For example, the chip integrates the ECB mode, CBC mode, CFB mode and OFB mode of encryption algorithm A, and the ECB mode and CBC mode of encryption algorithm B. In the subsequent maintenance and update process, the multiple working modes of each encryption algorithm integrated inside the chip need to be updated and maintained separately, which not only increases the cost of the chip, but also reduces the efficiency of update and maintenance.

[0092] Based on this, this specification proposes a technical solution to decouple the encryption algorithm and the working mode through the working mode module and the basic encryption and decryption module, so that any working mode in the working mode module can be applied to all encryption algorithms. Thus, the cost of the chip is reduced and the efficiency of update and maintenance is improved.

[0093] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0094] Figure 1 The following is a flow chart of a method for data encryption shown in an exemplary embodiment, wherein the method specifically comprises the following steps:

[0095] S100: Acquire the data to be encrypted, the symmetric key and the target working mode received by the user interface module corresponding to the target encryption algorithm.

[0096] S102: Input the data to be encrypted, the symmetric key and the target working mode into the working mode module, so that the working mode module divides the data to be encrypted based on a preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain target encrypted data.

[0097] In the embodiments of this specification, the data encryption method can be applied to an encryption device, which includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm.

[0098] In actual applications, encryption algorithms and working modes are not bound together, that is, not only algorithm A has CBC mode, and not only algorithm B has CTR mode. Any encryption algorithm can implement working modes such as CBC and CTR. Since the ECB working mode is the most basic encryption mode, data is encrypted to obtain encrypted data. Moreover, the implementation methods of these working modes are fixed, so the ECB working mode can be used as a sub-operation of these working modes.

[0099] In the embodiment of this specification, the encryption device can obtain the encrypted data, symmetric key and target working mode received by the user interface module corresponding to the target encryption algorithm. The encryption algorithm mentioned here can refer to SM4 algorithm, AES algorithm, DES algorithm, etc.

[0100] Then, the encryption device can input the data to be encrypted, the symmetric key and the target working mode into the working mode module, so that the working mode module divides the data to be encrypted based on the preset packet length corresponding to the target encryption algorithm to obtain at least one group of packet data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt at least one group of packet data to obtain the target encrypted data. The basic encryption and decryption module mentioned here may refer to an encryption and decryption module that encrypts data through the ECB working mode.

[0101] It should be noted that different encryption algorithms support different packet lengths. For example, the SM4 algorithm supports the use of a 128-bit (16-byte) packet length. The AES algorithm supports the use of a 128-bit (16-byte) packet length. The DES algorithm supports the use of a 64-bit (8-byte) packet length. If it is determined that the data length of the data to be encrypted is 48 bytes and the target encryption algorithm is the SM4 algorithm, the data to be encrypted can be divided into three groups of packet data.

[0102] In the embodiments of this specification, the target working mode includes a basic working mode and an advanced working mode. The basic working mode mentioned here may refer to an ECB working mode.

[0103] If the target working mode is determined to be the basic working mode, at least one group of grouped data and the symmetric key are sequentially input into the target basic encryption and decryption module, so that the target basic encryption and decryption module sequentially encrypts at least one group of grouped data based on the symmetric key to obtain at least one group of grouped encrypted data, and concatenates at least one group of grouped encrypted data to obtain target encrypted data. Figure 2 shown.

[0104] Figure 2It is a schematic diagram of an encryption process of a basic working mode shown in an exemplary embodiment.

[0105] exist Figure 2 In the example, the working mode module divides the data to be encrypted into group data 1, group data 2, and group data 3. The basic encryption and decryption module is called to encrypt group data 1 based on the symmetric key to obtain group encrypted data 1. The group data 2 is encrypted based on the symmetric key to obtain group encrypted data 2. The group data 3 is encrypted based on the symmetric key to obtain group encrypted data 3. The group encrypted data 1, group encrypted data 2, and group encrypted data 3 are concatenated to obtain the target encrypted data.

[0106] Furthermore, if the target operating mode is determined to be an advanced operating mode, an initialization vector corresponding to the data to be encrypted is obtained, and at least one set of grouped data, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one set of grouped encrypted data based on at least one set of grouped data, the initialization vector and the symmetric key, and concatenates at least one set of grouped encrypted data to obtain the target encrypted data.

[0107] Among them, the advanced working modes include: CBC working mode, CFB working mode, OFB working mode, CTR working mode, CMAC working mode, XTS working mode, etc. This specification takes CBC working mode, CFB working mode, OFB working mode, and CTR working mode as examples to illustrate the advanced working modes, and this specification does not specifically limit the advanced working modes.

[0108] In an embodiment of the present specification, if the target working mode is determined to be the CBC working mode, the working mode module can perform an XOR operation on the first group data in at least one group of group data and the initialization vector to obtain the first group data after the XOR operation, and input the first group data after the XOR operation and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group data after the XOR operation based on the symmetric key to obtain the first group encrypted data.

[0109] Then, the working mode module can perform an XOR operation on the first grouped encrypted data and the second grouped data in at least one group of grouped data to obtain the second grouped data after the XOR operation, and input the second grouped data after the XOR operation and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the second grouped data after the XOR operation based on the symmetric key to obtain the second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data. Specifically, Figure 3 shown.

[0110] Figure 3 It is a schematic diagram of an encryption process of a CBC working mode shown in an exemplary embodiment.

[0111] exist Figure 3 In the example, the working mode module can divide the data to be encrypted into group data 1, group data 2, and group data 3. The working mode module can perform an XOR operation on the initialization vector and the group data 1 to obtain the group data 1 after the XOR operation, and call the basic encryption and decryption module to encrypt the group data 1 after the XOR operation based on the symmetric key to obtain the group encrypted data 1.

[0112] Then, the working mode module can perform an XOR operation on the packet encrypted data 1 and the packet data 2 to obtain the packet data 2 after the XOR operation, and call the basic encryption and decryption module to encrypt the packet data 2 after the XOR operation based on the symmetric key to obtain the packet encrypted data 2.

[0113] Next, the working mode module can perform an XOR operation on the packet encrypted data 2 and the packet data 3 to obtain the packet data 3 after the XOR operation, and call the basic encryption and decryption module to encrypt the packet data 3 after the XOR operation based on the symmetric key to obtain the packet encrypted data 3.

[0114] Finally, the working mode module can concatenate the grouped encrypted data 1, the grouped encrypted data 2, and the grouped encrypted data 3 to obtain the target encrypted data.

[0115] From the above embodiment, it can be seen that in the basic encryption and decryption module, data is encrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the encryption process of the CBC working mode to obtain encrypted data.

[0116] In the embodiment of the present specification, if the target working mode is determined to be the CFB working mode, the working mode module can input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the encrypted initialization vector.

[0117] Then, the working mode module can perform an XOR operation on the first group data in at least one group of group data and the encrypted initialization vector to obtain the first group encrypted data, and input the first group encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group encrypted data based on the symmetric key to obtain the encrypted first group encrypted data.

[0118] Then, the working mode module can perform an XOR operation on the encrypted first grouped encrypted data and the second grouped data in at least one group of grouped data to obtain the second grouped encrypted data, and so on until the last group of grouped data to obtain at least one group of grouped encrypted data. Figure 4 shown.

[0119] Figure 4 It is a schematic diagram of an encryption process in a CFB working mode shown in an exemplary embodiment.

[0120] exist Figure 4 In the example, the working mode module can divide the data to be encrypted into group data 1, group data 2, and group data 3. The basic encryption and decryption module is called to encrypt the initialization vector based on the symmetric key to obtain the encrypted initialization vector.

[0121] Then, the working mode module can perform an XOR operation on the encrypted initialization vector and the grouped data 1 to obtain the grouped encrypted data 1, and call the basic encryption and decryption module to encrypt the grouped encrypted data 1 based on the symmetric key to obtain the encrypted grouped encrypted data 1.

[0122] Next, the working mode module can perform an XOR operation on the encrypted grouped encrypted data 1 and grouped data 2 to obtain grouped encrypted data 2, and call the basic encryption and decryption module to encrypt the grouped encrypted data 2 based on the symmetric key to obtain the encrypted grouped encrypted data 2.

[0123] Then, the working mode module can perform an XOR operation on the encrypted grouped encrypted data 2 and the grouped data 3 to obtain the grouped encrypted data 3.

[0124] Finally, the working mode module can concatenate the grouped encrypted data 1, the grouped encrypted data 2, and the grouped encrypted data 3 to obtain the target encrypted data.

[0125] From the above embodiment, it can be seen that in the basic encryption and decryption module, data is encrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the encryption process of the CFB working mode to obtain encrypted data.

[0126] In an embodiment of the present specification, if the target operating mode is determined to be the OFB operating mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the encrypted initialization vector, and performs an XOR operation on the first group data in at least one group of group data and the encrypted initialization vector to obtain the first group encrypted data.

[0127] The initialization vector and the symmetric key after the first encryption are continuously inputted into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector after the first encryption based on the symmetric key to obtain the initialization vector after the second encryption, and performs an XOR operation on the second group data in at least one group of group data and the initialization vector after the second encryption to obtain the second group encrypted data, and so on and so forth until the last group of group data, to obtain at least one group of group encrypted data. Specifically, Figure 5 shown.

[0128] Figure 5 It is a schematic diagram of an encryption process of an OFB working mode shown in an exemplary embodiment.

[0129] exist Figure 5 In the example, the working mode module can divide the data to be encrypted into group data 1, group data 2, and group data 3. The working mode module can call the basic encryption and decryption module to encrypt the initialization vector based on the symmetric key to obtain the encrypted initialization vector, and perform an XOR operation on the group data 1 and the encrypted initialization vector to obtain the group encrypted data 1.

[0130] Secondly, the working mode module can call the basic encryption and decryption module to encrypt the initialization vector after the first encryption based on the symmetric key, obtain the initialization vector after the second encryption, and perform an XOR operation on the group data 2 and the initialization vector after the second encryption to obtain the group encrypted data 2.

[0131] Then, the working mode module can call the basic encryption and decryption module to encrypt the twice-encrypted initialization vector based on the symmetric key to obtain the thrice-encrypted initialization vector, and perform an XOR operation on the grouped data 3 and the thrice-encrypted initialization vector to obtain the grouped encrypted data 3.

[0132] Finally, the grouped encrypted data 1, the grouped encrypted data 2, and the grouped encrypted data 3 are concatenated to obtain the target encrypted data.

[0133] It can be seen from the above embodiments that in the basic encryption and decryption module, data is encrypted based on a symmetric key through the ECB working mode. Then, in the working mode module, a corresponding XOR operation is performed according to the encryption process of the OFB working mode to obtain encrypted data.

[0134] In the embodiment of the present specification, if the target working mode is determined to be the CTR working mode, the initialization vector and the group sequence number corresponding to at least one group of group data are concatenated to obtain a counter value corresponding to at least one group of group data.

[0135] The counter value corresponding to at least one group of grouped data and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to at least one group of grouped data based on the symmetric key to obtain the encrypted counter value corresponding to at least one group of grouped data.

[0136] An XOR operation is performed on the encrypted counter value corresponding to at least one group of grouped data and at least one group of grouped data to obtain at least one group of grouped encrypted data. Figure 6 shown.

[0137] Figure 6 It is a schematic diagram of an encryption process of a CTR working mode shown in an exemplary embodiment.

[0138] exist Figure 6 In the example, the working mode module can divide the data to be encrypted into group data 1, group data 2, and group data 3. The group sequence number of group data 1, the group sequence number of group data 2, and the group sequence number of group data 3 are respectively concatenated with the initialization vector to obtain the counter value 1 of group data 1, the counter value 2 of group data 2, and the counter value 3 of group data 3. Among them, the initialization vector mentioned here can refer to a Nonce of a set number of bytes. Nonce is an arbitrary or non-repeating random value that is used only once. The group sequence number can refer to the sequence number of a set number of bytes. For example, the initialization vector is 661F9CD37A38B4B, the group sequence number of group data 1 is 00000000000000001, and the Nonce and the group sequence number are concatenated to obtain the counter value 1 of 661F9CD37A38B4B0000000000000001.

[0139] Then, the working mode module can call the basic encryption and decryption module to encrypt counter value 1, counter value 2, and counter value 3 based on the symmetric key to obtain encrypted counter value 1, encrypted counter value 2, and encrypted counter value 3.

[0140] Next, the working mode module can perform an XOR operation on the encrypted counter value 1 and the packet data 1 to obtain the packet encrypted data 1. Perform an XOR operation on the encrypted counter value 2 and the packet data 2 to obtain the packet encrypted data 2. Perform an XOR operation on the encrypted counter value 3 and the packet data 3 to obtain the packet encrypted data 3.

[0141] Finally, the grouped encrypted data 1, the grouped encrypted data 2, and the grouped encrypted data 3 are concatenated to obtain the target encrypted data.

[0142] From the above embodiment, it can be seen that in the basic encryption and decryption module, data is encrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the encryption process of the CTR working mode to obtain encrypted data.

[0143] Furthermore, the same working mode of multiple encryption algorithms only needs to be updated and maintained once. Moreover, after implementing the ECB mode of a new algorithm, the other working modes of the algorithm can be supported through the working mode module without having to implement them separately. Thus, the cost of the chip is reduced and the efficiency of updating and maintenance is improved.

[0144] In the embodiments of this specification, the encryption device can also decrypt the encrypted data to obtain target decrypted data.

[0145] The encryption device can obtain the encrypted data received by the user interface module corresponding to the target decryption algorithm, the symmetric key corresponding to the encrypted data, and the target working mode.

[0146] Then, the encryption device can input the encrypted data, the symmetric key corresponding to the encrypted data, and the target working mode into the working mode module, so that the working mode module divides the encrypted data based on the preset group length corresponding to the target decryption algorithm to obtain at least one group of grouped encrypted data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target decryption algorithm to decrypt at least one group of grouped encrypted data to obtain the target decrypted data.

[0147] In the embodiments of this specification, the target working mode for encrypting the encrypted data includes a basic working mode and an advanced working mode. Similarly, the target working mode for decrypting the encrypted data also includes a basic working mode and an advanced working mode.

[0148] If the target working mode is determined to be the basic working mode, at least one set of grouped encrypted data and the symmetric key are sequentially input into the target basic encryption and decryption module, so that the target basic encryption and decryption module sequentially decrypts at least one set of grouped encrypted data based on the symmetric key to obtain at least one set of grouped decrypted data, and concatenates at least one set of grouped decrypted data to obtain target decrypted data. Figure 7 shown.

[0149] Figure 7 It is a schematic diagram of a decryption process of a basic working mode shown in an exemplary embodiment.

[0150] exist Figure 7In the example, the working mode module divides the encrypted data into group encrypted data 1, group encrypted data 2, and group encrypted data 3. The basic encryption and decryption module is called to decrypt the group encrypted data 1 based on the symmetric key to obtain the group decrypted data 1. The group encrypted data 2 is decrypted based on the symmetric key to obtain the group decrypted data 2. The group encrypted data 3 is decrypted based on the symmetric key to obtain the group decrypted data 3.

[0151] Then, the group decrypted data 1, the group decrypted data 2, and the group decrypted data 3 are concatenated to obtain the target decrypted data.

[0152] Furthermore, if the target operating mode is determined to be an advanced operating mode, an initialization vector corresponding to the encrypted data is obtained, and at least one set of grouped encrypted data, the initialization vector, and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one set of grouped decrypted data based on at least one set of grouped encrypted data, the initialization vector, and the symmetric key, and splices at least one set of grouped decrypted data to obtain the target encrypted data.

[0153] Among them, the advanced working mode includes: CBC working mode, CFB working mode, OFB working mode, etc. This specification takes CBC working mode, CFB working mode, and OFB working mode as examples to illustrate the advanced working mode, and this specification does not specifically limit the advanced working mode.

[0154] In an embodiment of the present specification, if the target operating mode is determined to be the CBC operating mode, the operating mode module can input the first group encrypted data in at least one group of group encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the first group encrypted data based on the symmetric key to obtain the decrypted first group encrypted data.

[0155] Then, the working mode module may perform an XOR operation on the decrypted first group encrypted data and the initialization vector to obtain the first group decrypted data.

[0156] Then, the working mode module can input the second group encrypted data and the symmetric key in at least one group of group encrypted data into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the second group encrypted data based on the symmetric key to obtain the decrypted second group encrypted data.

[0157] Finally, the working mode module can perform an XOR operation on the decrypted second group encrypted data and the first group encrypted data to obtain the second group decrypted data, and so on until the last group encrypted data, to obtain at least one group decrypted data. Figure 8 shown.

[0158] Figure 8 It is a schematic diagram of a decryption process of a CBC working mode shown in an exemplary embodiment.

[0159] exist Figure 8 In the example, the working mode module can divide the encrypted data to obtain group encrypted data 1, group encrypted data 2, and group encrypted data 3. The basic encryption and decryption module is called to decrypt the group encrypted data 1 based on the symmetric key to obtain the decrypted group encrypted data 1. The working mode module can perform an XOR operation on the decrypted group encrypted data 1 and the initialization vector to obtain the group decrypted data 1.

[0160] Then, the working mode module can call the basic encryption and decryption module to decrypt the block encrypted data 2 based on the symmetric key to obtain the decrypted block encrypted data 2. The working mode module can perform an XOR operation on the decrypted block encrypted data 2 and the block encrypted data 1 to obtain the block decrypted data 2.

[0161] Next, the working mode module can call the basic encryption and decryption module to decrypt the block encrypted data 3 based on the symmetric key to obtain the decrypted block encrypted data 3. The working mode module can perform an XOR operation on the decrypted block encrypted data 3 and the block encrypted data 2 to obtain the block decrypted data 3.

[0162] Finally, the working mode module can concatenate the group decrypted data 1, the group decrypted data 2, and the group decrypted data 3 to obtain the target decrypted data.

[0163] From the above embodiment, it can be seen that in the basic encryption and decryption module, the encrypted data is decrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the decryption process of the CBC working mode to obtain the decrypted data.

[0164] In the embodiment of the present specification, if the target working mode is determined to be the CFB working mode, the working mode module can input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the encrypted initialization vector.

[0165] Then, the working mode module may perform an XOR operation on the first group encrypted data in at least one group of group data and the encrypted initialization vector to obtain the first group decrypted data.

[0166] Next, the working mode module may input the first group encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group encrypted data based on the symmetric key to obtain the encrypted first group encrypted data.

[0167] Finally, the working mode module can perform an XOR operation on the second encrypted data in at least one group of grouped data and the encrypted first encrypted data to obtain the second decrypted data, and so on until the last group of encrypted data to obtain at least one group of decrypted data. Fig. 9 shown.

[0168] Fig. 9 It is a schematic diagram of a decryption process of a CFB working mode shown in an exemplary embodiment.

[0169] exist Fig. 9 In the example, the working mode module can divide the encrypted data to obtain group encrypted data 1, group encrypted data 2, and group encrypted data 3. The basic encryption and decryption module is called to encrypt the initialization vector based on the symmetric key to obtain the encrypted initialization vector. The working mode module can perform an XOR operation on the group encrypted data 1 and the encrypted initialization vector to obtain the group decrypted data 1.

[0170] Then, the working mode module can call the basic encryption and decryption module to encrypt the block encrypted data 1 based on the symmetric key to obtain the encrypted block encrypted data 1. The working mode module can perform an XOR operation on the block encrypted data 2 and the encrypted block encrypted data 1 to obtain the block decrypted data 2.

[0171] Next, the working mode module can call the basic encryption and decryption module to encrypt the block encrypted data 2 based on the symmetric key to obtain the encrypted block encrypted data 2. The working mode module can perform an XOR operation on the block encrypted data 3 and the encrypted block encrypted data 2 to obtain the block decrypted data 3.

[0172] Finally, the working mode module can concatenate the group decrypted data 1, the group decrypted data 2, and the group decrypted data 3 to obtain the target decrypted data.

[0173] From the above embodiment, it can be seen that in the basic encryption and decryption module, the encrypted data is decrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the decryption process of the CFB working mode to obtain the decrypted data.

[0174] In the embodiment of the present specification, if the target working mode is determined to be the OFB working mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the encrypted initialization vector, and performs an XOR operation on the first group data in at least one group of group data and the encrypted initialization vector to obtain the first group encrypted data.

[0175] The initialization vector and the symmetric key after the first encryption are continuously inputted into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector after the first encryption based on the symmetric key to obtain the initialization vector after the second encryption, and performs an XOR operation on the second group data in at least one group of group data and the initialization vector after the second encryption to obtain the second group encrypted data, and so on and so forth until the last group of group data, to obtain at least one group of group encrypted data. Specifically, Fig.10 shown.

[0176] Fig.10 It is a schematic diagram of a decryption process of an OFB working mode shown in an exemplary embodiment.

[0177] exist Fig.10 In the example, the working mode module can divide the encrypted data into group encrypted data 1, group encrypted data 2, and group encrypted data 3. The basic encryption and decryption module is called to encrypt the initialization vector based on the symmetric key to obtain the encrypted initialization vector.

[0178] Secondly, the working mode module can perform an XOR operation on the grouped encrypted data 1 and the encrypted initialization vector to obtain the grouped decrypted data 1, and perform an XOR operation on the grouped encrypted data 1 and the grouped decrypted data 1 to obtain a first XOR operation result as the initialization vector of the grouped encrypted data 2.

[0179] Then, the working mode module can call the basic encryption and decryption module to encrypt the initialization vector of the block encrypted data 2 based on the symmetric key to obtain the encrypted initialization vector of the block encrypted data 2.

[0180] Then, the working mode module can perform an XOR operation on the initialization vector of the encrypted group encryption data 2 and the group encryption data 2 to obtain the group decrypted data 2, and perform an XOR operation on the group encryption data 2 and the group decrypted data 2 to obtain a second XOR operation result as the initialization vector of the group encryption data 3.

[0181] Next, the working mode module may call the basic encryption and decryption module to encrypt the initialization vector of the block encrypted data 3 based on the symmetric key, and obtain the encrypted initialization vector of the block encrypted data 3.

[0182] Again, the working mode module can perform an XOR operation on the initialization vector of the encrypted grouped encrypted data 3 and the grouped encrypted data 3 to obtain the grouped decrypted data 3.

[0183] Finally, the working mode module can concatenate the group decrypted data 1, the group decrypted data 2, and the group decrypted data 3 to obtain the target decrypted data.

[0184] It can be seen from the above embodiments that in the basic encryption and decryption module, the encrypted data is decrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the decryption process of the OFB working mode to obtain the decrypted data.

[0185] In the embodiment of the present specification, if the target working mode is determined to be the CTR working mode, the initialization vector and the group sequence number corresponding to at least one group of grouped encrypted data are concatenated to obtain a counter value corresponding to at least one group of grouped encrypted data.

[0186] The counter value corresponding to at least one group of grouped encrypted data and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to at least one group of grouped encrypted data based on the symmetric key to obtain the encrypted counter value corresponding to the at least one group of grouped encrypted data.

[0187] An XOR operation is performed on the encrypted counter value corresponding to at least one group of encrypted data and at least one group of encrypted data to obtain at least one group of decrypted data. Fig.11 shown.

[0188] Fig.11 It is a schematic diagram of an encryption process of a CTR working mode shown in an exemplary embodiment.

[0189] exist Fig.11 In the example, the working mode module can divide the encrypted data into grouped encrypted data 1, grouped encrypted data 2, and grouped encrypted data 3. The group sequence number of grouped encrypted data 1, the group sequence number of grouped encrypted data 2, and the group sequence number of grouped encrypted data 3 are respectively concatenated with the initialization vector to obtain the counter value 1 of grouped encrypted data 1, the counter value 2 of grouped encrypted data 2, and the counter value 3 of grouped encrypted data 3.

[0190] Then, the working mode module can call the basic encryption and decryption module to encrypt counter value 1, counter value 2, and counter value 3 based on the symmetric key to obtain encrypted counter value 1, encrypted counter value 2, and encrypted counter value 3.

[0191] Next, the working mode module can perform an XOR operation on the encrypted counter value 1 and the packet encrypted data 1 to obtain the packet decrypted data 1. Perform an XOR operation on the encrypted counter value 2 and the packet encrypted data 2 to obtain the packet decrypted data 2. Perform an XOR operation on the encrypted counter value 3 and the packet encrypted data 3 to obtain the packet decrypted data 3.

[0192] Finally, the group decrypted data 1, the group decrypted data 2, and the group decrypted data 3 are concatenated to obtain the target decrypted data.

[0193] It can be seen from the above embodiments that in the basic encryption and decryption module, the encrypted data is decrypted based on the symmetric key through the ECB working mode. Then, in the working mode module, the corresponding XOR operation is performed according to the decryption process of the CTR working mode to obtain the decrypted data.

[0194] That is to say, in the advanced working mode, the basic working mode encrypts and decrypts the data based on the symmetric key. The basic working mode may be the ECB working mode.

[0195] Fig.12 An encryption device is shown in an exemplary embodiment.

[0196] exist Fig.12 In the invention, the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm.

[0197] The user interface module is used to receive the data to be encrypted, the symmetric key and the target working mode sent by the user. After receiving the data to be encrypted, it is also necessary to determine the data length, data integrity and other information of the data to be encrypted.

[0198] The working mode module is used to receive the data length, the data to be encrypted, the symmetric key and the target working mode sent by the user interface module, and divide the data to be encrypted based on the preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data. Then, based on the target working mode, the target basic encryption and decryption module corresponding to the target encryption algorithm is called to encrypt at least one group of grouped data to obtain at least one group of grouped encrypted data. Then, at least one group of grouped encrypted data is spliced ​​to obtain target encrypted data.

[0199] The basic encryption and decryption module is used to receive the data to be encrypted sent by the working mode module, such as packet data, initialization vector, etc., and encrypt the data to be encrypted.

[0200] Among them, when the working mode is the advanced working mode, the advanced working mode includes encryption operation and XOR operation. The working mode module calls the basic encryption and decryption module to perform encryption operation on the data, and the working mode module performs XOR operation on the data.

[0201] It can be seen from the above method that the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm. The encryption device obtains the data to be encrypted, the symmetric key, and the target working mode received by the user interface module corresponding to the target encryption algorithm. Then, the data to be encrypted, the symmetric key, and the target working mode are input into the working mode module, so that the working mode module divides the data to be encrypted based on the preset packet length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt at least one group of grouped data to obtain the target encrypted data.

[0202] Through the working mode module and the basic encryption and decryption module, the encryption algorithm and the working mode are decoupled, so that any working mode in the working mode module can be applied to all encryption algorithms. Thus, it is avoided to update and maintain the multiple working modes of each encryption algorithm separately, which not only reduces the cost of the chip, but also improves the efficiency of update and maintenance.

[0203] Corresponding to the above-mentioned embodiment of the method based on data encryption, this specification also provides an embodiment of a data encryption device.

[0204] See also Fig.13 , Fig.13 It is a structural diagram of an electronic device in which a data encryption device is located, which is shown in an exemplary embodiment. At the hardware level, the device includes a processor 1302, an internal bus 1304, a network interface 1306, a memory 1308, and a non-volatile memory 1310, and of course may also include other required hardware. One or more embodiments of this specification can be implemented based on software, such as the processor 1302 reading the corresponding computer program from the non-volatile memory 1310 into the memory 1308 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0205] See also Fig.14 , Fig.14 FIG. 1 is a structural diagram of a data encryption device according to an exemplary embodiment. The data encryption device can be applied to Fig.11In the electronic device shown in the figure, the technical solution of this specification is implemented. The device may include:

[0206] An acquisition module 1400 is used to acquire the data to be encrypted, the symmetric key and the target working mode received by the user interface module corresponding to the target encryption algorithm;

[0207] The encryption module 1402 is used to input the data to be encrypted, the symmetric key and the target working mode into the working mode module, so that the working mode module divides the data to be encrypted based on the preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain the target encrypted data.

[0208] Optionally, the target operating mode includes a basic operating mode; the encryption module 1402 is specifically used to, if it is determined that the target operating mode is the basic operating mode, input the at least one group of grouped data and the symmetric key into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module encrypts the at least one group of grouped data in sequence based on the symmetric key to obtain at least one group of grouped encrypted data, and splices the at least one group of grouped encrypted data to obtain target encrypted data.

[0209] Optionally, the target operating mode includes an advanced operating mode; the encryption module 1402 is specifically used to obtain an initialization vector corresponding to the data to be encrypted if it is determined that the target operating mode is the advanced operating mode, and input the at least one group of grouped data, the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector and the symmetric key; and splices the at least one group of grouped encrypted data to obtain target encrypted data.

[0210] Optionally, the advanced working mode includes: a CBC working mode; the encryption module 1402 is specifically used to, if it is determined that the target working mode is the CBC working mode, perform an XOR operation on the first grouped data in the at least one group of grouped data and the initialization vector to obtain the first grouped data after the XOR operation, and input the first grouped data after the XOR operation and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first grouped data after the XOR operation based on the symmetric key to obtain the first grouped encrypted data; perform an XOR operation on the first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain the second grouped data after the XOR operation, and input the second grouped data after the XOR operation and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the second grouped data after the XOR operation based on the symmetric key to obtain the second grouped encrypted data, and so on, until the last group of grouped data, at least one group of grouped encrypted data is obtained.

[0211] Optionally, the advanced working mode includes: CFB working mode; the encryption module 1402 is specifically used to, if it is determined that the target working mode is the CFB working mode, input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain an encrypted initialization vector; perform an XOR operation on the first grouped data in the at least one group of grouped data and the encrypted initialization vector to obtain first grouped encrypted data, and input the first grouped encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first grouped encrypted data based on the symmetric key to obtain encrypted first grouped encrypted data; perform an XOR operation on the encrypted first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain second grouped encrypted data, and so on, until the last group of grouped data, at least one group of grouped encrypted data is obtained.

[0212] Optionally, the advanced working mode includes: OFB working mode; the encryption module 1402 is specifically used to, if it is determined that the target working mode is the OFB working mode, input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the once-encrypted initialization vector, and performs an XOR operation on the first group data in the at least one group of group data and the once-encrypted initialization vector to obtain the first group encrypted data; continue to input the once-encrypted initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain the twice-encrypted initialization vector, and performs an XOR operation on the second group data in the at least one group of group data and the twice-encrypted initialization vector to obtain the second group encrypted data, and so on, until the last group of group data, at least one group of group encrypted data is obtained.

[0213] Optionally, the advanced working mode includes: a CTR working mode; the encryption module 1402 is specifically used to, if it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped data to obtain a counter value corresponding to the at least one group of grouped data; input the counter value corresponding to the at least one group of grouped data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of grouped data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of grouped data; and perform an XOR operation on the encrypted counter value corresponding to the at least one group of grouped data and the at least one group of grouped data to obtain at least one group of encrypted grouped data.

[0214] Optionally, the device may further include:

[0215] The decryption module 1404 is specifically used to obtain the encrypted data received by the user interface module corresponding to the target decryption algorithm, the symmetric key corresponding to the encrypted data, and the target working mode; the encrypted data, the symmetric key corresponding to the encrypted data, and the target working mode are input into the working mode module, so that the working mode module divides the encrypted data based on the preset group length corresponding to the target decryption algorithm to obtain at least one group of grouped encrypted data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target decryption algorithm to decrypt the at least one group of grouped encrypted data to obtain target decrypted data.

[0216] Optionally, the target operating mode includes a basic operating mode; the decryption module 1404 is specifically used to, if it is determined that the target operating mode is the basic operating mode, input the at least one group of grouped encrypted data and the symmetric key into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module decrypts the at least one group of grouped encrypted data in sequence based on the symmetric key to obtain at least one group of grouped decrypted data, and splices the at least one group of grouped decrypted data to obtain target decrypted data.

[0217] Optionally, the target operating mode includes an advanced operating mode; the decryption module 1404 is specifically used to obtain an initialization vector corresponding to the encrypted data if it is determined that the target operating mode is the advanced operating mode, and input the at least one group of grouped encrypted data, the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped decrypted data based on the at least one group of grouped encrypted data, the initialization vector and the symmetric key; and splices the at least one group of grouped decrypted data to obtain the target encrypted data.

[0218] Optionally, the advanced working mode includes: a CBC working mode; the decryption module 1404 is specifically used to, if it is determined that the target working mode is the CBC working mode, input the first block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the first block encrypted data based on the symmetric key to obtain the decrypted first block encrypted data; performs an XOR operation on the decrypted first block encrypted data and the initialization vector to obtain the first block decrypted data; inputs the second block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the second block encrypted data based on the symmetric key to obtain the decrypted second block encrypted data; performs an XOR operation on the decrypted second block encrypted data and the first block encrypted data to obtain the second block decrypted data, and so on, until the last group of block encrypted data, at least one group of block decrypted data is obtained.

[0219] Optionally, the advanced working mode includes: CFB working mode; the decryption module 1404 is specifically used to, if it is determined that the target working mode is the CFB working mode, input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the encrypted initialization vector; perform an XOR operation on the first group encrypted data in the at least one group of grouped data and the encrypted initialization vector to obtain the first group decrypted data; input the first group encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group encrypted data based on the symmetric key to obtain the encrypted first group encrypted data; perform an XOR operation on the second group encrypted data in the at least one group of grouped data and the encrypted first group encrypted data to obtain the second group decrypted data, and so on, until the last group of group encrypted data, to obtain at least one group of group decrypted data.

[0220] Optionally, the advanced working mode includes: OFB working mode; the decryption module 1404 is specifically used to, if it is determined that the target working mode is the OFB working mode, input the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain the once-encrypted initialization vector, and performs an XOR operation on the first group encrypted data in the at least one group of group encrypted data and the once-encrypted initialization vector to obtain the first group decrypted data; continue to input the once-encrypted initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain the twice-encrypted initialization vector, and performs an XOR operation on the second group encrypted data in the at least one group of group encrypted data and the twice-encrypted initialization vector to obtain the second group decrypted data, and so on, until the last group of group encrypted data, at least one group of group decrypted data is obtained.

[0221] Optionally, the advanced working mode includes: a CTR working mode; the decryption module 1404 is specifically used to, if it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped encrypted data to obtain a counter value corresponding to the at least one group of grouped encrypted data; input the counter value corresponding to the at least one group of grouped encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of grouped encrypted data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of grouped encrypted data; perform an XOR operation on the encrypted counter value corresponding to the at least one group of grouped encrypted data and the at least one group of grouped encrypted data to obtain at least one group of grouped decrypted data.

[0222] Optionally, the basic operating mode is the ECB operating mode.

[0223] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0224] Based on the same concept as the above method, this specification also provides an electronic device, including: a processor; a memory for storing processor executable instructions; wherein the processor implements the steps of the method described in any of the above embodiments by running the executable instructions.

[0225] Based on the same concept as the above method, this specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.

[0226] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.

[0227] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0228] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A method for data encryption, characterized in that: The method is applied to an encryption device, the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm, and the method includes: Obtaining the data to be encrypted, the symmetric key, and the target working mode received by the user interface module corresponding to the target encryption algorithm; The data to be encrypted, the symmetric key and the target working mode are input into the working mode module, so that the working mode module divides the data to be encrypted based on a preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain target encrypted data.

2. The method according to claim 1, characterized in that The target working mode includes a basic working mode; Based on the target working mode and the symmetric key, calling a basic encryption and decryption module corresponding to the target encryption algorithm, encrypting the at least one group of packet data to obtain target encrypted data, including: If the target operating mode is determined to be the basic operating mode, the at least one group of grouped data and the symmetric key are input into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module encrypts the at least one group of grouped data in sequence based on the symmetric key to obtain at least one group of grouped encrypted data, and concatenates the at least one group of grouped encrypted data to obtain the target encrypted data.

3. The method according to claim 1, characterized in that The target working mode includes an advanced working mode; Based on the target working mode and the symmetric key, calling a basic encryption and decryption module corresponding to the target encryption algorithm, encrypting the at least one group of packet data to obtain target encrypted data, including: If it is determined that the target operating mode is the advanced operating mode, obtaining an initialization vector corresponding to the data to be encrypted, inputting the at least one group of grouped data, the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector and the symmetric key; The at least one group of grouped encrypted data is concatenated to obtain target encrypted data.

4. The method according to claim 3, characterized in that The advanced working modes include: CBC working mode; Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the CBC working mode, an XOR operation is performed on the first grouped data in the at least one group of grouped data and the initialization vector to obtain first grouped data after the XOR operation, and the first grouped data after the XOR operation and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first grouped data after the XOR operation based on the symmetric key to obtain first grouped encrypted data; An XOR operation is performed on the first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain the second grouped data after the XOR operation, and the second grouped data after the XOR operation and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the second grouped data after the XOR operation based on the symmetric key to obtain the second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data.

5. The method according to claim 3, characterized in that The advanced working modes include: CFB working mode; Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the CFB working mode, inputting the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain an encrypted initialization vector; performing an XOR operation on a first group of data in the at least one group of data and the encrypted initialization vector to obtain first group of encrypted data, and inputting the first group of encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first group of encrypted data based on the symmetric key to obtain encrypted first group of encrypted data; An XOR operation is performed on the encrypted first grouped encrypted data and the second grouped data in the at least one group of grouped data to obtain the second grouped encrypted data, and so on and so forth until the last group of grouped data to obtain at least one group of grouped encrypted data.

6. The method according to claim 3, characterized in that The advanced working modes include: OFB working mode; Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the OFB working mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain a first encrypted initialization vector, and performs an XOR operation on a first group of data in the at least one group of data and the first encrypted initialization vector to obtain a first group of encrypted data; The once-encrypted initialization vector and the symmetric key are continuously input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain a twice-encrypted initialization vector, and performs an XOR operation on the second grouped data in the at least one group of grouped data and the twice-encrypted initialization vector to obtain second grouped encrypted data, and so on, until the last group of grouped data, to obtain at least one group of grouped encrypted data.

7. The method according to claim 3, characterized in that The advanced working modes include: CTR working mode; Inputting the at least one group of grouped data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of grouped encrypted data based on the at least one group of grouped data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped data to obtain a counter value corresponding to the at least one group of grouped data; Inputting the counter value corresponding to the at least one group of packet data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of packet data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of packet data; An XOR operation is performed on the encrypted counter value corresponding to the at least one group of grouped data and the at least one group of grouped data to obtain at least one group of encrypted grouped data.

8. The method according to claim 1, characterized in that The method further comprises: Acquire encrypted data received by a user interface module corresponding to a target decryption algorithm, a symmetric key corresponding to the encrypted data, and a target operating mode; The encrypted data, the symmetric key corresponding to the encrypted data, and the target working mode are input into the working mode module, so that the working mode module divides the encrypted data based on a preset group length corresponding to the target decryption algorithm to obtain at least one group of grouped encrypted data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target decryption algorithm to decrypt the at least one group of grouped encrypted data to obtain target decrypted data.

9. The method according to claim 8, characterized in that The target working mode includes a basic working mode; Based on the target working mode and the symmetric key, calling a target basic encryption and decryption module corresponding to the target decryption algorithm, decrypting the at least one group of block encrypted data to obtain target decrypted data, including: If the target operating mode is determined to be the basic operating mode, the at least one group of grouped encrypted data and the symmetric key are input into the target basic encryption and decryption module in sequence, so that the target basic encryption and decryption module decrypts the at least one group of grouped encrypted data in sequence based on the symmetric key to obtain at least one group of grouped decrypted data, and concatenates the at least one group of grouped decrypted data to obtain target decrypted data.

10. The method according to claim 8, characterized in that The target working mode includes an advanced working mode; Based on the target working mode and the symmetric key, calling a target basic encryption and decryption module corresponding to the target decryption algorithm, decrypting the at least one group of block encrypted data to obtain target decrypted data, including: If it is determined that the target operating mode is the advanced operating mode, obtaining an initialization vector corresponding to the encrypted data, inputting the at least one set of grouped encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one set of grouped decrypted data based on the at least one set of grouped encrypted data, the initialization vector, and the symmetric key; The at least one group of grouped decrypted data is concatenated to obtain target encrypted data.

11. The method according to claim 10, characterized in that The advanced working modes include: CBC working mode; Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including: If it is determined that the target operating mode is the CBC operating mode, inputting the first block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the first block encrypted data based on the symmetric key to obtain the decrypted first block encrypted data; Performing an XOR operation on the decrypted first group encrypted data and the initialization vector to obtain first group decrypted data; Inputting the second block encrypted data in the at least one group of block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module decrypts the second block encrypted data based on the symmetric key to obtain the decrypted second block encrypted data; An XOR operation is performed on the decrypted second group encrypted data and the first group encrypted data to obtain second group decrypted data, and so on until the last group of group encrypted data, to obtain at least one group of group decrypted data.

12. The method according to claim 10, characterized in that The advanced working modes include: CFB working mode; Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the CFB working mode, inputting the initialization vector and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain an encrypted initialization vector; Performing an XOR operation on the first group encrypted data in the at least one group of group data and the encrypted initialization vector to obtain first group decrypted data; Inputting the first block encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the first block encrypted data based on the symmetric key to obtain the encrypted first block encrypted data; An XOR operation is performed on the second grouped encrypted data in the at least one group of grouped data and the encrypted first grouped encrypted data to obtain second grouped decrypted data, and so on until the last group of grouped encrypted data to obtain at least one group of grouped decrypted data.

13. The method according to claim 10, characterized in that The advanced working modes include: OFB working mode; Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the OFB working mode, the initialization vector and the symmetric key are input into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the initialization vector based on the symmetric key to obtain a first encrypted initialization vector, and performs an XOR operation on the first block encrypted data in the at least one group of block encrypted data and the first encrypted initialization vector to obtain a first block decrypted data; The once-encrypted initialization vector and the symmetric key are continuously input into the target basic encryption / decryption module, so that the target basic encryption / decryption module encrypts the once-encrypted initialization vector based on the symmetric key to obtain a twice-encrypted initialization vector, and performs an XOR operation on the second grouped encrypted data in the at least one group of grouped encrypted data and the twice-encrypted initialization vector to obtain second grouped decrypted data, and so on, until the last group of grouped encrypted data is obtained, to obtain at least one group of grouped decrypted data.

14. The method according to claim 10, characterized in that The advanced working modes include: CTR working mode; Inputting the at least one group of encrypted data, the initialization vector, and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module obtains at least one group of decrypted data based on the at least one group of encrypted data, the initialization vector, and the symmetric key, including: If it is determined that the target working mode is the CTR working mode, concatenate the initialization vector and the group sequence number corresponding to the at least one group of grouped encrypted data to obtain a counter value corresponding to the at least one group of grouped encrypted data; Inputting the counter value corresponding to the at least one group of encrypted data and the symmetric key into the target basic encryption and decryption module, so that the target basic encryption and decryption module encrypts the counter value corresponding to the at least one group of encrypted data based on the symmetric key to obtain an encrypted counter value corresponding to the at least one group of encrypted data; An XOR operation is performed on the encrypted counter value corresponding to the at least one group of grouped encrypted data and the at least one group of grouped encrypted data to obtain at least one group of grouped decrypted data.

15. The method according to any one of claims 1 to 14, characterized in that: The basic working mode is the ECB working mode.

16. A data encryption device, characterized in that: The device is applied to an encryption device, the encryption device includes a user interface module corresponding to at least one encryption algorithm, a working mode module, and a basic encryption and decryption module corresponding to at least one encryption algorithm; the device includes: An acquisition module, used to acquire the data to be encrypted, the symmetric key and the target working mode received by the user interface module corresponding to the target encryption algorithm; An encryption module is used to input the data to be encrypted, the symmetric key and the target working mode into the working mode module, so that the working mode module divides the data to be encrypted based on a preset group length corresponding to the target encryption algorithm to obtain at least one group of grouped data, and based on the target working mode and the symmetric key, calls the target basic encryption and decryption module corresponding to the target encryption algorithm to encrypt the at least one group of grouped data to obtain target encrypted data.

17. An electronic device, characterized in that: It includes a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus; The memory stores machine-readable instructions, and the processor executes the method according to any one of claims 1 to 15 by calling the machine-readable instructions.

18. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by the processor, the method according to any one of claims 1 to 15 is implemented.