Method and device for verifying correctness of encryption result

By receiving encryption mode instructions on the test machine and sending data to be encrypted, the encryption results of the target device are automatically verified, and the correctness of the encryption results are verified by using standard databases, the problem of low verification efficiency of existing SM4 encryption algorithms is solved, and efficient and accurate are achieved cryptographic algorithm verification.

CN119248662APending Publication Date: 2025-01-03SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411310465.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The existing SM4 encryption algorithm verification methods rely on hardware devices and manual operations, are inefficient, cannot meet the needs of large-scale and automated testing, and are susceptible to human factors, which affects the accuracy and consistency of test results.

Method used

The test machine receives the encryption mode instructions sent by the controller, sends the data to be encrypted and the encryption mode to the target device, receives the encryption results, and uses the pre-established standard database to verify the correctness of the encryption results to realize automated encryption algorithm verification.

Benefits of technology

It improves the efficiency and accuracy of encryption algorithm verification, realizes the automation of the test process, ensures the integrity and correctness of encrypted data, and reduces the influence of human factors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248662A_ABST
    Figure CN119248662A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for verifying the correctness of an encryption result, and the method comprises the steps: a test machine receives a first instruction sent by a control machine, the first instruction carries N encryption modes, and N is an integer greater than or equal to 1; the test machine sends a second instruction to the target equipment, the second instruction carries the to-be-encrypted data set and all or part of the encryption modes in the N encryption modes, and the second instruction is used for instructing the target equipment to encrypt the to-be-encrypted data in the to-be-encrypted data set by using all or part of the encryption modes in the N encryption modes; the test machine receives an encrypted file sent by the target device, the encrypted file comprises an encryption result, and the encryption result is a result obtained by encrypting the to-be-encrypted data by the target device in the encryption mode; and the test machine verifies the correctness of an encryption result included in the encryption file according to a pre-established standard database to obtain a verification result, and the standard database records standard data and a ciphertext of the standard data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the computer field, and more specifically, to a method and device for verifying the correctness of an encryption result. Background Art

[0002] In today's digital age, data security has become a global focus. With the rapid development of network technology and the explosive growth of data volume, personal information and corporate data are facing unprecedented security threats. In this context, data encryption technology has become an important means to protect data security. For example, the SM4 encryption algorithm, as a symmetric encryption algorithm, is widely used in various information encryption scenarios due to its high efficiency and security, especially in storage devices such as solid-state drives (SSDs).

[0003] As a key component in modern computing devices, its high-speed read and write capabilities and durability have made it widely used in the market. However, with the development of SSD technology, the requirements for its encryption performance are becoming higher and higher. The existing SM4 encryption algorithm verification methods mainly rely on hardware equipment and manual operations. These methods are not only costly but also inefficient and cannot meet the needs of large-scale and automated testing. In addition, traditional methods are easily affected by human factors during the testing process, which affects the accuracy and consistency of the test results.

[0004] There is currently no effective solution to the above problems. Summary of the invention

[0005] The embodiments of the present application provide a method and device for verifying the correctness of an encryption result, so as to at least solve the problem of low efficiency of manually verifying an encryption algorithm in the related art.

[0006] According to one embodiment of the present application, a method for verifying the correctness of an encryption result is provided, comprising: a test machine receives a first instruction sent by a control machine, wherein the first instruction carries N encryption modes, and N is an integer greater than or equal to 1; the test machine sends a second instruction to a target device, wherein the second instruction carries a set of data to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; the test machine receives an encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode; the test machine verifies the correctness of the encryption result included in the encryption file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and ciphertext of the standard data.

