Data sequence encryption and decryption method and device, equipment and storage medium

By adopting a key expansion method based on the grid problem framework in sequence encryption, decoupling the key expansion and encryption and decryption process, the problem of insufficient anti-quantum attack capability and security in the prior art is solved, and high flexibility and ability are achieved Reconstructive encryption and decryption process.

CN119402186AActive Publication Date: 2025-02-07CHANGCHUN JIDA ZHENGYUAN INFORMATION TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411522756.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-07
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

The existing sequence encryption algorithms have shortcomings in their ability to resist quantum attacks and security, and there is strong coupling between key expansion and encryption and decryption processes, resulting in low flexibility and reconfigurability.

Method used

The key expansion method based on the grid problem framework is adopted to completely decouple the key expansion process and the encryption and decryption process, and the user's initial key and grid-based matrix are used to generate the wheel key, thereby generating the sequence encryption key and decryption key.

Benefits of technology

It improves the anti-quantum attack capability and security of sequence encryption, realizes the reconfigurability and flexibility of the encryption and decryption process, and is easy to apply in scenarios such as the Internet of Things.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402186A_ABST
    Figure CN119402186A_ABST
Patent Text Reader

Abstract

The invention discloses a data sequence encryption and decryption method and device, equipment and a storage medium. The method comprises the following steps: generating a user initial key, and generating a lattice basis matrix; generating at least one round key according to the user initial key and the lattice basis matrix; obtaining to-be-encrypted plaintext data, and based on a preset plaintext data unit length, performing data segmentation on the to-be-encrypted plaintext data to obtain at least one plaintext sequence; determining a key generation round number of the sequence encryption key according to the sequence number of the plaintext sequence; determining a round key corresponding to the key generation round according to the generation mode of the sequence encryption key of any round; generating a sequence encryption key of the key generation round according to the round key corresponding to the key generation round; generating a ciphertext sequence under the key generation round according to the sequence encryption key and the plaintext sequence under the key generation round; and generating encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequence corresponding to each key generation round.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Sequence 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) and the like.

[0004] The existing sequence encryption algorithms have weak resistance to quantum attacks, resulting in low security of quantum encryption. 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 to improve 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 user initial key and lattice basis 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 performing data segmentation on 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 method, 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 respectively 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 user initial key and lattice basis 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 the sequence decryption key according to the sequence number of the ciphertext sequence;

[0020] For any round of sequence decryption key generation method, 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 the 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 respectively 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 the device comprises:

[0025] An initial key generation module, used to generate a user initial key and a lattice basis matrix;

[0026] A round key generation module, used to generate at least one round key according to the user initial key and the lattice basis matrix;

[0027] A plaintext sequence generation module, 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, used to determine the key generation round number of the sequence encryption key according to the sequence number of the plaintext sequence;

[0029] A corresponding key determination module, for determining 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, used to generate a sequence encryption key of the key generation round according to the round key corresponding to the key generation round;

[0031] A ciphertext sequence generation module, used 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 generating module is used to generate the 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 the device comprises:

[0034] An initial key generation module, used to generate a user initial key and a lattice basis matrix;

[0035] A round key generation module, used to generate at least one round key according to the user initial key and the lattice basis matrix;

[0036] A ciphertext sequence generation module, used to obtain encrypted ciphertext data, and based on a preset ciphertext data unit length, perform data segmentation on the encrypted ciphertext data to obtain at least one ciphertext sequence;

[0037] A generation round number determination module, used to determine the key generation round number of the sequence decryption key according to the sequence number of the ciphertext sequence;

[0038] A corresponding key generation module is used to determine a round key corresponding to the key generation round according to a generation method of a sequence decryption key of any round;

[0039] A sequence key generation module, used to generate a sequence decryption key of the key generation round according to the round key corresponding to the key generation round;

[0040] A plaintext sequence generation module, used 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 generating module is used to generate the plaintext data of the encrypted ciphertext data according to the plaintext sequences respectively corresponding to the key generating rounds.

[0042] According to another aspect of the present invention, an electronic device is provided, the electronic device 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 executable 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 execute 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 uses a key expansion method based on the lattice problem framework, and the key expansion process and the encryption and decryption process are completely decoupled. The key generation and expansion modules and the encryption and decryption modules can be deployed in different components, which is convenient for application in scenarios such as the Internet of Things. In addition, the data encryption and decryption method of the above technical solution improves the anti-quantum attack capability of the sequence encryption and improves the security of the sequence encryption, and realizes the reconfiguration of the sequence encryption process, which improves the flexibility of the encryption and decryption process.

