A quantum random number-based key generation method for a national encryption algorithm
Patent Information
- Application Number
- CN202611278222.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-21
- Publication Date
- 2026-09-22
AI Technical Summary
[0005]针对现有技术的不足,本发明提供了一种基于量子随机数的国密算法密钥生成方法,解决了现有量子随机数生成国密密钥方案存在原始随机序列易受干扰、缺乏标准化随机性校验的缺陷,未针对不同密钥设计专属生成流程,易出现密钥参数失效,同时其缺少密钥存储、分发、更新、销毁全生命周期管控与审计机制的问题
1、该基于量子随机数的国密算法密钥生成方法,通过完整的量子随机序列采集、预处理与标准化检测体系,解决传统方案中原生量子随机信号易受硬件噪声干扰、0/1分布失衡且缺少统一随机性验证机制的缺陷,通过滑动窗口完成频率、序列、扑克、游程、熵值五项权威随机性测试,任一指标不合格便废弃当前批次并重新采集,同步留存异常日志触发告警,大幅提升随机序列熵值与不可预测性,为国密密钥生成提供安全可信的底层随机源,从根源降低密钥被预测、破解的安全风险。
Smart Images

Figure CN122802155A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of key generation technology, specifically to a key generation method for Chinese cryptographic algorithms based on quantum random numbers. Background Technology
[0002] In high-security information systems such as government affairs, finance, industrial control, and public information dissemination, the core security of cryptographic algorithms relies on the unpredictability and high entropy of the key. The security of the key directly determines the protection capability of the entire cryptographic system.
[0003] The reference patent title is: A Database Encryption Method Based on Quantum Random Numbers and Chinese National Cryptographic Algorithm (Patent Publication No.: CN110719160A, Patent Publication Date: 2020-01-21). The method includes the following steps: S1, the encryption system uses QRNG to generate random numbers as the master key; S2, the master key is expanded using a key expansion algorithm to generate a symmetric key; S3, the plaintext data is encrypted using the symmetric key to obtain ciphertext data; or the ciphertext is decrypted using the symmetric key to obtain the plaintext data. By strengthening the randomness of the encryption key and the security and controllability of the encryption algorithm based on the quantum random number generator, a higher level of security can be obtained, and the data security of the user database can be more effectively protected.
[0004] Based on the above-mentioned documents, in the existing operation of generating national cryptographic keys using quantum random numbers, the original quantum random sequence is easily disturbed, causing distribution imbalance. There is a lack of standardized multi-dimensional randomness verification, and there is no dedicated compliant generation process for different keys. The keys are prone to parameter failure, and there is a lack of full lifecycle management and auditing for key storage, distribution, updating, and destruction. Therefore, this invention provides a national cryptographic algorithm key generation method based on quantum random numbers. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a key generation method for national cryptographic algorithms based on quantum random numbers. This method solves the problems of existing quantum random number-based national cryptographic key generation schemes, such as the susceptibility of the original random sequence to interference, the lack of standardized randomness verification, the absence of a dedicated generation process for different keys, the susceptibility to key parameter failure, and the lack of a full lifecycle management and auditing mechanism for key storage, distribution, updating, and destruction.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a key generation method for a national cryptographic algorithm based on quantum random numbers, specifically comprising the following steps: A1. Real-time acquisition of raw quantum random sequences is achieved by communicating with the quantum random number chip through hardware driver; A2. Perform preprocessing on the original quantum random sequence. Use a test kit to perform five core tests on the preprocessed random sequence. If all tests are passed, proceed to the key generation stage. If any test fails, discard the batch of sequences, re-acquire and preprocess them, and record the abnormal log to trigger a minor alarm. A3. Based on the target national cryptographic algorithm type, the qualified quantum random sequence is segmented, parameter verified, and format converted to generate compliant SM2 public and private keys, SM3 hash keys, and SM4 block keys respectively; A4. The generated keys are encrypted and stored, SM2 key exchange is securely distributed, automatically updated during the runtime, and multi-level overwrite and destruction are controlled throughout the entire process, with operation audit logs retained throughout the process. A5. Layered protection through physical layer, data layer, and application layer, with real-time monitoring of key retrieval behavior.
[0007] Preferably, the operation in A1 to realize the real-time acquisition of the original quantum random sequence is as follows: a11. Load the quantum random number chip driver, establish a communication link between the driver and the chip, and configure the chip's operating parameters; a12. Based on the key generation requirements, the chip is triggered to start collecting quantum tunneling events and converting the physical signal into a binary random sequence; a13. Cache the collected raw random sequences to a high-speed buffer to avoid data loss and support high-concurrency acquisition; a14. Perform a preliminary verification for each random sequence of a fixed length collected. If data loss occurs, trigger a re-collection command until the verification is passed, and then output the original random sequence for use.
[0008] Preferably, the preprocessing operation performed on the original quantum random sequence in A2 is as follows: a21. A linear filtering algorithm is used to filter out high-frequency noise in the original sequence and retain the effective random signal. a22. Use the XOR operation to XOR two adjacent binary numbers to eliminate the correlation in the sequence and ensure that the generation of each binary number is independent and unrelated. a23. Calculate the probability of 0 and 1 appearing in the sequence. If the deviation exceeds the threshold, adjust the sequence through a random permutation algorithm to ensure that the probability of 0 and 1 appearing is within the deviation threshold range.
[0009] Preferably, the operation in A2, which uses a test suite to perform five core tests on the preprocessed random sequence, is as follows: B1. The preprocessed random sequence is traversed from the beginning through the set sequence recognition window, and the length of the recognition content of the sequence recognition window is set by the threshold of the sequence length test. B2. After each content recognition and extraction, the sequence recognition window moves by the corresponding window length for the next operation, and the extracted content is identified in sequence each time. B3. Based on the extracted content, perform frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing to determine whether the test results of each batch of random sequences are qualified.
[0010] Preferably, the operations in B3 that perform frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing based on the extracted content are as follows: Frequency test: Check whether the frequency of 0 and 1 in the sequence is within the frequency deviation threshold range; Sequence testing: Detects whether the length distribution of consecutive 0s or consecutive 1s in a sequence is shorter than the longest consecutive length threshold; Poker test: Detects whether the randomness of grouping a sequence satisfies a distribution bias threshold; Runs test: Detects whether the frequency of 0 and 1 transitions in a sequence conforms to a random distribution. Entropy test: Detects whether the entropy value of a sequence meets the entropy threshold.
[0011] Preferably, the operation of generating compliant SM2 public and private keys in A3 is as follows: c11. Extract 256 bits from the preprocessed quantum random sequence as the SM2 private key. The private key must meet the requirements of the national cryptographic standard SM2. c12. Based on the SM2 elliptic curve algorithm, calculate the public key P using the SM2 private key, and P = d × G, where G is the base point of the SM2 elliptic curve. c13. Verify the validity of the public key P, ensuring that P≠0 and satisfies the elliptic curve equation. If the verification fails, regenerate the private key by truncating a random sequence and repeat steps c12 and c13. c14. Convert the verified private and public keys into hexadecimal format to match the key input specifications of the SM2 algorithm, and generate a key fingerprint for identity authentication.
[0012] Preferably, the operation of generating a compliant SM3 hash key in A3 is as follows: c21. Depending on the application scenario requirements, extract 128 bits or 256 bits from the preprocessed quantum random sequence as the SM3 hash key; c22. XOR the truncated random sequence with the SM3 initialization vector to obfuscate it, and verify that the obfuscated key entropy value is ≥128 bits to ensure that it meets the key security requirements of the hash function. c23. Convert the SM3 key to Base64 format for use in data integrity verification and key derivation.
[0013] Preferably, the operation of generating a compliant SM4 block key in A3 is as follows: c31. Extract 128 bits from the preprocessed quantum random sequence as the SM4 key; c32. Using the key expansion function of the SM4 algorithm, the 128-bit key is expanded into 32 32-bit subkeys for subsequent encryption or decryption operations. c33. Verify the correctness of the key expansion to ensure that the subkey generation conforms to the algorithm specifications and avoid subsequent encryption anomalies; c34. Convert the 128-bit key to hexadecimal format and store it in the security chip.
[0014] Preferably, the operation in A4 that performs full-process control over the generated key is as follows: a41. The SM4 algorithm is used to encrypt and store the key. The encryption key is regenerated by quantum random number. Access permissions are set for the key, and only authorized users and authorized modules are authorized to access the key. All access operations are recorded. The core key is backed up in an off-site encrypted manner, and the backup key is stored separately from the master key. a42. Key distribution is implemented using the SM2 key exchange protocol. The specific operation is as follows: The key distributor generates an SM2 key pair and sends the public key to the receiver. The receiver generates its own SM2 key pair and sends the public key to the distributor. Based on their respective private keys and the other party's public key, both parties use the SM2 key exchange algorithm to derive the same session key from the key generated by quantum random numbers. Both parties verify the consistency of the session key through the SM3 hash function. a43. Keys are called through standardized interfaces. Keys are only used for decryption in memory and are not written to disk. After use, the key in memory is cleared immediately. The key usage is monitored in real time, and the key call time, caller, and usage scenario are recorded. If an abnormal call occurs, an alarm is triggered immediately and the key usage is suspended. At the same time, the key validity period is set according to the scenario requirements. When the key expires, a new key is automatically generated to replace the old key, and the old key is destroyed immediately. a44. When destroying the key, the stored key is overwritten multiple times to ensure that the key cannot be obtained through data recovery technology. If the security chip is damaged, the device is completely destroyed by physical destruction to prevent key leakage. At the same time, the key destruction time, destruction method and destruction person are recorded to form a destruction log for traceability.
[0015] Preferably, the layered protection operation in A5 through the physical layer, data layer, and application layer is as follows: Physical layer: Secure chip with sealed electromagnetic shielding to prevent power consumption side-channel attacks; device deployed in a controlled physical area. Data layer: Random number collection and transmission are encrypted with SM4 throughout and verified with SM3 hash integrity to prevent eavesdropping and tampering; Application layer: Role-based hierarchical access control, SM2 digital signature authentication is performed before key calls, and abnormal calls are alerted and blocked in real time.
[0016] This invention provides a key generation method for national cryptographic algorithms based on quantum random numbers. Compared with existing technologies, it has the following advantages: 1. This national cryptographic algorithm key generation method based on quantum random numbers addresses the shortcomings of traditional schemes, such as the susceptibility of native quantum random signals to hardware noise interference, 0 / 1 distribution imbalance, and lack of a unified randomness verification mechanism, through a complete quantum random sequence acquisition, preprocessing, and standardized detection system. It completes five authoritative randomness tests—frequency, sequence, poker, run length, and entropy—through a sliding window. If any indicator fails, the current batch is discarded and re-acquired, and anomaly logs are simultaneously retained to trigger alarms. This significantly improves the entropy and unpredictability of random sequences, providing a secure and reliable underlying random source for national cryptographic key generation and fundamentally reducing the security risks of key prediction and cracking.
[0017] 2. This key generation method based on quantum random numbers for national cryptographic algorithms designs independent and standardized key generation processes for three mainstream national cryptographic algorithms, achieving full-process compliance verification of keys, performing standard key expansion operations and verifying the correctness of subkeys, and encrypting and storing them in a secure chip. Each type of key is equipped with dedicated parameter verification and format conversion logic, eliminating encryption and decryption failures caused by abnormal key parameters. It can seamlessly adapt to diverse national cryptographic application scenarios such as signatures, hash verification, and data encryption, significantly reducing the compliance verification cost in the key generation stage.
[0018] 3. This national cryptographic algorithm key generation method based on quantum random numbers employs a closed-loop security management system covering the entire key lifecycle. In the storage phase, SM4 encryption is used, and the core key is backed up off-site. Access permissions are strictly defined, and all operation logs are recorded. In the distribution phase, the session key is negotiated based on the SM2 key exchange protocol, and consistency verification is performed using SM3 hashing to ensure untampered transmission. During runtime, the key is decrypted only in memory and immediately cleared after use. An expiration date is set for automatic key rotation. Abnormal calls trigger real-time alarms and suspend key use. During the destruction phase, multiple data overwrites are performed, and scrapped chips are physically destroyed. Complete destruction information is recorded for traceability. Simultaneously, a layered protection architecture is built. The physical layer relies on electromagnetic shielding to resist side-channel attacks; the data layer uses end-to-end encryption and hash verification to prevent eavesdropping and tampering; and the application layer relies on hierarchical permissions and SM2 signatures to complete call authentication. This dual security system works together to comprehensively block security threats such as key leakage, unauthorized access, and data tampering. Attached Figure Description
[0019] Figure 1This is a flowchart illustrating the key generation method of the present invention. Figure 2 This is a logic diagram for data preprocessing and core testing in this invention. Figure 3 This is a logic diagram for the key execution process control of the present invention. Figure 4 This is the test item table for the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Please see Figures 1-4 This invention provides a technical solution: a method for generating keys for a national cryptographic algorithm based on quantum random numbers, specifically including the following steps: A1. Real-time acquisition of raw quantum random sequences is achieved by communicating with the quantum random number chip through hardware driver; A2. Perform preprocessing on the original quantum random sequence. Use a test kit to perform five core tests on the preprocessed random sequence. If all tests are passed, proceed to the key generation stage. If any test fails, discard the batch of sequences, re-acquire and preprocess them, and record the abnormal log to trigger a minor alarm. A3. Based on the target national cryptographic algorithm type, the qualified quantum random sequence is segmented, parameter verified, and format converted to generate compliant SM2 public and private keys, SM3 hash keys, and SM4 block keys respectively; A4. The generated keys are encrypted and stored, SM2 key exchange is securely distributed, automatically updated during the runtime, and multi-level overwrite and destruction are controlled throughout the entire process, with operation audit logs retained throughout the process. A5. Layered protection through physical layer, data layer, and application layer, with real-time monitoring of key retrieval behavior.
[0022] The hardware layer uses a commercially available integrated quantum tunneling QRNG chip, accompanied by a dedicated low-level driver. The driver consists of two layers: a kernel-mode driver and a user-mode interaction SDK. The kernel driver is responsible for directly reading and writing chip registers and controlling hardware timing. The communication link supports three hardware interfaces: USB 3.0, PCIe, and SPI. The system automatically completes a handshake upon startup: issuing a chip reset command, configuring the sampling clock frequency, setting the quantum tunneling bias voltage, simultaneously enabling the hardware checksum channel, and transmitting the chip's operating status code in real time. If the three-way handshake fails, a hardware fault is identified, the system reports a hardware-level alarm, and switches to a backup quantum random number hardware channel.
[0023] By establishing a complete quantum random sequence acquisition, preprocessing, and standardized detection system, this approach addresses the shortcomings of traditional schemes, such as the susceptibility of native quantum random signals to hardware noise interference, 0 / 1 distribution imbalance, and the lack of a unified randomness verification mechanism. It utilizes a sliding window to perform five authoritative randomness tests: frequency, sequence, poker, run length, and entropy. If any indicator fails to meet the requirements, the current batch is discarded and reacquired, with anomaly logs simultaneously stored to trigger alarms. This significantly improves the entropy and unpredictability of random sequences, providing a secure and reliable underlying random source for national cryptographic key generation and fundamentally reducing the security risks of key prediction and cracking.
[0024] In this embodiment of the invention, the operation for real-time acquisition of the original quantum random sequence in A1 is as follows: a11. Load the quantum random number chip driver, establish a communication link between the driver and the chip, and configure the chip's operating parameters; a12. Based on the key generation requirements, the chip is triggered to start collecting quantum tunneling events and converting the physical signal into a binary random sequence; a13. Cache the collected raw random sequences to a high-speed buffer to avoid data loss and support high-concurrency acquisition; a14. Perform a preliminary verification for each random sequence of a fixed length collected. If data loss occurs, trigger a re-collection command until the verification is passed, and then output the original random sequence for use.
[0025] A circular high-speed memory buffer is adopted, with the buffer capacity configured to 2MB according to the maximum key generation requirement in a single operation. A read-write dual pointer separation mechanism is set up, with the write pointer driven by the quantum chip hardware interrupt and the read pointer scheduled by the upper-level key generation thread, so as to realize asynchronous parallelism between sampling and key generation without blocking each other.
[0026] In this embodiment of the invention, the preprocessing operation performed on the original quantum random sequence in A2 is as follows: a21. A linear filtering algorithm is used to filter out high-frequency noise in the original sequence and retain the effective random signal. a22. Use the XOR operation to XOR two adjacent binary numbers to eliminate the correlation in the sequence and ensure that the generation of each binary number is independent and unrelated. a23. Calculate the probability of 0 and 1 appearing in the sequence. If the deviation exceeds the threshold, adjust the sequence through a random permutation algorithm to ensure that the probability of 0 and 1 appearing is within the deviation threshold range.
[0027] A sliding window linear mean filter is employed with a fixed window length of 8 bits. The original sequence is traversed bit by bit to distinguish between quantum effective random impulse noise and continuous high-frequency interference bits caused by environmental electromagnetic and temperature factors. Noise segments of 8 or more consecutive fixed 0 / 1 bits are directly discarded, and gaps are filled by interpolation with effective random bits before and after the noise. Only the effective bit stream with quantum random characteristics is retained, without destroying the original random entropy.
[0028] The number of 0s and 1s within each 1024 bits is counted segment by segment, with an allowable deviation threshold of ±1%. If the number exceeds the threshold, the Fisher-Yates random permutation algorithm is used to shuffle the bit order of the current segment, and the distribution is recounted. This process is repeated until the proportion of 0s and 1s falls within the threshold range, thus avoiding sequence bias caused by hardware limitations. In this embodiment of the invention, the operation of using a test suite to perform five core tests on the preprocessed random sequence in A2 is as follows: B1. The preprocessed random sequence is traversed from the beginning through the set sequence recognition window, and the length of the recognition content of the sequence recognition window is set by the threshold of the sequence length test. B2. After each content recognition and extraction, the sequence recognition window moves by the corresponding window length for the next operation, and the extracted content is identified in sequence each time. B3. Based on the extracted content, perform frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing to determine whether the test results of each batch of random sequences are qualified.
[0029] Define a fixed-length sliding recognition window (standard window length 10 bits), traverse the preprocessed complete bit stream from beginning to end, set the window step size to 256 bits, and ensure that there is some bit overlap between adjacent windows to ensure that there are no blind spots in the detection of the entire sequence. Each extracted window of data is separately packaged into a detection sample, and assigned a unique batch number, sampling timestamp, and hardware device ID. It is then stored in the detection queue and five tests are performed in parallel.
[0030] Please see Figure 4 In this embodiment of the invention, the operations in B3 for frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing based on the extracted content are as follows: Frequency test: Check whether the frequency of 0 and 1 in the sequence is within the frequency deviation threshold range; Sequence testing: Detects whether the length distribution of consecutive 0s or consecutive 1s in a sequence is shorter than the longest consecutive length threshold; Poker test: Detects whether the randomness of grouping a sequence satisfies a distribution bias threshold; Runs test: Detects whether the frequency of 0 and 1 transitions in a sequence conforms to a random distribution. Entropy test: Detects whether the entropy value of a sequence meets the entropy threshold.
[0031] In this embodiment of the invention, the operation of generating compliant SM2 public and private keys in A3 is as follows: c11. Extract 256 bits from the preprocessed quantum random sequence as the SM2 private key. The private key must meet the requirements of the national cryptographic standard SM2. c12. Based on the SM2 elliptic curve algorithm, calculate the public key P using the SM2 private key, and P = d × G, where G is the base point of the SM2 elliptic curve. c13. Verify the validity of the public key P, ensuring that P≠0 and satisfies the elliptic curve equation. If the verification fails, regenerate the private key by truncating a random sequence and repeat steps c12 and c13. c14. Convert the verified private and public keys into hexadecimal format to match the key input specifications of the SM2 algorithm, and generate a key fingerprint for identity authentication.
[0032] 256 bits of raw values are continuously extracted from a qualified quantum random stream. First, a modulo p operation is performed to map the values to the finite field range of the SM2 standard elliptic curve. Values that exceed the valid range of the private key are filtered out to ensure that the private key d satisfies 1≤d≤n-1 (n is the order of the SM2 curve). The public and private keys are uniformly converted from binary to uppercase hexadecimal strings with a fixed length of 64 characters. The SM3 is used to hash the concatenated string of private and public keys, and the output 256-bit hash value is used as the unique fingerprint of the key for fast key ledger retrieval and identity comparison.
[0033] Preferably, the operation of generating a compliant SM3 hash key in A3 is as follows: c21. Depending on the application scenario requirements, extract 128 bits or 256 bits from the preprocessed quantum random sequence as the SM3 hash key; c22. XOR the truncated random sequence with the SM3 initialization vector to obfuscate it, and verify that the obfuscated key entropy value is ≥128 bits to ensure that it meets the key security requirements of the hash function. c23. Convert the SM3 key to Base64 format for use in data integrity verification and key derivation.
[0034] In this embodiment of the invention, the operation of generating a compliant SM4 block key in A3 is as follows: c31. Extract 128 bits from the preprocessed quantum random sequence as the SM4 key; c32. Using the key expansion function of the SM4 algorithm, the 128-bit key is expanded into 32 32-bit subkeys for subsequent encryption or decryption operations. c33. Verify the correctness of the key expansion to ensure that the subkey generation conforms to the algorithm specifications and avoid subsequent encryption anomalies; c34. Convert the 128-bit key to hexadecimal format and store it in the security chip.
[0035] The persistent key storage adopts a layered encryption architecture: all national cryptographic keys are encrypted and stored on disk using an SM4 root key generated by another independent quantum random number. The root key is stored separately inside a secure encryption chip and is not exported.
[0036] The access control system adopts a hierarchical role model based on RBAC, divided into three roles: administrator, operations and maintenance, and business applications. Administrators have full lifecycle operation permissions for keys; operations and maintenance personnel can only view audit logs and trigger key updates; business applications can only use keys for encryption operations and cannot read the raw keys. Each key read, call, and backup operation generates an audit log with a timestamp, operator ID, and device IP. The logs themselves are protected against tampering using SM3.
[0037] The core master key is backed up in an off-site active-active environment with physical isolation between the backup server and the master server. The two servers use different storage media, and the backup key is encrypted twice with an independent root key. The backup key cannot be cracked even if the master key is leaked.
[0038] By designing independent and standardized key generation processes for three mainstream national cryptographic algorithms, the system achieves full-process compliance verification of keys, performs standard key expansion operations and verifies the correctness of subkeys, and encrypts and stores them in a secure chip. Each type of key is equipped with dedicated parameter verification and format conversion logic, eliminating encryption and decryption failures caused by abnormal key parameters. It can seamlessly adapt to diverse national cryptographic application scenarios such as signatures, hash verification, and data encryption, and significantly reduce the compliance verification cost in the key generation stage.
[0039] In this embodiment of the invention, the operation of performing full-process control over the generated key in A4 is as follows: a41. The SM4 algorithm is used to encrypt and store the key. The encryption key is regenerated by quantum random number. Access permissions are set for the key, and only authorized users and authorized modules are authorized to access the key. All access operations are recorded. The core key is backed up in an off-site encrypted manner, and the backup key is stored separately from the master key. a42. Key distribution is implemented using the SM2 key exchange protocol. The specific operation is as follows: The key distributor generates an SM2 key pair and sends the public key to the receiver. The receiver generates its own SM2 key pair and sends the public key to the distributor. Based on their respective private keys and the other party's public key, both parties use the SM2 key exchange algorithm to derive the same session key from the key generated by quantum random numbers. Both parties verify the consistency of the session key through the SM3 hash function. a43. Keys are called through standardized interfaces. Keys are only used for decryption in memory and are not written to disk. After use, the key in memory is cleared immediately. The key usage is monitored in real time, and the key call time, caller, and usage scenario are recorded. If an abnormal call occurs, an alarm is triggered immediately and the key usage is suspended. At the same time, the key validity period is set according to the scenario requirements. When the key expires, a new key is automatically generated to replace the old key, and the old key is destroyed immediately. a44. When destroying the key, the stored key is overwritten multiple times to ensure that the key cannot be obtained through data recovery technology. If the security chip is damaged, the device is completely destroyed by physical destruction to prevent key leakage. At the same time, the key destruction time, destruction method and destruction person are recorded to form a destruction log for traceability.
[0040] The system configuration allows for customizable key validity periods (1 day / 7 days / 30 days). When a background scheduled task expires, this method is automatically invoked to generate a new compliant key, enabling a smooth switch of business keys without business interruption. The old key is marked as pending destruction. The background collects key call behavior indicators in real time: call frequency, call subject, access time period, and operation type. Short-term high-frequency calls, batch readings outside of working hours, and calls from unknown IPs are identified as abnormal. The system immediately blocks the current key interface, triggers a platform alarm, locks the corresponding call subject, and retains abnormal operation logs.
[0041] In this embodiment of the invention, the layered protection operation of A5 through the physical layer, data layer, and application layer is as follows: Physical layer: Secure chip with sealed electromagnetic shielding to prevent power consumption side-channel attacks; device deployed in a controlled physical area. Data layer: Random number collection and transmission are encrypted with SM4 throughout and verified with SM3 hash integrity to prevent eavesdropping and tampering; Application layer: Role-based hierarchical access control, SM2 digital signature authentication is performed before key calls, and abnormal calls are alerted and blocked in real time.
[0042] Through a closed-loop security management system covering the entire key lifecycle, the storage stage employs SM4 encryption and off-site backup of core keys, strictly defines access permissions and records all operation logs, and the distribution stage negotiates session keys based on the SM2 key exchange protocol, using SM3 hashing to complete consistency verification to ensure that transmission is not tampered with. During runtime, keys are only decrypted in memory and are immediately cleared after use. Validity periods are set for automatic key rotation, abnormal calls trigger real-time alarms and suspend key use, and the destruction stage performs multiple data overwrites. Scrapped chips are physically destroyed, and destruction information is fully recorded for easy traceability. Simultaneously, a layered protection architecture is built: the physical layer relies on electromagnetic shielding to resist side-channel attacks, the data layer uses end-to-end encryption and hash verification to prevent eavesdropping and tampering, and the application layer relies on hierarchical permissions and SM2 signatures to complete call authentication. These dual security systems work together to comprehensively block security threats such as key leakage, unauthorized access, and data tampering.
[0043] Furthermore, any content not described in detail in this specification is existing technology known to those skilled in the art.
[0044] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0045] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A key generation method for a national cryptographic algorithm based on quantum random numbers, characterized in that: Specifically, the following steps are included: A1. Real-time acquisition of raw quantum random sequences is achieved by communicating with the quantum random number chip through hardware driver; A2. Perform preprocessing on the original quantum random sequence. Use a test kit to perform five core tests on the preprocessed random sequence. If all tests are passed, proceed to the key generation stage. If any test fails, discard the batch of sequences, re-acquire and preprocess them, and record the abnormal log to trigger a minor alarm. A3. Based on the target national cryptographic algorithm type, the qualified quantum random sequence is segmented, parameter verified, and format converted to generate compliant SM2 public and private keys, SM3 hash keys, and SM4 block keys respectively; A4. The generated keys are encrypted and stored, SM2 key exchange is securely distributed, automatically updated during the runtime, and multi-level overwrite and destruction are controlled throughout the entire process, with operation audit logs retained throughout the process. A5. Layered protection through physical layer, data layer, and application layer, with real-time monitoring of key retrieval behavior.
2. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation in A1 to achieve real-time acquisition of the original quantum random sequence is as follows: a11. Load the quantum random number chip driver, establish a communication link between the driver and the chip, and configure the chip's operating parameters; a12. Based on the key generation requirements, the chip is triggered to start collecting quantum tunneling events and converting the physical signal into a binary random sequence; a13. Cache the collected raw random sequences to a high-speed buffer to avoid data loss and support high-concurrency acquisition; a14. Perform a preliminary verification for each random sequence of a fixed length collected. If data loss occurs, trigger a re-collection command until the verification is passed, and then output the original random sequence for use.
3. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The preprocessing operation performed on the original quantum random sequence in A2 is as follows: a21. A linear filtering algorithm is used to filter out high-frequency noise in the original sequence and retain the effective random signal. a22. Use the XOR operation to XOR two adjacent binary numbers to eliminate the correlation in the sequence and ensure that the generation of each binary number is independent and unrelated. a23. Calculate the probability of 0 and 1 appearing in the sequence. If the deviation exceeds the threshold, adjust the sequence through a random permutation algorithm to ensure that the probability of 0 and 1 appearing is within the deviation threshold range.
4. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation in A2, which uses a test suite to perform five core tests on the preprocessed random sequence, is as follows: B1. The preprocessed random sequence is traversed from the beginning through the set sequence recognition window, and the length of the recognition content of the sequence recognition window is set by the threshold of the sequence length test. B2. After each content recognition and extraction, the sequence recognition window moves by the corresponding window length for the next operation, and the extracted content is identified in sequence each time. B3. Based on the extracted content, perform frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing to determine whether the test results of each batch of random sequences are qualified.
5. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 4, characterized in that: The operations in B3, which perform frequency testing, sequence testing, poker testing, run-length verification testing, and entropy testing based on the extracted content, are as follows: Frequency test: Check whether the frequency of 0 and 1 in the sequence is within the frequency deviation threshold range; Sequence testing: Detects whether the length distribution of consecutive 0s or consecutive 1s in a sequence is shorter than the longest consecutive length threshold; Poker test: Detects whether the randomness of grouping a sequence satisfies a distribution bias threshold; Runs test: Detects whether the frequency of 0 and 1 transitions in a sequence conforms to a random distribution. Entropy test: Detects whether the entropy value of a sequence meets the entropy threshold.
6. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation of generating compliant SM2 public and private keys in A3 is as follows: c11. Extract 256 bits from the preprocessed quantum random sequence as the SM2 private key. The private key must meet the requirements of the national cryptographic standard SM2. c12. Based on the SM2 elliptic curve algorithm, calculate the public key P using the SM2 private key, and P = d × G, where G is the base point of the SM2 elliptic curve. c13. Verify the validity of the public key P, ensuring that P≠0 and satisfies the elliptic curve equation. If the verification fails, regenerate the private key by truncating a random sequence and repeat steps c12 and c13. c14. Convert the verified private and public keys into hexadecimal format to match the key input specifications of the SM2 algorithm, and generate a key fingerprint for identity authentication.
7. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation for generating a compliant SM3 hash key in A3 is as follows: c21. Depending on the application scenario requirements, extract 128 bits or 256 bits from the preprocessed quantum random sequence as the SM3 hash key; c22. XOR the truncated random sequence with the SM3 initialization vector to obfuscate it, and verify that the obfuscated key entropy value is ≥128 bits to ensure that it meets the key security requirements of the hash function. c23. Convert the SM3 key to Base64 format for use in data integrity verification and key derivation.
8. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation for generating a compliant SM4 block key in A3 is as follows: c31. Extract 128 bits from the preprocessed quantum random sequence as the SM4 key; c32. Using the key expansion function of the SM4 algorithm, the 128-bit key is expanded into 32 32-bit subkeys for subsequent encryption or decryption operations. c33. Verify the correctness of the key expansion to ensure that the subkey generation conforms to the algorithm specifications and avoids subsequent encryption anomalies; c34. Convert the 128-bit key to hexadecimal format and store it in the security chip.
9. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The operation in A4 to manage the generated key throughout the entire process is as follows: a41. The SM4 algorithm is used to encrypt and store the key. The encryption key is regenerated by quantum random number. Access permissions are set for the key, and only authorized users and authorized modules are authorized to access the key. All access operations are recorded. The core key is backed up in an off-site encrypted manner, and the backup key is stored separately from the master key. a42. Key distribution is implemented using the SM2 key exchange protocol. The specific operation is as follows: The key distributor generates an SM2 key pair and sends the public key to the receiver. The receiver generates its own SM2 key pair and sends the public key to the distributor. Based on their respective private keys and the other party's public key, both parties use the SM2 key exchange algorithm to derive the same session key from the key generated by quantum random numbers. Both parties verify the consistency of the session key through the SM3 hash function. a43. Keys are called through standardized interfaces. Keys are only used for decryption in memory and are not written to disk. After use, the key in memory is cleared immediately. The key usage is monitored in real time, and the key call time, caller, and usage scenario are recorded. If an abnormal call occurs, an alarm is triggered immediately and the key usage is suspended. At the same time, the key validity period is set according to the scenario requirements. When the key expires, a new key is automatically generated to replace the old key, and the old key is destroyed immediately. a44. When destroying the key, the stored key is overwritten multiple times to ensure that the key cannot be obtained through data recovery technology. If the security chip is damaged, the device is completely destroyed by physical destruction to prevent key leakage. At the same time, the key destruction time, destruction method and destruction person are recorded to form a destruction log for traceability.
10. The method for generating a national cryptographic algorithm key based on quantum random numbers according to claim 1, characterized in that: The layered protection mechanism (physical layer, data layer, and application layer) in A5 is as follows: Physical layer: Secure chip with sealed electromagnetic shielding to prevent power consumption side-channel attacks; device deployed in a controlled physical area. Data layer: Random number collection and transmission are encrypted with SM4 throughout and verified with SM3 hash integrity to prevent eavesdropping and tampering; Application layer: Role-based hierarchical access control, SM2 digital signature authentication is performed before key calls, and abnormal calls are blocked with real-time alarms.
Citation Information
Patent Citations
Database encryption method based on quantum random number and national cryptographic algorithm
CN110719160A