[0007] In an exemplary embodiment, the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, including: the test machine obtains the current encryption result to be verified from the encrypted file, wherein the current encryption result to be verified is the result obtained by the target device encrypting first data to be encrypted using a first encryption mode, the N encryption modes include the first encryption mode, and the set of data to be encrypted includes the first data to be encrypted; the test machine searches the standard database for first standard data that is identical to the first data to be encrypted, and determines the ciphertext of the first standard data in the standard database under the first encryption mode as the first ciphertext; the test machine verifies the correctness of the encryption result included in the encrypted file according to whether the current encryption result to be verified is identical to the first ciphertext, wherein, in the case of the sameness, the test machine determines that the verification result of the current encryption result to be verified is a correct encryption result, and in the case of differentness, the test machine determines that the verification result of the current encryption result to be verified is an incorrect encryption result.

[0008] In an exemplary embodiment, before the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes: the test machine obtains multiple standard data, and uses each of the N encryption modes to encrypt each of the multiple standard data respectively, to obtain the ciphertext of each of the standard data in various encryption modes, including: the test machine encrypts the second standard data to be encrypted in each of the N encryption modes respectively, to obtain N ciphertexts of the second standard data, wherein the multiple standard data include the second standard data; the test machine establishes a correspondence between the ciphertexts of each of the standard data in various encryption modes, and records them in the standard database, including: the test machine establishes a correspondence between the second standard data and the N ciphertexts, to obtain N encryption relationships of the second standard data; the test machine records the N encryption relationships of the second standard data in the standard database; after the test machine verifies the correctness of the encryption result included in the encrypted file according to the pre-established standard database, the method further includes: the test machine sends the verification result to the control machine.

[0009] In an exemplary embodiment, after the test machine sends a second instruction to the target device, the method further includes: the target device parses the data set to be encrypted and M encryption modes from the second instruction, where M is an integer greater than or equal to 1 and less than or equal to N; the target device uses M firmware corresponding to the M encryption modes to encrypt the data to be encrypted in the data set to be encrypted, respectively.

[0010] In an exemplary embodiment, the target device uses the M firmwares corresponding to the M encryption modes to encrypt the data to be encrypted in the data set to be encrypted, including: the target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtains an encryption result set of the i-th firmware, wherein i is an integer greater than or equal to 1 and less than or equal to M, and the i-th encryption mode is any encryption mode among the M encryption modes.

[0011] In an exemplary embodiment, the target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtains the encryption result set of the i-th firmware, including: the i-th firmware obtains an encryption key from a pre-established key library, and uses the encryption key to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtains the encryption result set of the i-th firmware.

[0012] In an exemplary embodiment, after the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes: if the correct encryption result in the encryption result set of the i-th firmware is greater than or equal to a preset threshold, the i-th firmware is determined to be qualified firmware, and the test machine marks the i-th firmware as qualified firmware in the verification result; if the correct encryption result in the encryption result set of the i-th firmware is less than the preset threshold, the i-th firmware is determined to be unqualified firmware, and the test machine marks the i-th firmware as unqualified firmware in the verification result.

[0013] According to another embodiment of the present application, a device for verifying the correctness of an encryption result is provided, comprising: a first receiving module, for receiving a first instruction sent by a control machine, wherein the first instruction carries N encryption modes, and N is an integer greater than or equal to 1; a sending module, for sending a second instruction to a target device, wherein the second instruction carries a set of data to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; a second receiving module, for receiving an encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode; a verification module, for verifying the correctness of the encryption result included in the encrypted file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and ciphertext of the standard data.

[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0015] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0016] Through the present application, since the test machine receives the first instruction sent by the control machine, the first instruction carries N encryption modes, N is an integer greater than or equal to 1; the test machine sends a second instruction to the target device, the second instruction carries a set of data to be encrypted and all or part of the encryption modes in the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the encryption modes in the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; the test machine receives the encrypted file sent by the target device, the encrypted file includes an encryption result, and the encryption result is the result obtained by the target device using the encryption mode to encrypt the data to be encrypted; the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database to obtain a verification result, and the standard database records the standard data and the ciphertext of the standard data. Therefore, the problem of low efficiency of manual verification of encryption algorithms in the related art can be solved, and the effect of improving the efficiency of verifying encryption algorithms can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a hardware structure block diagram of a server device of a method for verifying the correctness of an encryption result according to an embodiment of the present application;