[0048] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily 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 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 is a flow chart of a data sequence encryption and decryption method provided according to Embodiment 2 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 Embodiment 3 of the present invention;

[0053] Figure 4 It 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 It is a schematic diagram of the structure of an electronic device for implementing the data sequence encryption and decryption method of an embodiment of the present invention. DETAILED DESCRIPTION

[0055] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme 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 described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0056] It should be noted that the terms "first", "second", etc. in the specification 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 data 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 that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0057] Embodiment 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 can be applied to data encryption and decryption situations where the encrypted plaintext data has the requirement to retain the original format, such as the same length, similar memory usage, and the encryption process has anti-quantity security. The method can be executed by a data sequence encryption and decryption device, which can be implemented in the form of hardware and / or software, and can be configured in the electronic device of the data encryption party. Figure 1 As shown, the method includes:

[0059] S110, generating 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 according to a specified length. The bit length of the user initial key can be 128, 192, 256, 512, etc. The length can be set according to actual needs, and this embodiment does not limit this. The user initial key can be generated in advance and stored in the form of a bit string, or it can be generated when performing a data encryption task.

[0061] The lattice basis matrix is ​​composed of randomly generated integer modulo q. The lattice basis matrix B is expressed as follows:

[0062]

[0063] The dimensions of M and N are pre-set by relevant technicians. The size of N is related to the key length of the user's initial key, and the user's initial key length is pre-set by relevant technicians according to actual needs.

[0064] S120. Generate at least one round key according to the user 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 with the lattice basis matrix to obtain a target matrix; the elements in the target matrix are determined as round keys.

[0066] In order 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 according to the user's initial key and the lattice 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, account information, etc. The encryption related information is merged according to a bit string of a specified length; the merged encryption related information and the user's initial key are merged to obtain an initial key bit string.

[0069] Specifically, the encryption related information is recorded as Auc, the user initial key is recorded as Key, and the encryption related information Auc and the user initial key Key are bit-concatenated to form an initial key bit string String of a specified length W:

[0070] String = Key || Auc;

[0071] Among them, “||” represents bit concatenation; wherein, the bit length of the initial key bit string String is W.

[0072] Step a2: according to a preset key data unit length, the initial key bit string is divided 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 is required to 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 according to 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 operation 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 according to the initial integer key.

[0081] Among them, 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 Transformed 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, the encrypted bit string String is extracted from the middle * Extract valid bits from the , and 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 bit intervals, 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 divide 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 sequence number 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 of the plaintext sequence. If the number of sequences is K, 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 the K rounds, determine the round key corresponding to the round of key generation. For example, if the round key corresponding to the i-th round of key generation 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 of the key generation round according to a round key corresponding to the key generation round includes:

[0104] Step b1, generating 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 according to a first preset number of preceding sub-bit strings in each initial encrypted sub-bit string.

