Key expansion method and device, and storage medium

By dividing the key file into two parts and using the XOR calculation method of address pointer offset, the problem of long time consumption in the key expansion process is solved, a faster key expansion process is achieved, and the system's work efficiency is improved.

CN120825280APending Publication Date: 2025-10-21MATRICTIME DIGITAL TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510953787.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

The existing key expansion method requires multiple cycles of XOR calculation of the root key and the key to be expanded, which makes the processing time-consuming and affects the real-time performance of communication.

Method used

The source key file to be expanded is divided into two files A and B, and divided by the minimum unit size C (which is an exponential power of 2). The address pointer offset method is used to perform XOR calculation to reduce the number of XOR operations. The key content is directly read from the equally divided files for XOR, and finally spliced ​​together to obtain the expanded key file.

Benefits of technology

Without destroying the randomness of the key, the number of XOR operations and interruptions is reduced, the time of the key expansion process is shortened, and the system's work efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120825280A_ABST
    Figure CN120825280A_ABST
Patent Text Reader

Abstract

The invention discloses a key expansion method and device and a storage medium, and the method comprises the steps: a terminal carries out the expansion of a local to-be-expanded source key file according to an expansion proportion M negotiated with a quantum key access gateway, and finally obtains and stores an expanded key file; the expansion comprises the following steps: recording the size of the to-be-expanded source key file as X, and then equally dividing the X-size to-be-expanded source key file into a file A and a file B; obtaining a minimum unit size C for executing the XOR calculation, and dividing the file A and the file B according to the minimum unit size for executing the XOR calculation to obtain N sub-files; obtaining N sub-files of the file A and the file B, and carrying out XOR calculation to obtain expanded first to 2M secret key files; and finally, splicing to obtain a complete expanded key file, and storing the complete expanded key file. According to the invention, during the key expansion operation, the time used by the key expansion process is shortened, and the key expansion rate is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of key technology, and in particular to a key expansion method, device and storage medium. Background Art

[0002] Due to the ubiquity of data transmission over the internet and rising security awareness, most data is transmitted encrypted. This means that plaintext data is encrypted using a key to create ciphertext, which is then transmitted as ciphertext. The key is only held by the sender and receiver, ensuring the security of data transmission. However, as the amount of data transmitted increases and its size increases, the corresponding key consumption is also increasing. This inevitably requires key expansion to ensure its proper use.

[0003] The key uses a true random number, which has the characteristics of randomness, unpredictability, and non-reproducibility. Therefore, the expanded key must also maintain these three characteristics. This requires that the key expansion method can increase the key's unpredictability and increase the difficulty of key cracking. Existing methods that meet this requirement for key expansion include XOR, which is an indispensable tool in modern information processing and security.

[0004] For example, application number 202311228957.7 proposes a key expansion method. According to the method described in the application, multiple XOR operations need to be performed on the key. In practice, this is reflected in the repeated XOR calculation of the root key and the key to be expanded, and there will be an interrupt after each XOR calculation. Therefore, although the method in the application can ensure the randomness of the key and other characteristics, the processing process is very time-consuming. In actual business operations, the real-time nature of the key issued by the system is related to the timeliness of communication. Therefore, how to perform key expansion in a shorter time is a technical problem. Summary of the Invention

[0005] Purpose of the Invention: This invention provides a key expansion method, device, and storage medium that address the time-consuming problem of existing key expansion processes, which often involve multiple cycles of XORing the root key and the key to be expanded, followed by interruptions after each XOR calculation. This invention reduces the time taken to perform the key expansion process, thereby increasing the key expansion rate.

[0006] Technical solution: The present invention provides a key expansion method, which includes the following steps:

[0007] The terminal expands the local source key file to be expanded according to the expansion ratio M negotiated with the quantum key access gateway, and finally obtains the expanded key file and stores it;

[0008] Expanding the local source key file to be expanded means:

[0009] (1) The size of the source key file to be expanded is recorded as X, and then the source key file to be expanded of size X is divided into two files A and B of size X / 2;

[0010] (2) The minimum unit size for performing XOR calculation is obtained as C, and files A and B are divided into N sub-files according to the minimum unit size for performing XOR calculation;

[0011] (3) Obtain N sub-files of files A and B and perform XOR calculation to obtain the expanded first to 2M key files; finally, splice the expanded first to 2M key files in turn to finally obtain the complete expanded key file and store it.