[0018] Figure 2 is a flowchart of a method for verifying the correctness of an encryption result according to an embodiment of the present application;

[0019] Figure 3 is a schematic diagram of information interaction according to an embodiment of the present application;

[0020] Figure 4 It is a structural block diagram of a device for verifying the correctness of an encryption result according to an embodiment of the present application. DETAILED DESCRIPTION

[0021] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0022] Definitions of Abbreviations and Key Terms:

[0023] Solid State Drive, or SSD for short: a data storage device that uses flash memory technology. Compared to traditional hard drives, it has no mechanical parts, making it more durable and more responsive.

[0024] SMS4 Encryption Algorithm, SMS4Encryption Algorithm, is a group symmetric encryption algorithm issued by the China National Cryptography Administration, used for data encryption and communication security protection;

[0025] PCIe (Peripheral Component Interconnect Express): A high-speed serial computer expansion bus standard used to connect hardware components inside a computer and supports high-speed data transmission.

[0026] ECB (Electronic Codebook): Electronic codebook mode, a block encryption mode in which each data block is encrypted independently without considering the contents of other blocks.

[0027] CTR (Counter Mode): Counter mode, a security mode for block encryption algorithms, which uses a predictable counter to generate a key stream and is suitable for data stream encryption.

[0028] XTS (XOREncryptXOR): XOR encryption mode, a mode used for sector encryption, especially suitable for hard drive encryption, can prevent certain types of attacks.

[0029] CBC (Cipher Block Chaining): Cipher Block Chaining mode, a block encryption mode that performs an XOR operation on the result of the previous encryption (or initial vector) and the data block of the next encryption, and then encrypts it to increase security.

[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0031] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a method for verifying the correctness of an encryption result in an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 for communication functions and an input and output device 108. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0032] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for verifying the correctness of the encryption result in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0033] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0034] In this embodiment, a method for verifying the correctness of the encryption result is provided. Figure 2 is a flowchart of a method for verifying the correctness of an encryption result according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:

[0035] Step S202, the test machine receives a first instruction sent by the control machine, wherein the first instruction carries N encryption modes, where N is an integer greater than or equal to 1;

[0036] Among them, the test machine and the control machine are located in the same network environment.

[0037] Step S204: the test machine sends a second instruction to the target device, wherein the second instruction carries the data set to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to encrypt the data to be encrypted in the data set to be encrypted using all or part of the N encryption modes;

[0038] The N encryption modes include but are not limited to ECB, CTR, XTS, and CBC. The target device includes but is not limited to a solid state drive SSD.

[0039] Step S206, the test machine receives the encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode;

[0040] Step S208, the testing machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and ciphertext of the standard data.

[0041] The execution subject of the above steps may be a server, a terminal, etc., but is not limited thereto.

[0042] The present invention improves the verification efficiency and accuracy of encryption algorithms after they are applied to solid-state storage devices through an automated testing process. The method simplifies the testing steps, automates the testing process, and ensures the integrity and correctness of encrypted data.

[0043] like Figure 3 The figure shows a schematic diagram of information interaction. The script of the control machine uses a remote connection to the test machine. The script traverses the SM4 encryption algorithm mode (including but not limited to the above-mentioned ECB, CTR, XTS, and CBC). Different initialization functions are called according to different encryption modes to initialize the test environment, and the keyID of the encryption key is passed in. The above traversed parameters are remotely transmitted and sent to the test machine through the first instruction.

[0044] The target device to be tested (which may be a storage device, such as an SSD) is connected to the tester through an appropriate interface. These interfaces may be USB, SATA, Pcie or other suitable interfaces. The tester sends a second instruction to the target device through the interface. The second instruction carries an operation instruction and a set of data to be encrypted (the data to be encrypted in the set of data to be encrypted may be standard data), which will be used for subsequent encryption and decryption operations.