[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 shift 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 according to the 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 head sub-bit string according to the second encrypted bit string and the second preset number of tail sub-bit strings in each initial encrypted sub-bit string.

[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. The order of using the round key is Key1, Key2, ..., Key R According to the target encrypted bit string X1,…,X C , the target encrypted bit string X1,…,X obtained in the last round (i.e., the Rth round) C Splice and obtain the sequence 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 is 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 sequence encryption key Stream based on this key i and the plaintext sequence Plain i , generate the ciphertext sequence Cipher under the key generation round i i =Plain i ⊕Stream i .

[0129] S180. Generate 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 together.

[0133] The technical solution of the embodiment of the present invention uses a key expansion method based on the lattice problem framework, and the key expansion process and the encryption and decryption process are completely decoupled. The key generation and expansion modules and the encryption and decryption modules can be deployed in different components, which is convenient for application in scenarios such as the Internet of Things. In addition, the data encryption and decryption method of the above technical solution improves the anti-quantum attack capability of the sequence encryption and improves the security of the sequence encryption, and realizes the reconfiguration of the sequence encryption process, which improves the flexibility of the encryption and decryption process.

[0134] Embodiment 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 can be applied to data encryption and decryption situations where the encrypted plaintext data has the requirement to retain the original format, such as the same 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, generating 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 according to a specified length. The bit length of the user initial key can be 128, 192, 256, 512, etc. The length can be set according to actual needs, and this embodiment does not limit this. The user initial key can be generated in advance and stored in the form of a bit string, or it can be generated when performing a data encryption task.

[0138] The lattice basis matrix is ​​composed of randomly generated integer modulo q. The lattice basis matrix B is expressed as follows:

[0139]

[0140] The dimensions of M and N are pre-set by relevant technicians. The size of N is related to the key length of the user's initial key, and the user's initial key length is pre-set by relevant technicians according to actual needs.

[0141] S220. Generate at least one round key according to the user 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 with the lattice basis matrix to obtain a target matrix; the elements in the target matrix are determined as round keys.

[0143] In order 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 according to the user's initial key and the lattice 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, account information, etc. The encryption related information is merged according to a bit string of a specified length; the merged encryption related information and the user's initial key are merged to obtain an initial key bit string.

[0146] Specifically, the encryption related information is recorded as Auc, the user initial key is recorded as Key, and the encryption related information Auc and the user initial key Key are bit-concatenated to form an initial key bit string String of a specified length W:

[0147] String = Key || Auc;

[0148] Among them, “||” represents bit concatenation; wherein, the bit length of the initial key bit string String is W.

[0149] Step c2: according to a preset key data unit length, the initial key bit string is divided 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 is required to 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 according to the lattice basis 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 according to the initial integer key.

[0158] Among them, 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 are M Transformed 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, the encrypted bit string String is extracted from the middle * Extract valid bits from the , and 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 bit intervals, 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 perform data segmentation on the encrypted ciphertext data based on a preset ciphertext data unit length to obtain at least one ciphertext sequence.

[0172] 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 sequences 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 of the sequence decryption key is the same as the number of sequences of the key sequence. If the number of sequences is K, the number of key generation rounds of the 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 i-th round of key generation 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 of the key generation round according to a round key corresponding to the key generation round includes:

[0181] Step d1, generating an initial decryption bit string of 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 in the encryption party and the decryption party respectively.

[0184] Step d2: Generate a first decrypted bit string according to 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 decryption bit string according to the round key corresponding to the key generation round and the first decryption 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 according to the key i and the new first decrypted bit string in integer form 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 head sub-bit string according to 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. 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 obtain 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 a plaintext sequence in the key generation round.

[0206] Generate the sequence decryption key Stream according to the key i and the 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 uses a key expansion method based on the lattice problem framework, and the key expansion process and the encryption and decryption process are completely decoupled. The key generation and expansion modules and the encryption and decryption modules can be deployed in different components, which is convenient for application in scenarios such as the Internet of Things. In addition, the data encryption and decryption method of the above technical solution improves the anti-quantum attack capability of the sequence encryption and improves the security of the sequence encryption, and realizes the reconfiguration of the sequence encryption process, which improves the flexibility of the encryption and decryption process.

[0211] This embodiment provides a preferred example based on the above embodiment. This solution includes the main steps of 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, usually 128, 256, 512, etc.; sequence unit length = P, usually 128, 256, 512, etc.; packet length = L, also known as word length, usually 16, 32, etc.; number of packets P / L = C; modulus = D, usually 2^16, 2^32, etc.; number of iterations = R, usually 16, 32, 48, 64, etc. This embodiment has no special restrictions and constraints on the parameters, and the parameters in the solution content are for reference only.

[0214] 2. Data initialization

[0215] 1. Each time the sequence password 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 the random number (1,N1) by hashing or other randomization methods C , the length of each string is L. It should be noted 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 according to the specified length by means of key negotiation, random number generator, etc. In general, the key bit string length is 128, 192, 256, 512, etc. This embodiment has no special restrictions and constraints on the parameters, and the parameters in the solution content are only for reference. The user's initial key is recorded as Key, and the key Key is saved in the system in the form of a bit string.

[0219] 4. Key expansion (generation of round keys)

[0220] 1. The user combines the key Key and the information related to this encryption (task ID, communication ID, account information, etc., collectively referred to as additional information, denoted as Auc) into a bit string of specified length W, denoted as String = Key||Auc. "||" indicates bit concatenation, and it can be seen 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, where 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 meaning.

[0225] 6. Add 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 String * =T1||T2||…||T M .

[0227] 8. According to the specified rules, in String * Extract valid bits from the key 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 mode of this embodiment can be divided into two categories: counter mode and feedback mode, which are introduced 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 the 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 modulo calculation (mod D)).

[0233] 4. Convert Y to bit string form.

[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 integer.

[0235] 6. Calculate the modular addition U=Y *+Key1 (where “+” indicates modulo 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 the round key is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after R rounds of calculation. C (This result is the result of the Rth round), and the pseudo-random bit string (counter state is 1) obtained after splicing and merging is Stream1=X1||…||X C (The concatenation is to concatenate the results of the Rth round), 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 key X1,…,X C That is, X1,…,X output from the last round of update calculation C .

[0240] 11. Split the plaintext according to the unit length P, and obtain the plaintext sequence string as Plaintext = Plain1||…||Plain k , each Plain i The bit length is P.

[0241] 12. For the counter state of 1, calculate the bitwise XOR of Cipher1=Plain1⊕Stream1.

[0242] 13. For the counter state set to 2, 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 Cipher2=Plain2⊕Stream2 is obtained.

[0243] 14. Counter status ++, finally all k ciphertext calculations are completed, and the ciphertext Ciphertext = Cipher1||…||Cipher k .

[0244] 6. Data encryption (feedback mode)

[0245] 1. The feedback mode has no counter concept. Based on the pseudo-random mechanism, C initial group bit strings Z1,…,Z are directly randomly generated. 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 modulo calculation (mod D)).

[0248] 4. Convert Y to bit string form.

[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 integer.

[0250] 6. Calculate the modular addition U=Y * +Key1 (where “+” indicates modulo 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 the round key is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after R rounds of calculation. C (This result is the result of the Rth round), and the pseudo-random bit string (counter state is 1) obtained after splicing and merging is Stream1=X1||…||X C(The concatenation is to concatenate the results of the Rth round), 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 key X1,…,X C That is, X1,…,X output from the last round of update calculation C .

[0255] 11. Split the plaintext according to the unit length P, and obtain the plaintext sequence string as Plaintext = Plain1||…||Plain k , each Plain i The bit length is P.

[0256] 12. For the counter state of 1, calculate the bitwise XOR of Cipher1=Plain1⊕Stream1.

[0257] 13. Start the second round of big loop, a total of k rounds of big loops, and directly convert the bit strings X1,…,X1 obtained by the first round of big loop into C As the initial bit string, complete the same operation and finally get Cipher2 = Plain2 ⊕ Sream2.

[0258] 14. Complete all k rounds of large cycles, complete all k ciphertext calculations, and 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 the 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 to bit string form.

[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 integer.

[0265] 6. Calculate the 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 the round key is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after R rounds of calculation. 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 the 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 of the previous round, and finally Plain2=Cipher2⊕Stream2 is obtained.

[0273] 14. Counter status ++, finally complete all k decryption calculations, and get the 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 to bit string form.

[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 integer.

[0280] 6. Calculate the 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 only difference between each round is the round key (the order of using the round keys is Key1, Key2, ..., Key R ), and finally obtain the result bit string X1,…,X after R rounds of calculation. 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 bit 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, complete the same operation and finally get Plain2=Cipher2⊕Stream2.

[0288] 14. Complete all k rounds of large cycles and all k decryption calculations to obtain the plaintext Plaintext = Plain1||…||Plain k .

[0289] This solution uses a key expansion method based on a lattice problem framework, uses random matrices to calculate expansion keys and round keys, and adopts a design method that combines block ciphers with sequence ciphers. The encryption and decryption process is computationally simple and has a high ability to resist 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, making it easy to apply in scenarios such as the Internet of Things.

[0290] Embodiment 3

[0291] Figure 3 A schematic diagram of the structure of a data sequence encryption and decryption device provided in the third embodiment of the present invention. A 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 encrypted plaintext data has the requirement to retain the original format, such as the same length, similar memory usage, 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 a user initial key and a lattice matrix;

[0294] A round key generation module 302, 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 used to obtain the plaintext data to be encrypted, and to perform data segmentation on 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, used to determine the key generation round number of the sequence encryption key according to the sequence number of the plaintext sequence;

[0297] A corresponding key determination module 305, for determining 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, configured to generate a sequence encryption key of the key generation round according to a round key corresponding to the key generation round;

[0299] A ciphertext sequence generating module 307, 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;

[0300] The ciphertext data generating module 308 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.

[0301] The technical solution of the embodiment of the present invention uses a key expansion method based on the lattice problem framework, and the key expansion process and the encryption and decryption process are completely decoupled. The key generation and expansion modules and the encryption and decryption modules can be deployed in different components, which is convenient for application in scenarios such as the Internet of Things. In addition, the data encryption and decryption method of the above technical solution improves the anti-quantum attack capability of the sequence encryption and improves the security of the sequence encryption, and realizes the reconfiguration of the sequence encryption process, which improves the flexibility of the encryption and decryption process.

[0302] Optionally, the round key generation module 302 includes:

[0303] A related information acquisition unit, used to acquire encryption related information and generate an initial key bit string according to 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 generating 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 generating unit, used to generate an intermediate encrypted bit string according to each of the intermediate key sub-bit strings;

[0307] The round key generating unit is used 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 used to:

[0309] Performing a base conversion operation on each of the initial key sub-bit strings to obtain an initial integer key;

[0310] Generate 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 used to:

[0314] Generate an initial encrypted bit string of the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string;

[0315] Generate 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] Generate a second encrypted bit string according to the round key corresponding to the key generation round and the first encrypted bit string;

[0317] Generate a head sub-bit string according to the second encrypted bit string and the 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 of 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] Embodiment 4

[0322] Figure 4A schematic diagram of the structure of a data sequence encryption and decryption device provided in the fourth embodiment of the present invention. A 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 encrypted plaintext data has the requirement to retain the original format, such as the same length, similar memory usage, 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 a user initial key and a lattice matrix;

[0325] A round key generation module 402, 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 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;

[0327] A generation round number determination module 404, configured to determine the number of key generation rounds of a sequence decryption key according to the number of sequences of the ciphertext sequence;

[0328] A corresponding key generation module 405 is used to determine a 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, configured to generate a sequence decryption key of the key generation round according to a round key corresponding to the key generation round;

[0330] A plaintext sequence generation module 407, 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;

[0331] The plaintext data generating module 408 is used 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 uses a key expansion method based on the lattice problem framework, and the key expansion process and the encryption and decryption process are completely decoupled. The key generation and expansion modules and the encryption and decryption modules can be deployed in different components, which is convenient for application in scenarios such as the Internet of Things. In addition, the data encryption and decryption method of the above technical solution improves the anti-quantum attack capability of the sequence encryption and improves the security of the sequence encryption, and realizes the reconfiguration of the sequence encryption process, which improves the flexibility of the encryption and decryption process.

[0333] Optionally, the sequence key generation module 406 is specifically used to:

[0334] Generate an initial decryption bit string of 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] Generate a second decrypted bit string according to the round key corresponding to the key generation round and the first decrypted bit string;

[0337] Generate a head sub-bit string according to the second decrypted bit string and the 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 of 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] Embodiment 5

[0342] Figure 5 A schematic diagram 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 processing, 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 required herein.

[0343] like Figure 5 As shown, the electronic device 50 includes at least one processor 51, and a memory connected to the at least one processor 51 in communication, such as a read-only memory (ROM) 52, a random access memory (RAM) 53, etc., wherein the memory stores a computer program that can be executed by at least one processor, and 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 to the random access memory (RAM) 53. In the RAM 53, various programs and data required for the operation of the electronic device 50 can also be stored. The processor 51, the ROM 52, and the 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] A number of 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 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 through a computer network such as the Internet and / or various telecommunication networks.

[0345] The processor 51 may be a variety of general and / or special processing components 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 special 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 performs the various methods and processes described above, such as a data sequence encryption and decryption method.

[0346] In some embodiments, the data sequence encryption and decryption method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 58. In some embodiments, part or all of the computer program may 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 may be performed. Alternatively, in other embodiments, the processor 51 may be configured to perform the data sequence encryption and decryption method in any other appropriate manner (e.g., by means of firmware).

[0347] Various implementations of the systems and techniques described above 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), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0349] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0350] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0351] The systems and techniques described herein may be implemented in a computing system that includes backend 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 frontend components (e.g., a user computer with a graphical user interface or a 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 backend components, middleware components, or frontend components. The components of the system may 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 a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0353] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0354] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A data sequence encryption and decryption method, characterized in that: Applicable to data encryption, including: Generate user initial key and lattice basis 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 performing data segmentation on 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 method, determine the round key corresponding to the key generation round; Generate a sequence encryption key for the key generation round according to the round key corresponding to the key generation round; 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 respectively corresponding to the key generation rounds.