[0012] Furthermore, the first to 2M key files expanded by performing XOR calculation on N sub-files of files A and B refer to:

[0013] First, obtain the first to Nth sub-files of file A and the first to Nth sub-files of file B and perform an XOR operation on the whole to obtain an expanded first key file;

[0014] Next, obtain the first to N-1th subfiles of file A and the second to Nth subfiles of file B and perform an XOR operation on them to obtain the first half of the expanded second key file; then obtain the Nth subfile of file A and the first subfile of file B and perform an XOR operation on them to obtain the second half of the expanded second key file; then, concatenate the first half of the expanded second key file with the second half of the expanded second key file to obtain the expanded second key file;

[0015] Next, obtaining the first to N-2th subfiles of file A and the third to Nth subfiles of file B and performing an XOR operation on them to obtain the first half of the expanded third key file; then obtaining the N-1th to Nth subfiles of file A and the first to second subfiles of file B and performing an XOR operation on them to obtain the second half of the expanded third key file; then, concatenating the first half of the expanded third key file with the second half of the expanded third key file to obtain the expanded third key file;

[0016] And so on, until the first to N-(2M-1)th sub-files of file A and the 2Mth to Nth sub-files of file B are obtained and an XOR operation is performed to obtain the first half of the expanded 2Mth key file; then the N+2-2Mth sub-file to the Nth sub-file of file A and the first to 2M-1th sub-files of file B are obtained and an XOR operation is performed to obtain the second half of the expanded 2Mth key file; then, the first half of the expanded 2Mth key file and the second half of the expanded 2Mth key file are spliced ​​to obtain the expanded 2Mth key file.

[0017] Furthermore, the N sub-files of files A and B are obtained by using an address pointer offset method.

[0018] Furthermore, the minimum unit C for performing the XOR calculation is an exponential power of 2.

[0019] Furthermore, the step (1) may be:

[0020] The size of the source key file to be expanded is recorded as X, and then the second half of the source key file to be expanded of size X is recorded as file A, and the first half is recorded as file B.

[0021] The present invention also includes a computer device, which includes at least a processor and a memory, wherein the processor is configured to implement the key expansion method as claimed in any one of the above claims when executing a computer program stored in the memory.

[0022] The present invention further includes a computer-readable storage medium storing a computer program, wherein the computer program implements the key expansion method according to any one of the above claims when executed by a processor.

[0023] The beneficial effects of the present invention are as follows: the method of the present invention avoids the process of repeatedly accessing key subfiles, reducing the number of XOR operations; at the same time, the number of times the system processes XOR interrupts is correspondingly reduced, and without destroying the randomness of the expanded key, the overall time occupied by the expansion operation is reduced, thereby improving the system's working efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 Schematic diagram of the key expansion method of the present invention;

[0025] Figure 2 This is a schematic diagram of the present invention using an address pointer offset method to obtain a sub-file. DETAILED DESCRIPTION

[0026] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0027] As described in the background, existing internet data transmission consumes a significant amount of cryptographic keys. Therefore, cryptographic keys need to be expanded to ensure their proper use. Furthermore, the expanded keys must also possess the characteristics of randomness, unpredictability, and non-reproducibility. Current key expansion methods require multiple XOR operations on the keys. This involves repeatedly performing XOR calculations on the root key and the key to be expanded, with interruptions occurring after each XOR calculation, making the process very time-consuming. Therefore, finding a way to perform key expansion in a more efficient manner remains a technical challenge.

[0028] In view of this, the present invention proposes a key expansion method, which includes the following steps:

[0029] The terminal expands the local source key file to be expanded according to the expansion ratio M negotiated with the quantum key access gateway, and finally obtains and stores the expanded key file. The expansion ratio M is generally an exponential power of 2. This embodiment uses M as an example to describe.

[0030] Expanding the local source key file to be expanded means:

[0031] (1) The size of the source key file to be expanded is recorded as X, and then the source key file of size X is divided into two files A and B of size X / 2; of course, the order of files A and B can be swapped, for example, the size of the source key file to be expanded is recorded as X, and then the second half of the source key file of size X is recorded as file A, and the first half is recorded as file B. Figure 1 As shown, the source key file to be expanded that has been downloaded to the device is divided into two equal parts, namely, files A and B. Taking the size of file X as 128M as an example, the sizes of files A and B are both 64M.