[0045] As an optional implementation manner, the target device uses the M firmwares corresponding to the M encryption modes to encrypt the data to be encrypted in the set of data to be encrypted respectively, including:

[0046] The target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtains an encryption result set of the i-th firmware, wherein i is an integer greater than or equal to 1 and less than or equal to M, and the i-th encryption mode is any encryption mode among the M encryption modes.

[0047] The above-mentioned i-th encryption mode can be any encryption mode among ECB, CTR, XTS, and CBC, and the i-th firmware contains the algorithm code of the i-th encryption mode. Taking the i-th encryption mode as ECB as an example, the set of data to be encrypted includes three data to be encrypted, A, B, and C. A, B, and C are encrypted respectively using the ECB algorithm code to obtain the encryption results QA, QB, and QC of ECB.

[0048] After receiving the second instruction, the target device writes the incoming data with SM4 encryption. The test machine reads the written ciphertext and generates a file, which can directly verify the correctness of the SM4 encryption algorithm and the performance of the storage device.

[0049] As an optional implementation, the target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each of the to-be-encrypted data in the to-be-encrypted data set, and obtains an encryption result set of the i-th firmware, including:

[0050] The i-th firmware obtains an encryption key from a pre-established key library, and uses the encryption key to perform an encryption operation on each to-be-encrypted data in the to-be-encrypted data set, to obtain an encryption result set of the i-th firmware.

[0051] The pre-established key library includes: the keyID of the encryption key transmitted by the control machine.

[0052] As an optional implementation, after the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes:

[0053] The i-th firmware is determined to be a qualified firmware if a correct encryption result in the encryption result set of the i-th firmware is greater than or equal to a preset threshold, and the test machine marks the i-th firmware as a qualified firmware in the verification result;

[0054] If a correct encryption result in the encryption result set of the i-th firmware is less than the preset threshold, it is determined that the i-th firmware is unqualified firmware, and the test machine marks the i-th firmware as unqualified firmware in the verification result.

[0055] The above preset threshold can be determined according to actual conditions, for example, 10, 20, etc., or a percentage can be set. For example, the encryption result set of the i-th firmware includes 100 encryption results, and the percentage threshold is set to 0.9. If 90 encryption results are correct, the i-th firmware is qualified firmware, otherwise the i-th firmware is unqualified firmware.

[0056] As an optional implementation, the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, including:

[0057] The test machine obtains a current encryption result to be verified from the encrypted file, wherein the current encryption result to be verified is a result obtained by the target device encrypting first data to be encrypted using a first encryption mode, the N encryption modes include the first encryption mode, and the set of data to be encrypted includes the first data to be encrypted;

[0058] The testing machine searches the standard database for first standard data identical to the first data to be encrypted, and determines the ciphertext of the first standard data in the standard database in the first encryption mode as the first ciphertext;

[0059] The test machine verifies the correctness of the encryption result included in the encrypted file based on whether the current encryption result to be verified is the same as the first ciphertext, wherein, in the case of the sameness, the test machine determines that the verification result of the current encryption result to be verified is a correct encryption result, and in the case of the differentness, the test machine determines that the verification result of the current encryption result to be verified is an incorrect encryption result.

[0060] The test machine compares the encrypted file it reads with the data in the standard database of the machine. If the encryption result to be verified is the same as the ciphertext recorded in the standard database, a successful mark is returned to the control machine; if the two are different, a failed mark is returned and the relevant failure log is recorded.

[0061] As an optional implementation, before the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes:

[0062] The test machine obtains a plurality of standard data, and uses each encryption mode of the N encryption modes to encrypt each of the plurality of standard data, respectively, to obtain ciphertext of each of the standard data in each encryption mode, including:

[0063] The test machine encrypts the second standard data to be encrypted in each of the N encryption modes to obtain N ciphertexts of the second standard data, wherein the plurality of standard data includes the second standard data;

