Format-preserving encryption and decryption method, device, electronic device and medium
By introducing a round function based on Zu Chong's sequence cryptographic algorithm in the Feistel structure, using the iterative round number and key adjustment information to generate an initialization vector, the problem of lack of retained format encryption algorithm based on the Guomin algorithm in the prior art is solved, and the encryption and decryption effect with high security is achieved.
Patent Information
- Application Number
- CN202110365891.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-06
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-04-06
AI Technical Summary
In the prior art, there are very few reserved format encryption algorithms based on the cryptographic algorithm, and the Feistel structure has fewer applications in the cryptographic algorithm construction.
The Feistel structure and the sequence cryptographic algorithm based on Zu Chong are used to generate an initialization vector by iterating the number of rounds and key adjustment information, and the output bit string is generated using the round function to realize the encryption and decryption of plain text digital strings.
A new encryption/decryption algorithm based on Zu Chongzhi sequence cryptography algorithm and Feistel structure is provided, and the reserved format encryption and decryption based on the Guo Secret algorithm is realized, and the security of the algorithm is ensured through multiple rounds of iterations.
Smart Images

Figure CN113824547B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a format-preserving encryption and decryption method, device, electronic device, and medium. Background Art
[0002] With the development of the Internet, the importance of research on secure encryption technology in the process of information transmission has become increasingly prominent. The format-preserving encryption algorithm is a new type of cryptographic algorithm. In the design process of the format-preserving encryption algorithm, the security of the algorithm is the most important consideration.
[0003] In the prior art, the Feistel structure is a common cryptographic structure, which is applied to the construction of multiple cryptographic algorithms, including the block cipher TDEA (block cipher algorithm published by the National Institute of Standards of the United States), the format-preserving encryption algorithms FF1 and FF3 (format-preserving encryption algorithms based on the AES algorithm published by the National Institute of Standards of the United States). However, there are very few format-preserving encryption algorithms based on the national secret algorithm. Summary of the invention
[0004] Embodiments of the present disclosure provide a format-preserving encryption and decryption method, apparatus, electronic device, and medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a format-preserving encryption method, the method comprising: obtaining a first sub-plaintext string and a second sub-plaintext string whose lengths match based on a plaintext digital string to be encrypted; obtaining key information for encrypting the plaintext digital string, wherein the key information comprises a key and key adjustment information; performing a preset number of iterations based on a Feistel structure to generate a ciphertext string, wherein each round of iteration of the Feistel structure comprises: generating an initialization vector based on the current number of iterations and the key adjustment information; generating an output bit string based on the initialization vector, the key, and the second sub-plaintext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; generating a digital string consistent with the base representation of the plaintext digital string based on a combination of the output bit string and the first sub-plaintext string; and exchanging the roles of the first sub-plaintext string and the second sub-plaintext string.
[0006] In a second aspect, an embodiment of the present disclosure provides a format-preserving decryption method, the method comprising: obtaining a first sub-ciphertext string and a second sub-ciphertext string whose lengths match based on a ciphertext digital string to be decrypted; obtaining key information for decrypting the ciphertext digital string, wherein the key information comprises a key and key adjustment information; performing a preset number of iterations based on a Feistel structure to generate a plaintext string, wherein each round of the Feistel structure comprises: generating an initialization vector based on a current iteration number and key adjustment information, wherein the current iteration number changes in a manner opposite to that of the encryption process; generating an output bit string based on the initialization vector, the key and the first sub-ciphertext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; generating a digital string consistent with the base representation of the ciphertext digital string based on a combination of the output bit string and the second sub-ciphertext string; and exchanging the roles of the first sub-ciphertext string and the second sub-ciphertext string.
[0007] In a third aspect, an embodiment of the present disclosure provides a format-preserving encryption device, the device comprising: a plaintext string acquisition unit, configured to acquire a first sub-plaintext string and a second sub-plaintext string that match the length of the plaintext digital string to be encrypted; an encryption key information acquisition unit, configured to acquire key information for encrypting the plaintext digital string, wherein the key information comprises a key and key adjustment information; an encryption unit, configured to perform a preset number of iterations based on a Feistel structure to generate a ciphertext string, wherein the encryption unit comprises: a first vector generation sub-unit, configured to generate an initialization vector based on the current iteration number and the key adjustment information; a first bit string generation sub-unit, configured to generate an output bit string based on the initialization vector, the key and the second sub-plaintext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; a first digital string generation sub-unit, configured to generate a digital string consistent with the base representation of the plaintext digital string based on a combination of the output bit string and the first sub-plaintext string; and a first exchange sub-unit, configured to exchange the roles of the first sub-plaintext string and the second sub-plaintext string.
[0008] In a fourth aspect, an embodiment of the present disclosure provides a format-preserving decryption device, the device comprising: a ciphertext string acquisition unit, configured to acquire a first sub-ciphertext string and a second sub-ciphertext string that match the length of the ciphertext digital string to be decrypted; a decryption key information acquisition unit, configured to acquire key information for decrypting the ciphertext digital string, wherein the key information includes a key and key adjustment information; a decryption unit, configured to perform a preset number of iterations based on a Feistel structure to generate a plaintext string, wherein the decryption unit comprises: a second vector generation subunit, configured to generate an initialization vector based on a current iteration number and key adjustment information, wherein the current iteration number changes in the opposite manner to the encryption process; a second bit string generation subunit, configured to generate an output bit string based on the initialization vector, the key and the first sub-ciphertext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; a second digital string generation subunit, configured to generate a digital string consistent with the base representation of the ciphertext digital string based on a combination of the output bit string and the second sub-ciphertext string; a second exchange subunit, configured to exchange the roles of the first sub-ciphertext string and the second sub-ciphertext string.
[0009] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0010] In a sixth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0011] The embodiments of the present invention provide a format-preserving encryption and decryption method, apparatus, electronic device and medium, which generate an initialization vector by iterating the number of rounds and key adjustment information, and use a round function constructed based on the Zu Chongzhi sequence cipher algorithm to output a bit string for changing another plaintext substring / ciphertext substring corresponding to the same plaintext / ciphertext according to the above initialization vector, key and plaintext substring / ciphertext substring, thereby providing a new encryption / decryption algorithm based on the Zu Chongzhi sequence cipher algorithm and the Feistel structure, and effectively ensuring the security of the encryption / decryption algorithm through multiple rounds of iterations. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0013] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0014] Figure 2 is a flow chart of one embodiment of a format-preserving encryption method according to the present disclosure;
[0015] Figure 3 is a schematic diagram of a 2-round iterative encryption process according to an embodiment of the present disclosure;
[0016] Figure 4 is a flow chart of one embodiment of a format-preserving decryption method according to the present disclosure;
[0017] Figure 5 is a structural diagram of an embodiment of a format-preserving encryption device according to the present disclosure;
[0018] Figure 6 is a structural schematic diagram of an embodiment of a format-preserving decryption device according to the present disclosure;
[0019] Figure 7 It is a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0020] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0021] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0022] Figure 1 An exemplary architecture 100 is shown to which the format-preserving encryption and decryption method or format-preserving encryption and decryption apparatus of the present disclosure can be applied.
[0023] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0024] The terminal devices 101, 102, 103 interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, etc.
[0025] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with data transmission functions and supporting human-computer interaction, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0026] The server 105 may be a server that provides various services, such as a background server that provides support for various applications installed on the terminal devices 101, 102, and 103. The background server may encrypt or decrypt data to be transmitted or received and generate a processing result (such as encrypted ciphertext or decrypted plaintext).
[0027] It should be noted that the above-mentioned terminal devices 101, 102, 103 and server 105 may also independently perform the above-mentioned format-preserving encryption method and format-preserving decryption method. Accordingly, in some cases, the network 104 and the server 105 may not exist; in other cases, the terminal devices 101, 102, 103 and the network 104 may not exist.
[0028] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0029] It should be noted that the format-preserving encryption and decryption method provided in the embodiments of the present disclosure may be executed by the terminal device 101, 102, 103 or the server 105. Accordingly, the format-preserving encryption and decryption apparatus may be disposed in the terminal device 101, 102, 103 or the server 105.
[0030] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0031] Continue to refer Figure 2 , shows a process 200 of an embodiment of a format-preserving encryption method according to the present disclosure. The format-preserving encryption method comprises the following steps:
[0032] Step 201 : obtaining a first sub-plaintext string and a second sub-plaintext string that match in length based on the division of the plaintext digital string to be encrypted.
[0033] In this embodiment, the execution subject of the format-preserving encryption method (such as Figure 1 The server 105 shown in the figure can obtain the first sub-plaintext string and the second sub-plaintext string of length matching based on the plaintext digital string to be encrypted through a wired connection method or a wireless connection method. Among them, the above-mentioned length matching can generally include the same length or the length difference is less than a preset threshold. As an example, if the length of the plaintext digital string to be encrypted is 17, the lengths of the first sub-plaintext string and the second sub-plaintext string can be 8 and 9 respectively. As another example, if the length of the plaintext digital string to be encrypted is 30, the lengths of the first sub-plaintext string and the second sub-plaintext string can both be 15.
[0034] In this embodiment, the plaintext digital string to be encrypted can be used to represent a string consisting entirely of digital characters, wherein the characters in the plaintext digital string are generally represented in the same system, such as binary, decimal, and the like.
[0035] In some optional implementations of this embodiment, the execution subject may also obtain the first sub-plaintext string and the second sub-plaintext string whose lengths match based on the division of the plaintext digital string to be encrypted according to the following steps:
[0036] The first step is to obtain the non-numeric plaintext string to be encrypted.
[0037] In these implementations, the execution subject may obtain the non-numeric plaintext string to be encrypted from a local or communication-connected electronic device. The non-numeric plaintext string may include non-numeric characters (e.g., letters, punctuation marks, etc.). As an example, the non-numeric plaintext string may be "hello".
[0038] The second step is to obtain the number of characters contained in the character table corresponding to the non-numeric plain text string.
[0039] In these implementations, the execution subject may obtain the number of characters contained in the character table corresponding to the non-numeric plaintext string obtained in the first step from a local or communication-connected electronic device. The character table corresponding to the non-numeric plaintext string may include a set of possible values of the characters in the non-numeric plaintext string. As an example, the character table corresponding to the non-numeric plaintext string "hello" may be {a, b, c, ..., z}. Thus, the number of characters contained in the character table corresponding to the non-numeric plaintext string "hello" may be 26.
[0040] It should be noted that the number of characters included in the above corresponding character table is usually in the range of [2,2 16 ]. The construction of the above character table usually needs to meet the above value requirements.
[0041] The third step is to generate a plaintext numeric string corresponding to the non-numeric plaintext string according to the preset mapping rule.
[0042] In these implementations, according to the preset mapping rules, the execution subject can generate a plaintext numeric string corresponding to the non-numeric plaintext string obtained in the first step in various ways. The mapping rules can match the number of characters included in the character table.
[0043] As an example, when the number of characters included in the character table is 26, the above mapping rules may include 26 pairs of mapping relationships, such as a→0, b→1, c→2, ..., z→25. Thus, the above execution entity may generate a plaintext numeric string "7 4 11 11 14" corresponding to the non-numeric plaintext string "hello" according to the above mapping rules.
[0044] It should be noted that the characters in the plain text numeric string can be separated by various separators (such as spaces, commas, etc.) to avoid confusion.
[0045] The fourth step is to divide the plaintext digital string into a first sub-plaintext string and a second sub-plaintext string, the difference of which length is no more than 1.
[0046] In these implementations, the execution subject may divide the plaintext digital string generated in the third step into a first sub-plaintext string and a second sub-plaintext string whose length difference is not greater than 1 in various ways. As an example, the execution subject may select a string consisting of the first x characters from the plaintext digital string generated in the third step as the first sub-plaintext string; and the remaining string as the second sub-plaintext string. The value of x may be the smallest integer not less than 1 / 2. The l may be used to represent the number of characters contained in the plaintext digital string, that is, the length of the plaintext digital string.
[0047] Based on the above optional implementation methods, this solution can digitize non-digital plaintext strings, providing a basis for the subsequent application of digital-based encryption algorithms, thereby enhancing the applicability of encryption algorithms.
[0048] Step 202: Obtain key information for encrypting the plaintext digital string.
[0049] In this embodiment, the execution subject may obtain key information for encrypting a plaintext digital string from a local or communication-connected electronic device. The key information may include a key and key adjustment information (Tweak). The key adjustment information may be plaintext and may be variable.
[0050] Step 203: Perform a preset number of iterations based on the Feistel structure to generate a ciphertext string.
[0051] In this embodiment, the execution subject may perform a preset number of iterations based on the Feistel structure to generate a ciphertext string, wherein the preset number of iterations may be pre-set according to actual needs, such as 8 or 16 rounds.
[0052] It should be noted that the Feistel structure is a multi-round iterative structure. Figure 3 , shows a schematic diagram of a 2-round iterative encryption process. Each round of iteration may mainly include the following steps:
[0053] 1) Split the input data (usually plain text) 301 into two parts, namely two substrings, such as Figure 3 A in i and B i (i=0,1,2). A0 and B0 are respectively Figure 3 As shown in 3011 and 3012.
[0054] 2) Round function 302 uses the second substring (such as Figure 3 B i ) is the input for transformation, and the output of the round function (such as Figure 3303 in ) is used to change (e.g., modulo addition) the first substring (e.g. Figure 3 A in i )’s ciphertext;
[0055] 3) Swap the roles of the two substrings for the next iteration ( Figure 3 In the second round of iteration, the round function input becomes the first substring, and the changed data is the second substring).
[0056] Continue to see Figure 2 In this embodiment, each round of iteration of the Feistel structure may include the following steps:
[0057] Step 2031: Generate an initialization vector based on the current iteration round number and key adjustment information.
[0058] In this embodiment, the execution subject may first obtain the current iteration round number. The current iteration round number may change according to the change of the number of iterations. As an example, the current iteration round number increases by 1 for each iteration round. Then, the execution subject may generate an initialization vector based on the current iteration round number and the key adjustment information in various ways. As an example, the execution subject may perform various mathematical operations according to the current iteration round number and the key adjustment information, and use the obtained operation results as the initialization vector.
[0059] In some optional implementations of this embodiment, the execution subject may generate an initialization vector based on the current iteration round number and the key adjustment information according to the following steps:
[0060] In the first step, the key adjustment information is divided into a key adjustment first substring and a key adjustment second substring with the same length.
[0061] In these implementations, the execution subject may divide the key adjustment information into a first key adjustment substring and a second key adjustment substring of the same length in various ways. As an example, the execution subject may extract every other character from the key adjustment information in the form of a character string, and determine the character string obtained by concatenating the extracted characters as the first substring. Then, the execution subject may select characters that are consistent with the length of the first substring (i.e., the number of characters included) from the key adjustment information, and determine the character string obtained by concatenating the selected characters as the second substring.
[0062] Optionally, the key adjustment first substring and the key adjustment second substring may be the first half string and the second half string of the key adjustment information, respectively. The key adjustment information may usually be in the form of a string with an even length.
[0063] In the second step, according to the parity of the current iteration round number, a target substring is selected from the key adjustment first substring and the key adjustment second substring.
[0064] In these implementations, the execution subject may first determine the parity of the current iteration round number obtained. According to the determined parity, the execution subject may select a target substring from the key adjustment first substring and the key adjustment second substring in various ways.
[0065] Optionally, based on the fact that the key adjustment first substring and the key adjustment second substring are respectively the first half string and the second half string of the key adjustment information, according to the parity of the current iteration round number, the execution subject may select a target substring from the key adjustment first substring (i.e., the first half string) and the key adjustment second substring (i.e., the second half string) through the following steps:
[0066] S1. In response to determining that the current iteration round number is an even number, selecting the key adjustment second substring as the target substring.
[0067] S2. In response to determining that the current iteration round number is an odd number, selecting the key adjustment first substring as the target substring.
[0068] Based on the above optional implementation methods, this solution provides a method for selecting a target substring of key adjustment information according to the current iteration round number.
[0069] The third step is to generate a bit string of preset length as an initialization vector based on the connection of the current iteration round number after the bit number expansion and the target substring.
[0070] In these implementations, based on the connection between the current iteration round number after the bit number expansion and the target substring, the execution subject can generate a bit string of a preset length as an initialization vector in various ways.
[0071] As an example, the preset length may be, for example, 128 bits. The execution subject may first expand the number of bits of the current iteration round, for example, to 8 bytes (i.e., 64 bits). When the length of the key adjustment target substring is 64 bits, the execution subject may concatenate the current iteration round after the number of bits has been expanded and the target substring to generate a bit string of the preset length as the initialization vector.
[0072] Based on the above optional implementation, this solution provides a method for generating an initialization vector by selecting a target substring of key adjustment information according to the current iteration round number.
[0073] Step 2032, based on the initialization vector, the key and the second sub-plaintext string, generate an output bit string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm.
[0074] In this embodiment, based on the initialization vector, the key and the second sub-plaintext string, the execution subject can generate an output bit string by using a round function constructed based on the Zu Chongzhi sequence cipher algorithm in various ways. As an example, the execution subject can use the initialization vector, the key and the second sub-plaintext string as inputs of the round function constructed based on the Zu Chongzhi sequence cipher algorithm, and determine the output of the round function as the output bit string.
[0075] In some optional implementations of this embodiment, the execution subject may generate an output bit string using a round function constructed based on the Zu Chongzhi sequence cryptographic algorithm according to the following steps:
[0076] In the first step, the second sub-plaintext string is extended in bit number to generate a bit string of a preset length as a new second sub-plaintext string.
[0077] In these implementations, the execution subject may expand the number of bits of the second sub-plaintext string in various ways to generate a bit string of a preset length as a new second sub-plaintext string. As an example, the execution subject may directly fill the high-order bits of the second sub-plaintext string with 0s, thereby generating a bit string of a preset length as a new second sub-plaintext string. As another example, the execution subject may convert the second sub-plaintext string into a numerical value according to the base representation (e.g., binary) of the second sub-plaintext string. Afterwards, the execution subject may convert the numerical value obtained by the conversion into a character string according to the target base representation (e.g., decimal). Finally, the execution subject may fill the high-order bits of the character string obtained by the conversion with 0s, thereby generating a bit string of a preset length as a new second sub-plaintext string.
[0078] In the second step, the initialization vector, the key and the new second sub-plaintext string of the preset length are input into the round function constructed based on the Zu Chongzhi sequence cipher algorithm to generate an output bit string of the preset length.
[0079] In these implementations, the execution subject may input the initialization vector of a preset length, the key, and the new second sub-plaintext string generated in the first step into the round function constructed based on the Zu Chongzhi sequence cipher algorithm to generate an output bit string of a preset length. Wherein, when the round function constructed based on the Zu Chongzhi sequence cipher algorithm requires the lengths of the input elements to be the same, the execution subject may convert the input elements into corresponding lengths, which will not be described in detail here.
[0080] Based on the above optional implementation, this solution provides a method for generating an output bit string based on bit number expansion.
[0081] Optionally, the execution subject may also input the initialization vector of a preset length, the key and the new second sub-plaintext string into a round function constructed based on the Zu Chongzhi sequence cipher algorithm according to the following steps to generate an output bit string of a preset length:
[0082] S1. Convert the key to a preset length.
[0083] In these implementations, the execution subject may convert the length of the key in various ways, such as converting it into binary and then filling the high bits with 0.
[0084] S2. Based on the Zu Chongzhi sequence cipher algorithm, execute the Zu Chongzhi sequence cipher generation steps for a target number of times to generate a target number of Zu Chongzhi sequence key strings.
[0085] In these implementations, based on the Zu Chongzhi sequence cipher algorithm, the execution subject may execute the Zu Chongzhi sequence cipher generation step a target number of times to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on the preset length.
[0086] As an example, the execution subject can first use the key and the initialization vector of the preset length to execute the initialization phase of the Zu Chongzhi sequence cipher algorithm and the process before the key output process during the working phase. Then, each time the Zu Chongzhi sequence cipher generation step is executed, a 32-bit string can be generated. If the preset length is 128 bits, the target number can be 128÷32=4.
[0087] S3. Generate an output bit string of a preset length based on the generated Zu Chongzhi sequence key string and the new second sub-plaintext string.
[0088] In these implementations, based on the Zu Chongzhi sequence key string generated in step S2 and the new second sub-plaintext string, the execution subject may generate an output bit string of a preset length in various ways. As an example, the execution subject may connect the Zu Chongzhi sequence key strings generated above, and determine the connected string as the output bit string of the preset length.
[0089] Based on the above optional implementation methods, this scheme provides an encryption algorithm that combines a round function constructed based on Zu Chongzhi's sequence cipher algorithm with a Feistel structure to generate a ciphertext of a preset length.
[0090] Optionally, the above execution subject may also generate an output bit string of a preset length according to the following steps:
[0091] S31, connecting the generated Zu Chongzhi sequence key strings to generate a key string of preset length.
[0092] S32. Perform an XOR operation on the key string of a preset length and the new second sub-plaintext string bit by bit to generate an output bit string of a preset length.
[0093] Based on the above optional implementation, this solution provides a method for outputting a bit string using a round function.
[0094] Step 2033: Based on the combination of the output bit string and the first sub-plaintext string, generate a digital string that is consistent with the base representation of the plaintext digital string.
[0095] In this embodiment, based on the combination of the output bit string and the first sub-plaintext string, the execution subject can generate a digital string consistent with the base representation of the plaintext digital string in various ways. As an example, the execution subject can generate corresponding numerical values according to the base representation of the output bit string and the first sub-plaintext string. Afterwards, the execution subject can convert the generated numerical values according to the base representation of the plaintext digital string to generate a first string and a second string. Finally, the execution subject can connect the first string and the second string to generate a digital string consistent with the base representation of the plaintext digital string.
[0096] In some optional implementations of this embodiment, the execution subject may generate a digital string consistent with the base representation of the plaintext digital string according to the following steps:
[0097] In the first step, the output bit string of a preset length is converted into a represented numerical value as a first numerical value.
[0098] In these implementations, the execution subject may perform numerical conversion according to the base representation of each character in the output bit string to generate the first value. As an example, the execution subject may convert the base 3 output bit string "102" into 1×3 2 +0×3+2=11 is used as the first numerical value.
[0099] In the second step, the first sub-plaintext string is converted into a numerical value represented by the base representation as the second numerical value.
[0100] In these implementations, the execution subject may perform numerical conversion according to the base representation of each character in the first sub-plaintext string to generate a second numerical value.
[0101] The third step is to perform modular addition of the second value and the first value to generate a third value.
[0102] In these implementations, the execution entity may perform modular addition of the second value and the first value in various ways to generate a third value.
[0103] Optionally, the execution entity may generate the third value according to the following steps:
[0104] S1. According to the parity of the current iteration round number, the number of digits contained in the first sub-plaintext string or the number of digits contained in the second sub-plaintext string is selected as the target length.
[0105] In these implementations, the execution entity may determine the target length according to preset parity and target length selection rules.
[0106] As an example, in response to determining that the current iteration round number is an even number, the above-mentioned execution entity can select the number of digits contained in the first sub-plaintext string as the above-mentioned target length; in response to determining that the current iteration round number is an odd number, the above-mentioned execution entity can select the number of digits contained in the second sub-plaintext string as the above-mentioned target length.
[0107] S2. Generate a target operand N according to the target length and base representation.
[0108] In these implementations, the execution subject can generate the target operand N according to the target length and the base representation in various ways. As an example, N=base m The base may be used to represent a base number. For example, the base of binary is 2, and the base of decimal is 10. The m may be used to represent the target length selected in step S1.
[0109] S3, performing modulo-N addition of the second value and the first value to generate a third value
[0110] In these implementations, the execution entity may generate the third value by the following formula:
[0111] y3=(y2+y1)mod N
[0112] Among them, the above =y1, y2, y3 can be used to represent the first value, the second value and the third value respectively, and the above N can be used to represent the target operand generated by the above step S2.
[0113] The fourth step is to convert the third value into a digital string according to the base representation.
[0114] In these implementations, the execution entity may convert the character string according to the base representation of the third value to generate the digital string.
[0115] Optionally, based on the above optional implementation, the above execution entity may also convert the above third value into a digital string represented in the above base and extend the number of bits to the above target length.
[0116] Based on the above optional implementation, this solution provides a method for generating a digital string that is consistent with the base representation of the plaintext digital string.
[0117] Step 2034, swapping the roles of the first sub-plaintext string and the second sub-plaintext string.
[0118] In this embodiment, the execution subject may exchange the substring used as the round function input and the substring for data change.
[0119] In this embodiment, after executing a preset number of iterations, the execution subject may connect the two obtained substrings to generate a ciphertext string.
[0120] The method provided by the above-mentioned embodiments of the present disclosure improves the iteration method of each round based on the Feistel structure, generates an initialization vector through the number of iterative rounds and key adjustment information, and uses a round function constructed based on the Zu Chongzhi sequence cipher algorithm to output a bit string for changing another plaintext substring corresponding to the same plaintext according to the above-mentioned initialization vector, key and plaintext substring. A new encryption algorithm based on the Zu Chongzhi sequence cipher algorithm and the Feistel structure is provided, a format-preserving encryption algorithm based on the national secret algorithm is implemented, and the security of the encryption algorithm is effectively guaranteed through multiple rounds of iterations.
[0121] Further references Figure 4 , which shows a process 400 of another embodiment of a format-preserving decryption method. The process 400 of the format-preserving decryption method includes the following steps:
[0122] Step 401 : obtaining a first sub-ciphertext string and a second sub-ciphertext string whose lengths match based on the division of the ciphertext digital string to be decrypted.
[0123] Step 402, obtaining key information for decrypting the ciphertext digital string.
[0124] Step 403: Perform a preset number of iterations based on the Feistel structure to generate a plaintext string.
[0125] In this embodiment, each round of iteration of the Feistel structure may include the following steps:
[0126] Step 4031: Generate an initialization vector based on the current iteration round number and key adjustment information.
[0127] In this embodiment, the current iteration number changes in the opposite manner to the encryption process. For example, if the current iteration number increases by 1 from 0 after each encryption process, then the current iteration number decreases by 1 from the preset number after each decryption process.
[0128] Step 4032, based on the initialization vector, the key and the first sub-ciphertext string, generate an output bit string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm.
[0129] Step 4033: Based on the combination of the output bit string and the second sub-ciphertext string, generate a digital string that is consistent with the base representation of the ciphertext digital string.
[0130] Step 4034, swapping the roles of the first sub-ciphertext string and the second sub-ciphertext string.
[0131] It should be noted that those skilled in the art know that the encryption process and the decryption process are inverse processes to each other, so there are similarities between their corresponding steps.
[0132] For the above steps 401 and 402, the execution subject of the format-retaining decryption method (e.g. Figure 1 The server 105 shown in the figure can be executed in a manner consistent with step 201, step 202 and their optional implementation methods in the aforementioned embodiment, which will not be repeated here.
[0133] For the above steps 4031-4034, the execution subject of the format-preserving decryption method (e.g. Figure 1 The server 105 shown in the figure can be executed in a manner similar to step 2031-step 2032 and its optional implementation in the above-mentioned embodiment, which will not be described in detail here. The differences may include: 1) the first sub-ciphertext string and the second sub-ciphertext string in the decryption process can respectively correspond to the second sub-plaintext string and the first sub-plaintext string in the encryption process; 2) the modular addition operation in the encryption process is correspondingly converted into a modular subtraction operation in the decryption process.
[0134] from Figure 4 It can be seen that the process 400 of the format-preserving decryption method in this embodiment improves the iteration method of each round based on the Feistel structure, generates an initialization vector by the number of iterative rounds and the key adjustment information, and uses the round function constructed based on the Zu Chongzhi sequence cipher algorithm to output the bit string corresponding to another ciphertext substring of the same ciphertext according to the above initialization vector, key and ciphertext substring, thereby providing a new decryption algorithm based on the Zu Chongzhi sequence cipher algorithm and the Feistel structure, realizing a format-preserving decryption algorithm based on the national secret algorithm, and effectively ensuring the security of the decryption algorithm through multiple rounds of iterations.
[0135] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a format-preserving encryption device, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0136] like Figure 5 As shown, the format-preserving encryption device 500 provided in this embodiment includes a plaintext string acquisition unit 501 , an encryption key information acquisition unit 502 and an encryption unit 503 . The plaintext string acquisition unit 501 is configured to acquire a first sub-plaintext string and a second sub-plaintext string that match the length of the plaintext digital string to be encrypted; the encryption key information acquisition unit 502 is configured to acquire key information for encrypting the plaintext digital string, wherein the key information includes a key and key adjustment information; the encryption unit 503 is configured to perform a preset number of iterations based on the Feistel structure to generate a ciphertext string, wherein the encryption unit 503 includes: a first vector generation sub-unit 5031, configured to generate an initialization vector based on the current iteration number and the key adjustment information; a first bit string generation sub-unit 5032, configured to generate an output bit string based on the initialization vector, the key, and the second sub-plaintext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; a first digital string generation sub-unit 5033, configured to generate a digital string consistent with the base representation of the plaintext digital string based on a combination of the output bit string and the first sub-plaintext string; and a first exchange sub-unit 5034, configured to exchange the roles of the first sub-plaintext string and the second sub-plaintext string.
[0137] In this embodiment, in the format-preserving encryption device 500, the specific processing of the plaintext string acquisition unit 501, the encryption key information acquisition unit 502 and the encryption unit 503 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of step 201, step 202 and step 203 in the corresponding embodiment are not repeated here.
[0138] In some optional implementations of this embodiment, the first vector generating subunit 5031 may include a partitioning module (not shown in the figure), a selection module (not shown in the figure), and a generation module (not shown in the figure). The partitioning module may be configured to partition the key adjustment information into a first key adjustment substring and a second key adjustment substring of the same length. The selection module may be configured to select a target substring from the first key adjustment substring and the second key adjustment substring according to the parity of the current iteration round number. The generation module may be configured to generate a bit string of a preset length as an initialization vector based on the connection of the current iteration round number after the bit number expansion and the target substring.
[0139] In some optional implementations of this embodiment, the key adjustment first substring and the key adjustment second substring may be the first half string and the second half string of the key adjustment information, respectively. The selection module may be further configured to: in response to determining that the current iteration round number is an even number, select the key adjustment second substring as the target substring; in response to determining that the current iteration round number is an odd number, select the key adjustment first substring as the target substring.
[0140] In some optional implementations of this embodiment, the first bit string generation subunit 5032 may include an expansion module (not shown in the figure) and an output module (not shown in the figure). The expansion module may be configured to expand the second sub-plaintext string by the number of bits, and generate a bit string of a preset length as a new second sub-plaintext string. The output module may be configured to input the initialization vector of the preset length, the key and the new second sub-plaintext string into a round function constructed based on the Zu Chongzhi sequence cipher algorithm, and generate an output bit string of a preset length.
[0141] In some optional implementations of the present embodiment, the output module may include a conversion submodule (not shown in the figure), a generation submodule (not shown in the figure), and an output submodule (not shown in the figure). The conversion submodule may be configured to convert the key into a preset length. The generation submodule may be configured to perform a target number of Zu Chongzhi sequence cipher generation steps based on the Zu Chongzhi sequence cipher algorithm to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on a preset length. The output submodule may be configured to generate an output bit string of a preset length based on the generated Zu Chongzhi sequence key string and a new second sub-plaintext string.
[0142] In some optional implementations of the present embodiment, the above-mentioned output submodule can be further configured to: connect the generated Zu Chongzhi sequence key strings to generate a key string of a preset length; perform a bit-by-bit XOR operation on the key string of the preset length and the new second sub-plaintext string to generate an output bit string of a preset length.
[0143] In some optional implementations of this embodiment, the first digital string generation subunit 5033 may include: a first conversion module (not shown in the figure), a second conversion module (not shown in the figure), a modular addition module (not shown in the figure), and a third conversion module (not shown in the figure). The first conversion module may be configured to convert an output bit string of a preset length into a represented numerical value as a first numerical value. The second conversion module may be configured to convert the first sub-plaintext string into a represented numerical value as a second numerical value according to a base representation. The modular addition module may be configured to perform modular addition of the second numerical value and the first numerical value to generate a third numerical value. The third conversion module may be configured to convert the third numerical value into a digital string according to a base representation.
[0144] In some optional implementations of this embodiment, the above-mentioned modulo addition module can be further configured to: select the number of digits contained in the first sub-plaintext string or the number of digits contained in the second sub-plaintext string as the target length according to the parity of the current iteration round number; generate the target operand N according to the target length and the base representation; perform modulo N addition on the second value and the first value to generate a third value. The above-mentioned third conversion module can be further configured to: convert the third value into a digital string represented in the base and expand the number of digits to the target length.
[0145] In some optional implementations of the present embodiment, the above-mentioned plaintext string acquisition unit 501 can be further configured to: obtain a non-numeric plaintext string to be encrypted; obtain the number of characters contained in the character table corresponding to the non-numeric plaintext string; generate a plaintext digital string corresponding to the non-numeric plaintext string according to a preset mapping rule, wherein the mapping rule matches the number of characters contained in the character table; divide the plaintext digital string into a first sub-plaintext string and a second sub-plaintext string, the difference between which has a length not greater than 1.
[0146] The device provided by the above-mentioned embodiment of the present disclosure improves the iteration method of each round based on the Feistel structure, generates an initialization vector through the first vector generation subunit 5031 iterative round number and key adjustment information, and the first bit string generation subunit 5032 uses the round function constructed based on the Zu Chongzhi sequence cipher algorithm to output the bit string corresponding to another plaintext substring of the same plaintext according to the above-mentioned initialization vector, key and plaintext substring, thereby providing a new encryption algorithm based on the Zu Chongzhi sequence cipher algorithm and the Feistel structure, realizing a format-preserving encryption algorithm based on the national secret algorithm, and effectively ensuring the security of the encryption algorithm through multiple rounds of iterations.
[0147] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a format-preserving decryption device, which is similar to Figure 4 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0148] like Figure 6As shown, the format-preserving decryption device 600 provided in this embodiment includes a ciphertext string acquisition unit 601, a decryption key information acquisition unit 602, and a decryption unit 603. The ciphertext string acquisition unit 601 is configured to acquire a first sub-ciphertext string and a second sub-ciphertext string that match the length of the ciphertext digital string to be decrypted; the decryption key information acquisition unit 602 is configured to acquire key information for decrypting the ciphertext digital string, wherein the key information includes a key and key adjustment information; the decryption unit 603 is configured to perform a preset number of iterations based on the Feistel structure to generate a plaintext string, wherein the decryption unit 603 includes: a second vector generation subunit 6031 configured to generate a plaintext string based on the current number of iterations and The key adjustment information generates an initialization vector, wherein the current iteration round number changes in the opposite manner to the encryption process; the second bit string generation subunit 6032 is configured to generate an output bit string based on the initialization vector, the key and the first sub-ciphertext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; the second digital string generation subunit 6033 is configured to generate a digital string consistent with the base representation of the ciphertext digital string based on a combination of the output bit string and the second sub-ciphertext string; the second exchange subunit 6034 is configured to exchange the roles of the first sub-ciphertext string and the second sub-ciphertext string.
[0149] In the format-preserving decryption device 600, the specific processing of the ciphertext string acquisition unit 601, the decryption key information acquisition unit 602 and the decryption unit 603 and the technical effects thereof can be referred to in Figure 4 The relevant descriptions of step 401, step 402 and step 403 in the corresponding embodiment are not repeated here.
[0150] In some optional implementations of this embodiment, the above-mentioned format-preserving decryption device 600 can be configured to execute the format-preserving decryption method described in any implementation of the second aspect in the aforementioned invention content.
[0151] The device provided by the above-mentioned embodiment of the present disclosure improves the iteration method of each round based on the Feistel structure, generates an initialization vector through the first vector generation subunit 6031 iterative round number and key adjustment information, and the first bit string generation subunit 6032 uses the round function constructed based on the Zu Chongzhi sequence encryption algorithm to output the bit string corresponding to another ciphertext substring of the same ciphertext according to the above-mentioned initialization vector, key and ciphertext substring, thereby providing a new decryption algorithm based on the Zu Chongzhi sequence encryption algorithm and the Feistel structure, realizing a format-preserving decryption algorithm based on the national secret algorithm, and effectively ensuring the security of the decryption algorithm through multiple rounds of iterations.
[0152] Reference below Figure 7, which shows an electronic device (eg, Figure 1 Schematic diagram of the structure of server 105)700. Figure 7 The server shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0153] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0154] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 7 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0155] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0156] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0157] The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist independently without being assembled into the server or terminal device. The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the server or terminal device, the server or terminal device: obtains a first sub-plaintext string and a second sub-plaintext string whose lengths match based on the plaintext digital string to be encrypted; obtains key information for encrypting the plaintext digital string, wherein the key information includes a key and key adjustment information; performs a preset number of iterations based on the Feistel structure to generate a ciphertext string, wherein each round of iteration of the Feistel structure includes: generating an initialization vector based on the current iteration number and the key adjustment information; based on the initialization vector, the key and the second sub-plaintext string, generating an output bit string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; based on the combination of the output bit string and the first sub-plaintext string, generating a digital string consistent with the base representation of the plaintext digital string; exchanging the roles of the first sub-plaintext string and the second sub-plaintext string;
[0158] Alternatively, a first sub-ciphertext string and a second sub-ciphertext string of length matching are obtained based on the division of the ciphertext digital string to be decrypted; key information for decrypting the ciphertext digital string is obtained, wherein the key information includes a key and key adjustment information; a preset number of iterations are performed based on a Feistel structure to generate a plaintext string, wherein each round of the Feistel structure includes: generating an initialization vector based on the current iteration round number and the key adjustment information, wherein the current iteration round number changes in a manner opposite to the encryption process; based on the initialization vector, the key and the first sub-ciphertext string, an output bit string is generated using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; based on a combination of the output bit string and the second sub-ciphertext string, a digital string consistent with the base representation of the ciphertext digital string is generated; and the roles of the first sub-ciphertext string and the second sub-ciphertext string are exchanged.
[0159] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C", Python, or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0160] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0161] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The units described may also be arranged in a processor, for example, may be described as: a processor including a plaintext string acquisition unit, an encryption key information acquisition unit, and an encryption unit; or a processor including a ciphertext string acquisition unit, a decryption key information acquisition unit, and a decryption unit. The names of these units do not constitute limitations on the units themselves in certain circumstances. For example, the plaintext string acquisition unit may also be described as "a unit for obtaining a first sub-plaintext string and a second sub-plaintext string that match the length of the plaintext digital string to be encrypted".
[0162] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) to form a technical solution.
Claims
1. A format-preserving encryption method comprising: Obtain a first sub-plaintext string and a second sub-plaintext string whose lengths match based on the division of the plaintext digital string to be encrypted; Acquire key information for encrypting the plaintext digital string, wherein the key information includes a key and key adjustment information; Based on the Feistel structure, a preset number of iterations are performed to generate a ciphertext string, wherein each round of iteration of the Feistel structure includes: generating an initialization vector based on the current iteration number and the key adjustment information; generating an output bit string based on the initialization vector, the key and the second sub-plaintext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; generating a digital string consistent with the base representation of the plaintext digital string based on a combination of the output bit string and the first sub-plaintext string; exchanging the roles of the first sub-plaintext string and the second sub-plaintext string; The step of generating an output bit string based on the initialization vector, the key and the second sub-plaintext string by using a round function constructed based on the Zu Chongzhi sequence cipher algorithm includes: Expanding the second sub-plaintext string by the number of bits to generate a bit string of a preset length as a new second sub-plaintext string; Converting the key to the preset length; Based on the Zu Chongzhi sequence cipher algorithm, executing the Zu Chongzhi sequence cipher generation step for a target number of times to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on the preset length; Based on the generated Zu Chongzhi sequence key string and the new second sub-plaintext string, an output bit string of the preset length is generated.
2. The method according to claim 1, wherein: The generating an initialization vector based on the current iteration round number and the key adjustment information includes: Dividing the key adjustment information into a first key adjustment substring and a second key adjustment substring of the same length; Selecting a target substring from the key adjustment first substring and the key adjustment second substring according to the parity of the current iteration round number; Based on the connection of the current iteration round number after the bit number expansion and the target substring, a bit string of preset length is generated as the initialization vector.
3. The method according to claim 2, wherein: The key adjustment first substring and the key adjustment second substring are respectively the first half string and the second half string of the key adjustment information; as well as The selecting a target substring from the key adjustment first substring and the key adjustment second substring according to the parity of the current iteration round number includes: In response to determining that the current iteration round number is an even number, selecting the key adjustment second substring as the target substring; In response to determining that the current iteration round number is an odd number, the key adjustment first substring is selected as the target substring.
4. The method according to claim 3, wherein: The step of generating the output bit string of the preset length based on the generated Zu Chongzhi sequence key string and the new second sub-plaintext string comprises: Connecting the generated Zu Chongzhi sequence key strings to generate a key string of the preset length; An XOR operation is performed bit by bit on the key string of the preset length and the new second sub-plaintext string to generate an output bit string of the preset length.
5. The method according to claim 4, wherein: The step of generating a digital string consistent with the base representation of the plaintext digital string based on the combination of the output bit string and the first sub-plaintext string includes: Converting the output bit string of the preset length into a represented value as a first value; Converting the first sub-plaintext string into a represented value according to the base representation as a second value; Performing modular addition of the second value and the first value to generate a third value; The third numerical value is converted into a digital string according to the base representation.
6. The method according to claim 5, wherein: The step of performing modular addition of the second value and the first value to generate a third value includes: According to the parity of the current iteration round number, the number of digits contained in the first sub-plaintext string or the number of digits contained in the second sub-plaintext string is selected as the target length; Generate a target operand N according to the target length and the base representation; Performing modulo-N addition of the second value and the first value to generate a third value; and The converting the third value into a digital string according to the base representation includes: The third value is converted into a digital string represented by the base and the number of bits is extended to the target length.
7. The method according to any one of claims 1 to 6, wherein: The method of obtaining the first sub-plaintext string and the second sub-plaintext string whose lengths match based on the division of the plaintext digital string to be encrypted comprises: Get the non-numeric plaintext string to be encrypted; Obtaining the number of characters contained in the character table corresponding to the non-numeric plaintext character string; Generating a plaintext numeric string corresponding to the non-numeric plaintext string according to a preset mapping rule, wherein the mapping rule matches the number of characters included in the character table; The plaintext digital string is divided into a first sub-plaintext string and a second sub-plaintext string, the difference in length of which is not greater than 1.
8. A format-preserving decryption method comprising: Obtaining a first sub-ciphertext string and a second sub-ciphertext string whose lengths match based on the division of the ciphertext digital string to be decrypted; Obtaining key information for decrypting the ciphertext digital string, wherein the key information includes a key and key adjustment information; Based on the Feistel structure, a preset number of iterations are performed to generate a plaintext string, wherein each round of the Feistel structure includes: generating an initialization vector based on the current iteration round number and the key adjustment information, wherein the current iteration round number changes in the opposite manner to the encryption process; based on the initialization vector, the key and the first sub-ciphertext string, generating an output bit string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; based on the combination of the output bit string and the second sub-ciphertext string, generating a digital string consistent with the base representation of the ciphertext digital string; exchanging the roles of the first sub-ciphertext string and the second sub-ciphertext string; The step of generating an output bit string based on the initialization vector, the key and the first sub-ciphertext string by using a round function constructed based on the Zu Chongzhi sequence cipher algorithm includes: Expanding the first sub-ciphertext string by the number of bits to generate a bit string of a preset length as a new first sub-ciphertext string; Converting the key to the preset length; Based on the Zu Chongzhi sequence cipher algorithm, executing the Zu Chongzhi sequence cipher generation step for a target number of times to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on the preset length; Based on the generated Zu Chongzhi sequence key string and the new first sub-ciphertext string, an output bit string of the preset length is generated.
9. A format-preserving encryption device comprising: A plaintext string acquisition unit configured to acquire a first sub-plaintext string and a second sub-plaintext string that match in length based on the plaintext digital string to be encrypted; an encryption key information acquisition unit, configured to acquire key information for encrypting the plaintext digital string, wherein the key information includes a key and key adjustment information; The encryption unit is configured to perform a preset number of iterations based on the Feistel structure to generate a ciphertext string, wherein the encryption unit includes: a first vector generation subunit, configured to generate an initialization vector based on the current iteration round number and the key adjustment information; a first bit string generation subunit, configured to generate an output bit string based on the initialization vector, the key and the second sub-plaintext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; a first digital string generation subunit, configured to generate a digital string consistent with the base representation of the plaintext digital string based on a combination of the output bit string and the first sub-plaintext string; a first exchange subunit, configured to exchange the roles of the first sub-plaintext string and the second sub-plaintext string; Wherein, the first bit string generating subunit is further configured to: Expanding the second sub-plaintext string by the number of bits to generate a bit string of a preset length as a new second sub-plaintext string; Converting the key to the preset length; Based on the Zu Chongzhi sequence cipher algorithm, executing the Zu Chongzhi sequence cipher generation step for a target number of times to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on the preset length; Based on the generated Zu Chongzhi sequence key string and the new second sub-plaintext string, an output bit string of the preset length is generated.
10. A format-preserving decryption device, comprising: A ciphertext string acquisition unit is configured to acquire a first sub-ciphertext string and a second sub-ciphertext string that match the length of the ciphertext digital string to be decrypted; a decryption key information acquisition unit, configured to acquire key information for decrypting the ciphertext digital string, wherein the key information includes a key and key adjustment information; A decryption unit is configured to perform a preset number of iterations based on a Feistel structure to generate a plaintext string, wherein the decryption unit includes: a second vector generation subunit, configured to generate an initialization vector based on a current iteration number and the key adjustment information, wherein the current iteration number changes in the opposite manner to the encryption process; a second bit string generation subunit, configured to generate an output bit string based on the initialization vector, the key and the first sub-ciphertext string using a round function constructed based on the Zu Chongzhi sequence cipher algorithm; a second digital string generation subunit, configured to generate a digital string consistent with the binary representation of the ciphertext digital string based on a combination of the output bit string and the second sub-ciphertext string; a second exchange subunit, configured to exchange the roles of the first sub-ciphertext string and the second sub-ciphertext string; Wherein, the second bit string generating subunit is further configured to: Expanding the first sub-ciphertext string by the number of bits to generate a bit string of a preset length as a new first sub-ciphertext string; Converting the key to the preset length; Based on the Zu Chongzhi sequence cipher algorithm, executing the Zu Chongzhi sequence cipher generation step for a target number of times to generate a target number of Zu Chongzhi sequence key strings, wherein the target number is determined based on the preset length; Based on the generated Zu Chongzhi sequence key string and the new first sub-ciphertext string, an output bit string of the preset length is generated.
11. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
12. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Encryption device, encryption method, and computer program
CN101553857A
Format-preserving encryption method and decryption method based on message authentication code algorithm
CN112994874A
Reserved format encryption method and decryption method based on national secret password hash algorithm
CN113037488A