2. The method according to claim 1, characterized in that The step of generating at least one round key according to the user initial key and the lattice basis matrix comprises: Acquire encryption related information, and generate an initial key bit string according to the encryption related information and the user initial key; According to a preset key data unit length, the initial key bit string is divided 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 The step of generating at least one intermediate key sub-bit string according to the lattice matrix and each of the initial key sub-bit strings comprises: Performing a base conversion operation on each of the initial key sub-bit strings to obtain an initial integer key; Generate 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. The method according to claim 1, characterized in that: The step of generating a sequence encryption key of the key generation round according to a round key corresponding to the key generation round includes: Generate an initial encrypted bit string of the key generation round; the initial encrypted bit string includes at least one initial encrypted sub-bit string; Generate 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; Generate a second encrypted bit string according to the round key corresponding to the key generation round and the first encrypted bit string; Generate a head sub-bit string according to the second encrypted bit string and the 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 of the key generation round is generated according to the target encrypted bit string.

5. A data sequence encryption and decryption method, characterized in that: Applicable to data decryption, including: Generate user initial key and lattice basis 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 the sequence decryption key according to the sequence number of the ciphertext sequence; For any round of sequence decryption key generation method, determine the round key corresponding to the key generation round; Generate a sequence decryption key for the key generation round according to the round key corresponding to the key generation round; 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; The plaintext data of the encrypted ciphertext data is generated according to the plaintext sequences respectively corresponding to the key generation rounds.