[0064] The test machine establishes a corresponding relationship between the ciphertexts of each of the standard data in each of the encryption modes and records the corresponding relationship in the standard database, including:

[0065] The testing machine establishes a corresponding relationship between the second standard data and the N ciphertexts to obtain N encryption relationships of the second standard data;

[0066] The testing machine records the N encrypted relationships of the second standard data in the standard database;

[0067] After the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes:

[0068] The testing machine sends the verification result to the control machine.

[0069] As an optional implementation manner, after the test machine sends the second instruction to the target device, the method further includes:

[0070] The target device parses the to-be-encrypted data set and M encryption modes from the second instruction, where M is an integer greater than or equal to 1 and less than or equal to N;

[0071] The target device uses the M firmwares corresponding to the M encryption modes to encrypt the data to be encrypted in the set of data to be encrypted respectively.

[0072] The control machine checks the log file returned by the test machine (the log file contains the verification result). If successful, it proves that the SM4 encryption algorithm of the storage device tested this time is accurate; if failed, it proves that there is a problem with the SM4 encryption algorithm of the storage device tested this time. The control machine can perform fault analysis and problem location based on the failure information in the log file. This can improve the efficiency of repairing errors.

[0073] Prepare a test computer (hereinafter referred to as the test machine) and a computer for controlling the test (hereinafter referred to as the control machine), and ensure that the two machines are in the same network environment. The test machine should have a stable operating system and necessary hardware resources to ensure the smooth progress of the test process. The control machine is used to remotely control the test machine, execute the test script, and collect test results.

[0074] In order to prepare the test data standard library for the SM4 encryption algorithm, the pycryptodome cryptographic library in Python is used to generate keys and corresponding encrypted data in different encryption modes in accordance with the specific requirements of SM4. You can choose to traverse ECB, CTR, XTS, and CBC for testing, and the key length test traverses 128bit, 192bit, and 256bit, achieving the technical effect of improving the comprehensiveness of the test.

[0075] Prepare the corresponding plaintext data for each encryption mode. Plaintext is a standard number, which can be a specific value defined in the SM4 standard to ensure that the encryption process meets expectations. Use the pycryptodome cryptographic library in Python to enter the key and plaintext of the corresponding mode and perform the encryption operation. After the encryption operation is completed, record the ciphertext in each mode. Organize the generated plaintext and the corresponding ciphertext according to the SM4 algorithm standard to build a standardized test database.

[0076] Deploy the constructed standard database to the test machine to ensure that the test environment can access the data, so as to improve the efficiency of testing and verification of encryption algorithms.

[0077] In addition to the SM4 algorithm, the test method can be further expanded to support other encryption algorithms, such as DES, etc. This will make the test platform more comprehensive and able to meet the diverse needs of different users. By integrating multiple encryption algorithms, the advantages and disadvantages of various algorithms can be compared and analyzed, providing users with a more scientific and reasonable encryption solution selection.

[0078] Performance evaluation: In addition to verifying the correctness of the encryption algorithm, you can also consider evaluating the performance of encryption and decryption, including the speed of reading and writing encrypted data, to provide a reference for the selection and optimization of encryption algorithms. Performance evaluation can help users understand the performance of different encryption algorithms in actual applications, so as to make more reasonable choices.

[0079] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0080] In this embodiment, a device for verifying the correctness of the encryption result is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0081] Figure 4is a structural block diagram of a device for verifying the correctness of an encryption result according to an embodiment of the present application, such as Figure 4 As shown, the device includes: a first receiving module 42, used to receive a first instruction sent by a control machine, wherein the first instruction carries N encryption modes, and N is an integer greater than or equal to 1; a sending module 44, used to send a second instruction to a target device, wherein the second instruction carries a set of data to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; a second receiving module 46, used to receive an encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode; a verification module 48, used to verify the correctness of the encryption result included in the encrypted file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and the ciphertext of the standard data.