[0032] (2) The minimum unit size for performing XOR calculation is C, which is an exponential power of 2, for example, C = 8 megabytes, that is, the size of the minimum XOR key file is 8M. Divide files A and B into N subfiles according to the minimum unit size for performing XOR calculation; for example, in this embodiment, file A is divided into the following 8 subfiles A1, A2, A3, ..., A8, and file B is divided into 8 subfiles B1, B2, B3, ..., B8;

[0033] (3) Obtain N sub-files of files A and B and perform XOR calculation to obtain the expanded first to 2M key files; Figure 2As shown, the N sub-files of files A and B are obtained by address pointer offset. In actual operation, it is not necessary to actually "split" the two files A and B. Instead, the file regions are divided. Each XOR calculation can directly obtain the corresponding key sub-file from the two files. Using the address pointer offset method, the corresponding key content is directly read from the equally divided files A and B. Then, the XOR calculation is performed to obtain the expanded key file. Specifically, it means:

[0034] like Figure 1 As shown, first, obtain the first to Nth subfiles of file A and the first to Nth subfiles of file B and perform an XOR operation on them as a whole to obtain an expanded first key file; in this embodiment, both file A and file B are divided into 8 subfiles, that is, N is 8, and perform an XOR operation on file A and file B as a whole to obtain an expanded first key file. In this embodiment, the first key file is XORed only once, while in the application file with application number 202311228957.7, the key file of the corresponding length is XORed four times. This shows that the number of XOR operations is reduced, which also reduces the number of XOR interrupts.

[0035] Next, obtain the first to N-1th subfiles of file A and the second to Nth subfiles of file B and perform an XOR operation on them to obtain the first half of the expanded second key file; then obtain the Nth subfile of file A and the first subfile of file B and perform an XOR operation on them to obtain the second half of the expanded second key file; then, concatenate the first half of the expanded second key file with the second half of the expanded second key file to obtain the expanded second key file; for example, obtain the first to seventh subfiles of file A and the second to eighth subfiles of file B and perform an XOR operation on them to obtain the expanded Then get the eighth sub-file of file A and the first sub-file of file B and perform XOR operation to get the expanded Then, the first half of the expanded second key file is concatenated with the second half of the expanded second key file to obtain an expanded second key file. In this embodiment, the second key file is XORed only twice, while in the application document with application number 202311228957.7, a key file of the corresponding length is XORed four times. This shows that the number of XOR operations is reduced, which also reduces the number of XOR processing interrupts.

[0036] Next, obtain the first to N-2 subfiles of file A and the third to N-th subfiles of file B and perform an XOR operation on them to obtain the first half of the expanded third key file; then obtain the N-1-th to N-th subfiles of file A and the first to second subfiles of file B and perform an XOR operation on them to obtain the second half of the expanded third key file; then, concatenate the first half of the expanded third key file with the second half of the expanded third key file to obtain the expanded third key file; for example, obtain the first to sixth subfiles of file A. Perform an XOR operation on the subfile of file A and the third to eighth subfiles of file B to obtain the first half of the expanded third key file = A1A2A3A4A5A6 ⊕ B3B4B5B6B7B8; then obtain the seventh to eighth subfiles of file A and the first to second subfiles of file B and perform an XOR operation on them to obtain the second half of the expanded third key file = A7A8 ⊕ B1B2; then, concatenate the first half of the expanded third key file with the second half of the expanded third key file to obtain the expanded third key file;

[0037] And so on, until the first to N-(2M-1)th sub-files of file A and the 2Mth to Nth sub-files of file B are obtained and an XOR operation is performed to obtain the first half of the expanded 2Mth key file; then the N+2-2Mth sub-file to the Nth sub-file of file A and the first to 2M-1th sub-files of file B are obtained and an XOR operation is performed to obtain the second half of the expanded 2Mth key file; then, the first half of the expanded 2Mth key file and the second half of the expanded 2Mth key file are spliced ​​to obtain the expanded 2Mth key file. Since the value of M in this embodiment is 2, the fourth key file is expanded. For example, the first to fifth subfiles of file A and the fourth to eighth subfiles of file B are obtained and an exclusive OR operation is performed to obtain the first half of the expanded fourth key file = A1A2A3A4A5⊕B4B5B6B7B8; the sixth to eighth subfiles of file A and the first to third subfiles of file B are obtained and an exclusive OR operation is performed to obtain the second half of the expanded fourth key file = A6A7A8⊕B1B2B3; then, the first half of the expanded fourth key file and the second half of the expanded fourth key file are concatenated to obtain the expanded fourth key file;

