Lightweight encryption method, decryption method, related device and vehicle
By performing multiple rounds of sequence permutation and data block encryption on the odd and even bit sequences of the master key, the problems of small data volume and limited device capabilities in vehicle networking are solved, achieving lightweight encryption and decryption and ensuring the security and correctness of in-vehicle communication.
Patent Information
- Application Number
- CN202410739174.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-06-07
AI Technical Summary
In the context of vehicle-to-everything (V2X) communication, the amount of communication data is small and the computing and storage capabilities of in-vehicle devices are limited. Existing encryption algorithms are difficult to achieve both lightweight design and security, especially under the limitation of 8 bits per frame of data on the CAN bus, which presents challenges for cryptographic algorithms in terms of data length.
A lightweight encryption method is adopted. An initialization sequence is generated by performing multiple rounds of sequence permutation on the odd-numbered and even-numbered bit sequences of the master key. The plaintext data is then divided into multiple data blocks for multiple rounds of encryption and sequence permutation to generate ciphertext data and tags. The receiving end verifies the correctness of the decryption result through the tags.
It achieves efficient and secure data encryption and decryption in the vehicle-to-everything (V2X) environment, adapts to the computing and storage limitations of in-vehicle devices, and ensures the security and accuracy of data transmission.
Smart Images

Figure CN118590219B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of communication security, and in particular to a lightweight encryption method, a decryption method, related equipment and a vehicle. BACKGROUND
[0002] When communicating in a vehicle Internet environment, since the amount of communication data is small, and the operation processing capability and storage capability of the vehicle components are relatively limited, the cryptographic algorithm suitable for the vehicle environment needs to be particularly lightweight, while ensuring a certain security, and since each frame of data on the CAN bus of the vehicle network communication is 8 bits, the cryptographic algorithm is also limited in data length. SUMMARY
[0003] Therefore, the purpose of the present application is to provide a lightweight encryption method, a decryption method, related equipment and a vehicle.
[0004] To achieve the above purpose, the present application provides a lightweight encryption method applied to a sending end, which comprises:
[0005] performing multi-round sequence permutation on a sequence composed of odd bit bits of a master key and a sequence composed of even bit bits of the master key by using a preset permutation function, to obtain a first initialization sequence and a second initialization sequence;
[0006] segmenting plaintext data into a plurality of plaintext data blocks according to the order of bit bits, performing multi-round encryption by using the first initialization sequence and the second initialization sequence, encrypting one plaintext data block in each round of encryption and performing sequence permutation once, and obtaining a plurality of ciphertext data blocks, a first encryption sequence and a second encryption sequence after multi-round encryption, and composing ciphertext data from the plurality of ciphertext data blocks;
[0007] performing multi-round sequence permutation on the first encryption sequence and the second encryption sequence by using the permutation function, to obtain a first tag sequence and a second tag sequence, and composing a first tag from the first tag sequence and the second tag sequence;
[0008] sending the ciphertext data and the first tag to a receiving end.
[0009] Further, performing multi-round sequence permutation on a sequence composed of odd bit bits of a master key and a sequence composed of even bit bits of the master key comprises:
[0010] In the first round of permutation, a plurality of sub-keys of the first round of permutation are constructed by using the first plurality of bits of the main key, and the main key is circularly shifted once to obtain a bit shift key in the next round of permutation, in each non-first round of permutation, a plurality of sub-keys of the current round of permutation are constructed by using the first plurality of bits of the bit shift key of the current round of permutation, and the bit shift key is circularly shifted once to obtain the bit shift key of the next round of permutation;
[0011] In the first round of permutation, the first input sequence of the first round of permutation is obtained by performing XOR operation on the sequence composed of the odd bits and the sequence composed of the even bits, in each non-first round of permutation, the first input sequence of the current round of permutation is obtained by performing XOR operation on the first intermediate sequence and the second intermediate sequence obtained in the previous round of permutation;
[0012] In each round of permutation, the first output sequence of the current round of permutation is obtained by performing operation of a composite function on the first input sequence and the plurality of sub-keys, and the first intermediate sequence and the second intermediate sequence of the current round of permutation are obtained by performing XOR operation on the first output sequence and the first intermediate sequence and the second intermediate sequence of the previous round of permutation respectively;
[0013] In response to reaching a preset number of permutation rounds, the first intermediate sequence and the second intermediate sequence obtained in the last round of permutation are determined as the first initialization sequence and the second initialization sequence respectively.
[0014] The plurality of sub-keys of the current round of permutation include a first sub-key, a second sub-key and a third sub-key;
[0015] Further, the operation of the composite function on the first input sequence and the plurality of sub-keys to obtain the first output sequence of the current round of permutation includes:
[0016] The first input sequence is divided into a first input data block, a second input data block, a third input data block and a fourth input data block;
[0017] The first sub-key is multiplied with the first input data block by modulo operation to obtain a first sub-sequence, the second sub-key is added with the second input data block by modulo operation to obtain a second sub-sequence, the first sub-key is added with the third input data block by modulo operation to obtain a third sub-sequence, and the second sub-key is multiplied with the fourth input data block by modulo operation to obtain a fourth sub-sequence;
[0018] XORing the first subsequence and the third subsequence to obtain a fifth subsequence, XORing the second subsequence and the fourth subsequence to obtain a sixth subsequence, performing modulo multiplication on the third subkey and the fifth subsequence to obtain a seventh subsequence, performing modulo addition on the sixth subsequence and the seventh subsequence to obtain an eighth subsequence, performing modulo multiplication on the third subkey and the eighth subsequence to obtain a ninth subsequence, performing modulo addition on the seventh subsequence and the ninth subsequence to obtain a tenth subsequence;
[0019] XORing the first subsequence and the ninth subsequence to obtain a first output data block, XORing the second subsequence and the tenth subsequence to obtain a second output data block, XORing the ninth subsequence and the third subsequence to obtain a third output data block, XORing the tenth subsequence and the fourth subsequence to obtain a fourth output data block;
[0020] The first output data block, the second output data block, the third output data block and the fourth output data block constitute the first output sequence.
[0021] Further, in each round of encryption, one plaintext data block is encrypted, and sequence permutation is performed once, including:
[0022] In the first round of encryption, XORing the first initialization sequence and the first plaintext data block to obtain a corresponding ciphertext data block, and performing sequence permutation on the ciphertext data block obtained in the current round of encryption and the second initialization sequence to obtain a first transition sequence and a second transition sequence in the current round of encryption;
[0023] In the non-first round of encryption, XORing the first transition sequence obtained in the previous round of encryption and the corresponding sequence plaintext data block to obtain a corresponding ciphertext data block, and performing sequence permutation on the ciphertext data block obtained in the current round of encryption and the second transition sequence obtained in the previous round of encryption to obtain a first transition sequence and a second transition sequence in the current round of encryption.
[0024] Based on the same inventive concept, the application provides a lightweight decryption method applied to a receiving end, which comprises:
[0025] Receiving ciphertext data and a first tag from the sending end, performing multi-round sequence permutation on a sequence composed of odd bits of a master key and a sequence composed of even bits of the master key by using a preset permutation function to obtain a third initialization sequence and a fourth initialization sequence;
[0026] The ciphertext data is divided into a plurality of ciphertext data blocks in the order of bit, a plurality of rounds of decryption is performed by using the third initialization sequence and the fourth initialization sequence, one ciphertext data block is decrypted and one sequence permutation is performed in each round of decryption, and a plurality of plaintext data blocks, a first decryption sequence and a second decryption sequence are obtained after the plurality of rounds of decryption, and the plurality of plaintext data blocks are combined to form plaintext data;
[0027] The first decryption sequence and the second decryption sequence are subjected to a plurality of rounds of sequence permutation by using the permutation function, a third label sequence and a fourth label sequence are obtained, the third label sequence and the fourth label sequence are combined to form a second label, and it is determined that the plaintext data is correct in response to determining that the second label is consistent with the first label.
[0028] Based on the same inventive concept, the application further provides a lightweight encryption device, comprising a first initialization module, an encryption module, a first label generation module and a sending module;
[0029] The first initialization module is configured to perform a plurality of rounds of sequence permutation on a sequence composed of odd bit bits and a sequence composed of even bit bits of a master key by using a preset permutation function, and obtain a first initialization sequence and a second initialization sequence.
[0030] The encryption module is configured to divide plaintext data into a plurality of plaintext data blocks in the order of bit, perform a plurality of rounds of encryption by using the first initialization sequence and the second initialization sequence, encrypt one plaintext data block in each round of encryption, and perform one sequence permutation, and obtain a plurality of ciphertext data blocks, a first encryption sequence and a second encryption sequence after the plurality of rounds of encryption, and combine the plurality of ciphertext data blocks to form ciphertext data.
[0031] The first label generation module is configured to perform a plurality of rounds of sequence permutation on the first encryption sequence and the second encryption sequence by using the permutation function, obtain a first label sequence and a second label sequence, and combine the first label sequence and the second label sequence to form a first label.
[0032] The sending module is configured to send the ciphertext data and the first label to a receiving end.
[0033] Based on the same inventive concept, the application further provides a lightweight decryption device, comprising a second initialization module, a decryption module and a second label generation module;
[0034] The second initialization module is configured to receive the ciphertext data and the first label from the sending end, perform multi-round sequence permutation on a sequence composed of odd bits of the master key and a sequence composed of even bits of the master key by using a preset permutation function, and obtain a third initialization sequence and a fourth initialization sequence.
[0035] The decryption module is configured to divide the ciphertext data into a plurality of ciphertext data blocks according to the order of bits, perform multi-round decryption on the ciphertext data blocks by using the third initialization sequence and the fourth initialization sequence, perform sequence permutation once in each round of decryption, obtain a plurality of plaintext data blocks, a first decryption sequence and a second decryption sequence after the multi-round decryption, and combine the plurality of plaintext data blocks into plaintext data.
[0036] The second label generation module is configured to perform multi-round sequence permutation on the first decryption sequence and the second decryption sequence by using the permutation function, obtain a third label sequence and a fourth label sequence, combine the third label sequence and the fourth label sequence into a second label, and determine that the plaintext data is correct in response to determining that the second label is consistent with the first label.
[0037] Based on the same inventive concept, the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the lightweight encryption method and the lightweight decryption method according to any one of the above.
[0038] Based on the same inventive concept, the present application further provides a non-transitory computer readable storage medium, wherein the non-transitory computer readable storage medium stores computer instructions for causing the computer to execute the lightweight encryption method and the lightweight decryption method.
[0039] Based on the same inventive concept, the present application further provides a computer program product, comprising computer program instructions, which, when executed on a computer, cause the computer to execute the lightweight encryption method and the lightweight decryption method according to any one of the above.
[0040] Based on the same inventive concept, the present application further provides a vehicle, comprising a lightweight encryption device and / or a lightweight decryption device, and the electronic device executes the lightweight encryption method and / or the lightweight decryption method according to any one of the above.
[0041] It can be seen from the above that the lightweight encryption method, decryption method, related device and vehicle provided by the application, the sending end divides the master key into two sequences of odd bit and even bit based on the set permutation function, completes initialization by performing multiple round sequence permutation on the two sequences, obtains a first initialization sequence and a second initialization sequence, divides the plaintext data into multiple plaintext data blocks, and comprehensively considers that each plaintext data block is encrypted and multiple sequence permutations are performed when the plaintext data is encrypted multiple rounds, so as to obtain multiple encrypted ciphertext data blocks, combines each ciphertext data block to obtain ciphertext data, and generates a first tag corresponding to the ciphertext data by multiple round sequence permutation, so that the receiving end can verify whether the decrypted plaintext data is correct and effective by using the generated second tag after decrypting the ciphertext data.
[0042] Further, the receiving end is similar to the sending end, and based on the permutation function, the initialization is completed by performing multiple round sequence permutation on the two sequences decomposed from the master key to obtain a first initialization sequence and a second initialization sequence, the ciphertext data is divided into multiple plaintext data blocks, and comprehensive consideration is given to that each ciphertext data block is decrypted and multiple sequence permutations are performed when the ciphertext data is decrypted multiple rounds, so as to obtain multiple decrypted plaintext data blocks, combine each plaintext data block to obtain plaintext data, and generate a second tag corresponding to the plaintext data by multiple round sequence permutation, so as to determine that the decrypted plaintext data is correct and effective when the second tag is consistent with the first tag. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the application or related art, the drawings needed in the embodiments or related art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0044] Figure 1 The first flowchart of the lightweight encryption method of the embodiment of the application;
[0045] Figure 2 The second flowchart of the lightweight encryption method of the embodiment of the application;
[0046] Figure 3 The schematic diagram of the cyclic shift of the embodiment of the application;
[0047] Figure 4 The schematic diagram of the sequence permutation of the embodiment of the application;
[0048] Figure 5 The operation schematic diagram of the composite function of the embodiment of the application;
[0049] Figure 6 The first flow chart of the lightweight decryption method of the embodiment of the present application;
[0050] Figure 7 The second flow chart of the lightweight decryption method of the embodiment of the present application;
[0051] Figure 8 The structure schematic diagram of the lightweight encryption device of the embodiment of the present application;
[0052] Figure 9 The structure schematic diagram of the lightweight decryption device of the embodiment of the present application;
[0053] Figure 10 The structure schematic diagram of the electronic device of the embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the embodiments and the accompanying drawings.
[0055] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be understood as the common meanings understood by those skilled in the art to which the present application belongs. The terms "first", "second" and similar terms used in the embodiments of the present application do not represent any order, number or importance, but are only used to distinguish different components. The terms "include" or "contain" and similar terms mean that the elements or objects before the terms cover the elements or objects listed after the terms and their equivalents, and do not exclude other elements or objects. The terms "connect" or "connected" and similar terms are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The terms "upper", "lower", "left", "right" and the like only represent relative positional relationships, and when the absolute positions of the described objects change, the relative positional relationships may also change accordingly.
[0056] As described in the background section, the related encryption and decryption methods are still difficult to meet the needs of actual use.
[0057] The applicant found in the process of implementing the present application that the main problem of the related encryption and decryption methods is that when communicating in the Internet of Vehicles environment, since the amount of communication data is small, and the operation processing capability and storage capability of the vehicle internal components are relatively limited, the cryptographic algorithm suitable for the vehicle internal environment needs to be particularly lightweight, while ensuring a certain security, and since each frame of data under the CAN bus of the vehicle internal network communication is 8 bits, the cryptographic algorithm is also limited in data length.
[0058] Based on this, one or more embodiments in the present application provide a lightweight encryption method and a lightweight decryption method.
[0059] In the embodiments of the present application, the specific application scenario can be that a vehicle encrypts plaintext data, and sends the encrypted ciphertext data to a cloud platform as a sending end, and the cloud platform decrypts and verifies the received ciphertext data as a receiving end of the ciphertext data.
[0060] In some other embodiments, the cloud platform can also encrypt plaintext data, and send the encrypted ciphertext data to a vehicle as a sending end, and the vehicle decrypts and verifies the received ciphertext data as a receiving end of the ciphertext data.
[0061] In some other embodiments, the cloud platform can also encrypt plaintext data, and send the encrypted ciphertext data to a vehicle as a sending end, and the vehicle decrypts and verifies the received ciphertext data as a receiving end of the ciphertext data.
[0062] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0063] Reference Figure 1 The lightweight encryption method of one embodiment of the present application is applied to a sending end, and specifically includes the following steps:
[0064] Step S101, using a preset permutation function to perform multi-round sequence permutation on a sequence composed of odd bits of the master key and a sequence composed of even bits of the master key, to obtain a first initialization sequence and a second initialization sequence.
[0065] In the embodiments of the present application, the vehicle as a sending end first initializes the master key using a pre-set permutation function, thereby obtaining a first initialization sequence and a second initialization sequence for the next encryption step.
[0066] Specifically, as shown in Figure 2 , the sending end divides the master key K into two sequences, and performs multi-round P permutation (sequence permutation) on the two divided sequences using the permutation function.
[0067] In the present embodiment, the master key K is 128 bits, as shown in Figure 2 , the odd bits and the even bits are extracted according to the bit order respectively, and the odd bit sequence X0 of 64 bits and the even bit sequence X1 of 64 bits are constructed according to the bit order respectively.
[0068] Based on this, the odd bit sequence and the even bit sequence are subjected to multi-round P permutation using the permutation function.
[0069] Specifically, during each round of P permutation, the master key in this round of permutation is cyclically shifted once, and a set of subkeys is constructed. The set of subkeys includes three subkeys of equal length: a first subkey, a second subkey, and a third subkey.
[0070] In this embodiment, as Figure 2 As shown, the P permutation in the initialization process has 6 rounds and is represented as P. 6 .
[0071] Therefore, a cyclic shift is required in each round of P permutation, and thus, as follows: Figure 3 As shown, for a 6-round P permutation, 6 sets of subkeys are obtained through 5 cyclic shifts.
[0072] Specifically, such as Figure 3 As shown, in the first round of P-permutation, the first 48 bits of the 128-bit master key are extracted and divided into three 16-bit sequences according to bit order. Each 16-bit sequence is used as a subkey. The three subkeys are then used as a set of subkeys for this round of P-permutation. Figure 3 The first subkey K1, the second subkey K2, and the third subkey K3.
[0073] Furthermore, each bit of the 128-bit master key is cyclically shifted 25 bits to the left, and the master key after this cyclic shift is used as the shift key for the next P permutation. Figure 3 The displacement key 1 in the middle.
[0074] Furthermore, in the next round of permutation, the first 48 bits of the shift key 1 are extracted and divided into three 16-bit sequences according to bit order. Each 16-bit sequence is used as a subkey. The three subkeys are then used as a set of subkeys for the P-permutation in this round. Figure 3 The first subkey K4, the second subkey K5, and the third subkey K6.
[0075] Furthermore, by cyclically shifting each bit of the 128-bit shift key 1 25 bits to the left, we obtain... Figure 3 The displacement key 2 shown is used for the next round of P permutation.
[0076] Furthermore, in the third round of permutation, the first 48 bits of the shift key 2 are extracted and divided into three 16-bit sequences according to bit order. Each 16-bit sequence is used as a subkey. The three subkeys are then used as a set of subkeys for the P-permutation in this round. Figure 3 The first subkey K7, the second subkey K8, and the third subkey K9.
[0077] Furthermore, by cyclically shifting each bit of the 128-bit shift key 2 2 25 bits to the left, we obtain...Figure 3 the displacement key 3 for the next round of P permutation.
[0078] Further, in the fourth round of permutation, the first 48 bits of the displacement key 3 are extracted and divided into 3 sequences of 16 bits in bit order, each sequence of 16 bits being a sub-key, and the three sub-keys obtained are used as a group of sub-keys for the round of P permutation, that is, the first sub-key K10, the second sub-key K11 and the third sub-key K12 in Figure 3
[0079] Further, each bit of the 128-bit displacement key 3 is cyclically shifted left by 25 bits to obtain Figure 3 the displacement key 4 for the next round of P permutation.
[0080] Further, in the fifth round of permutation, the first 48 bits of the displacement key 4 are extracted and divided into 3 sequences of 16 bits in bit order, each sequence of 16 bits being a sub-key, and the three sub-keys obtained are used as a group of sub-keys for the round of P permutation, that is, the first sub-key K13, the second sub-key K14 and the third sub-key K15 in Figure 3
[0081] Further, each bit of the 128-bit displacement key 4 is cyclically shifted left by 25 bits to obtain Figure 3 the displacement key 5 for the next round of P permutation.
[0082] Further, in the sixth round of permutation, the first 48 bits of the displacement key 4 are extracted and divided into 3 sequences of 16 bits in bit order, each sequence of 16 bits being a sub-key, and the three sub-keys obtained are used as a group of sub-keys for the round of P permutation, that is, the first sub-key K16, the second sub-key K17 and the third sub-key K18 in Figure 4
[0083] Based on this, in the first round of P permutation, the 64-bit odd bit sequence X0 and the 64-bit even bit sequence X1 are XORed to obtain a first input sequence for input to the composite function (F function) in the first round of P permutation, and the sub-keys K1, K2 and K3 obtained by corresponding first round of cyclic shift are used to perform F function operation on the first input sequence of the round of P permutation, after the F function operation is completed, the first output sequence of the first round of P permutation is output, the first output sequence of the first round of P permutation is XORed with the odd bit sequence X0 to obtain the first intermediate sequence of the first round of P permutation, and the first output sequence of the first round of P permutation is XORed with the even bit sequence X1 to obtain the second intermediate sequence of the first round of P permutation, wherein the first input sequence, the first output sequence, the first intermediate sequence and the second intermediate sequence are all 64 bits.
[0084] Further, at each non-first round P-permutation, as shown in Figure 5 at the i-th round P-permutation, the first intermediate sequence L i-1 and the second intermediate sequence R i-1 are XORed to obtain a first input sequence for inputting into the F function at the round P-permutation, and after the operation of the F function is completed, a first output sequence of the round P-permutation is outputted, the first output sequence of the round P-permutation is XORed with the first intermediate sequence L i-1 of the previous round P-permutation to obtain the first intermediate sequence L i of the round P-permutation, and the first output sequence of the round P-permutation is XORed with the second intermediate sequence R i-1 of the previous round P-permutation to obtain the second intermediate sequence R i of the first round P-permutation.
[0085] Further, when the preset number of P-permutation rounds is reached, in the present embodiment, when the 6th round P-permutation is performed, the first intermediate sequence obtained at the round P-permutation is taken as the first initialization sequence, and the second intermediate sequence is taken as the second initialization sequence.
[0086] In some embodiments of the present application, at each round P-permutation, when the F function is operated using the first input sequence and the sub-key, as shown in Figure 5 the 64-bit first input sequence is divided into four 16-bit input data blocks in bit order: a first input data block P1, a second input data block P2, a third input data block P3, and a fourth input data block P4.
[0087] Further, Figure 5 taking the first round P-permutation as an example, the sub-keys K1, K2, and K3 obtained at the first round P-permutation are used to operate the F function with the P4 input data blocks.
[0088] Specifically, as shown in Figure 2 K1 is multiplied with P1 to obtain a first sub-sequence;
[0089] K2 is added with P2 to obtain a second sub-sequence;
[0090] K1 is added with P3 to obtain a third sub-sequence;
[0091] K2 is multiplied with P4 to obtain a fourth sub-sequence;
[0092] the first sub-sequence and the third sub-sequence are XORed to obtain a fifth sub-sequence;
[0093] the second sub-sequence and the fourth sub-sequence are XORed to obtain a sixth sub-sequence;
[0094] The K3 and the fifth sub-sequence are used to perform the modular multiplication to obtain a seventh sub-sequence;
[0095] The sixth sub-sequence and the seventh sub-sequence are used to perform the modular addition to obtain an eighth sub-sequence;
[0096] The K3 and the eighth sub-sequence are used to perform the modular multiplication to obtain a ninth sub-sequence;
[0097] The first sub-sequence and the ninth sub-sequence are used to perform the XOR operation to obtain a first output data block R1;
[0098] The seventh sub-sequence and the ninth sub-sequence are used to perform the modular addition to obtain a tenth sub-sequence;
[0099] The second sub-sequence and the tenth sub-sequence are used to perform the XOR operation to obtain a second output data block R2;
[0100] The ninth sub-sequence and the third sub-sequence are used to perform the XOR operation to obtain a third output data block R3;
[0101] The tenth sub-sequence and the fourth sub-sequence are used to perform the XOR operation to obtain a fourth output data block R4.
[0102] Based on this, R1, R2, R3 and R4 constitute the first output sequence of 64 bits of the round P permutation.
[0103] In step S102, the plaintext data is divided into a plurality of plaintext data blocks according to the bit order, a plurality of rounds of encryption are performed using the first initialization sequence and the second initialization sequence, one plaintext data block is encrypted in each round of encryption, and a sequence permutation is performed once, a plurality of ciphertext data blocks, a first encryption sequence and a second encryption sequence are obtained after the plurality of rounds of encryption, and the plurality of ciphertext data blocks constitute the ciphertext data.
[0104] In the present embodiment, in the process of encrypting the plaintext data, the first intermediate sequence and the second intermediate sequence obtained in the foregoing steps are used to perform a plurality of rounds of encryption on the disassembled plaintext data blocks, thereby obtaining a plurality of ciphertext data blocks, and each ciphertext data block constitutes the ciphertext data.
[0105] Specifically, the preset plaintext data is divided into a plurality of plaintext data blocks, wherein the plaintext data can be, for example, a sequence of 128 bits, 64 bits or other lengths, which is divided into n plaintext data blocks according to the bit order, with 8 bits as the length of one plaintext data block, and is represented as P1, P2……Pn respectively. n-1 , P n .
[0106] Further, in each round of encryption, one plaintext block is encrypted and a permutation is performed after the encryption, that is, the number of rounds of encryption is the same as the number of plaintext blocks, that is, when there are n plaintext blocks, n rounds of encryption are needed to encrypt each plaintext block, but no P permutation is performed in the last round of encryption, that is, n-1 times of P permutation are performed.
[0107] Specifically, as shown in the first round of encryption, the first initialization sequence obtained in the foregoing step is XORed with the first plaintext block P1 to obtain the first ciphertext block C1 corresponding to P1. Figure 2
[0108] Further, 1 time of P permutation is performed using the first initialization sequence and the second initialization sequence.
[0109] Specifically, before the P permutation, similar to the foregoing step, each bit of the displacement key 5 after 6 rounds of P permutation is cyclically shifted left by 25 bits to obtain the displacement key 6 for the P permutation.
[0110] Further, in the P permutation, the first 48 bits of the displacement key 5 are extracted and divided into 3 sequences of 16 bits in bit order, and each sequence of 16 bits is used as a subkey, and the three subkeys obtained are used as a group of subkeys for the P permutation.
[0111] Further, the first initialization sequence and the second initialization sequence are XORed to obtain the first input sequence for the P permutation, and the first input sequence for the P permutation and each subkey obtained in the current round of encryption are input into the F function and operated in the manner of the foregoing step to obtain the first transition sequence and the second transition sequence in the current round of encryption.
[0112] Further, in the non-first round of encryption, the first transition sequence obtained in the foregoing step is XORed with the plaintext block corresponding to the current round of encryption, for example, in the n-1th round of encryption, the first transition sequence obtained in the n-2th round of encryption is XORed with the n-1th plaintext block P n-1 to obtain the ciphertext block C n-1 corresponding to P n-1 , and in the n th round of encryption, the first transition sequence obtained in the n-1th round of encryption is XORed with the n th plaintext block P n to obtain the ciphertext block C n corresponding to P n .
[0113] Further, 1 time of P permutation is performed using the first transition sequence and the second transition sequence obtained in the previous round of encryption.
[0114] Specifically, before this P-permutation, similar to the steps described above, each bit of the shift key after the P-permutation in the previous round of encryption is cyclically shifted 25 bits to the left to obtain the shift key used for this P-permutation.
[0115] Furthermore, in this P permutation, the first 48 bits of the shift key are extracted and divided into three 16-bit sequences according to the bit order. Each 16-bit sequence is used as a subkey, and the three subkeys are used as a set of subkeys for this P permutation.
[0116] Furthermore, the first transition sequence and the second transition sequence obtained from the previous round of encryption are XORed to obtain the first input sequence of the current P permutation. The first input sequence of the current P permutation and each subkey obtained in this round of encryption are input into the F function, and the operation is performed in the manner described above to obtain the first transition sequence and the second transition sequence of this round of encryption.
[0117] Furthermore, such as Figure 2 As shown, in the final round of encryption, that is, in the nth round of encryption, when C is obtained... n Then, construct the first parameter sequence.
[0118] In this first parameter sequence, the first 63 bits are 0 and the 64th bit is 1.
[0119] Furthermore, the second transition sequence obtained from the (n-1)th round of encryption is XORed with the first parameter sequence to obtain the second encryption sequence used to generate the first label, and the first transition sequence obtained from the (n-1)th round of encryption is used as the first encryption sequence used to generate the first label.
[0120] Based on this, the ciphertext data blocks obtained from each round of encryption are combined to form ciphertext data.
[0121] Step S103: Using the permutation function, perform multiple rounds of sequence permutation on the first encrypted sequence and the second encrypted sequence to obtain a first tag sequence and a second tag sequence, and use the first tag sequence and the second tag sequence to form a first tag.
[0122] In this embodiment, based on the first and second encryption sequences determined in the aforementioned steps, tags corresponding to the ciphertext data can be generated by performing multiple rounds of sequence permutations.
[0123] Specifically, such as Figure 2 As shown, during each round of P permutation, the displacement key in this round of permutation is cyclically shifted once, and a set of subkeys is constructed.
[0124] In this embodiment, as Figure 6 As shown, the P permutation in the label generation process has 6 rounds, and is represented as P. 6 .
[0125] Based on this, a cyclic shift needs to be performed once in each round P permutation to obtain a set of sub-keys of the round P permutation.
[0126] In the first round P permutation in the process of generating the tag, the first encrypted sequence and the second encrypted sequence are XORed to obtain a first input sequence, the first input sequence is operated by the F function using 3 sub-keys corresponding to the first round P permutation, after the operation of the F function is completed, a first output sequence of the first round P permutation is output, the first output sequence of the first round P permutation is XORed with the first encrypted sequence to obtain a first intermediate sequence of the first round P permutation, and the first output sequence of the first round P permutation is XORed with the second encrypted sequence to obtain a second intermediate sequence of the first round P permutation.
[0127] Further, in each non-first round P permutation, the first intermediate sequence and the second intermediate sequence obtained in the previous round P permutation are XORed to obtain a first input sequence input to the F function in the round P permutation, after the operation of the F function is completed, a first output sequence of the round P permutation is output, the first output sequence of the round P permutation is XORed with the first intermediate sequence of the previous round P permutation to obtain a first intermediate sequence of the round P permutation, and the first output sequence of the round P permutation is XORed with the second intermediate sequence of the previous round P permutation to obtain a second intermediate sequence of the round P permutation.
[0128] Further, when a preset round P permutation is reached, in the present embodiment, when the 6th round P permutation is reached, the first intermediate sequence obtained in the round P permutation is taken as a first tag sequence T1, and the second intermediate sequence is taken as a second tag sequence T2.
[0129] Based on this, the obtained first tag sequence and second tag sequence are combined into a first tag T1.
[0130] Step S104, the ciphertext data and the first tag are sent to the receiving end.
[0131] In the present embodiment, the ciphertext data and the first tag obtained in the foregoing steps are sent to the receiving end at the same time, so that the receiving end can use the first tag to verify whether the ciphertext data is correct.
[0132] It can be seen that the lightweight decryption method of the embodiment of the application, the sending end divides the master key into two sequences of odd bit and even bit based on the set permutation function, completes initialization by performing multiple round sequence permutation on the two sequences, obtains a first initialization sequence and a second initialization sequence, divides the plaintext data into multiple plaintext data blocks, and comprehensively considers that the multiple round encryption is performed on the plaintext data, each plaintext data block is encrypted, and multiple sequence permutations are performed, so as to obtain multiple encrypted ciphertext data blocks, the ciphertext data is obtained by combining each ciphertext data block, and the first tag corresponding to the ciphertext data is generated by multiple round sequence permutation, so that the receiving end can verify whether the decrypted plaintext data is correct and effective by using the generated second tag after the ciphertext data is decrypted.
[0133] Reference Figure 7 The lightweight decryption method of one embodiment of the application is applied to the receiving end and specifically includes the following steps.
[0134] Step S601, receiving the ciphertext data and the first tag from the sending end, performing multiple round sequence permutation on the sequence composed of the odd bit of the master key and the sequence composed of the even bit of the master key by using the preset permutation function, and obtaining a third initialization sequence and a fourth initialization sequence.
[0135] In this embodiment, the cloud platform as the receiving end receives the ciphertext data P and the first tag T1 sent by the vehicle, and as shown in Figure 7 , in the same way as step S101, the master key is initialized by using the preset permutation function, so as to obtain the third initialization sequence X2 and the fourth initialization sequence X3 for the next decryption step.
[0136] Step S602, dividing the ciphertext data into multiple ciphertext data blocks according to the order of bit positions, performing multiple round decryption by using the third initialization sequence and the fourth initialization sequence, decrypting one ciphertext data block in each round of decryption and performing sequence permutation once, obtaining multiple plaintext data blocks, a first decryption sequence and a second decryption sequence after multiple round decryption, and combining the multiple plaintext data blocks into plaintext data.
[0137] In this embodiment, based on the first initialization sequence and the second initialization sequence obtained in the foregoing steps, multiple round decryption is performed on the disassembled ciphertext data blocks, so as to obtain multiple plaintext data blocks, and each plaintext data block is combined into plaintext data.
[0138] Specifically, the received ciphertext data is divided into multiple ciphertext data blocks, which are divided into n ciphertext data blocks with a length of 8 bits as one ciphertext data block according to the order of bit positions, and are represented as C1, C2……Cn respectively. n-1 , Cn .
[0139] Further, in each round of decryption, one ciphertext data block is decrypted, and a sequence permutation is performed after decryption, that is, the number of rounds of decryption is the same as the number of ciphertext data blocks, that is, when there are n ciphertext data blocks, n rounds of decryption are needed to decrypt each ciphertext data block, but no P permutation is performed in the last round of decryption, that is, n-1 times of P permutation are performed.
[0140] Specifically, as shown in Figure 7 , in the first round of decryption, the third initialization sequence obtained in the foregoing step is XORed with the first ciphertext data block C1 to obtain the first plaintext data block P1 corresponding to C1.
[0141] Further, 1 time of P permutation is performed using the third initialization sequence and the fourth initialization sequence.
[0142] Specifically, before the P permutation, similar to the foregoing step, each bit of the displacement key 5 after 6 rounds of P permutation is cyclically shifted left by 25 bits to obtain the displacement key 6 used for the P permutation.
[0143] Further, in the P permutation, the first 48 bits of the displacement key 5 are extracted and divided into 3 sequences of 16 bits in bit order, and each sequence of 16 bits is used as a subkey, and the three subkeys obtained are used as a group of subkeys for the P permutation.
[0144] Further, the third initialization sequence and the fourth initialization sequence are XORed to obtain the second input sequence for the P permutation, and the second input sequence for the P permutation and each subkey obtained in the round of decryption are input to the F function and operated in the manner of the foregoing step to obtain the third transition sequence and the fourth transition sequence for the round of decryption.
[0145] Further, in the non-first round of decryption, the third transition sequence obtained in the foregoing step is XORed with the ciphertext data block corresponding to the round of decryption, for example, in the n-1th round of decryption, the third transition sequence obtained in the n-2th round of decryption is XORed with the n-1th ciphertext data block C n-1 to obtain the plaintext data block P n-1 corresponding to C n-1 , and in the n th round of decryption, the third transition sequence obtained in the n-1 th round of decryption is XORed with the n th ciphertext data block C n to obtain the plaintext data block P n corresponding to C n .
[0146] Further, 1 time of P permutation is performed using the third transition sequence and the fourth transition sequence obtained in the previous round of decryption.
[0147] Specifically, before the P permutation, similar to the previous step, each bit of the P-permuted bit-shift key in the previous round of decryption is cyclically shifted left by 25 bits to obtain the bit-shift key for the current P permutation.
[0148] Further, in the current P permutation, the first 48 bits of the bit-shift key are extracted and divided into three 16-bit sequences in bit order, and each 16-bit sequence is taken as a subkey. The three obtained subkeys are taken as a group of subkeys for the current P permutation.
[0149] Further, the third transition sequence and the fourth transition sequence obtained in the previous round of decryption are XORed to obtain the second input sequence for the current P permutation. The second input sequence for the current P permutation and each subkey obtained in the current round of decryption are input into the F function, and the operation is performed in the manner of the above step to obtain the third transition sequence and the fourth transition sequence in the current round of decryption.
[0150] Further, as shown in Figure 7 , in the last round of decryption, i.e., in the nth round of decryption, after obtaining the P n , a second parameter sequence is constructed.
[0151] The first 63 bits of the second parameter sequence are 0, and the 64th bit is 1.
[0152] Further, the fourth transition sequence obtained in the (n-1)th round of decryption is XORed with the second parameter sequence to obtain a first decryption sequence for generating a second tag, and the third transition sequence obtained in the (n-1)th round of decryption is taken as a second decryption sequence for generating a first tag.
[0153] Based on this, each plaintext data block obtained in each round of decryption is grouped to form plaintext data P.
[0154] In step S603, the first decryption sequence and the second decryption sequence are subjected to a plurality of rounds of sequence permutation using the permutation function to obtain a third tag sequence and a fourth tag sequence. The second tag is composed of the third tag sequence and the fourth tag sequence. In response to determining that the second tag and the first tag are consistent, it is determined that the plaintext data is authentic.
[0155] In this embodiment, based on the first decryption sequence and the second decryption sequence determined in the previous step, a tag corresponding to the plaintext data can be generated by performing a plurality of rounds of sequence permutation.
[0156] Specifically, as shown in Figure 8 , in each round of P permutation, the bit-shift key in the current round of permutation is cyclically shifted, and a group of subkeys is constructed.
[0157] In this embodiment, as Figure 9 As shown, the label generation process is similar to the aforementioned step S103, except that P is permuted in 6 rounds and is denoted as P. 6 .
[0158] In this embodiment, during the first round of P-permutation in the tag generation process, the first decryption sequence and the second decryption sequence are XORed to obtain the first input sequence. The three subkeys corresponding to the first round of P-permutation are used to perform F-function operation on the first input sequence of the first round of P-permutation. After the F-function operation is completed, the first output sequence of the first round of P-permutation is output. The first output sequence of the first round of P-permutation is XORed with the first decryption sequence to obtain the first intermediate sequence of the first round of P-permutation. The first output sequence of the first round of P-permutation is XORed with the second decryption sequence to obtain the second intermediate sequence of the first round of P-permutation.
[0159] Furthermore, in each subsequent non-first round of P-permutation, the first intermediate sequence and the second intermediate sequence obtained from the previous round of P-permutation are XORed to obtain the first input sequence used to input to the F function in this round of P-permutation. After the operation of the F function is completed, the first output sequence of this round of P-permutation is output. The first output sequence of this round of P-permutation is XORed with the first intermediate sequence of the previous round of P-permutation to obtain the first intermediate sequence of this round of P-permutation. The first output sequence of this round of P-permutation is XORed with the second intermediate sequence of the previous round of P-permutation to obtain the second intermediate sequence of the first round of P-permutation.
[0160] Furthermore, when the preset P permutation round is reached, in this embodiment, when the 6th round of P permutation is performed, the first intermediate sequence obtained by the P permutation in that round is used as the third label sequence, and the second intermediate sequence is used as the fourth label sequence.
[0161] Based on this, the obtained third and fourth tag sequences are combined to form the second tag.
[0162] Furthermore, the first label and the second label are compared. If the first label and the second label are consistent, the current plaintext data is considered to be correct. If the first label and the second label are inconsistent, the current plaintext data is considered to be incorrect and may have been tampered with.
[0163] It can be seen that the lightweight decryption method of the embodiment of the present application is similar to the sending end, based on a permutation function, the initialization is completed by performing multi-round sequence permutation on two sequences decomposed from the master key, to obtain a first initialization sequence and a second initialization sequence, the ciphertext data is divided into a plurality of plaintext data blocks, and the decryption of each ciphertext data block is considered when the multi-round decryption of the ciphertext data is performed, and the multi-round sequence permutation is performed, so as to obtain a plurality of decrypted plaintext data blocks, the plaintext data is obtained by combining each plaintext data block, and the second tag corresponding to the plaintext data is generated by multi-round sequence permutation, so that when the second tag is consistent with the first tag, it is determined that the decrypted plaintext data is correct and effective.
[0164] It should be noted that the method of the embodiment of the present application can be executed by a single device, such as a computer or a server. The method of the embodiment can also be applied to a distributed scenario, and completed by multiple devices cooperating with each other. In this distributed scenario, one of the multiple devices can only execute one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the method.
[0165] It should be noted that some embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than that described above and still achieve desirable results. In addition, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.
[0166] Based on the same inventive concept, the embodiment of the present application also provides a lightweight encryption device corresponding to any of the above-mentioned embodiment methods.
[0167] Reference Figure 10 The lightweight encryption device comprises a first initialization module 801, an encryption module 802, a first tag generation module 803, and a sending module 804.
[0168] The first initialization module 801 is configured to perform multi-round sequence permutation on a sequence composed of odd bits and a sequence composed of even bits of the master key by using a preset permutation function, to obtain a first initialization sequence and a second initialization sequence.
[0169] The encryption module 802 is configured to split the plaintext data into a plurality of plaintext data blocks in the order of bit positions, perform multi-round encryption by using the first initialization sequence and the second initialization sequence, encrypt one plaintext data block in each round of encryption, and perform sequence permutation once, obtain a plurality of ciphertext data blocks, the first encryption sequence and the second encryption sequence after the multi-round encryption, and compose ciphertext data from the plurality of ciphertext data blocks.
[0170] The first tag generation module 803 is configured to perform multi-round sequence permutation on the first encryption sequence and the second encryption sequence by using the permutation function, obtain a first tag sequence and a second tag sequence, and compose a first tag by using the first tag sequence and the second tag sequence.
[0171] The sending module 804 is configured to send the ciphertext data and the first tag to a receiving end.
[0172] Based on the same inventive concept, embodiments of the present application also provide a lightweight decryption device corresponding to the method of any of the above embodiments.
[0173] Reference The lightweight decryption device comprises a second initialization module 901, a decryption module 902 and a second tag generation module 903.
[0174] The second initialization module 901 is configured to receive ciphertext data and a first tag from a sending end, perform multi-round sequence permutation on a sequence composed of odd bit positions of a master key and a sequence composed of even bit positions of the master key by using a preset permutation function, and obtain a third initialization sequence and a fourth initialization sequence.
[0175] The decryption module 902 is configured to split the ciphertext data into a plurality of ciphertext data blocks in the order of bit positions, perform multi-round decryption by using the third initialization sequence and the fourth initialization sequence, decrypt one ciphertext data block in each round of decryption, and perform sequence permutation once, obtain a plurality of plaintext data blocks, a first decryption sequence and a second decryption sequence after the multi-round decryption, and compose plaintext data from the plurality of plaintext data blocks.
[0176] The second tag generation module 903 is configured to perform multi-round sequence permutation on the first decryption sequence and the second decryption sequence by using the permutation function, obtain a third tag sequence and a fourth tag sequence, compose a second tag by using the third tag sequence and the fourth tag sequence, and determine that the plaintext data is correct in response to determining that the second tag is consistent with the first tag.
[0177] For the convenience of description, the above apparatus is described in various modules in terms of functions. Of course, the functions of the modules can be implemented in one or more software and / or hardware when implementing the embodiments of the present application.
[0178] The apparatus of the above embodiments is used to implement the corresponding lightweight encryption method and lightweight decryption method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described here again.
[0179] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the embodiments of the present application also provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the lightweight encryption method and the lightweight decryption method according to any of the above embodiments when executing the program.
[0180] A more specific hardware structure schematic diagram of an electronic device provided by the present embodiment is shown, which can include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040 and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030 and the communication interface 1040 are connected to each other through the bus 1050 for communication within the device.
[0181] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, etc., for executing related programs to implement the technical solutions provided by the embodiments of the present application.
[0182] The memory 1020 can be implemented by a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 1020 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 1020 and executed by the processor 1010.
[0183] The input / output interface 1030 is configured to connect an input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure) or externally connected to the device to provide corresponding functions. The input device can include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device can include a display, a speaker, a vibrator, an indicator light, etc.
[0184] The communication interface 1040 is configured to connect a communication module (not shown in the figure) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.).
[0185] The bus 1050 includes a channel to transmit information between various components (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040) of the device.
[0186] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device can also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device can also only contain components necessary for implementing the embodiments of the present application, and does not necessarily contain all the components shown in the figure.
[0187] The device of the above embodiment is used to implement the corresponding lightweight encryption method and lightweight decryption method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which are not repeated here.
[0188] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a vehicle, which includes a lightweight encryption device and / or a lightweight decryption device.
[0189] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a non-transitory computer readable storage medium, which stores computer instructions for causing the computer to execute the lightweight encryption method and lightweight decryption method of any of the above embodiments.
[0190] The computer readable medium of the embodiments can include permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device.
[0191] The storage medium of the above embodiments stores computer instructions for causing the computer to perform the lightweight encryption method and the lightweight decryption method as described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which are not repeated here.
[0192] Based on the same concept, the present application also provides a computer program product corresponding to the method of any of the above embodiments, comprising computer program instructions, when the computer program instructions run on the computer, so that the computer executes the lightweight encryption method and the lightweight decryption method as described in any of the above embodiments, has the beneficial effects of the corresponding method embodiments, which are not repeated here.
[0193] Those skilled in the art should understand that the above discussion of any of the embodiments is only exemplary and is not intended to imply that the scope of the present application (including claims) is limited to these examples; the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes of the different aspects of the embodiments of the present application as described above. In order to be brief, they are not provided in detail.
[0194] Additionally, to simplify the description and discussion, and so as not to obscure the embodiments of the application being presented, the well-known power / ground connections of integrated circuits (ICs) and other components can or can not be shown in the provided figures. Furthermore, devices can be shown in block diagram form in order to avoid obscuring the embodiments of the application being presented, and also in view of the fact that details of implementation of the devices shown can vary depending on the platform within which the embodiments of the application are to be implemented (i.e., these details should be understood as being well within the purview of one of ordinary skill in the art). Where specific details of particular implementations are set forth in order to describe example embodiments of the application, it can be understood, however, that the embodiments of the application can be practiced without these specific details. In other instances, well-known methods, procedures and circuits have not been described in detail so as not to unnecessarily obscure aspects of the embodiments of the application.
[0195] While the application has been described in connection with specific embodiments thereof, it will be understood that many modifications, substitutions and changes can be made by those skilled in the art to the specific embodiments without departing from the spirit or scope of the application. For example, other memory architectures (e.g., dynamic RAM (DRAM)) can use the embodiments discussed.
[0196] It is intended to cover all alternatives, modifications and variations of this application falling within the scope of the appended claims. Accordingly, all such changes are intended to be included within the scope of the application as claimed.
Claims
1. A lightweight encryption method, characterized in that, Applied to the sending end; The method includes: Using a preset permutation function, multiple rounds of sequence permutation are performed on the sequence of odd-numbered bits and the sequence of even-numbered bits of the master key to obtain the first initialization sequence and the second initialization sequence. Plaintext data is divided into multiple plaintext data blocks according to the order of bits. Multiple rounds of encryption are performed using the first initialization sequence and the second initialization sequence. In each round of encryption, one plaintext data block is encrypted and a sequence permutation is performed. After multiple rounds of encryption, multiple ciphertext data blocks, the first encryption sequence, and the second encryption sequence are obtained. The multiple ciphertext data blocks are combined to form ciphertext data. Using the permutation function, multiple rounds of sequence permutation are performed on the first encrypted sequence and the second encrypted sequence to obtain a first tag sequence and a second tag sequence. The first tag is formed by using the first tag sequence and the second tag sequence. The encrypted data and the first tag are sent to the receiving end; The process of performing multiple rounds of sequence permutations on the sequences of odd-numbered bits and even-numbered bits of the master key includes: In the first round of permutation, the first few bits of the master key are used to construct multiple subkeys for the first round of permutation, and the master key is cyclically shifted once to obtain the shift key for the next round of permutation. In each non-first round of permutation, the first few bits of the shift key in this round of permutation are used to construct multiple subkeys for this round of permutation, and the shift key is cyclically shifted once to obtain the shift key for the next round of permutation. In the first round of permutation, the sequence composed of odd-numbered bits and the sequence composed of even-numbered bits are XORed to obtain the first input sequence of the first round of permutation. In each non-first round of permutation, the first intermediate sequence and the second intermediate sequence obtained from the previous round of permutation are XORed to obtain the first input sequence of the current round of permutation. In each round of permutation, the first input sequence is used to perform a composite function operation with the multiple subkeys to obtain the first output sequence of this round of permutation. The first output sequence is then XORed with the first intermediate sequence and the second intermediate sequence of the previous round of permutation to obtain the first intermediate sequence and the second intermediate sequence of this round of permutation. In response to reaching a preset permutation round, the first intermediate sequence and the second intermediate sequence obtained in the last permutation round are respectively used to determine the first initialization sequence and the second initialization sequence.
2. The method according to claim 1, characterized in that, The multiple subkeys replaced in this round include the first subkey, the second subkey, and the third subkey; The step of performing a composite function operation using the first input sequence and the plurality of subkeys to obtain the first output sequence of this round of permutation includes: The first input sequence is divided into a first input data block, a second input data block, a third input data block, and a fourth input data block; A first subsequence is obtained by performing modular multiplication with the first input data block using the first subkey; a second subsequence is obtained by performing modular addition with the second input data block using the second subkey; a third subsequence is obtained by performing modular addition with the third input data block using the first subkey; and a fourth subsequence is obtained by performing modular multiplication with the fourth input data block using the second subkey. The fifth subsequence is obtained by XORing the first subsequence and the third subsequence; the sixth subsequence is obtained by XORing the second subsequence and the fourth subsequence; the seventh subsequence is obtained by modular multiplication of the third subkey and the fifth subsequence; the eighth subsequence is obtained by modular addition of the sixth subsequence and the seventh subsequence; the ninth subsequence is obtained by modular multiplication of the third subkey and the eighth subsequence; and the tenth subsequence is obtained by modular addition of the seventh subsequence and the ninth subsequence. The first output data block is obtained by XORing the first subsequence and the ninth subsequence; the second output data block is obtained by XORing the second subsequence and the tenth subsequence; the third output data block is obtained by XORing the ninth subsequence and the third subsequence; and the fourth output data block is obtained by XORing the tenth subsequence and the fourth subsequence. The first output data block, the second output data block, the third output data block, and the fourth output data block are combined to form the first output sequence.
3. The method according to claim 1, characterized in that, The step of encrypting a plaintext data block and performing a sequence permutation in each round of encryption includes: During the first round of encryption, the first initialization sequence is XORed with the first plaintext data block to obtain the corresponding ciphertext data block. The ciphertext data block obtained in this round of encryption is then permuted with the second initialization sequence to obtain the first transition sequence and the second transition sequence for this round of encryption. In non-first rounds of encryption, the first transition sequence obtained from the previous round of encryption is XORed with the plaintext data block in the corresponding order to obtain the corresponding ciphertext data block. The ciphertext data block obtained in this round of encryption is then permuted with the second transition sequence obtained in the previous round of encryption to obtain the first transition sequence and the second transition sequence for this round of encryption.
4. A lightweight decryption method, characterized in that, Applied to the receiving end; The method includes: The system receives ciphertext data and a first tag from the sending end, and uses a preset permutation function to perform multiple rounds of sequence permutations on the sequences of odd-numbered bits and even-numbered bits of the master key to obtain a third initialization sequence and a fourth initialization sequence. The multiple rounds of sequence permutations performed by the sending end on the sequences of odd-numbered bits and even-numbered bits of the master key include: In the first round of permutation, the first few bits of the master key are used to construct multiple subkeys for the first round of permutation, and the master key is cyclically shifted once to obtain the shift key for the next round of permutation. In each non-first round of permutation, the first few bits of the shift key in this round of permutation are used to construct multiple subkeys for this round of permutation, and the shift key is cyclically shifted once to obtain the shift key for the next round of permutation. In the first round of permutation, the sequence composed of odd-numbered bits and the sequence composed of even-numbered bits are XORed to obtain the first input sequence of the first round of permutation. In each non-first round of permutation, the first intermediate sequence and the second intermediate sequence obtained from the previous round of permutation are XORed to obtain the first input sequence of the current round of permutation. In each round of permutation, the first input sequence is used to perform a composite function operation with the multiple subkeys to obtain the first output sequence of this round of permutation. The first output sequence is then XORed with the first intermediate sequence and the second intermediate sequence of the previous round of permutation to obtain the first intermediate sequence and the second intermediate sequence of this round of permutation. In response to reaching a preset number of permutation rounds, the first intermediate sequence and the second intermediate sequence obtained in the last round of permutation are respectively used to determine the first initialization sequence and the second initialization sequence. The ciphertext data is divided into multiple ciphertext data blocks according to the order of the bits. Multiple rounds of decryption are performed using the third initialization sequence and the fourth initialization sequence. In each round of decryption, one ciphertext data block is decrypted and a sequence permutation is performed. After multiple rounds of decryption, multiple plaintext data blocks, a first decryption sequence, and a second decryption sequence are obtained. The multiple plaintext data blocks are then combined to form plaintext data. Using the permutation function, multiple rounds of sequence permutations are performed on the first decryption sequence and the second decryption sequence to obtain a third tag sequence and a fourth tag sequence. The third tag sequence and the fourth tag sequence are used to form a second tag. In response to determining that the second tag and the first tag are consistent, the plaintext data is determined to be correct.
5. A lightweight encryption device, characterized in that, include: The module comprises a first initialization module, an encryption module, a first tag generation module, and a sending module. The first initialization module is configured to use a preset permutation function to perform multiple rounds of sequence permutation on the sequence of odd-numbered bits and the sequence of even-numbered bits of the master key to obtain the first initialization sequence and the second initialization sequence. The encryption module is configured to divide plaintext data into multiple plaintext data blocks according to the order of bits, perform multiple rounds of encryption using the first initialization sequence and the second initialization sequence, encrypt one plaintext data block in each round of encryption, and perform a sequence permutation once, and obtain multiple ciphertext data blocks, the first encryption sequence and the second encryption sequence after multiple rounds of encryption, and combine the multiple ciphertext data blocks into ciphertext data. The first tag generation module is configured to use the permutation function to perform multiple rounds of sequence permutation on the first encrypted sequence and the second encrypted sequence to obtain a first tag sequence and a second tag sequence, and to use the first tag sequence and the second tag sequence to form a first tag; The sending module is configured to send the encrypted data and the first tag to the receiving end; The process of performing multiple rounds of sequence permutations on the sequences of odd-numbered bits and even-numbered bits of the master key includes: In the first round of permutation, the first few bits of the master key are used to construct multiple subkeys for the first round of permutation, and the master key is cyclically shifted once to obtain the shift key for the next round of permutation. In each non-first round of permutation, the first few bits of the shift key in this round of permutation are used to construct multiple subkeys for this round of permutation, and the shift key is cyclically shifted once to obtain the shift key for the next round of permutation. In the first round of permutation, the sequence composed of odd-numbered bits and the sequence composed of even-numbered bits are XORed to obtain the first input sequence of the first round of permutation. In each non-first round of permutation, the first intermediate sequence and the second intermediate sequence obtained from the previous round of permutation are XORed to obtain the first input sequence of the current round of permutation. In each round of permutation, the first input sequence is used to perform a composite function operation with the multiple subkeys to obtain the first output sequence of this round of permutation. The first output sequence is then XORed with the first intermediate sequence and the second intermediate sequence of the previous round of permutation to obtain the first intermediate sequence and the second intermediate sequence of this round of permutation. In response to reaching a preset permutation round, the first intermediate sequence and the second intermediate sequence obtained in the last permutation round are respectively used to determine the first initialization sequence and the second initialization sequence.
6. A lightweight decryption device, characterized in that, include: The second initialization module, the decryption module, and the second tag generation module; The second initialization module is configured to receive ciphertext data and a first tag from the sending end, and use a preset permutation function to perform multiple rounds of sequence permutation on the sequence of odd-numbered bits and the sequence of even-numbered bits of the master key to obtain a third initialization sequence and a fourth initialization sequence. The multiple rounds of sequence permutation performed by the sending end on the sequence of odd-numbered bits and the sequence of even-numbered bits of the master key include: In the first round of permutation, the first few bits of the master key are used to construct multiple subkeys for the first round of permutation, and the master key is cyclically shifted once to obtain the shift key for the next round of permutation. In each non-first round of permutation, the first few bits of the shift key in this round of permutation are used to construct multiple subkeys for this round of permutation, and the shift key is cyclically shifted once to obtain the shift key for the next round of permutation. In the first round of permutation, the sequence composed of odd-numbered bits and the sequence composed of even-numbered bits are XORed to obtain the first input sequence of the first round of permutation. In each non-first round of permutation, the first intermediate sequence and the second intermediate sequence obtained from the previous round of permutation are XORed to obtain the first input sequence of the current round of permutation. In each round of permutation, the first input sequence is used to perform a composite function operation with the multiple subkeys to obtain the first output sequence of this round of permutation. The first output sequence is then XORed with the first intermediate sequence and the second intermediate sequence of the previous round of permutation to obtain the first intermediate sequence and the second intermediate sequence of this round of permutation. In response to reaching a preset number of permutation rounds, the first intermediate sequence and the second intermediate sequence obtained in the last round of permutation are respectively used to determine the first initialization sequence and the second initialization sequence. The decryption module is configured to divide the ciphertext data into multiple ciphertext data blocks according to the order of the bits, perform multiple rounds of decryption using the third initialization sequence and the fourth initialization sequence, decrypt one ciphertext data block in each round of decryption and perform a sequence permutation, and obtain multiple plaintext data blocks, a first decryption sequence and a second decryption sequence after multiple rounds of decryption, and combine the multiple plaintext data blocks into plaintext data. The second tag generation module is configured to perform multiple rounds of sequence permutation on the first decryption sequence and the second decryption sequence using the permutation function to obtain a third tag sequence and a fourth tag sequence, and to form a second tag using the third tag sequence and the fourth tag sequence. In response to determining that the second tag and the first tag are consistent, the plaintext data is determined to be correct.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 4.
8. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions for causing the computer to perform the method according to any one of claims 1 to 4.
9. A vehicle, characterized in that, Includes the lightweight encryption device as described in claim 7 and / or the lightweight decryption device as described in claim 8.
Citation Information
Patent Citations
Implementation method of a lightweight block cipher algorithm Wheel
CN109768854A
Symmetric key encryption algorithm
CN112118097A