[0082] In an exemplary embodiment, the test machine is also used to obtain a current encryption result to be verified from the encrypted file, wherein the current encryption result to be verified is a result obtained by the target device encrypting first data to be encrypted using a first encryption mode, the N encryption modes include the first encryption mode, and the set of data to be encrypted includes the first data to be encrypted; searching the standard database for first standard data that is identical to the first data to be encrypted, and determining the ciphertext of the first standard data in the standard database under the first encryption mode as the first ciphertext; and verifying the correctness of the encryption result included in the encrypted file based on whether the current encryption result to be verified is identical to the first ciphertext, wherein, in the case of the sameness, determining the verification result of the current encryption result to be verified is a correct encryption result, and in the case of differentness, determining the verification result of the current encryption result to be verified is an incorrect encryption result.

[0083] In an exemplary embodiment, the test machine is also used to obtain multiple standard data, and use each encryption mode among the N encryption modes to encrypt each of the multiple standard data, and obtain the ciphertext of each of the standard data in various encryption modes, including: encrypting the second standard data to be encrypted in each of the N encryption modes, and obtaining N ciphertexts of the second standard data, wherein the multiple standard data include the second standard data; establishing a correspondence between the ciphertexts of each of the standard data in various encryption modes, and recording them in the standard database, including: establishing a correspondence between the second standard data and the N ciphertexts, and obtaining N encryption relationships of the second standard data; recording the N encryption relationships of the second standard data in the standard database; after the test machine verifies the correctness of the encryption result included in the encrypted file according to the pre-established standard database, the test machine is also used to send the verification result to the control machine.

[0084] In an exemplary embodiment, the target device is also used to parse the data set to be encrypted and M encryption modes from the second instruction, where M is an integer greater than or equal to 1 and less than or equal to N; the target device uses M firmware corresponding to the M encryption modes to encrypt the data to be encrypted in the data set to be encrypted respectively.

[0085] In an exemplary embodiment, the target device is also used to use the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtain an encryption result set of the i-th firmware, wherein i is an integer greater than or equal to 1 and less than or equal to M, and the i-th encryption mode is any encryption mode among the M encryption modes.

[0086] In an exemplary embodiment, the i-th firmware is also used to obtain an encryption key from a pre-established key library, and use the encryption key to perform encryption operations on each data to be encrypted in the data set to be encrypted, to obtain an encryption result set of the i-th firmware.

[0087] In an exemplary embodiment, if the correct encryption result in the encryption result set of the i-th firmware is greater than or equal to a preset threshold, it is determined that the i-th firmware is qualified firmware, and the test machine is also used to mark the i-th firmware as qualified firmware in the verification result; if the correct encryption result in the encryption result set of the i-th firmware is less than the preset threshold, it is determined that the i-th firmware is unqualified firmware, and the test machine is also used to mark the i-th firmware as unqualified firmware in the verification result.

[0088] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0089] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0090] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0091] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0092] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0093] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0094] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0095] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for verifying the correctness of an encryption result, characterized in that: include: The test machine receives a first instruction sent by the control machine, wherein the first instruction carries N encryption modes, where N is an integer greater than or equal to 1; The test machine sends a second instruction to the target device, wherein the second instruction carries a set of data to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; the test machine receives an encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode; the test machine verifies the correctness of the encryption result included in the encryption file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and the ciphertext of the standard data.

2. The method according to claim 1, characterized in that: The testing machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, including: The test machine obtains a current encryption result to be verified from the encrypted file, wherein the current encryption result to be verified is a result obtained by the target device encrypting first data to be encrypted using a first encryption mode, the N encryption modes include the first encryption mode, and the set of data to be encrypted includes the first data to be encrypted; The testing machine searches the standard database for first standard data identical to the first data to be encrypted, and determines the ciphertext of the first standard data in the standard database in the first encryption mode as the first ciphertext; The test machine verifies the correctness of the encryption result included in the encrypted file based on whether the current encryption result to be verified is the same as the first ciphertext, wherein, in the case of the sameness, the test machine determines that the verification result of the current encryption result to be verified is a correct encryption result, and in the case of the differentness, the test machine determines that the verification result of the current encryption result to be verified is an incorrect encryption result.