[0038] Finally, the expanded key files (1st to 2Mth) are sequentially concatenated, for example, the first to fourth key files are concatenated, to ultimately obtain a complete expanded key file and store it. Each key file in the first to fourth key files is half the length of the source key file to be expanded, so the length of the concatenated complete key file is twice that of the source key file to be expanded, i.e., the key file is expanded according to the expansion ratio M = 2.

[0039] In summary, the method of the present invention avoids the process of repeatedly accessing key subfiles, reducing the number of XOR operations; at the same time, it also correspondingly reduces the number of times the system processes XOR interrupts. Without destroying the randomness of the expanded key, it reduces the overall time occupied by the expansion operation and improves the system's work efficiency.

[0040] An embodiment of the present invention further provides a computer device, which includes at least a processor and a memory, wherein the memory stores a computer program, and the processor is configured to implement the steps of the key expansion method of the embodiment of the present invention when executing the computer program stored in the memory.

[0041] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the key expansion method of the embodiment of the present invention are implemented.

Claims

1. A key expansion method, characterized in that: The method comprises the following steps: The terminal expands the local source key file to be expanded according to the expansion ratio M negotiated with the quantum key access gateway, and finally obtains the expanded key file and stores it; Expanding the local source key file to be expanded means: (1) The size of the source key file to be expanded is recorded as X, and then the source key file to be expanded of size X is divided into two files A and B of size X / 2; (2) The minimum unit size for performing XOR calculation is obtained as C, and files A and B are divided into N sub-files according to the minimum unit size for performing XOR calculation; (3) Obtain N sub-files of files A and B and perform XOR calculation to obtain the expanded first to 2M key files; finally, splice the expanded first to 2M key files in turn to finally obtain the complete expanded key file and store it.

2. A key expansion method according to claim 1, characterized in that: The first to 2M key files obtained by performing XOR calculation on N sub-files of files A and B are: First, obtain the first to Nth sub-files of file A and the first to Nth sub-files of file B and perform an XOR operation on the whole to obtain an expanded first key file; Next, obtain the first to N-1th subfiles of file A and the second to Nth subfiles of file B and perform an XOR operation on them to obtain the first half of the expanded second key file; then obtain the Nth subfile of file A and the first subfile of file B and perform an XOR operation on them to obtain the second half of the expanded second key file; then, concatenate the first half of the expanded second key file with the second half of the expanded second key file to obtain the expanded second key file; Next, obtaining the first to N-2th subfiles of file A and the third to Nth subfiles of file B and performing an XOR operation on them to obtain the first half of the expanded third key file; then obtaining the N-1th to Nth subfiles of file A and the first to second subfiles of file B and performing an XOR operation on them to obtain the second half of the expanded third key file; then, concatenating the first half of the expanded third key file with the second half of the expanded third key file to obtain the expanded third key file; And so on, until the first to N-(2M-1)th sub-files of file A and the 2Mth to Nth sub-files of file B are obtained and an XOR operation is performed to obtain the first half of the expanded 2Mth key file; then the N+2-2Mth sub-file to the Nth sub-file of file A and the first to 2M-1th sub-files of file B are obtained and an XOR operation is performed to obtain the second half of the expanded 2Mth key file; then, the first half of the expanded 2Mth key file and the second half of the expanded 2Mth key file are spliced ​​to obtain the expanded 2Mth key file.

3. A key expansion method according to claim 1, characterized in that: The N sub-files of files A and B are obtained by using an address pointer offset method.

4. A key expansion method according to claim 1, characterized in that: The minimum unit C for performing the XOR calculation is an exponential power of 2.

5. A key expansion method according to claim 1, characterized in that: The step (1) may be: The size of the source key file to be expanded is recorded as X, and then the second half of the source key file to be expanded of size X is recorded as file A, and the first half is recorded as file B.

6. A computer device, characterized in that: The computer device comprises at least a processor and a memory, and the processor is configured to implement the key expansion method according to any one of claims 1 to 5 when executing a computer program stored in the memory.

7. A computer-readable storage medium, characterized in that: The device stores a computer program, which, when executed by a processor, implements the key expansion method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Key expansion method

    CN117201012A