6. The method according to claim 5, characterized in that The step of generating a sequence decryption key of the key generation round according to a round key corresponding to the key generation round includes: Generate an initial decryption bit string of 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; Generate a second decrypted bit string according to the round key corresponding to the key generation round and the first decrypted bit string; Generate a head sub-bit string according to the second decrypted bit string and the 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 of the key generation round is generated according to the target decrypted bit string.

7. A data sequence encryption and decryption device, characterized in that: Configuration on the data encryption side includes: An initial key generation module, used to generate a user initial key and a lattice basis matrix; A round key generation module, used to generate at least one round key according to the user initial key and the lattice basis matrix; A plaintext sequence generation module, 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, used to determine the key generation round number of the sequence encryption key according to the sequence number of the plaintext sequence; A corresponding key determination module, for determining 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, used to generate a sequence encryption key of the key generation round according to the round key corresponding to the key generation round; A ciphertext sequence generation module, used 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; The ciphertext data generating module is used to generate the encrypted ciphertext data of the plaintext data to be encrypted according to the ciphertext sequences corresponding to the key generation rounds.

8. A data sequence encryption and decryption device, characterized in that: Configured on the data decryption side, including: An initial key generation module, used to generate a user initial key and a lattice basis matrix; A round key generation module, used to generate at least one round key according to the user initial key and the lattice basis matrix; A ciphertext sequence generation module, used to obtain encrypted ciphertext data, and based on a preset ciphertext data unit length, perform data segmentation on the encrypted ciphertext data to obtain at least one ciphertext sequence; A generation round number determination module, used to determine the key generation round number of the sequence decryption key according to the sequence number of the ciphertext sequence; A corresponding key generation module is used to determine a round key corresponding to the key generation round according to a generation method of a sequence decryption key of any round; A sequence key generation module, used to generate a sequence decryption key of the key generation round according to the round key corresponding to the key generation round; A plaintext sequence generation module, used 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; The plaintext data generating module is used to generate the plaintext data of the encrypted ciphertext data according to the plaintext sequences respectively corresponding to the key generating rounds.

9. 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 executable 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 execute the data sequence encryption and decryption method described in any one of claims 1-4 and / or 5-6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the data sequence encryption and decryption method described in any one of claims 1-4 and / or 5-6 when executed by a processor.

Citation Information

Patent Citations

  • Method and system for generation of cipher round keys by bit-mixers

    CN108206735A

  • Format-reserved encryption and decryption method and device, electronic equipment and medium

    CN113824547A

  • Iterative encryption method and device

    CN115459950A

  • Internet of Things security encryption method and device, storage medium and electronic equipment

    CN115694796A

  • Key packaging lightweight method and system based on number-theory transformation, medium and equipment

    CN117714054A