3. The method according to claim 1, characterized in that Before the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes: The test machine obtains a plurality of standard data, and uses each encryption mode of the N encryption modes to encrypt each standard data of the plurality of standard data, to obtain ciphertext of each standard data in each encryption mode, including: The test machine encrypts the second standard data to be encrypted in each of the N encryption modes to obtain N ciphertexts of the second standard data, wherein the plurality of standard data includes the second standard data; The test machine establishes a corresponding relationship between the ciphertexts of each of the standard data in each of the encryption modes and records the corresponding relationship in the standard database, including: The testing machine establishes a corresponding relationship between the second standard data and the N ciphertexts to obtain N encryption relationships of the second standard data; The testing machine records the N encrypted relationships of the second standard data in the standard database; After the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes: The testing machine sends the verification result to the control machine.

4. The method according to any one of claims 1 to 3, characterized in that After the test machine sends the second instruction to the target device, the method further includes: The target device parses the to-be-encrypted data set and M encryption modes from the second instruction, where M is an integer greater than or equal to 1 and less than or equal to N; The target device uses the M firmwares corresponding to the M encryption modes to encrypt the data to be encrypted in the set of data to be encrypted respectively.

5. The method according to claim 4, characterized in that The target device uses the M firmwares corresponding to the M encryption modes to encrypt the data to be encrypted in the set of data to be encrypted respectively, including: The target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each data to be encrypted in the data set to be encrypted, and obtains an encryption result set of the i-th firmware, wherein i is an integer greater than or equal to 1 and less than or equal to M, and the i-th encryption mode is any encryption mode among the M encryption modes.

6. The method according to claim 5, characterized in that The target device uses the i-th firmware corresponding to the i-th encryption mode to perform encryption operations on each of the to-be-encrypted data in the to-be-encrypted data set, and obtains an encryption result set of the i-th firmware, including: The i-th firmware obtains an encryption key from a pre-established key library, and uses the encryption key to perform an encryption operation on each to-be-encrypted data in the to-be-encrypted data set, to obtain an encryption result set of the i-th firmware.

7. The method according to claim 5 or 6, characterized in that: After the test machine verifies the correctness of the encryption result included in the encrypted file according to a pre-established standard database, the method further includes: The i-th firmware is determined to be a qualified firmware if a correct encryption result in the encryption result set of the i-th firmware is greater than or equal to a preset threshold, and the test machine marks the i-th firmware as a qualified firmware in the verification result; If a correct encryption result in the encryption result set of the i-th firmware is less than the preset threshold, it is determined that the i-th firmware is unqualified firmware, and the test machine marks the i-th firmware as unqualified firmware in the verification result.

8. A device for verifying the correctness of an encryption result, characterized in that: Applicable to test machines, including: include: A first receiving module, used for receiving a first instruction sent by a control machine, wherein the first instruction carries N encryption modes, where N is an integer greater than or equal to 1; A sending module is used to send a second instruction to a target device, wherein the second instruction carries a set of data to be encrypted and all or part of the N encryption modes, and the second instruction is used to instruct the target device to use all or part of the N encryption modes to encrypt the data to be encrypted in the set of data to be encrypted; a second receiving module is used to receive an encrypted file sent by the target device, wherein the encrypted file includes an encryption result, and the encryption result is a result obtained by the target device encrypting the data to be encrypted using the encryption mode; a verification module is used to verify the correctness of the encryption result included in the encrypted file according to a pre-established standard database to obtain a verification result, wherein the standard database records standard data and the ciphertext of the standard data.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.