Decryption verification method, device, electronic chip and storage medium
By running the assembler on the working chip of the embedded device and using the Montgomery algorithm for decryption processing, the problem of the need for a dedicated chip for decryption of embedded devices in the prior art is solved, efficient decryption verification is achieved and system complexity is reduced.
Patent Information
- Application Number
- CN202111657512.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2041-12-30
AI Technical Summary
When decrypting in embedded devices in prior art, special decoding chips are required, resulting in large size, high cost and high system complexity, making it difficult to be suitable for embedded devices with smaller sizes.
By running an assembler program written in assembly language on the working chip of the lower computer, the Montgomery algorithm is used to decrypt the encrypted data, and the initial message data is processed based on the hash function and preset data filling method to achieve decryption verification.
Without adding dedicated encryption chips, the decoding efficiency of embedded devices is improved, the system complexity is reduced, and it is suitable for embedded devices with smaller sizes.
Smart Images

Figure CN114297694B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of encryption and decryption algorithms, and in particular to a decryption verification method, device, electronic chip and storage medium. Background Art
[0002] In order to achieve security verification of embedded devices, it is usually necessary to use a decryption algorithm to decrypt the encrypted data.
[0003] In the prior art, when decrypting, the method generally adopted is to install a dedicated decoding chip in the embedded device, implement hardware decoding based on the dedicated decoding chip, and thus perform decryption processing.
[0004] However, if a dedicated decoding chip is installed, the entire embedded device will be larger in size and is not suitable for smaller embedded devices, such as charging cables. In addition, the additional chip will also result in higher costs and higher complexity of the entire embedded system. Summary of the invention
[0005] The purpose of this application is to provide a decryption verification method, device, electronic chip and storage medium, which can achieve fast decoding based on a smaller embedded device, thereby improving the decoding efficiency and reducing the complexity of the system.
[0006] The embodiment of the present application is implemented as follows:
[0007] In one aspect of an embodiment of the present application, a decryption verification method is provided, which is applied to a working chip of a lower computer, the lower computer is communicatively connected with a host computer, and the method includes:
[0008] Sending initial message data to the host computer, where the initial message data is a digital message generated by the working chip;
[0009] Receive the encrypted data sent by the host computer, where the encrypted data is the digital signature data obtained by the host computer through RSA encryption based on the initial message data;
[0010] Run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on the hash function and the preset data filling method to obtain verification data, and determine whether the decrypted data and the verification data meet the preset requirements. If so, determine that the decryption verification is successful.
[0011] Optionally, decrypting the encrypted data to obtain decrypted data includes:
[0012] Perform modular exponentiation on the encrypted data using assembly language to obtain decrypted data. The modular exponentiation is the Montgomery algorithm.
[0013] Optionally, before performing modular exponentiation operation on the encrypted data using assembly language, the method further comprises:
[0014] The target decryption method is determined based on the pre-configured security level, and the target decryption method includes: public key decryption or private key decryption.
[0015] Optionally, using assembly language to perform modular exponentiation operation on the encrypted data to obtain decrypted data includes:
[0016] The encrypted data is subjected to equivalent operations of large number exponentiation, large number simplification, small number multiplication, small number multiplication cyclic accumulation, equivalent operation of large number modulus operation, modulus simplification and grouping, modulus address transfer, modulus decomposition operation, modulus cyclic operation, large modulus exponentiation operation and modulus exponentiation supplement operation to obtain decrypted data.
[0017] Optionally, the initial message data is processed based on a hash function and a preset data filling method to obtain verification data, including:
[0018] Processing the initial message data based on the hash function to obtain a hash function value;
[0019] Performing length supplementation processing on the hash function value to establish an encryption block, the encryption block includes: a leading byte, an operation type identifier, a padding byte, a separation character byte and a payload data;
[0020] Output the encrypted block as verification data.
[0021] Optionally, before performing length supplementation processing on the hash function value to establish the encryption block, the method further includes:
[0022] Determining the message supplemental length based on a preconfigured security level;
[0023] The hash function value is length-complemented to create an encrypted block, including:
[0024] The hash function value is length-complemented according to the message complement length to create an encrypted block.
[0025] Optionally, determining whether the decrypted data and the verification data meet preset requirements includes:
[0026] Determine whether the value of the decrypted data is equal to the value of the verification data.
[0027] Another aspect of the embodiment of the present application provides a decryption verification device, which is applied to a working chip of a lower computer, and the lower computer is communicatively connected with a host computer, and the device includes: a sending module, a receiving module and a processing module;
[0028] A sending module, used to send initial message data to the host computer, where the initial message data is a digital message generated by the working chip;
[0029] The receiving module is used to receive the encrypted data sent by the host computer, where the encrypted data is the digital signature data obtained by the host computer through RSA encryption based on the initial message data;
[0030] The processing module is used to run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on the hash function and the preset data filling method to obtain verification data, and determine whether the decrypted data and the verification data meet the preset requirements. If so, determine that the decryption verification is successful.
[0031] Optionally, the processing module is specifically used to perform a modular exponentiation operation on the encrypted data to obtain decrypted data, and the modular exponentiation operation is a Montgomery algorithm.
[0032] Optionally, the processing module is further used to determine a target decryption method based on a pre-configured security level, where the target decryption method includes: public key decryption or private key decryption.
[0033] Optionally, the processing module is specifically used to perform equivalent operations of large number exponentiation, large number simplification, small number multiplication, small number multiplication and cyclic accumulation, equivalent operations of large number modulus operation, modulus simplification and grouping, modulus address transfer, modulus decomposition operation, modulus cyclic operation, modulus large cyclic operation and modulus supplementation operation on the encrypted data to obtain decrypted data.
[0034] Optionally, the processing module is specifically used to process the initial message data based on the hash function to obtain a hash function value; perform length supplementation processing on the hash function value to establish an encryption block, the encryption block includes: a leading byte, an operation type identifier, a padding byte, a separation character segment and payload data; and output the encryption block as verification data.
[0035] Optionally, the processing module is further used to determine the message supplement length based on a pre-configured security level; and perform length supplement processing on the hash function value according to the message supplement length to establish an encryption block.
[0036] Optionally, the processing module is specifically used to determine whether the value of the decrypted data is equal to the value of the verification data.
[0037] Another aspect of an embodiment of the present application provides an electronic chip including: a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the steps of the above-mentioned decryption and verification method are implemented.
[0038] In another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned decryption and verification method are implemented.
[0039] The beneficial effects of the embodiments of the present application include:
[0040] In a decryption verification method, device, electronic chip and storage medium provided by the embodiment of the present application, initial message data can be sent to the host computer, and the initial message data is a digital message generated by the working chip; the encrypted data sent by the host computer is received, and the encrypted data is the digital signature data obtained by the host computer based on the initial message data through RSA encryption; the assembly program written in assembly language on the working chip is run to decrypt the encrypted data to obtain decrypted data, and the initial message data is processed based on the hash function and the preset data filling method to obtain verification data, and it is determined whether the decrypted data and the verification data meet the preset requirements. If so, it is determined that the decryption verification is successful. Among them, when performing decoding verification, it can be specifically performed by the working chip based on the assembly written in assembly language to perform program decoding verification, without the need to set up a dedicated decoding chip, and can be suitable for security verification on smaller embedded devices; and in the process of verification, it is implemented by assembly language, without relying on other computer devices and other calculations, which improves the efficiency of verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A schematic diagram of a scenario of a decryption verification method provided in an embodiment of the present application;
[0043] Figure 2 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 1 ;
[0044] Figure 3 A schematic diagram of a specific process of performing the Montgomery algorithm in the decryption verification method provided in an embodiment of the present application;
[0045] Figure 4 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 2 ;
[0046] Figure 5 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 3;
[0047] Figure 6 A schematic diagram of the overall process of the decryption verification method provided in an embodiment of the present application;
[0048] Figure 7 A schematic diagram of the structure of a decryption verification device provided in an embodiment of the present application;
[0049] Figure 8 A schematic diagram of the structure of the electronic chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0051] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0052] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0053] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0054] It should be noted that in data encryption technology, RSA is currently recognized by the industry as the most secure and mature public key cryptographic system. RSA can not only realize data encryption and decryption, but also meet the needs of digital signature authentication and identity recognition, and is a representative of public key cryptographic algorithms. However, the security of its algorithm is based on the difficulty of large integer decomposition. With the improvement of computer processing power, the security of RSA is increasingly dependent on more complex mathematical operations. However, exponentiation is the speed bottleneck of RSA, and the Montgomery algorithm is considered to be the fastest algorithm for calculating large number modular multiplication, which can greatly improve the encryption and decryption efficiency of RSA. Even so, in practical applications, the implementation of the Montgomery algorithm is still very dependent on the ability of the computer processor, and it takes a long time to call the existing high-level language function library, which also limits the implementation of the RSA algorithm on some low-power, low-performance chips, and hinders the application and development of embedded development encryption algorithms. In this application, the underlying assembly language programming method can be used to speed up the operation speed by 50% to 70%.
[0055] In order to implement the RSA encryption algorithm in embedded devices, the existing solution is to use a dedicated decoding chip, that is, hardware decoding, which increases the volume, cost and system complexity. The technical means adopted in this application can improve the chip's computing efficiency without adding an additional dedicated encryption chip.
[0056] The following is a detailed explanation of an implementation example of a practical application scenario of the decryption verification method provided in the embodiments of the present application.
[0057] Figure 1 For a schematic diagram of the scenario of the decryption verification method provided in the embodiment of the present application, please refer to Figure 1 , the scenario includes: a working chip 110 of the lower computer and a host computer 120 .
[0058] Optionally, the working chip 110 of the lower computer can be connected to the upper computer 120 for communication. Specifically, the working chip 110 of the lower computer can be a working chip in a relatively small embedded device, such as a working chip in a charging cable; the upper computer 120 can be a device for sending encrypted data to the working chip 110 in the lower computer, such as when the working chip 110 of the lower computer is a working chip in a charging cable, the upper computer 120 can be a mobile phone or other electronic device that can be charged based on a charging cable, and this is not limited here.
[0059] Among them, the working chip 110 of the lower computer can specifically be a chip that works based on an assembler program written in assembly language. The chip can execute a series of assembly algorithms based on a pre-configured assembler program, such as addition, subtraction, multiplication, division, judgment, comparison, etc., which is not limited here.
[0060] Optionally, taking the working chip 110 of the lower computer as the working chip in the charging cable and the upper computer 120 as a mobile phone as an example, the decryption verification method can specifically be a specific process of charging verification after the charging cable is connected to the mobile phone, or, when performing other types of data transmission and other tasks, the transmitted data can also be verified accordingly, but is not limited to this.
[0061] The specific implementation process of the decryption verification method provided in the embodiment of the present application is explained below based on the above-mentioned actual application scenario.
[0062] Figure 2 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 1 , please refer to Figure 2 , the method comprising:
[0063] S210: Send initial message data to the host computer.
[0064] The initial message data is a digital message generated by the working chip.
[0065] Optionally, the execution subject of the method may be a working chip of the above-mentioned lower computer, and the working chip may send initial message data to the upper computer after establishing a connection with the upper computer, wherein the initial message data may be a digital message automatically generated by the working chip.
[0066] For example, taking mobile phone charging authentication as an example, the working chip in the charging cable can send an authentication request to the mobile phone after the charging cable is connected to the mobile phone. The authentication request can be the above-mentioned initial message data.
[0067] S220: Receive the encrypted data sent by the host computer.
[0068] The encrypted data is the digital signature data obtained by the host computer through RSA encryption based on the initial message data.
[0069] Optionally, after receiving the above-mentioned initial message data, the upper computer can generate encrypted data and send the encrypted data to the working chip of the lower computer, wherein the encrypted data can be the digital signature data obtained by the upper computer based on the initial message data by RSA encryption, wherein RSA encryption can specifically be an asymmetric encryption algorithm, and this type of encryption algorithm has a pair of secret keys, one of which is used for encryption and the other for decryption. One of the secret keys can be selected as a private key (to be kept by oneself) and the other as a public key (to be disclosed to the public). Content encrypted with a private key can only be decrypted with the corresponding public key, and conversely, content encrypted with a public key can only be decrypted with the corresponding private key.
[0070] For example, taking mobile phone charging authentication as an example, after receiving the authentication request, the mobile phone can send verification data to the charging cable, and the verification data can be the above-mentioned encrypted data.
[0071] S230: Run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on the hash function and the preset data filling method to obtain verification data, and determine whether the decrypted data and the verification data meet the preset requirements. If so, determine that the decryption verification is successful.
[0072] Optionally, after the working chip of the lower computer receives the encrypted data, it can perform decryption processing. The specific decryption processing steps can be to decrypt the encrypted data based on a preset decryption method to obtain decrypted data; and, in order to ensure security, the decrypted data can also be verified. The specific process of verification can be to process the initial message data based on a hash function and a preset data filling method to obtain verification data, and then compare the decrypted data with the verification data to determine whether the verification is successful.
[0073] The hash function may be the same as the hash function used by the host computer during the encryption process, for example, a hash function; the result calculated using the same hash function has the same data length, that is, the hash function constant length.
[0074] When determining the verification result, it can be determined whether the decrypted data and the verification data meet the preset requirements, which can be a preset numerical relationship, for example: determining whether the value of the decrypted data is equal to the value of the verification data. If the two are equal, it can be determined that the verification is successful, that is, the decrypted data is correct.
[0075] It should be noted that, in the process of executing the above S230, it can be based on an assembly program written in assembly language on the working chip. The assembly program has a specific pre-written processing flow, which can process the encrypted data and the initial message data respectively to obtain decrypted data and verification data.
[0076] In a decryption verification method provided by an embodiment of the present application, initial message data can be sent to a host computer, and the initial message data is a digital message generated by a working chip; encrypted data sent by the host computer is received, and the encrypted data is digital signature data obtained by the host computer based on RSA encryption of the initial message data; an assembly program written in assembly language on the working chip is run to decrypt the encrypted data to obtain decrypted data, and the initial message data is processed based on a hash function and a preset data filling method to obtain verification data, and it is determined whether the decrypted data and the verification data meet the preset requirements. If so, it is determined that the decryption verification is successful. Among them, when performing decoding verification, it can be specifically performed by the working chip based on the assembly written in assembly language to perform program decoding verification, without the need to set up a dedicated decoding chip, and can be suitable for security verification on smaller embedded devices; and in the process of verification, it is implemented by assembly language, without relying on other computer devices and other calculations, which improves the efficiency of verification.
[0077] Optionally, decrypting the encrypted data to obtain the decrypted data includes: performing modular exponentiation operation on the encrypted data using assembly language to obtain the decrypted data, wherein the modular exponentiation operation is a Montgomery algorithm.
[0078] After receiving the encrypted data, the working chip of the lower computer may use a preset decryption method to decrypt the encrypted data. The decryption method may specifically be modular exponentiation operation, which may be implemented using the Montgomery algorithm.
[0079] Optionally, before performing modular exponentiation operation on the encrypted data using assembly language, the method further includes: determining a target decryption method based on a preconfigured security level, the target decryption method including: public key decryption or private key decryption.
[0080] Optionally, since the RSA encryption method can include two methods: private key encryption and public key decryption and public key encryption and private key decryption; before performing modular exponentiation operation on the encrypted data, the encryption method adopted by the upper computer can be determined. Specifically, the encryption method adopted by the upper computer can be determined according to the pre-configured security level. After determining the encryption method adopted by the upper computer, the target decryption method can be determined, thereby determining whether to use public key decryption or private key decryption, and then performing corresponding decryption.
[0081] The pre-configured security level may be a level determined according to the risk level of the data. Different encryption and decryption methods may be used for different levels, and no specific limitation is made here.
[0082] The following is a detailed explanation of the specific implementation process based on the Montgomery algorithm in the decryption verification method provided in the embodiment of the present application.
[0083] Figure 3For a specific flow chart of the Montgomery algorithm in the decryption verification method provided in the embodiment of the present application, please refer to Figure 3 , use assembly language to perform modular exponentiation operation on encrypted data to obtain decrypted data, including: performing equivalent operation of large number exponentiation operation, simplification of large numbers, small number multiplication operation, small number multiplication cyclic accumulation operation, equivalent operation of large number modulus operation, simplification and grouping of moduli, transfer of modulus addresses, modular decomposition operation, modular cyclic operation, large modular exponentiation operation and modular exponentiation supplement operation on the encrypted data to obtain decrypted data.
[0084] S301: Performing an equivalent operation of large number exponentiation operation on the encrypted data.
[0085] S302: Simplify large numbers.
[0086] S303: Perform decimal multiplication operation.
[0087] S304: Perform decimal multiplication and accumulation operations to store the addition of high and low byte bits into a RAM address.
[0088] S305: Determine whether the number of loops is equal to the number of decimal units; if so, execute S306; if not, execute S303.
[0089] S306: Perform an equivalent operation of a large number modulo operation.
[0090] S307: Simplify and group the moduli.
[0091] S308: Perform modulus address transfer, and transfer what needs to be taken out from the ROM address to the RAM address.
[0092] S309: Perform a modulo decomposition operation.
[0093] S310: Perform a modulo loop operation.
[0094] S311: Determine whether the number of cycles is equal to the number of groups after the modulus simplification. If so, execute S312; if not, execute S309.
[0095] S312: Perform a large exponentiation cycle operation.
[0096] S313: Determine whether the number of cycles is equal to the number of periods. If so, execute S314; if not, execute S302.
[0097] S314: Perform a power module supplement operation to obtain decrypted data.
[0098] The specific implementation content of each execution step is as follows:
[0099] Equivalent operation of large number exponentiation: In the calculation process, the modulus MUL is the source of the public key p and the private key q, that is, MUL = p*q. The base of the large number is C, and the exponent is Zm. The specific Zm can be simplified to the form of 2 integer power Zn with remainder Zo, so the exponentiation operation of the large number C can be simplified to: C 2 Raise the result to the Zn power and multiply it by C to the Zo power.
[0100] Simplification of large numbers: Use different chips' on-chip resources and different operations to implement large number multiplication. The length of the large number multiplier is NUM bits, and the minimum length that the chip can perform multiplication is CAL_LEN bits.
[0101] Calculate the number of groups after the large number is simplified: BLOCK = NUM / CAL_LEN. The large number is divided into BLOCK number of decimal units a0 to an.
[0102] Decimal multiplication operation: According to the principle of large number multiplication decomposition, large number multiplication can be decomposed into decimal multiplication. Starting from the lowest decimal unit a0, calculate the square of a0, store the high and low bytes of the result, and complete the first single cycle. The second cycle calculates a1*a0 and a1*a1. Calculate in this way until the nth cycle, n=BLOCK.
[0103] Decimal multiplication loop accumulation operation: Decimal multiplication operation performs a total of BLOCK loop operation cycles, traversing and calculating the product of a single decimal unit and each decimal unit, in the form of (a0+a1+…+an) 2 Complete square expansion form. After calculating the product result in each cycle, the high and low byte bits are accumulated and stored according to the address bit according to the multiplication decomposition accumulation rule. Stored to the RAM (Random Access Memory) address of the working chip, a total of 2*BLOCK storage addresses, the result data is NUM_ar. Finally, a large number square operation is completed.
[0104] The equivalent operation of the modulo operation of large numbers is: after the large number is squared, the result is modulo the modulus MUL.
[0105] Modulus simplification and grouping: Utilize the on-chip resources of different chips and adopt different modulus operations to implement large number modulus operations. The modulus length of large numbers is NUM_MUL bits, and the minimum length that the chip can perform division operations on is DIV_LEN bits.
[0106] Calculate the number of groups after the modulus simplification BLOCK_MUL = NUM_MUL / DIV_LEN. The large modulus is divided into BLOCK_MUL number of decimal units b0 to bm.
[0107] Modulus address transfer: After the RSA encryption and decryption mode is determined, it means that the three numbers MUL, p, and q are determined. MUL is fixed in the chip ROM (Read-Only Memory). Before calculation, it needs to be taken out from the ROM address and transferred to the RAM address, which can improve the efficiency of modulus calculation.
[0108] Modulo decomposition operation: According to the principle of large number modulo decomposition, large number modulo decomposition can be decomposed into decimal multiplication, division and subtraction operations. The input data is the data NUM_ar of 2*BLOCK storage addresses obtained by the aforementioned decimal multiplication and accumulation operation and the modulo decomposition units b0~bm. Multiplication and division are performed according to the rules, and the results are calculated bit by bit and stored in the high and low bytes. Finally, the calculation result is subtracted from NUM_ar and stored again in the 2*BLOCK storage addresses.
[0109] Modulo cycle operation: perform BLOCK_MUL cycles of modulo decomposition operation and finally output the result NUM_br. After this step, the large number modulo operation is completed and C is obtained. 2 Calculation result of %MUL.
[0110] Modulo exponentiation cycle operation: The public key p or the private key q determines the exponent of the exponentiation operation, and the above steps are continued in a cycle with the number of cycles being Zn.
[0111] Modular supplementation of exponentiation: Complete Zo times of modular supplementation of exponentiation of base C. This method is similar to the above-mentioned loop steps. The difference is that when calculating large number multiplication, the multiplier and multiplicand are not the same, and the expanded form of the decimal operation should be (a0+a1+…+an)*(b0+b1+…+bn).
[0112] After processing based on the above steps, the above decrypted data can be obtained.
[0113] Another specific implementation process of the decryption verification method provided in the embodiment of the present application is explained in detail below.
[0114] Figure 4 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 2 , please refer to Figure 4 , based on the hash function and the preset data filling method, the initial message data is processed to obtain verification data, including:
[0115] S410: Processing the initial message data based on the hash function to obtain a hash function value.
[0116] Optionally, the initial message data may be processed based on a hash function first, specifically by performing a function operation to obtain a mapping result of the initial message data in a hash function table, and then using the result as a hash function value.
[0117] S420: Perform length supplementation processing on the hash function value to create an encryption block.
[0118] The encryption block includes: a leading byte, an operation type identifier, a padding byte, a separation character byte, and payload data.
[0119] Optionally, the preset data filling method is specifically to fill based on the encryption block method, and the encryption block may specifically be content composed of multiple characters. The specific content of the encryption block is as follows:
[0120] Encrypted block EB = 00||BT||PS1~PSm||00||D1~Dn||. The first 00 may be the above-mentioned leading byte, BT may be a description of the operation type of the encrypted block (for example, 01 represents private key operation, 02 represents public key operation), PS1~PSm may be padding bytes, the value of private key operation is FF (hex), the value of public key operation is a non-zero random number, the last 00 may be a separator character, D1~Dn may be payload data, wherein the payload data may include a hash function identifier, that is, the above-mentioned hash function value.
[0121] S430: Output the encrypted block as verification data.
[0122] Optionally, after obtaining the above encryption block, the encryption block can be output as verification data.
[0123] The following is another specific implementation process of the decryption verification method provided in the embodiment of the present application.
[0124] Figure 5 Schematic diagram of the decryption verification method provided in the embodiment of the present application Figure 3 , please refer to Figure 5 Before performing length supplementation processing on the hash function value to establish the encryption block, the method further comprises:
[0125] S510: Determine the message supplement length based on the pre-configured security level.
[0126] Optionally, the corresponding message supplement length may be determined based on a pre-configured security level. It should be noted that different message supplement lengths may be configured for different security levels.
[0127] The commonly used key lengths can be 512 bits, 1024 bits, 2048 bits, etc. according to the level. The corresponding level length can be supplemented according to actual needs, and there is no restriction here.
[0128] The hash function value is length-complemented to create an encrypted block, including:
[0129] S520: Perform length supplementation processing on the hash function value according to the message supplementation length to establish an encryption block.
[0130] Optionally, after determining the message supplement length, the hash function value may be subjected to length supplement processing according to the message supplement length to establish an encryption block.
[0131] The following is a detailed explanation of the overall implementation process of the decryption verification method provided in the embodiment of the present application.
[0132] Figure 6 For the overall flow chart of the decryption verification method provided in the embodiment of the present application, please refer to Figure 6 , the method comprising:
[0133] S610: Receive encrypted data sent by the host computer.
[0134] S620: Perform Montgomery decryption on the encrypted data to obtain decrypted data.
[0135] S630: Process the initial message data based on the hash function to obtain a hash function value.
[0136] S640: Perform length supplementation processing on the hash function value to create an encryption block.
[0137] S650: Output the encrypted block as verification data.
[0138] S660: Determine whether the value of the decrypted data is equal to the value of the verification data. If so, execute S670.
[0139] S670: Determine whether the decryption verification is successful.
[0140] It should be noted that the above steps S610-S620 and S630-S650 can be performed simultaneously, and after obtaining the decrypted data and the verification data respectively, S660-S670 can be performed in sequence. The specific implementation process of the above steps has been explained above, and will not be repeated here.
[0141] The following describes the devices, equipment, storage media, etc. corresponding to the decryption and verification method provided by the present application. The specific implementation process and technical effects are described above and will not be repeated below.
[0142] Figure 7 For a schematic diagram of the structure of the decryption verification device provided in the embodiment of the present application, please refer to Figure 7, the device includes: a sending module 710, a receiving module 720 and a processing module 730;
[0143] A sending module 710 is used to send initial message data to a host computer, where the initial message data is a digital message generated by a working chip;
[0144] The receiving module 720 is used to receive the encrypted data sent by the host computer, where the encrypted data is the digital signature data obtained by the host computer through RSA encryption based on the initial message data;
[0145] The processing module 730 is used to run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on the hash function and the preset data filling method to obtain verification data, and determine whether the decrypted data and the verification data meet the preset requirements. If so, it is determined that the decryption verification is successful.
[0146] Optionally, the processing module 730 is specifically configured to perform a modular exponentiation operation on the encrypted data to obtain decrypted data, wherein the modular exponentiation operation is a Montgomery algorithm.
[0147] Optionally, the processing module 730 is further configured to determine a target decryption method based on a preconfigured security level, where the target decryption method includes: public key decryption or private key decryption.
[0148] Optionally, the processing module 730 is specifically used to perform equivalent operations of large number exponentiation, large number simplification, small number multiplication, small number multiplication and cyclic accumulation, equivalent operations of large number modulus operation, modulus simplification and grouping, modulus address transfer, modulus decomposition operation, modulus cyclic operation, modulus large cyclic operation and modulus supplement operation on the encrypted data to obtain decrypted data.
[0149] Optionally, the processing module 730 is specifically used to process the initial message data based on the hash function to obtain a hash function value; perform length supplementation processing on the hash function value to establish an encryption block, the encryption block includes: a leading byte, an operation type identifier, a padding byte, a separation character segment and payload data; and output the encryption block as verification data.
[0150] Optionally, the processing module 730 is further configured to determine a message supplement length based on a preconfigured security level; and perform length supplement processing on the hash function value according to the message supplement length to establish an encryption block.
[0151] Optionally, the processing module 730 is specifically configured to determine whether the value of the decrypted data is equal to the value of the verification data.
[0152] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0153] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0154] Figure 8 For a schematic diagram of the structure of the electronic chip provided in the embodiment of the present application, please refer to Figure 8 The electronic chip includes: a memory 810 and a processor 820. The memory 810 stores a computer program that can be run on the processor 820. When the processor 820 executes the computer program, the steps of the above-mentioned decryption and verification method are implemented.
[0155] Optionally, the electronic chip is the working chip in the aforementioned lower computer.
[0156] In another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned decryption and verification method are implemented.
[0157] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0159] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0160] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0161] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0162] 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 spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A decryption verification method, characterized in that: The method is applied to a working chip of a lower computer, the lower computer is communicatively connected with a host computer, and the method comprises: Sending initial message data to the host computer, wherein the initial message data is a digital message generated by the working chip; Receive encrypted data sent by the host computer, where the encrypted data is digital signature data obtained by the host computer through RSA encryption based on the initial message data; Run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on a hash function and a preset data filling method to obtain verification data, determine whether the decrypted data and the verification data meet preset requirements, and if so, determine that the decryption verification is successful.
2. The method according to claim 1, characterized in that The decrypting the encrypted data to obtain the decrypted data comprises: The encrypted data is subjected to modular exponentiation operation using assembly language to obtain the decrypted data, wherein the modular exponentiation operation is a Montgomery algorithm.
3. The method according to claim 2, characterized in that Before performing modular exponentiation operation on the encrypted data using assembly language, the method further includes: The target decryption mode is determined based on a pre-configured security level, and the target decryption mode includes: public key decryption or private key decryption.
4. The method according to claim 2, characterized in that The step of performing modular exponentiation operation on the encrypted data using assembly language to obtain the decrypted data includes: The encrypted data is subjected to equivalent operations of large number exponentiation, large number simplification, small number multiplication, small number multiplication cyclic accumulation, large number modulus operation, modulus simplification and grouping, modulus address transfer, modulus decomposition, modulus cyclic operation, large modulus exponentiation operation and modulus exponentiation supplementation to obtain the decrypted data.
5. The method according to claim 1, characterized in that The processing of the initial message data based on the hash function and the preset data filling method to obtain verification data includes: Processing the initial message data based on the hash function to obtain a hash function value; Performing length supplementation processing on the hash function value to establish an encryption block, wherein the encryption block includes: a leading byte, an operation type identifier, a padding byte, a separation character segment, and payload data; The encrypted block is output as verification data.
6. The method according to claim 5, characterized in that Before performing length supplementation processing on the hash function value to establish an encryption block, the method further includes: Determining the message supplemental length based on a preconfigured security level; The performing length supplementation processing on the hash function value to establish an encryption block includes: The hash function value is length-complemented according to the message supplement length to create an encryption block.
7. The method according to any one of claims 1 to 6, characterized in that: The determining whether the decrypted data and the verification data meet preset requirements includes: It is determined whether the value of the decrypted data is equal to the value of the verification data.
8. A decryption verification device, characterized in that: The device is applied to a working chip of a lower computer, the lower computer is communicatively connected with a host computer, and the device comprises: a sending module, a receiving module and a processing module; The sending module is used to send initial message data to the host computer, wherein the initial message data is a digital message generated by the working chip; The receiving module is used to receive the encrypted data sent by the host computer, wherein the encrypted data is the digital signature data obtained by the host computer through RSA encryption based on the initial message data; The processing module is used to run the assembly program written in assembly language on the working chip, decrypt the encrypted data to obtain decrypted data, and process the initial message data based on a hash function and a preset data filling method to obtain verification data, and determine whether the decrypted data and the verification data meet preset requirements. If so, determine that the decryption verification is successful.
9. An electronic chip, characterized in that: include: A memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the steps of the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Encryption method and equipment applied to key security
CN106506159A
Software encryption and decryption method for vehicle-mounted decoder
CN108171018A