Data sequence encryption and decryption method, device, equipment and storage medium
Through a key expansion method based on the lattice problem framework, the key generation and expansion modules are decoupled, and round keys are generated to improve the quantum attack resistance and security of sequence encryption, solving the problems of insufficient security and flexibility of existing sequence encryption algorithms, and is suitable for scenarios such as the Internet of Things.
Patent Information
- Application Number
- CN202411522756.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2044-10-29
AI Technical Summary
Existing serial encryption algorithms have weak resistance to quantum attacks, and key expansion and generation are coupled with data encryption and decryption calculations, resulting in low security and insufficient flexibility.
A key expansion method based on the lattice problem framework is adopted. The key generation and expansion modules are decoupled. The key generation process generates round keys through the lattice basis matrix and the user's initial key, and combines the counter and random number to generate sequential encryption and decryption keys, achieving the flexibility of the encryption and decryption process and the ability to resist quantum attacks.
It improves the ability of serial encryption to resist quantum attacks, enhances security, and realizes the flexibility and reconfigurability of the encryption and decryption process, making it suitable for scenarios such as the Internet of Things.
Smart Images

Figure CN119402186B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data sequence encryption technology, and in particular to a data sequence encryption and decryption method, device, equipment and storage medium. Background Art
[0002] Serial encryption is the most common concept in modern cryptography. It is a cryptographic technology that is similar to a one-time pad. It has the advantages of high theoretical security, easy implementation, low overhead, and low diffusion. It is widely used in scenarios such as confidential communications in special industries and data security encryption.
[0003] Existing serial encryption algorithms include RC4 (Rivest Cipher 4, stream encryption algorithm), SEAL (Simple Encrypted Arithmetic Library, simple encryption arithmetic library) and SM7 (SM7 Cryptographic Algorithm, symmetric encryption algorithm).
[0004] The existing serial encryption algorithms have weak resistance to quantum attacks, resulting in low quantum encryption security. In addition, there is a strong coupling between key expansion and generation and data encryption and decryption calculations, resulting in low flexibility and reconfigurability in the key encryption and decryption stages. Summary of the Invention
[0005] The present invention provides a data sequence encryption and decryption method, device, equipment and storage medium to improve the anti-quantum attack capability of sequence encryption, improve the security of sequence encryption, and realize the reconfiguration of the sequence encryption process, thereby improving the flexibility of the encryption and decryption process.
[0006] According to one aspect of the present invention, a data sequence encryption and decryption method is provided, which is applied to a data encryption party, and the method comprises:
[0007] Generate the user's initial key and the lattice matrix;
[0008] Generate at least one round key according to the user initial key and the lattice basis matrix;
[0009] Obtaining plaintext data to be encrypted, and segmenting the plaintext data to be encrypted based on a preset plaintext data unit length to obtain at least one plaintext sequence;
[0010] Determining the number of key generation rounds of the sequence encryption key according to the sequence number of the plaintext sequence;
[0011] For any round of sequence encryption key generation, determine the round key corresponding to the key generation round;
[0012] Generate a sequence encryption key for the key generation round according to the round key corresponding to the key generation round;
[0013] Generate a ciphertext sequence under the key generation round according to the sequence encryption key and the plaintext sequence under the key generation round;
[0014] The encrypted ciphertext data of the plaintext data to be encrypted is generated according to the ciphertext sequences corresponding to the key generation rounds.
[0015] According to another aspect of the present invention, a data sequence encryption and decryption method is provided, which is applied to a data decryption party, and the method comprises:
[0016] Generate the user's initial key and the lattice matrix;
[0017] Generate at least one round key according to the user initial key and the lattice basis matrix;
[0018] Acquire encrypted ciphertext data, and perform data segmentation on the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence;
[0019] Determining the number of key generation rounds of a sequence decryption key according to the number of sequences of the ciphertext sequence;
[0020] For any round of sequence decryption key generation, determine the round key corresponding to the key generation round;
[0021] Generate a sequence decryption key for the key generation round according to the round key corresponding to the key generation round;
[0022] Decrypt the key and ciphertext sequence according to the sequence in the key generation round to generate the plaintext sequence in the key generation round;
[0023] The plaintext data of the encrypted ciphertext data is generated according to the plaintext sequences corresponding to the key generation rounds.
[0024] According to another aspect of the present invention, there is provided a data sequence encryption and decryption device, which is configured on a data encryption side, and comprises:
[0025] The initial key generation module is used to generate the user's initial key and the lattice matrix;
[0026] a round key generation module, configured to generate at least one round key according to the user initial key and the lattice basis matrix;
[0027] A plaintext sequence generation module is used to obtain plaintext data to be encrypted and, based on a preset plaintext data unit length, perform data segmentation on the plaintext data to be encrypted to obtain at least one plaintext sequence;
[0028] A generation round number determination module, configured to determine the number of key generation rounds for a sequence encryption key according to the number of sequences of the plaintext sequence;
[0029] A corresponding key determination module, configured to determine a round key corresponding to a key generation round according to a generation method of a sequence encryption key of any round;
[0030] A sequence key generation module, configured to generate a sequence encryption key for the key generation round based on a round key corresponding to the key generation round;
[0031] A ciphertext sequence generation module, configured to generate a ciphertext sequence under the key generation round according to the sequence encryption key and the plaintext sequence under the key generation round;
[0032] The ciphertext data generation module is used to generate encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequences corresponding to the key generation rounds.
[0033] According to another aspect of the present invention, there is provided a data sequence encryption and decryption device, which is configured on a data decryption side, and comprises:
[0034] The initial key generation module is used to generate the user's initial key and the lattice matrix;
[0035] a round key generation module, configured to generate at least one round key according to the user initial key and the lattice basis matrix;
[0036] A ciphertext sequence generation module is used to obtain encrypted ciphertext data and perform data segmentation on the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence;
[0037] A generation round number determination module, configured to determine the number of key generation rounds for a sequence decryption key according to the number of sequences of the ciphertext sequence;
[0038] A corresponding key generation module is used to determine the round key corresponding to the key generation round according to the generation method of the sequence decryption key of any round;
[0039] A sequence key generation module, configured to generate a sequence decryption key for the key generation round based on the round key corresponding to the key generation round;
[0040] A plaintext sequence generation module, configured to generate a plaintext sequence under the key generation round according to the sequence decryption key and the ciphertext sequence under the key generation round;
[0041] The plaintext data generation module is used to generate the plaintext data of the encrypted ciphertext data according to the plaintext sequences corresponding to the key generation rounds.
[0042] According to another aspect of the present invention, an electronic device is provided, comprising:
[0043] at least one processor; and
[0044] a memory communicatively connected to the at least one processor; wherein,
[0045] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the data sequence encryption and decryption method described in any embodiment of the present invention.
[0046] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data sequence encryption and decryption method described in any embodiment of the present invention when executed.
[0047] The technical solution of the embodiment of the present invention utilizes a key expansion method based on a lattice problem framework. Furthermore, the key expansion process is completely decoupled from the encryption and decryption process. The key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in separate components, facilitating application in scenarios such as the Internet of Things. Furthermore, the data encryption and decryption method of the above technical solution improves the resistance of serial encryption to quantum attacks and enhances its security. Furthermore, the serial encryption process is reconfigurable, increasing the flexibility of the encryption and decryption process.
[0048] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 This is a flow chart of a data sequence encryption and decryption method provided according to the first embodiment of the present invention;
[0051] Figure 2 This is a flow chart of a data sequence encryption and decryption method provided according to the second embodiment of the present invention;
[0052] Figure 3 This is a schematic diagram of the structure of a data sequence encryption and decryption device provided according to the third embodiment of the present invention;
[0053] Figure 4 This is a schematic diagram of the structure of a data sequence encryption and decryption device provided according to a fourth embodiment of the present invention;
[0054] Figure 5 The present invention is a schematic diagram of the structure of an electronic device for implementing the data sequence encryption and decryption method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0056] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0057] Example 1
[0058] Figure 1 This is a flowchart of a data sequence encryption and decryption method provided in the first embodiment of the present invention. This embodiment is applicable to data encryption and decryption situations where there is a requirement to retain the original format of the encrypted plaintext data, such as consistent length, similar memory usage, and the encryption process has anti-quantity security. This method can be executed by a data sequence encryption and decryption device. The data sequence encryption and decryption device can be implemented in the form of hardware and / or software. The data sequence encryption and decryption device can be configured in the electronic device of the data encryption party. Figure 1 As shown, the method includes:
[0059] S110: Generate a user initial key and a lattice basis matrix.
[0060] Specifically, the user can use key negotiation or a random number generator to generate a user initial key of a specified length. The bit length of the user initial key can be 128, 192, 256, or 512, and can be set based on actual needs. This embodiment does not limit this. The user initial key can be pre-generated and stored in the form of a bit string, or it can be generated during a data encryption task.
[0061] The lattice matrix is composed of randomly generated integer modulo q. The lattice matrix B is expressed as follows:
[0062]
[0063] The dimensions of M and N are pre-set by relevant technical personnel. The size of N is related to the key length of the user's initial key, which is pre-set by relevant technical personnel based on actual needs.
[0064] S120: Generate at least one round key according to the user's initial key and the lattice basis matrix.
[0065] The user's initial key can be converted into a matrix form, and the key matrix of the user's initial key is multiplied by the lattice basis matrix to obtain a target matrix; and the elements in the target matrix are determined as round keys.
[0066] To further improve the security and reliability of round key generation and make the key more resistant to quantum attacks, in an optional embodiment, at least one round key is generated based on the user's initial key and the lattice basis matrix, including:
[0067] Step a1: Obtain encryption-related information, and generate an initial key bit string based on the encryption-related information and the user's initial key.
[0068] The encryption-related information may be information related to the current encryption, such as task information, communication information, and account information. The encryption-related information is combined into a bit string of a specified length; the combined encryption-related information is combined with the user's initial key to obtain an initial key bit string.
[0069] Specifically, the encryption-related information is recorded as Auc, the user's initial key is recorded as Key, and the encryption-related information Auc and the user's initial key Key are bit-concatenated to form an initial key bit string String of a specified length W:
[0070] String = Key || Auc;
[0071] Here, “||” represents bit concatenation; wherein, the bit length of the initial key bit string String is W.
[0072] Step a2: split the initial key bit string according to the preset key data unit length to obtain at least one initial key sub-bit string.
[0073] If the preset key data unit length is T, it should be noted that the bit length of the initial key bit string String is W and must be divisible by the preset key data unit length T. If the bit length W of the initial key bit string String divided by the preset key data unit length T is N, then N initial key sub-bit strings can be generated. The initial key bit string String is segmented as follows:
[0074] String=S1||S2||…||S N ;
[0075] Among them, S1, S2, ..., S N is the initial key sub-bit string, and the length of each initial key sub-bit string is T.
[0076] Step a3: Generate at least one intermediate key sub-bit string based on the lattice matrix and each initial key sub-bit string.
[0077] In an optional embodiment, generating at least one intermediate key sub-bit string according to the lattice matrix and each initial key sub-bit string includes:
[0078] Step a31: Perform base conversion on each initial key sub-bit string to obtain an initial integer key.
[0079] Each initial key sub-bit string S1, S2, ..., S N Convert to integer (decimal) form to get the initial integer key a1,…,a N , that is: (S1, S2, ..., S N )=(a1,…,a N ).
[0080] Step a32: Generate an initial key matrix based on the initial integer key.
[0081] The elements in the initial matrix key are composed of the initial integer key, and the initial key matrix a is as follows:
[0082] (a1,…,a N )=a;
[0083] Step a33: Perform a matrix multiplication operation on the lattice basis matrix and the transposed matrix of the initial key matrix to obtain a target key matrix.
[0084] The target key matrix Q is generated as follows:
[0085] Q=Ba t =(b1,b2,…,b M ) t ;
[0086] Among them, B is the lattice matrix; a t is the transposed matrix of the initial key matrix; (b1,b2,…,b M ) t is the transposed matrix of the target key matrix.
[0087] Step a34: Generate at least one intermediate key sub-bit string according to the target key matrix.
[0088] The elements b1, b2, ..., b in the target key matrix M Converted into M binary intermediate key sub-bit strings T1, T2, ..., T M .
[0089] Step a4: Generate an intermediate encrypted bit string based on each intermediate key sub-bit string.
[0090] Specifically, each intermediate key sub-bit string T1, T2, ..., T M Merge to get the intermediate encrypted bit string String * =T1||T2||…||T M .
[0091] Step a5: Generate at least one round key based on the intermediate encrypted bit string.
[0092] Based on the preset bit extraction rules, encrypt the bit string String from the middle * Extract valid bits from the cipher to form a preset number R of round keys Key1,…,Key R . The length of each round key is L.
[0093] Among them, the bit extraction rules can be pre-set by relevant technical personnel, for example, extracting L bits every three bits, or randomly extracting L bits, or randomly extracting L bits and then performing XOR operations on each other. This embodiment does not limit this.
[0094] S130: Obtain the plaintext data to be encrypted, and segment the plaintext data to be encrypted based on a preset plaintext data unit length to obtain at least one plaintext sequence.
[0095] If the preset plaintext data unit length is P, the encrypted plaintext data Plaintext is segmented into sequences according to the unit length P to obtain at least one plaintext sequence Plaintext. i :
[0096] Plaintext=Plain1||…||Plain k ;
[0097] Among them, each plaintext sequence Plain i The bit length is P.
[0098] S140: Determine the number of key generation rounds of the sequence encryption key according to the number of sequences of the plaintext sequence.
[0099] A counter can be used to set the number of key generation rounds, which is the same as the number of sequences in the plaintext sequence. If the number of sequences is K, then the number of key generation rounds for the sequence encryption key is K rounds.
[0100] S150 : For any round of sequence encryption key generation method, determine the round key corresponding to the key generation round.
[0101] For any round of sequence encryption key generation in K rounds, determine the round key corresponding to the round key generation round. For example, if the round key corresponding to the i-th round key generation round is Key i .
[0102] S160: Generate a sequence encryption key for the key generation round according to the round key corresponding to the key generation round.
[0103] In an optional embodiment, generating a sequence encryption key for the key generation round according to a round key corresponding to the key generation round includes:
[0104] Step b1: Generate an initial encrypted bit string for the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string.
[0105] According to the counter state i of the key generation round, based on the random number (i, N i ), generate a preset number C of initial encrypted bit strings Z1,…,Z C ; where each Z i The length is L.
[0106] Step b2: Generate a first encrypted bit string based on a first preset number of preceding sub-bit strings in each of the initial encrypted sub-bit strings.
[0107] The first preset number is 1 to C-1. For example, if the length of the initial encrypted bit string is C, the first preset number is C-1.
[0108] Specifically, the initial encrypted bit string Z1,…,Z C Convert to integer form X1,…,X C The calculation method of the first encrypted integer string Y is as follows:
[0109] Y=X1+X2+…X C-1 ;
[0110] Among them, "+" represents modular addition calculation.
[0111] The first encrypted integer string Y is converted into a bit string to obtain a first encrypted bit string.
[0112] Step b3: Generate a second encrypted bit string based on the round key corresponding to the key generation round and the first encrypted bit string.
[0113] The first encrypted bit string is cyclically shifted. For example, the lower bits can be converted to higher bits by cyclic right shifting to obtain a new first encrypted bit string Y * , and convert the new first encrypted bit string into integer form.
[0114] Generate the round key Key for round i based on this key i and the integer form of the new first encrypted bit string Y * , generate the second encrypted bit string U:
[0115] U=Y * +Key i ;
[0116] Among them, "+" represents modular addition calculation.
[0117] Step b4: Generate a header sub-bit string based on the second encrypted bit string and the second preset number of tail sub-bit strings in each of the initial encrypted sub-bit strings.
[0118] The second preset number is the last bit string. For example, if the initial encrypted sub-bit string is X1,…,X C , then the last sub-bit string under the second preset number is X C .
[0119] Specifically, the header sub-bit string X0 is determined as follows:
[0120] X0=U⊕X C ;
[0121] Where U represents the second encrypted bit string, X C Indicates the last sub-bit string.
[0122] Step b5: Use the header sub-bit string to update the initial encrypted sub-bit string to obtain the target encrypted bit string.
[0123] The specific update method is X j =X j-1 ,j=1,2,…C, and use the updated result as the target encrypted bit string.
[0124] Step b6: Generate the sequence encryption key of the key generation round according to the target encrypted bit string.
[0125] After R rounds of calculation, the difference between each round is only the round key key, and the order of using the round key is Key1, Key2, ..., Key R According to the target encrypted bit string X1,…,X obtained in the last round (i.e., the Rth round), C , the target encrypted bit string X1,…,X obtained in the last round (i.e., the Rth round) C Splice and get the serial encryption key Stream1=X1||…||X of the key generation round C .
[0126] It should be noted that in the above R rounds of cyclic calculation, the initial encrypted bit string X1,…,X C The target encrypted bit string X1,…,X obtained at the end of the previous round C .
[0127] S170 : Generate a ciphertext sequence in the key generation round according to the sequence encryption key and the plaintext sequence in the key generation round.
[0128] Generate the next round of serial encryption key Stream based on the key i and plaintext sequence Plain i , generate the ciphertext sequence Cipher under the key generation round i i =Plain i ⊕Stream i .
[0129] S180 , generating encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequences corresponding to the key generation rounds.
[0130] The encrypted ciphertext data Ciphertext of the plaintext data to be encrypted is the concatenation of the ciphertext sequences corresponding to each key generation round:
[0131] Ciphertext=Cipher1||…||Cipher k
[0132] The encrypted ciphertext data of the plaintext data to be encrypted obtained above is sent to the data demander, and the data demander performs decryption processing.
[0133] The technical solution of the embodiment of the present invention utilizes a key expansion method based on a lattice problem framework. Furthermore, the key expansion process is completely decoupled from the encryption and decryption process. The key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in separate components, facilitating application in scenarios such as the Internet of Things. Furthermore, the data encryption and decryption method of the above technical solution improves the resistance of serial encryption to quantum attacks and enhances its security. Furthermore, the serial encryption process is reconfigurable, increasing the flexibility of the encryption and decryption process.
[0134] Example 2
[0135] Figure 2 This is a flowchart of a data sequence encryption and decryption method provided in the second embodiment of the present invention. This embodiment is applicable to data encryption and decryption situations where there is a requirement to retain the original format of the encrypted plaintext data, such as consistent length, similar memory usage, and the encryption process has anti-quantity security. This method can be executed by a data sequence encryption and decryption device. The data sequence encryption and decryption device can be implemented in the form of hardware and / or software. The data sequence encryption and decryption device can be configured in the electronic device of the data decryption party. Figure 2 As shown, the method includes:
[0136] S210: Generate a user initial key and a lattice basis matrix.
[0137] Specifically, the user can use key negotiation or a random number generator to generate a user initial key of a specified length. The bit length of the user initial key can be 128, 192, 256, or 512, and can be set based on actual needs. This embodiment does not limit this. The user initial key can be pre-generated and stored in the form of a bit string, or it can be generated during a data encryption task.
[0138] The lattice matrix is composed of randomly generated integer modulo q. The lattice matrix B is expressed as follows:
[0139]
[0140] The dimensions of M and N are pre-set by relevant technical personnel. The size of N is related to the key length of the user's initial key, which is pre-set by relevant technical personnel based on actual needs.
[0141] S220: Generate at least one round key according to the user's initial key and the lattice basis matrix.
[0142] The user's initial key can be converted into a matrix form, and the key matrix of the user's initial key is multiplied by the lattice basis matrix to obtain a target matrix; and the elements in the target matrix are determined as round keys.
[0143] To further improve the security and reliability of round key generation and make the key more resistant to quantum attacks, in an optional embodiment, at least one round key is generated based on the user's initial key and the lattice basis matrix, including:
[0144] Step c1: Obtain encryption-related information, and generate an initial key bit string based on the encryption-related information and the user's initial key.
[0145] The encryption-related information may be information related to the current encryption, such as task information, communication information, and account information. The encryption-related information is combined into a bit string of a specified length; the combined encryption-related information is combined with the user's initial key to obtain an initial key bit string.
[0146] Specifically, the encryption-related information is recorded as Auc, the user's initial key is recorded as Key, and the encryption-related information Auc and the user's initial key Key are bit-concatenated to form an initial key bit string String of a specified length W:
[0147] String = Key || Auc;
[0148] Here, “||” represents bit concatenation; wherein, the bit length of the initial key bit string String is W.
[0149] Step c2: split the initial key bit string according to the preset key data unit length to obtain at least one initial key sub-bit string.
[0150] If the preset key data unit length is T, it should be noted that the bit length of the initial key bit string String is W and must be divisible by the preset key data unit length T. If the bit length W of the initial key bit string String divided by the preset key data unit length T is N, then N initial key sub-bit strings can be generated. The initial key bit string String is segmented as follows:
[0151] String=S1||S2||…||S N ;
[0152] Among them, S1, S2, ..., S N is the initial key sub-bit string, and the length of each initial key sub-bit string is T.
[0153] Step c3: Generate at least one intermediate key sub-bit string based on the lattice matrix and each initial key sub-bit string.
[0154] In an optional embodiment, generating at least one intermediate key sub-bit string according to the lattice matrix and each initial key sub-bit string includes:
[0155] Step c31: Perform base conversion on each initial key sub-bit string to obtain an initial integer key.
[0156] Each initial key sub-bit string S1, S2, ..., S N Convert to integer (decimal) form to get the initial integer key a1,…,a N , that is: (S1, S2, ..., S N )=(a1,…,a N ).
[0157] Step c32: Generate an initial key matrix based on the initial integer key.
[0158] The elements in the initial matrix key are composed of the initial integer key, and the initial key matrix a is as follows:
[0159] (a1,…,a N )=a;
[0160] Step c33: Perform a matrix multiplication operation on the lattice basis matrix and the transposed matrix of the initial key matrix to obtain a target key matrix.
[0161] The target key matrix Q is generated as follows:
[0162] Q=Ba t =(b1,b2,…,b M ) t ;
[0163] Among them, B is the lattice matrix; a t is the transposed matrix of the initial key matrix; (b1,b2,…,b M ) t is the transposed matrix of the target key matrix.
[0164] Step c34: Generate at least one intermediate key sub-bit string according to the target key matrix.
[0165] The elements b1, b2, ..., b in the target key matrix M Converted into M binary intermediate key sub-bit strings T1, T2, ..., T M .
[0166] Step c4: Generate an intermediate encrypted bit string based on each intermediate key sub-bit string.
[0167] Specifically, each intermediate key sub-bit string T1, T2, ..., T M Merge to get the intermediate encrypted bit string String * =T1||T2||…||T M .
[0168] Step c5: Generate at least one round key based on the intermediate encrypted bit string.
[0169] Based on the preset bit extraction rules, encrypt the bit string String from the middle * Extract valid bits from the cipher to form a preset number R of round keys Key1,…,Key R . The length of each round key is L.
[0170] Among them, the bit extraction rules can be pre-set by relevant technical personnel, for example, extracting L bits every three bits, or randomly extracting L bits, or randomly extracting L bits and then performing XOR operations on each other. This embodiment does not limit this.
[0171] S230: Obtain encrypted ciphertext data, and segment the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence.
[0172] Wherein, the preset ciphertext data unit length is the same as the preset plaintext data unit length. If the preset ciphertext data unit length is P, the encrypted ciphertext data Ciphertext is segmented into a sequence according to the preset ciphertext data unit length P to obtain at least one ciphertext sequence Ciphertext. i :
[0173] Ciphertext=Cipher1||…||Cipher k
[0174] Among them, each ciphertext sequence Cipher i The bit length is P.
[0175] S240: Determine the number of key generation rounds of the sequence decryption key according to the sequence number of the ciphertext sequence.
[0176] The number of key generation rounds for a sequence decryption key is the same as the number of sequences in the key sequence. If the number of sequences is K, the number of key generation rounds for a sequence decryption key is K rounds.
[0177] S250 : For any round of sequence decryption key generation method, determine the round key corresponding to the key generation round.
[0178] For any round of sequence decryption key generation in K rounds, determine the round key corresponding to the round of key generation. For example, if the round key corresponding to the round of key generation in round i is Key i .
[0179] S260: Generate a sequence decryption key for the key generation round according to the round key corresponding to the key generation round.
[0180] In an optional embodiment, generating a sequence decryption key for the key generation round according to a round key corresponding to the key generation round includes:
[0181] Step d1: Generate an initial decryption bit string for the key generation round; the initial decryption bit string includes at least one initial decryption sub-bit string.
[0182] According to the counter state i of the key generation round, based on the random number (i, N i ), generate a preset number C of initial decryption bit strings Z1,…,Z C ; where each Z i The length is L.
[0183] It should be noted that the initial decrypted bit string is the same as the initial encrypted bit string, and can be generated in advance and stored separately in the encryption party and the decryption party.
[0184] Step d2: Generate a first decrypted bit string based on a first preset number of preceding sub-bit strings in each initial decrypted sub-bit string.
[0185] The first preset number is 1 to C-1. For example, if the length of the initial decrypted bit string is C, the first preset number is C-1.
[0186] Specifically, the initial decrypted bit string Z1,…,Z C Convert to integer form X1,…,X C The calculation method of the first decrypted integer string Y is as follows:
[0187] Y=X1+X2+…X C-1 ;
[0188] Among them, "+" represents modular addition calculation.
[0189] The first decrypted integer string Y is converted into a bit string to obtain a first decrypted bit string.
[0190] Step d3: Generate a second decrypted bit string based on the round key corresponding to the key generation round and the first decrypted bit string.
[0191] The first decrypted bit string is cyclically shifted. For example, the lower bits can be converted to higher bits by cyclic right shifting to obtain a new first decrypted bit string Y * , and convert the new first decrypted bit string into an integer form. It should be noted that the cyclic shift method of the first decrypted bit string is the same as the cyclic shift method of the first encrypted bit string.
[0192] Generate the round key Key for round i based on this key i and the integer form of the new first decrypted bit string Y* , generate the second decrypted bit string U:
[0193] U=Y * +Key i ;
[0194] Among them, "+" represents modular addition calculation.
[0195] Step d4: Generate a header sub-bit string based on the second decrypted bit string and the second preset number of tail sub-bit strings in each initial decrypted bit string.
[0196] The second preset number is the last bit string. For example, if the initial decryption sub-bit string is X1,…,X C , then the last sub-bit string under the second preset number is X C .
[0197] Specifically, the header sub-bit string X0 is determined as follows:
[0198] X0=U⊕X C ;
[0199] Where U represents the second decrypted bit string, X C Indicates the last sub-bit string.
[0200] Step d5: Use the header sub-bit string to update the initial decrypted sub-bit string to obtain the target decrypted bit string.
[0201] The specific update method is X j =X j-1 ,j=1,2,…C, and use the updated result as the target decrypted bit string.
[0202] Step d6: Generate the sequence encryption key of the key generation round according to the target decryption bit string.
[0203] After R rounds of calculation, the difference between each round is only the round key key, and the order of using the round key is Key1, Key2, ..., Key R According to the target decrypted bit string X1,…,X obtained in the last round (i.e., the Rth round), C , the target decrypted bit string X1,…,X obtained in the last round (i.e., the Rth round) C Splice and get the sequence decryption key Stream1=X1||…||X of the key generation round C .
[0204] It should be noted that in the above R rounds of calculation, the initial decrypted bit string X1,…,X C Decrypt the target bit string X1,…,X obtained at the end of the previous round C.
[0205] S270: Decrypt the key and the ciphertext sequence according to the sequence in the key generation round to generate the plaintext sequence in the key generation round.
[0206] Generate the next round of sequence decryption key Stream based on the key i and ciphertext sequence Cipher i , generate the plaintext sequence Plain1=Cipher1⊕Stream1 under the key generation round i.
[0207] S280 . Generate plaintext data of the encrypted ciphertext data according to the plaintext sequences corresponding to the key generation rounds.
[0208] The plaintext data of the encrypted ciphertext data is the concatenation of the plaintext sequences corresponding to each key generation round:
[0209] Plaintext=Plain1||…||Plain k
[0210] The technical solution of the embodiment of the present invention utilizes a key expansion method based on a lattice problem framework. Furthermore, the key expansion process is completely decoupled from the encryption and decryption process. The key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in separate components, facilitating application in scenarios such as the Internet of Things. Furthermore, the data encryption and decryption method of the above technical solution improves the resistance of serial encryption to quantum attacks and enhances its security. Furthermore, the serial encryption process is reconfigurable, increasing the flexibility of the encryption and decryption process.
[0211] This embodiment provides a preferred example based on the above embodiment. This solution includes the following main steps: algorithm initialization, data initialization, key generation, key expansion, sequence encryption, and sequence decryption. Each step is described in detail below:
[0212] 1. Algorithm Initialization
[0213] Determine the basic parameters of the algorithm: including key length = K, typically 128, 256, 512, etc.; sequence unit length = P, typically 128, 256, 512, etc.; block length = L, also known as word length, typically 16, 32, etc.; number of blocks P / L = C; modulus = D, typically 2^16, 2^32, etc.; number of iterations = R, typically 16, 32, 48, 64, etc. This embodiment has no specific restrictions or constraints on these parameters; the parameters in the solution are for reference only.
[0214] 2. Data Initialization
[0215] 1. Each time the sequence cipher is called to encrypt data, the counter and random number need to be reset. A pseudo-random number generator can be used to generate a counter and random number array in the form of (1, N1), (2, N2), ..., (j, N j ), generate C initial group bit strings Z1,…,Z based on the counter and random number (1,N1) by hashing or other randomization methods C , the length of each string is L. It should be pointed out that the random number cannot be the same in each call and needs to be regenerated to ensure security.
[0216] 2. Randomly generate a lattice matrix of integer modulo q After B is generated, it is stored for a long time as the initialization data of the serial encryption algorithm. If this initialization data is updated, it means that the serial encryption algorithm has changed and updated.
[0217] 3. Key Generation
[0218] The user generates a key of a specified length using methods such as key negotiation and a random number generator. Typically, the key bit string length is 128, 192, 256, or 512 bytes. This embodiment imposes no specific restrictions or constraints on these parameters; the parameters in this solution are for reference only. The user's initial key is denoted as "Key," and the key is stored within the system as a bit string.
[0219] 4. Key Expansion (Generating Round Keys)
[0220] 1. The user combines the key Key and information related to this encryption (such as the task ID, communication ID, and account information, collectively referred to as additional information, denoted as Auc) into a bit string of a specified length W, denoted as String = Key||Auc. The "||" indicates bit concatenation, indicating that the bit length of String is W.
[0221] 2. Split the string into W / T=N sub-bit strings according to the unit length = T. The requirement is that W is divisible by T. The sub-bit strings are denoted as S1, S2, ..., S N , satisfying String=S1||S2||…||S N The length of each sub-bit string is T.
[0222] 3. Convert each sub-bit string (binary) into an integer (decimal), then (S1, S2, ..., S N )=(a1,…,a N )=a.
[0223] 4. Randomly generate a lattice matrix of integer modulo q
[0224] 5. Calculate the matrix multiplication by the vector Bat =(b1,b2,…,b M ) t . t means matrix transpose, not power.
[0225] 6. Integers b1, b2, ..., b M Converted into M binary bit strings (T1, T2, ..., T M )=(b1,…,b M ).
[0226] 7. Combine the above bit strings to get the long bit string * =T1||T2||…||T M .
[0227] 8. According to the specified rules, in String * Extract valid bits from the cipher to form R round keys, denoted as Key1,…,Key R , the bit length of each round key is L.
[0228] It should be noted that the encryption modes of this embodiment can be divided into two categories: counter mode and feedback mode, which are described below respectively:
[0229] 5. Data encryption (counter mode)
[0230] 1. Set the counter state to 1 and generate C initial group bit strings Z1,…,Z based on the counter and random number (1,N1). C , read the initial bit string Z1,…,Z C , each Z i The length L.
[0231] 2. Let (X1,…,X C )=(Z1,…,Z C ), and each X i are converted into integer form.
[0232] 3. Calculate integer modular addition Y = X1 + X2 + ... X C-1 (where “+” represents modular calculation (mod D)).
[0233] 4. Convert Y into a bit string.
[0234] 5. Circularly shift the bit string calculated in the previous step. For example, you can convert the low-order bits to high-order bits by circularly shifting right to obtain a new bit string Y. * , and convert the bit string Y * Convert to an integer.
[0235] 6. Calculate modular addition U=Y *+Key1 (where “+” represents modular calculation (mod D)).
[0236] 7. Update calculation X0=U⊕X C (where “⊕” represents an exclusive OR operation).
[0237] 8. Update calculation X j =X j-1 ,j=1,2,…C.
[0238] 9. Output the updated X1,…,X C As the calculation result of the first cycle.
[0239] 10. After R rounds of calculation, the difference between each round is only the round key (the order of using round keys is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after the R rounds of calculation are completed C (This result is the result of the Rth round), and the pseudo-random bit string obtained after splicing and merging (the counter state is 1) is Stream1 = X1||…||X C (The splicing is to splice the results of the R rounds), and the total bit length is P. It should be noted that for any round except the initial round in the R round cycle, the initial keys X1,…,X C That is, X1,…,X output from the last round of update calculation C .
[0240] 11. Split the plaintext into units of length P, and obtain the plaintext sequence string: Plaintext = Plain1||…||Plain k , each Plain i The bit length is P.
[0241] 12. When the counter state is 1, calculate the bitwise exclusive OR of Cipher1 = Plain1 ⊕ Stream1.
[0242] 13. For the counter state set to 2, complete the same operation. It should be noted that the C initial group bit strings Z1,…,Z are generated based on the counter and the random number (2,N2). C , the initial bit string is different from the bit string in the previous round, and finally we get Cipher2=Plain2⊕Stream2.
[0243] 14. Counter status ++, finally complete all k ciphertext calculations, and get the ciphertext Ciphertext = Cipher1||…||Cipher k .
[0244] 6. Data Encryption (Feedback Mode)
[0245] 1. The feedback mode has no counter concept and directly generates C initial group bit strings Z1,…,Z based on a pseudo-random mechanism. C , read the initial bit string Z1,…,Z C , each Z i The length L.
[0246] 2. Let (X1,…,X C )=(Z1,…,Z C ), and each X i are converted into integer form.
[0247] 3. Calculate integer modular addition Y = X1 + X2 + ... X C-1 (where “+” represents modular calculation (mod D)).
[0248] 4. Convert Y into a bit string.
[0249] 5. Circularly shift the bit string calculated in the previous step. For example, you can convert the low-order bits to high-order bits by circularly shifting right to obtain a new bit string Y. * , and convert the bit string Y * Convert to an integer.
[0250] 6. Calculate modular addition U=Y * +Key1 (where “+” represents modular calculation (mod D)).
[0251] 7. Update calculation X0=U⊕X C (where “⊕” represents an exclusive OR operation).
[0252] 8. Update calculation X j =X j-1 ,j=1,2,…C.
[0253] 9. Output the updated X1,…,X C As the calculation result of the first cycle.
[0254] 10. After R rounds of calculation, the difference between each round is only the round key (the order of using round keys is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after the R rounds of calculation are completed C (This result is the result of the Rth round), and the pseudo-random bit string obtained after splicing and merging (the counter state is 1) is Stream1 = X1||…||X C(The splicing is to splice the results of the R rounds), and the total bit length is P. It should be noted that for any round except the initial round in the R round cycle, the initial keys X1,…,X C That is, X1,…,X output from the last round of update calculation C .
[0255] 11. Split the plaintext into units of length P, and obtain the plaintext sequence string: Plaintext = Plain1||…||Plain k , each Plain i The bit length is P.
[0256] 12. When the counter state is 1, calculate the bitwise exclusive OR of Cipher1 = Plain1 ⊕ Stream1.
[0257] 13. Start the second round of large loop, a total of k rounds of large loops, and directly calculate the bit strings X1,…,X C As the initial bit string, the same operation is performed, and finally Cipher2=Plain2⊕Sream2 is obtained.
[0258] 14. Complete all k rounds of large cycles and all k ciphertext calculations to obtain the ciphertext Ciphertext = Cipher1||…||Cipher k .
[0259] 7. Data Decryption (Counter Mode)
[0260] 1. Set the counter state to 1 and generate C initial group bit strings Z1,…,Z based on the counter and random number (1,N1). C , read the initial bit string Z1,…,Z C , each Z i The length L.
[0261] 2. Let (X1,…,X C )=(Z1,…,Z C ), and each X i are converted into integer form.
[0262] 3. Calculate integer modular addition Y = X1 + X2 + ... X C-1 (mod D).
[0263] 4. Convert Y into a bit string.
[0264] 5. Circularly shift the bit string calculated in the previous step. For example, you can convert the low-order bits to high-order bits by circularly shifting right to obtain a new bit string Y. * , and convert the bit string Y* Convert to an integer.
[0265] 6. Calculate modular addition U=Y * +Key1(mod D).
[0266] 7. Update calculation X0=U⊕X C .
[0267] 8. Update calculation X j =X j-1 ,j=1,2,…C.
[0268] 9. Output the updated X1,…,X C As the calculation result of the first cycle.
[0269] 10. After R rounds of calculation, the difference between each round is only the round key (the order of using round keys is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after the R rounds of calculation are completed C , after splicing and merging, the pseudo-random bit string (counter state is 1) is Stream1 = X1||…||X C , the total bit length is P.
[0270] 11. Divide the ciphertext Ciphertext into k groups according to the unit length P, and get: Cipher1||…||Cipher k ; Then for each Cipher1, according to the group length L, it is divided into C groups, recorded as Cipher i =W 1,i ||…||W C,i .
[0271] 12. For a counter state of 1, calculate the bitwise XOR of Plain1 = Cipher1 ⊕ Stream1.
[0272] 13. Set the counter state to 2 and complete the same operation. It should be noted that C initial group bit strings Z1,…,Z are generated based on the counter and the random number (2,N2). C , the initial bit string is different from the bit string in the previous round, and finally we get Plain2=Cipher2⊕Stream2.
[0273] 14. Counter state ++, finally complete all k decryption calculations, and get plaintext Plaintext = Plain1||…||Plain k .
[0274] 8. Data Decryption (Feedback Mode)
[0275] 1. No counter concept, based on pseudo-random mechanism, directly generate C initial group bit strings Z1,…,Z C , which is consistent with the initial bit string generated by the encryption process, read the initial bit string Z1,…,Z C , each Z i The length L.
[0276] 2. Let (X1,…,X C )=(Z1,…,Z C ), and each X i are converted into integer form.
[0277] 3. Calculate integer modular addition Y = X1 + X2 + ... X C-1 (mod D).
[0278] 4. Convert Y into a bit string.
[0279] 5. Circularly shift the bit string calculated in the previous step. For example, you can convert the low-order bits to high-order bits by circularly shifting right to obtain a new bit string Y. * , and convert the bit string Y * Convert to an integer.
[0280] 6. Calculate modular addition U=Y * +Key1(mod D).
[0281] 7. Update calculation X0=U⊕X C .
[0282] 8. Update calculation X j =X j-1 ,j=1,2,…C.
[0283] 9. Output the updated X1,…,X C As the calculation result of the first cycle.
[0284] 10. After R rounds of calculation, the difference between each round is only the round key (the order of using round keys is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after the R rounds of calculation are completed C , the pseudo-random bit string obtained after splicing and merging is Stream1=X1||…||X C , the total bit length is P, completing the first round of large cycles (a total of k rounds of large cycles).
[0285] 11. Divide the ciphertext Ciphertext into k groups according to the unit length P, and get: Cipher1||…||Cipher k; Then for each Cipher1, according to the group length L, it is divided into C groups, recorded as Cipher i =W 1,i ||…||W C,i .
[0286] 12. Calculate the bitwise XOR of the first large loop: Plain1 = Cipher1 ⊕ Stream1.
[0287] 13. Start the second big loop and directly convert the bit string X1,…,X obtained by the first big loop into C As the initial bit string, the same operation is performed, and finally Plain2 = Cipher2 ⊕ Stream2 is obtained.
[0288] 14. Complete all k rounds of large loops and all k decryption calculations to obtain the plaintext Plaintext = Plain1||…||Plain k .
[0289] This solution uses a key expansion method based on the lattice problem framework, uses random matrices to calculate the expansion key and round key, and adopts a design method that combines block ciphers with sequence ciphers. The encryption and decryption process is computationally simple and has a high resistance to quantum attacks. The key expansion process and the encryption and decryption process are completely decoupled, and the key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in different components, facilitating application in scenarios such as the Internet of Things.
[0290] Example 3
[0291] Figure 3 This is a structural diagram of a data sequence encryption and decryption device provided in the third embodiment of the present invention. The data sequence encryption and decryption device provided in the embodiment of the present invention can be applied to data encryption and decryption situations where the original format of the encrypted plaintext data needs to be retained, such as the length is consistent, the memory usage is similar, and the encryption process has anti-quantity security. The data sequence encryption and decryption device can be implemented in the form of hardware and / or software. The data sequence encryption and decryption device can be configured in the data encryption method, such as Figure 3 As shown, the device specifically includes: an initial key generation module 301, a round key generation module 302, a plaintext sequence generation module 303, a generation round number determination module 304, a corresponding key determination module 305, a sequence key generation module 306, a ciphertext sequence generation module 307 and a ciphertext data generation module 308.
[0292] in,
[0293] The initial key generation module 301 is used to generate the user's initial key and the lattice matrix;
[0294] A round key generation module 302 is configured to generate at least one round key according to the user initial key and the lattice basis matrix;
[0295] The plaintext sequence generation module 303 is configured to obtain plaintext data to be encrypted and segment the plaintext data to be encrypted based on a preset plaintext data unit length to obtain at least one plaintext sequence;
[0296] A generation round number determination module 304 is configured to determine the number of key generation rounds for the sequence encryption key according to the number of sequences of the plaintext sequence;
[0297] A corresponding key determination module 305 is configured to determine a round key corresponding to a key generation round according to a generation method of a sequence encryption key of any round;
[0298] A sequence key generation module 306 is configured to generate a sequence encryption key for the key generation round based on a round key corresponding to the key generation round;
[0299] A ciphertext sequence generation module 307 is configured to generate a ciphertext sequence in the key generation round according to the sequence encryption key and the plaintext sequence in the key generation round;
[0300] The ciphertext data generating module 308 is configured to generate encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequences corresponding to the key generation rounds.
[0301] The technical solution of the embodiment of the present invention utilizes a key expansion method based on a lattice problem framework. Furthermore, the key expansion process is completely decoupled from the encryption and decryption process. The key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in separate components, facilitating application in scenarios such as the Internet of Things. Furthermore, the data encryption and decryption method of the above technical solution improves the resistance of serial encryption to quantum attacks and enhances its security. Furthermore, the serial encryption process is reconfigurable, increasing the flexibility of the encryption and decryption process.
[0302] Optionally, the round key generation module 302 includes:
[0303] a related information acquisition unit, configured to acquire encryption related information and generate an initial key bit string based on the encryption related information and the user initial key;
[0304] a key segmentation unit, configured to segment the initial key bit string according to a preset key data unit length to obtain at least one initial key sub-bit string;
[0305] a key sub-bit string generation unit, configured to generate at least one intermediate key sub-bit string according to the lattice basis matrix and each of the initial key sub-bit strings;
[0306] an intermediate bit string generation unit, configured to generate an intermediate encrypted bit string based on each of the intermediate key sub-bit strings;
[0307] The round key generating unit is configured to generate at least one round key according to the intermediate encrypted bit string.
[0308] Optionally, a key sub-bit string generation unit is specifically configured to:
[0309] Performing a base conversion operation on each of the initial key sub-bit strings to obtain an initial integer key;
[0310] generating an initial key matrix according to the initial integer key;
[0311] Performing a matrix multiplication operation on the lattice matrix and the transposed matrix of the initial key matrix to obtain a target key matrix;
[0312] At least one intermediate key sub-bit string is generated according to the target key matrix.
[0313] Optionally, the sequence key generation module 306 is specifically configured to:
[0314] Generate an initial encrypted bit string for the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string;
[0315] generating a first encrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial encrypted sub-bit strings;
[0316] generating a second encrypted bit string based on the round key corresponding to the key generation round and the first encrypted bit string;
[0317] generating a head sub-bit string according to the second encrypted bit string and a second preset number of tail sub-bit strings in each of the initial encrypted sub-bit strings;
[0318] Using the header sub-bit string to update the initial encrypted sub-bit string to obtain a target encrypted bit string;
[0319] A sequence encryption key for the key generation round is generated according to the target encrypted bit string.
[0320] The data sequence encryption and decryption device provided in the embodiment of the present invention can execute the data sequence encryption and decryption method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0321] Example 4
[0322] Figure 4This is a structural diagram of a data sequence encryption and decryption device provided in the fourth embodiment of the present invention. The data sequence encryption and decryption device provided in the embodiment of the present invention is applicable to data encryption and decryption situations where the original format of the encrypted plaintext data needs to be retained, such as the length is consistent, the memory usage is similar, and the encryption process has anti-quantity security. The data sequence encryption and decryption device can be implemented in the form of hardware and / or software. The data sequence encryption and decryption device can be configured in the data decryption method, such as Figure 3 As shown, the device specifically includes: an initial key generation module 401, a round key generation module 402, a ciphertext sequence generation module 403, a generation round number determination module 404, a corresponding key determination module 405, a sequence key generation module 406, a plaintext sequence generation module 407 and a plaintext data generation module 408.
[0323] in,
[0324] The initial key generation module 401 is used to generate the user's initial key and the lattice matrix;
[0325] A round key generation module 402 is configured to generate at least one round key according to the user initial key and the lattice basis matrix;
[0326] The ciphertext sequence generation module 403 is configured to obtain encrypted ciphertext data and segment the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence;
[0327] A generation round number determination module 404 is configured to determine the number of key generation rounds for a sequence decryption key according to the number of sequences of the ciphertext sequence;
[0328] The corresponding key generation module 405 is used to determine the round key corresponding to the key generation round according to the generation method of the sequence decryption key of any round;
[0329] A sequence key generation module 406 is configured to generate a sequence decryption key for the key generation round based on a round key corresponding to the key generation round;
[0330] A plaintext sequence generation module 407 is configured to generate a plaintext sequence in the key generation round according to the sequence decryption key and the ciphertext sequence in the key generation round;
[0331] The plaintext data generating module 408 is configured to generate the plaintext data of the encrypted ciphertext data according to the plaintext sequences corresponding to the key generation rounds.
[0332] The technical solution of the embodiment of the present invention utilizes a key expansion method based on a lattice problem framework. Furthermore, the key expansion process is completely decoupled from the encryption and decryption process. The key generation and expansion modules, as well as the encryption and decryption modules, can be deployed in separate components, facilitating application in scenarios such as the Internet of Things. Furthermore, the data encryption and decryption method of the above technical solution improves the resistance of serial encryption to quantum attacks and enhances its security. Furthermore, the serial encryption process is reconfigurable, increasing the flexibility of the encryption and decryption process.
[0333] Optionally, the sequence key generation module 406 is specifically configured to:
[0334] Generate an initial decryption bit string for the key generation round; the initial decryption bit string includes at least one initial decryption sub-bit string;
[0335] generating a first decrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial decrypted sub-bit strings;
[0336] generating a second decrypted bit string based on the round key corresponding to the key generation round and the first decrypted bit string;
[0337] generating a head sub-bit string according to the second decrypted bit string and a second preset number of tail sub-bit strings in each of the initial decrypted bit strings;
[0338] Using the header sub-bit string to update the initial decrypted sub-bit string to obtain a target decrypted bit string;
[0339] A sequence encryption key for the key generation round is generated according to the target decrypted bit string.
[0340] The data sequence encryption and decryption device provided in the embodiment of the present invention can execute the data sequence encryption and decryption method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0341] Example 5
[0342] Figure 5 A schematic diagram of the structure of an electronic device 50 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0343] like Figure 5 As shown, the electronic device 50 includes at least one processor 51 and a memory, such as a read-only memory (ROM) 52, a random access memory (RAM) 53, etc., which is communicatively connected to the at least one processor 51. The memory stores a computer program that can be executed by the at least one processor. The processor 51 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 52 or the computer program loaded from the storage unit 58 into the random access memory (RAM) 53. Various programs and data required for the operation of the electronic device 50 can also be stored in the RAM 53. The processor 51, ROM 52, and RAM 53 are connected to each other via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.
[0344] Multiple components in the electronic device 50 are connected to the I / O interface 55, including an input unit 56, such as a keyboard, a mouse, etc.; an output unit 57, such as various types of displays, speakers, etc.; a storage unit 58, such as a magnetic disk, an optical disk, etc.; and a communication unit 59, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 59 allows the electronic device 50 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0345] The processor 51 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 51 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 51 executes the various methods and processes described above, such as the data sequence encryption and decryption method.
[0346] In some embodiments, the data sequence encryption and decryption method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 58. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 50 via the ROM 52 and / or the communication unit 59. When the computer program is loaded into the RAM 53 and executed by the processor 51, one or more steps of the data sequence encryption and decryption method described above can be performed. Alternatively, in other embodiments, the processor 51 can be configured to perform the data sequence encryption and decryption method by any other appropriate means (e.g., by means of firmware).
[0347] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0348] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0349] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0350] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0351] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0352] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0353] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0354] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A data sequence encryption and decryption method, characterized in that: Applicable to data encryption, including: Generate the user's initial key and the lattice matrix; Generate at least one round key according to the user initial key and the lattice basis matrix; Obtaining plaintext data to be encrypted, and segmenting the plaintext data to be encrypted based on a preset plaintext data unit length to obtain at least one plaintext sequence; Determining the number of key generation rounds of the sequence encryption key according to the sequence number of the plaintext sequence; For any round of sequence encryption key generation, determine the round key corresponding to the key generation round; Generate an initial encrypted bit string for the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string; generating a first encrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial encrypted sub-bit strings; generating a second encrypted bit string based on the round key corresponding to the key generation round and the first encrypted bit string; generating a head sub-bit string according to the second encrypted bit string and a second preset number of tail sub-bit strings in each of the initial encrypted sub-bit strings; Using the header sub-bit string to update the initial encrypted sub-bit string to obtain a target encrypted bit string; generating a sequence encryption key for the key generation round according to the target encrypted bit string; Generate a ciphertext sequence under the key generation round according to the sequence encryption key and the plaintext sequence under the key generation round; The encrypted ciphertext data of the plaintext data to be encrypted is generated according to the ciphertext sequences corresponding to the key generation rounds.
2. The method according to claim 1, characterized in that Generating at least one round key according to the user initial key and the lattice basis matrix includes: Obtaining encryption-related information, and generating an initial key bit string based on the encryption-related information and the user initial key; Splitting the initial key bit string according to a preset key data unit length to obtain at least one initial key sub-bit string; generating at least one intermediate key sub-bit string according to the lattice matrix and each of the initial key sub-bit strings; generating an intermediate encrypted bit string according to each of the intermediate key sub-bit strings; At least one round key is generated according to the intermediate encrypted bit string.
3. The method according to claim 2, characterized in that Generating at least one intermediate key sub-bit string according to the lattice matrix and each of the initial key sub-bit strings includes: Performing a base conversion operation on each of the initial key sub-bit strings to obtain an initial integer key; generating an initial key matrix according to the initial integer key; Performing a matrix multiplication operation on the lattice matrix and the transposed matrix of the initial key matrix to obtain a target key matrix; At least one intermediate key sub-bit string is generated according to the target key matrix.
4. A data sequence encryption and decryption method, characterized in that: Applicable to data decryption, including: Generate the user's initial key and the lattice matrix; Generate at least one round key according to the user initial key and the lattice basis matrix; Acquire encrypted ciphertext data, and perform data segmentation on the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence; Determining the number of key generation rounds of a sequence decryption key according to the number of sequences of the ciphertext sequence; For any round of sequence decryption key generation, determine the round key corresponding to the key generation round; Generate an initial decryption bit string for the key generation round; the initial decryption bit string includes at least one initial decryption sub-bit string; generating a first decrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial decrypted sub-bit strings; generating a second decrypted bit string based on the round key corresponding to the key generation round and the first decrypted bit string; generating a head sub-bit string according to the second decrypted bit string and a second preset number of tail sub-bit strings in each of the initial decrypted bit strings; Using the header sub-bit string to update the initial decrypted sub-bit string to obtain a target decrypted bit string; Generating a sequence encryption key for the key generation round according to the target decrypted bit string; Decrypt the key and ciphertext sequence according to the sequence in the key generation round to generate the plaintext sequence in the key generation round; The plaintext data of the encrypted ciphertext data is generated according to the plaintext sequences corresponding to the key generation rounds.
5. A data sequence encryption and decryption device, characterized in that: Configuration on the data encryption side, including: The initial key generation module is used to generate the user's initial key and the lattice matrix; a round key generation module, configured to generate at least one round key according to the user initial key and the lattice basis matrix; A plaintext sequence generation module is used to obtain plaintext data to be encrypted and, based on a preset plaintext data unit length, perform data segmentation on the plaintext data to be encrypted to obtain at least one plaintext sequence; A generation round number determination module, configured to determine the number of key generation rounds for a sequence encryption key according to the number of sequences of the plaintext sequence; a corresponding key determination module, configured to determine a round key corresponding to a key generation round according to a generation method of a sequence encryption key of any round; A sequence key generation module, configured to generate a sequence encryption key for the key generation round based on a round key corresponding to the key generation round; A ciphertext sequence generation module, configured to generate a ciphertext sequence under the key generation round according to the sequence encryption key and the plaintext sequence under the key generation round; a ciphertext data generation module, configured to generate encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequences corresponding to the key generation rounds; The sequence key generation module is specifically used to: Generate an initial encrypted bit string for the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string; generating a first encrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial encrypted sub-bit strings; generating a second encrypted bit string based on the round key corresponding to the key generation round and the first encrypted bit string; generating a head sub-bit string according to the second encrypted bit string and a second preset number of tail sub-bit strings in each of the initial encrypted sub-bit strings; Using the header sub-bit string to update the initial encrypted sub-bit string to obtain a target encrypted bit string; A sequence encryption key for the key generation round is generated according to the target encrypted bit string.
6. A data sequence encryption and decryption device, characterized in that: Configuration on the data decryption side, including: The initial key generation module is used to generate the user's initial key and the lattice matrix; a round key generation module, configured to generate at least one round key according to the user initial key and the lattice basis matrix; A ciphertext sequence generation module is used to obtain encrypted ciphertext data and perform data segmentation on the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence; A generation round number determination module, configured to determine the number of key generation rounds for a sequence decryption key according to the number of sequences of the ciphertext sequence; A corresponding key generation module is used to determine the round key corresponding to the key generation round according to the generation method of the sequence decryption key of any round; A sequence key generation module, configured to generate a sequence decryption key for the key generation round based on the round key corresponding to the key generation round; A plaintext sequence generation module, configured to generate a plaintext sequence under the key generation round according to the sequence decryption key and the ciphertext sequence under the key generation round; A plaintext data generation module, configured to generate plaintext data of the encrypted ciphertext data according to the plaintext sequences corresponding to the key generation rounds; The sequence key generation module is specifically used to: Generate an initial decryption bit string for the key generation round; the initial decryption bit string includes at least one initial decryption sub-bit string; generating a first decrypted bit string according to a first preset number of preceding sub-bit strings in each of the initial decrypted sub-bit strings; generating a second decrypted bit string based on the round key corresponding to the key generation round and the first decrypted bit string; generating a head sub-bit string according to the second decrypted bit string and a second preset number of tail sub-bit strings in each of the initial decrypted bit strings; Using the header sub-bit string to update the initial decrypted sub-bit string to obtain a target decrypted bit string; A sequence encryption key for the key generation round is generated according to the target decrypted bit string.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the data sequence encryption and decryption method described in any one of claims 1-3 and / or 5.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data sequence encryption and decryption method according to any one of claims 1 to 3 and / or 5 when executed.
Citation Information
Patent Citations
Internet of Things security encryption method and device, storage medium and electronic equipment
CN115694796A