Method for generating secure private key, encryption method, system, device and medium

By performing preset rule conversion and hardware identification conversion on the original private key, a secure private key is generated and stored, which solves the risk of theft of the private key when it is saved on the terminal, and achieves trusted storage of the private key and the security of the encryption process.

CN111949996BActive Publication Date: 2024-10-11QI AN XIN TECHNOLOGY GROUP INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910406116.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-05-15
Publication Date
2024-10-11
Estimated Expiration
2039-05-15

AI Technical Summary

Technical Problem

In the existing technology, there is a risk of the private key being stolen when stored in the terminal, and there is a lack of effective secure storage solutions.

Method used

By obtaining the original private key and performing the first conversion according to the preset rules, the intermediate private key is obtained, and then the hardware identification of the device hardware is used for the second conversion to generate a secure private key and store it in the local system to ensure that it cannot be reversed by the outside world. Get the original private key.

Benefits of technology

It achieves trusted storage of private keys, prevents private keys from being stolen, reduces development difficulty, improves system computing speed, and ensures the security of the encryption process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111949996B_ABST
    Figure CN111949996B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for generating a secure private key, which can realize the trusted storage of the private key. The method for generating a secure private key comprises: obtaining an original private key, performing a first conversion on the original private key according to a preset rule to obtain an intermediate private key; obtaining a hardware identification of device hardware, performing a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for generating a secure private key, an encryption method, a system, a computer device and a computer-readable storage medium. Background Art

[0002] In real-world scenarios, users usually use key pairs to achieve purposes such as data encryption or digital signatures. Encryption is to encrypt data so that even if an illegal user obtains the encrypted data, he cannot obtain the correct data content. Therefore, data encryption can protect data and prevent eavesdropping attacks. Digital signatures are used to achieve identity authentication and to determine the authenticity of an identity. After the identity is confirmed, the system can grant different permissions based on different identities. Regardless of the scenario, the use of key pair encryption will inevitably involve private keys and public keys. The public key can be made public, while the private key is kept by the user. Usually, the private key must be saved on the terminal as core data, and once saved, there are various risks of being stolen.

[0003] At present, there is no solution to the above technical problems in the prior art. Summary of the invention

[0004] The object of the present invention is to provide a method for generating a secure private key, an encryption method, a system, a computer device and a computer-readable storage medium, which can realize the trusted storage of the private key.

[0005] One aspect of the present invention provides a method for generating a secure private key, the method comprising: obtaining an original private key, performing a first conversion on the original private key according to a preset rule to obtain an intermediate private key; obtaining a hardware identifier of device hardware, performing a second conversion on the intermediate private key according to the hardware identifier to obtain a secure private key.

[0006] Optionally, the above-mentioned first conversion is performed on the above-mentioned original private key according to a preset rule to obtain an intermediate private key, including: obtaining a first preset conversion table, wherein the above-mentioned first preset conversion table includes multiple first mapping relationships, each of the above-mentioned first mapping relationships includes original data and first conversion data corresponding to the above-mentioned original data; in the above-mentioned first preset conversion table, the above-mentioned original private key is used as the above-mentioned original data, and the first target mapping relationship corresponding to the above-mentioned original private key is determined from the above-mentioned multiple mapping relationships; the above-mentioned original private key is replaced by the first conversion data in the above-mentioned first target mapping relationship to obtain the above-mentioned intermediate private key.

[0007] Optionally, the above-mentioned second conversion of the intermediate private key according to the above-mentioned hardware identification to obtain a secure private key includes: performing a third conversion on the above-mentioned hardware identification and determining the identification length of the hardware identification after the third conversion; dividing the above-mentioned intermediate private key into equal parts according to the above-mentioned identification length to obtain N first segmented private keys, wherein N is a positive integer greater than or equal to 1; and obtaining the above-mentioned secure private key according to the hardware identification after the third conversion and the N above-mentioned first segmented private keys.

[0008] Optionally, the above-mentioned secure private key is obtained based on the hardware identification after the third conversion and the N above-mentioned first-segment private keys, including: Step A1: Calculate the hardware identification after the third conversion and the first first-segment private key among the N above-mentioned first-segment private keys according to a preset algorithm to obtain the first first intermediate calculation result; Step A2: Determine whether i is equal to N, when i is not equal to N, execute step A3, when i is equal to N, execute step A4, wherein the initial value of i is 1; Step A3: Obtain the i+1th above-mentioned first-segment private key among the N above-mentioned first-segment private keys, calculate the i-th above-mentioned first intermediate calculation result and the i+1th above-mentioned first-segment private key according to the above-mentioned preset algorithm to obtain the i+1th above-mentioned first intermediate calculation result; Step A4: Combine all the calculated first intermediate calculation results to obtain the above-mentioned secure private key.

[0009] Another aspect of the present invention provides an encryption method, which includes: obtaining a secure private key, wherein the secure private key is obtained according to the method described in any of the above embodiments; encrypting the data to be encrypted according to the secure private key and a preset encryption library to obtain an encryption result.

[0010] Optionally, the above-mentioned method of encrypting the data to be encrypted according to the above-mentioned security private key and the preset encryption library to obtain an encryption result includes: obtaining the hardware identification of the device hardware, performing a third conversion on the above-mentioned hardware identification, and determining the identification length of the hardware identification after the third conversion; dividing the above-mentioned security private key equally according to the above-mentioned identification length to obtain N second segmented private keys, wherein N is a positive integer greater than or equal to 1; obtaining the above-mentioned intermediate private key according to the hardware identification after the third conversion and the N above-mentioned second segmented private keys; encrypting the above-mentioned data to be encrypted according to the above-mentioned intermediate private key to obtain the above-mentioned encryption result.

[0011] Optionally, the above-mentioned intermediate private key is obtained according to the hardware identification after the third conversion and the N above-mentioned second segment private keys, including: step B1: the hardware identification after the third conversion and the first above-mentioned second segment private key among the N above-mentioned second segment private keys are calculated according to a preset algorithm to obtain the first second intermediate calculation result; step B2: determine whether j is equal to N, when j is not equal to N, execute step B3, when j is equal to N, execute step B4, wherein the initial value of j is 1; step B3: obtain the j+1th above-mentioned second segment private key among the N above-mentioned second segment private keys, calculate the hardware identification after the third conversion, the jth above-mentioned second intermediate calculation result and the j+1th above-mentioned second segment private key according to the above-mentioned preset algorithm to obtain the j+1th above-mentioned second intermediate calculation result; step B4: combine all the calculated above-mentioned second intermediate calculation results to obtain the above-mentioned intermediate private key.

[0012] Optionally, the above-mentioned data to be encrypted is encrypted according to the above-mentioned intermediate private key to obtain an encryption result, including: obtaining a second preset conversion table, wherein the above-mentioned second preset conversion table includes multiple second mapping relationships, each of the above-mentioned second mapping relationships includes an input element and second conversion data corresponding to the above-mentioned input element; in the above-mentioned second preset conversion table, the above-mentioned intermediate private key and the above-mentioned data to be encrypted are used as the above-mentioned input elements, and the second target mapping relationship corresponding to the above-mentioned intermediate private key and the above-mentioned data to be encrypted is determined from the above-mentioned multiple second mapping relationships; and the above-mentioned encryption result is obtained according to the second conversion data in the above-mentioned second target mapping relationship.

[0013] Another aspect of the present invention provides a system for generating a secure private key, the system comprising: a first conversion module, used to obtain an original private key, and perform a first conversion on the original private key according to a preset rule to obtain an intermediate private key; a second conversion module, used to obtain a hardware identification of device hardware, and perform a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key.

[0014] Another aspect of the present invention provides an encryption system, which includes: a first conversion module, used to obtain an original private key, and perform a first conversion on the original private key according to a preset rule to obtain an intermediate private key; a second conversion module, used to obtain a hardware identification of device hardware, and perform a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key.

[0015] Another aspect of the present invention provides a computer device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for generating a secure private key and / or the encryption method described in any one of the above embodiments when executing the computer program.

[0016] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for generating a secure private key and / or the encryption method described in any of the above embodiments is implemented.

[0017] The method for generating a secure private key provided by the present invention first uses a preset rule to dynamically protect the original private key before the original private key is landed, and then uses a hardware identifier that cannot be known to the outside world to statically protect the original private key after dynamic protection, to obtain a secure private key, and store the secure private key in a local system file. Since the outside world cannot know the hardware identifier, even if the outside world obtains the locally stored secure private key, it cannot know the original private key by reversing, thereby realizing the trusted storage of the private key.

[0018] In addition, the encryption algorithm provided by the present invention encrypts the data to be encrypted based on the secure private key and the preset algorithm library, and the encryption result obtained is consistent with the result of encrypting the data to be encrypted using the original private key using the original encryption library, so that only the original decryption method needs to be used for decryption, which reduces the development difficulty and improves the system operation speed. At the same time, the original private key will not appear in the encryption process of the present invention, and even if the outside world obtains the secure private key and the preset algorithm library, the original private key cannot be known. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0020] Figure 1 A flowchart schematically shows a method for generating a secure private key according to an embodiment of the present invention;

[0021] Figure 2 A flowchart schematically shows a method for generating a secure private key according to another embodiment of the present invention;

[0022] Figure 3 A schematic diagram schematically shows a scheme for generating a secure private key according to an embodiment of the present invention;

[0023] Figure 4 A flowchart of an encryption method according to an embodiment of the present invention is schematically shown;

[0024] Figure 5 Schematically shows a block diagram of a system for generating a secure private key according to an embodiment of the present invention;

[0025] Figure 6 A block diagram of an encryption system according to an embodiment of the present invention is schematically shown;

[0026] Figure 7 A block diagram of a computer device suitable for implementing a method for generating a secure private key and / or an encryption method according to an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0028] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0029] The method for generating a secure private key provided by the present invention is described below with reference to the accompanying drawings.

[0030] Figure 1 A flowchart schematically shows a method for generating a secure private key according to an embodiment of the present invention.

[0031] like Figure 1 As shown, the method for generating the secure private key may include steps S101 to S102, wherein:

[0032] Step S101, obtaining an original private key, performing a first conversion on the original private key according to a preset rule, and obtaining an intermediate private key.

[0033] It should be noted that the method for generating the secure private key can be applied to a terminal device, and the terminal device can pre-generate an original private key and an original public key paired with the original private key. In this embodiment, in order to ensure the security of the original private key, before the original private key is landed, the original private key can be converted to obtain a secure private key, and the obtained secure private key is stored in the terminal device, wherein the process of obtaining the secure private key from the original private key can be called a white box process, and the white box process can be implemented by a white box encryption module, and the white box encryption module can include steps S101 to S102, and the secure private key can also be called a white box private key.

[0034] In this embodiment, performing a first conversion on the original private key according to a preset rule may include:

[0035] Obtaining a first preset conversion table, wherein the first preset conversion table includes a plurality of first mapping relationships, each of which includes original data and first conversion data corresponding to the original data;

[0036] In the first preset conversion table, the original private key is used as the original data, and a first target mapping relationship corresponding to the original private key is determined from multiple mapping relationships;

[0037] The original private key is replaced with the first conversion data in the first target mapping relationship to obtain an intermediate private key.

[0038] For example, the original private key is 1234, and the first mapping relationships included in the first preset conversion table are: the original data is 1, and the corresponding first conversion data is 4; the original data is 2, and the corresponding first conversion data is 6; the original data is 3, and the corresponding first conversion data is 2; the original data is 4, and the corresponding first conversion data is 7. Based on this, the original private key is converted into the first conversion data in the first target mapping relationship: 4627. Further, the hash calculation of "4627" obtained in the previous step can be performed to obtain the intermediate private key, for example, 0110.

[0039] Step S102, obtaining a hardware identification of the device hardware, and performing a second conversion on the original private key after the first conversion according to the hardware identification to obtain a secure private key.

[0040] The device hardware may be locally installed hardware, such as a CPU, hard disk, and / or physical network card, etc. The hardware identification code is used to identify the hardware of the device, and may be generated by calculating the identification information of several hardware parts of the device. In this step, the hardware identification code may be obtained by obtaining the identification information of each hardware part and then calculating it, or the hardware identification code generated by calculation may be directly obtained, or the obtained identification information may be directly used as the hardware identification.

[0041] Optionally, the hardware identification of the device hardware can be calculated based on the device's CPU identification, hard disk serial number and / or the MAC (Media Access Control) address of the physical network card. The CPU identification includes the type, model, manufacturer information, trademark information, cache size and clock speed of the information processor, etc. The hard disk serial number refers to the physical serial number of the hard disk, which refers to the factory code of the hard disk and is unique; the MAC address of the physical network card is the hardware address information burned into the physical network card, and is a unique identifier assigned by the physical network card manufacturer itself. Optionally, this embodiment can use the driver of the device operating system to obtain the CPU identification, hard disk serial number and / or the MAC address of the physical network card to ensure that the obtained identification information is not counterfeited.

[0042] It should be noted that the use of CPU identification, hard disk serial number and / or physical network card MAC address to calculate the hardware identification of the device hardware can, on the one hand, better identify the client terminal from the hardware perspective, so that different devices have different hardware identifications; on the other hand, when the device has temporary failures or changes such as disk track damage or temporary addition of peripherals, the hardware identification will not change, which is conducive to improving the stability of the security private key. This embodiment does not limit the device hardware, as long as the hardware identification can be guaranteed to be fixed, unique and private.

[0043] In this embodiment, performing a second conversion on the original private key after the first conversion according to the hardware identifier to obtain a secure private key may include:

[0044] Performing a third conversion on the hardware identifier and determining an identifier length of the hardware identifier after the third conversion;

[0045] Divide the intermediate private key into equal parts according to the identifier length to obtain N first segment private keys, where N is a positive integer greater than or equal to 1;

[0046] A secure private key is obtained according to the hardware identification after the third conversion and the N first segmented private keys.

[0047] Specifically, the third conversion of the hardware identification can be to convert the hardware identification using a hash algorithm to obtain a stream key, which is the hardware identification after the third conversion, wherein any hash algorithm can be used in the present invention. The intermediate private key is further divided into N parts, i.e., N first segment private keys, using the determined identification length. For example, if the intermediate private key is 0110 and the hardware identification after the third conversion is 11, two first segment private keys can be obtained, the first first segment private key is 01, and the second first segment private key is 10. Further, a secure private key can be obtained based on the hardware identification after the third conversion and the N first segment private keys. Optionally, this embodiment can also take only a part of the intermediate private key, such as the first 10 bytes, and then divide this part of the intermediate private key into equal parts using the identification length. It should be noted that the part of the intermediate private key that cannot be divided can be discarded, such as if the length of the intermediate private key is 11 bytes and the identification length is 5 bytes, then the remaining 1 byte that cannot be divided can be discarded.

[0048] In this embodiment, obtaining a secure private key according to the hardware identification after the third conversion and the N first segmented private keys may include:

[0049] Step A1: Calculate the third converted hardware identifier and the first first segment private key among the N first segment private keys according to a preset algorithm to obtain a first first intermediate calculation result;

[0050] Step A2: Determine whether i is equal to N. When i is not equal to N, execute Step A3. When i is equal to N, execute Step A4, where the initial value of i is 1;

[0051] Step A3: Obtain the (i + 1)-th first segmented private key among the N first segmented private keys, and calculate the i-th first intermediate calculation result and the (i + 1)-th first segmented private key according to a preset algorithm to obtain the (i + 1)-th first intermediate calculation result;

[0052] Step A4: Combine all the calculated first intermediate calculation results to obtain the secure private key.

[0053] For example, the preset algorithm in this embodiment can be an exclusive OR operation. Combining the above example, N = 2. When i = 1, perform an exclusive OR operation on the third converted hardware identifier 11 and the first first segmented private key 01 to obtain the first first intermediate calculation result 10; determine whether i is equal to 2 at this time. Since i < N at this time, the first first intermediate calculation result 10 and the second first segmented private key 10 can be exclusive ORed to obtain the second first intermediate calculation result 00. At this time, i = 2. Since i = N at this time, the first first intermediate calculation result 10 and the second first intermediate calculation result 00 can be combined to obtain the secure private key 1000.

[0054] It should be noted that when the present invention executes the step of "obtaining the secure private key according to the third converted hardware identifier and N first segmented private keys", there can be multiple alternative embodiments. Steps A1 to A4 are only an example. For example, the initial value of i can also be set to 0, or Step A2 can be executed before Step A1, etc. The present invention does not limit this.

[0055] Furthermore, in this embodiment, the obtained secure private key can be stored locally. Since the secure private key stored locally is first dynamically protected by a preset rule and then statically protected by a hardware identifier that cannot be known to the outside world, even if the outside world copies the secure private key, the original private key cannot be decoded, and thus the trusted storage of the private key can be realized.

[0056] Figure 2 Schematically shows a flowchart of a method for generating a secure private key according to another embodiment of the present invention.

[0057] As Figure 2 shown, the method for generating the secure private key may include Step S201 to Step S205, where:

[0058] Step S201, call the key generation interface;

[0059] Step S202, determine whether a TPM / TCM chip is installed on the device. If so, execute Step S203. If not, execute Step S204;

[0060] Step S203, calling the TPM / TCM chip to generate a key pair;

[0061] Step S204, generating a secure private key and outputting a public key;

[0062] Step S205, returning the public key.

[0063] In this embodiment, the key generation interface is Figure 3 Then through the API Figure 3 The Adaptor in determines whether a TPM (Trusted Platform Module) / TCM (Trusted Cryptography Module) chip is installed locally. If so, the TPM / TCM chip is called to generate a key pair. Taking the TPM chip as an example, on devices with TPM chips, the TPM chip is preferred to store private keys. By calling the programming interface of the TPM chip, keys can be directly generated and saved inside the TPM chip. Applying for a TPM chip to generate a custom TPM user and associated user keys, and using user password protection, can protect the keys from malicious export and copying, and prevent other local programs from illegal use. The application and protection process uses the standard protocol of TPM1.2, which is a universal standard and will not be repeated. After Windows Vista, Microsoft has centralized cross-application TPM access on the Windows platform. You can write your own TSS module on top of the TPM Base Service to use the TPM chip, and use the self-implemented TSS module to use the TPM. The caller is verified in the self-implemented TSS module to ensure that it is not used impersonally. When there is no TPM / TCM chip installed on the device, you can use Figure 3 The Adaptor in the system inputs the original key and the original public key into the WhiteBox module (i.e., the white box encryption module), and the WhiteBox module can output the secure private key and the original public key. Furthermore, the original public key can be exposed to other devices that need to interact. It should be noted that in this embodiment, it is also possible to manually specify whether to generate the key through the TPM / TCM chip or to generate the secure private key and output the public key through the WhiteBox module.

[0064] In addition, if the private key is generated by the TPM / TCM chip, it can be stored in the hardware module and provided with a key index for use. If the secure private key is generated by the white box encryption module, it can be stored in the file system because the secure private key itself is secure and reliable.

[0065] After the security private key is generated, the security private key can be used for encryption or digital signing. The algorithms supported by the present disclosure may include, for example, the RSA (Rivest-Shamir-Adleman) algorithm, the ECDSA (The Elliptic Curve Digital Signature Algorithm) algorithm, and the SM2 algorithm.

[0066] Figure 4 The flowchart of the encryption method according to the embodiment of the present invention is schematically shown.

[0067] like Figure 4 As shown, the encryption method may include steps S401 to S402, wherein:

[0068] Step S401, obtaining a secure private key, wherein the secure private key can be obtained according to the above embodiment.

[0069] It should be noted that the encryption method provided by the present invention can be applied to a client terminal. Preferably, in order to ensure the security of the encryption result, the method for generating a secure private key and the encryption method can be applied to the same client terminal.

[0070] Step S402, encrypt the data to be encrypted according to the security private key and the preset encryption library to obtain an encryption result.

[0071] Among them, the encryption result in this embodiment is consistent with the result of encrypting the data to be encrypted using the original private key using the original encryption library. In the prior art, the original private key is not white-boxed, and the data to be encrypted is directly encrypted using the original private key and the original encryption library, and then decrypted using the original public key. In this embodiment, the secure private key is different from the original private key. If the secure private key and the original encryption library are continued to be used to encrypt the corresponding data to be encrypted, the original public key cannot be used for decryption. Based on this, this implementation constructs a preset encryption library so that the encryption result obtained after encrypting the data to be encrypted using the secure private key and the preset encryption library can still be decrypted using the original public key.

[0072] Optionally, the data to be encrypted is encrypted according to the security private key and the preset encryption library to obtain an encryption result, including:

[0073] Obtaining a hardware identifier of the device hardware, performing a third conversion on the hardware identifier, and determining an identifier length of the hardware identifier after the third conversion;

[0074] Divide the secure private key equally according to the identifier length to obtain N second segmented private keys, where N is a positive integer greater than or equal to 1;

[0075] Obtain an intermediate private key according to the hardware identifier after the third conversion and the N second segmented private keys;

[0076] Encrypt the data to be encrypted according to the intermediate private key to obtain an encryption result.

[0077] Specifically, the hardware identification part can be as described in the above embodiments and will not be elaborated here. In this embodiment, the third conversion of the hardware identification may be to convert the hardware identification using a hash algorithm to obtain a stream key, which is the hardware identification after the third conversion. Then, the security private key is equally divided into N parts, that is, N second segmented private keys, using the determined identification length. For example, if the security private key is 1000 and the hardware identification after the third conversion is 11, two second segmented private keys can be obtained. The first second segmented private key is 10, and the second second segmented private key is 00. Further, the security private key can be obtained based on the hardware identification after the third conversion and these N second segmented private keys.

[0078] In this embodiment, obtaining the intermediate private key based on the hardware identification after the third conversion and N second segmented private keys includes:

[0079] Step B1: Calculate the third converted hardware identification and the first second segmented private key among the N second segmented private keys according to a preset algorithm to obtain a first second intermediate calculation result.

[0080] Step B2: Determine whether j is equal to N. When j is not equal to N, execute Step B3. When j is equal to N, execute Step B4, where the initial value of j is 1.

[0081] Step B3: Obtain the (j + 1)-th second segmented private key among the N second segmented private keys, and calculate the third converted hardware identification, the j-th second intermediate calculation result, and the (j + 1)-th second segmented private key according to a preset algorithm to obtain the (j + 1)-th second intermediate calculation result.

[0082] Step B4: Combine all the calculated second intermediate calculation results to obtain the intermediate private key.

[0083] For example, the preset algorithm in this embodiment may be an exclusive OR operation. Combining the above example, N = 2. When j = 1, the exclusive OR of the third converted hardware identification 11 and the first second segmented private key 10 is performed to obtain the first second intermediate calculation result 01. Determine whether j is equal to 2 at this time. Since j < N at this time, the exclusive OR of the third converted hardware identification 11, the first second intermediate calculation result 01, and the second second segmented private key 00 is sequentially performed to obtain the second second intermediate calculation result 10. At this time, j = 2. Since j = N at this time, the first second intermediate calculation result 01 and the second second intermediate calculation result 10 are combined to obtain the intermediate private key 0110.

[0084] It should be noted that the present invention may have multiple alternative embodiments when executing the step of "obtaining a secure private key based on the hardware identifier after the third conversion and N second segmented private keys". Steps B1 to B4 are merely an example. For example, the initial value of i may be set to 0, or step B2 may be executed before step B1, and so on. The present invention is not limited to this.

[0085] Further, encrypting the data to be encrypted according to the intermediate private key to obtain an encryption result may include:

[0086] Obtaining a second preset conversion table, wherein the second preset conversion table includes a plurality of second mapping relationships, each of which includes an input element and second conversion data corresponding to the input element;

[0087] In the second preset conversion table, taking the intermediate private key and the data to be encrypted as input elements, determining a second target mapping relationship corresponding to the intermediate private key and the data to be encrypted from a plurality of second mapping relationships;

[0088] An encryption result is obtained according to the second conversion data in the second target mapping relationship.

[0089] In this embodiment, the role of the second preset conversion table is to make the encryption result of this time consistent with the result of encrypting the data to be encrypted using the original private key through internal conversion. This embodiment may include multiple second preset conversion tables, each of which is used to correspond to an operation rule, and the input element in each second preset conversion table may include at least two elements. When using multiple second preset conversion tables for internal conversion, it is necessary to first determine the operation rule of the intermediate private key and the data to be encrypted, and then use the operation rule of the intermediate private key and the data to be encrypted as the operation rule corresponding to the second preset conversion table, determine the second target preset conversion table from the multiple second preset conversion tables, and then use the part of the intermediate private key and the data to be encrypted involving the operation rule as the input element, determine the second target mapping relationship from the multiple second mapping relationships of the second target preset conversion table, and then obtain the encryption result according to the second conversion data in the second target mapping relationship. It should be noted that when executing the step of "encrypting the data to be encrypted according to the intermediate private key to obtain the encryption result", multiple operation rules may be involved, and each operation rule can be executed according to the steps described in the above embodiment, which will not be repeated here.

[0090] For example, the process of encrypting the data to be encrypted using the intermediate private key involves addition and multiplication operations, such as the operation formula (a+b)×c=a×c+b×c. Among them, this embodiment may include an addition conversion table and a multiplication conversion table. The multiplication conversion table is applicable to a×c and b×c. According to the multiplication conversion table, a×c corresponds to the second conversion data d, and b×c corresponds to the second conversion data f. At this time, the operation formula is changed to d+f. The addition conversion table is applicable to d+f. According to the addition conversion table, d+f corresponds to the second conversion data g. Then g is the encrypted data finally obtained, and the encrypted data is consistent with the result of encrypting the data to be encrypted using the original private key using the original encryption library.

[0091] The encryption method provided by the present invention can not only encrypt data, but also be used for data signing. No matter what the encryption scenario is, since the security private key uses the hardware identification that cannot be known to the outside world as an additional conversion factor, even if the security private key and the preset encryption library are copied to other device black boxes to use the encryption function, since other devices cannot know the hardware identification of this device, once the hardware identification does not match, the encryption result will definitely be illegal, and the subsequent process of using the public key to verify the digital signature will also fail.

[0092] Figure 5 A block diagram of a system for generating a secure private key according to an embodiment of the present invention is schematically shown.

[0093] like Figure 5 As shown, the security private key generation system 500 may include a first conversion module 501 and a second conversion module 502, wherein:

[0094] The first conversion module 501 is used to obtain an original private key and perform a first conversion on the original private key according to a preset rule to obtain an intermediate private key;

[0095] The second conversion module 502 is used to obtain the hardware identification of the device hardware, and perform a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key.

[0096] Optionally, when the first conversion module performs the first conversion on the original private key according to the preset rule to obtain the intermediate private key, it is further used to:

[0097] Obtaining a first preset conversion table, wherein the first preset conversion table includes a plurality of first mapping relationships, each of which includes original data and first conversion data corresponding to the original data;

[0098] In the first preset conversion table, the original private key is used as the original data, and a first target mapping relationship corresponding to the original private key is determined from multiple mapping relationships;

[0099] The original private key is replaced with the first conversion data in the first target mapping relationship to obtain an intermediate private key.

[0100] Optionally, when the second conversion module performs a second conversion on the intermediate private key according to the hardware identifier to obtain the secure private key, the second conversion module is further used to:

[0101] Performing a third conversion on the hardware identifier and determining an identifier length of the hardware identifier after the third conversion;

[0102] Divide the intermediate private key into equal parts according to the identifier length to obtain N first segment private keys, where N is a positive integer greater than or equal to 1;

[0103] A secure private key is obtained according to the hardware identification after the third conversion and the N first segmented private keys.

[0104] Optionally, when the first conversion module obtains the security private key according to the hardware identifier after the third conversion and the N first segmented private keys, it is further used to:

[0105] Step A1: Calculate the third converted hardware identifier and the first first segment private key among the N first segment private keys according to a preset algorithm to obtain a first first intermediate calculation result;

[0106] Step A2: Determine whether i is equal to N. When i is not equal to N, execute step A3. When i is equal to N, execute step A4, wherein the initial value of i is 1.

[0107] Step A3: obtaining the i+1th first segment private key among the N first segment private keys, and calculating the i+1th first intermediate calculation result and the i+1th first segment private key according to a preset algorithm to obtain the i+1th first intermediate calculation result;

[0108] Step A4: Combine all the first intermediate calculation results to obtain a secure private key.

[0109] Figure 6 The block diagram of the encryption system according to the embodiment of the present invention is schematically shown.

[0110] like Figure 6 As shown, the encryption system 600 may include an acquisition module 601 and an encryption module 602, wherein:

[0111] An acquisition module 601 is used to acquire a security private key, wherein the security private key is obtained according to the above-mentioned embodiment;

[0112] The encryption module 602 is used to encrypt the data to be encrypted according to the security private key and the preset encryption library to obtain an encryption result.

[0113] Optionally, the encryption module is also used to:

[0114] Obtaining a hardware identifier of the device hardware, performing a third conversion on the hardware identifier, and determining an identifier length of the hardware identifier after the third conversion;

[0115] Divide the secure private key equally according to the identifier length to obtain N second segmented private keys, where N is a positive integer greater than or equal to 1;

[0116] Obtain an intermediate private key according to the hardware identifier after the third conversion and the N second segmented private keys;

[0117] The data to be encrypted is encrypted according to the intermediate private key to obtain an encryption result.

[0118] Optionally, when the encryption module obtains the intermediate private key according to the hardware identification after the third conversion and the N second segmented private keys, it is further used to:

[0119] Step B1: Calculate the hardware identifier after the third conversion and the first second segment private key among the N second segment private keys according to a preset algorithm to obtain a first second intermediate calculation result;

[0120] Step B2: Determine whether j is equal to N. When j is not equal to N, execute step B3. When j is equal to N, execute step B4, wherein the initial value of j is 1.

[0121] Step B3: Obtain the j+1th second segment private key from the N second segment private keys, and calculate the third converted hardware identifier, the jth second intermediate calculation result, and the j+1th second segment private key according to a preset algorithm to obtain the j+1th second intermediate calculation result;

[0122] Step B4: Combine all the calculated second intermediate calculation results to obtain an intermediate private key.

[0123] Optionally, when the encryption module encrypts the data to be encrypted according to the intermediate private key to obtain an encryption result, it is also used to:

[0124] Obtaining a second preset conversion table, wherein the second preset conversion table includes a plurality of second mapping relationships, each of which includes an input element and second conversion data corresponding to the input element;

[0125] In the second preset conversion table, taking the intermediate private key and the data to be encrypted as input elements, determining a second target mapping relationship corresponding to the intermediate private key and the data to be encrypted from a plurality of second mapping relationships;

[0126] An encryption result is obtained according to the second conversion data in the second target mapping relationship.

[0127] Figure 7The block diagram of a computer device suitable for implementing a method for generating a secure private key and / or an encryption method according to an embodiment of the present invention is schematically shown. In this embodiment, the computer device 700 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server or a server cluster composed of multiple servers) that executes a program. Figure 7 As shown, the computer device 700 of this embodiment includes at least but is not limited to: a memory 701, a processor 702, and a network interface 703 that can be interconnected through a system bus. It should be noted that Figure 7 Only computer device 700 having components 701 - 703 is shown, but it should be understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.

[0128] In this embodiment, the memory 703 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 701 can be an internal storage unit of the computer device 700, such as a hard disk or memory of the computer device 700. In other embodiments, the memory 701 can also be an external storage device of the computer device 700, such as a plug-in hard disk equipped on the computer device 700, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 701 can also include both the internal storage unit of the computer device 700 and its external storage device. In this embodiment, the memory 701 is generally used to store the operating system and various application software installed on the computer device 700, such as the program code of the method for generating a security private key and / or the program code of the encryption method, etc. In addition, the memory 701 can also be used to temporarily store various data that have been output or are to be output.

[0129] In some embodiments, the processor 702 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 702 is generally used to control the overall operation of the computer device 700. For example, the program code and / or the program code of the encryption method for executing control and processing related to data interaction or communication with the computer device 700.

[0130] In this embodiment, the security private key generation method and / or encryption method stored in the memory 701 can also be divided into one or more program modules and executed by one or more processors (processor 702 in this embodiment) to complete the present invention.

[0131] The network interface 703 may include a wireless network interface or a wired network interface, and the network interface 703 is generally used to establish a communication link between the computer device 700 and other computer devices. For example, the network interface 703 is used to connect the computer device 700 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 700 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.

[0132] This embodiment also provides a computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, App application store, etc., on which a computer program is stored, and when the computer program is executed by a processor, a method for generating a secure private key and / or an encryption method is implemented.

[0133] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention 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, and optionally, 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 here, 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. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0134] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods 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.

[0135] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for generating a secure private key, characterized in that: The method comprises: Obtaining an original private key, and performing a first conversion on the original private key according to a preset rule to obtain an intermediate private key; Obtaining a hardware identification of the device hardware, and performing a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key; The performing a second conversion on the intermediate private key according to the hardware identifier to obtain a secure private key includes: Performing a third conversion on the hardware identifier and determining an identifier length of the hardware identifier after the third conversion; Divide the intermediate private key equally according to the identifier length to obtain N first segment private keys, where N is a positive integer greater than or equal to 1; The secure private key is obtained according to the third converted hardware identifier and the N first segmented private keys.

2. The method according to claim 1, characterized in that The first conversion of the original private key according to a preset rule to obtain an intermediate private key includes: Obtaining a first preset conversion table, wherein the first preset conversion table includes a plurality of first mapping relationships, each of the first mapping relationships includes original data and first conversion data corresponding to the original data; In the first preset conversion table, the original private key is used as the original data, and a first target mapping relationship corresponding to the original private key is determined from the multiple mapping relationships; The original private key is replaced with the first conversion data in the first target mapping relationship to obtain the intermediate private key.

3. The method according to claim 1, characterized in that The obtaining the secure private key according to the third converted hardware identifier and the N first segmented private keys includes: Step A1: Calculating the third converted hardware identifier and the first first segment private key among the N first segment private keys according to a preset algorithm to obtain a first first intermediate calculation result; Step A2: Determine whether i is equal to N. When i is not equal to N, execute step A3. When i is equal to N, execute step A4, wherein the initial value of i is 1. Step A3: obtaining the i+1th first segment private key among the N first segment private keys, and calculating the i+1th first intermediate calculation result and the i+1th first segment private key according to the preset algorithm to obtain the i+1th first intermediate calculation result; Step A4: Combine all the first intermediate calculation results to obtain the secure private key.

4. An encryption method, characterized in that: The method comprises: Obtaining a secure private key, wherein the secure private key is obtained according to the method according to any one of claims 1 to 3; The data to be encrypted is encrypted according to the security private key and the preset encryption library to obtain an encryption result.

5. The method according to claim 4, characterized in that The step of encrypting the data to be encrypted according to the security private key and the preset encryption library to obtain an encryption result includes: Acquire a hardware identifier of the device hardware, perform a third conversion on the hardware identifier, and determine an identifier length of the hardware identifier after the third conversion; Divide the secure private key equally according to the identifier length to obtain N second segmented private keys, where N is a positive integer greater than or equal to 1; Obtain the intermediate private key according to the third converted hardware identifier and the N second segmented private keys; The data to be encrypted is encrypted according to the intermediate private key to obtain the encryption result.

6. The method according to claim 5, characterized in that The obtaining the intermediate private key according to the third converted hardware identifier and the N second segmented private keys includes: Step B1: Calculating the third converted hardware identifier and the first second segment private key among the N second segment private keys according to a preset algorithm to obtain a first second intermediate calculation result; Step B2: Determine whether j is equal to N. When j is not equal to N, execute step B3. When j is equal to N, execute step B4, wherein the initial value of j is 1. Step B3: obtaining the j+1th second segment private key among the N second segment private keys, and calculating the third converted hardware identifier, the jth second intermediate calculation result and the j+1th second segment private key according to the preset algorithm to obtain the j+1th second intermediate calculation result; Step B4: Combine all the calculated second intermediate calculation results to obtain the intermediate private key.

7. The method according to claim 5, characterized in that The step of encrypting the data to be encrypted according to the intermediate private key to obtain the encryption result includes: Obtaining a second preset conversion table, wherein the second preset conversion table includes a plurality of second mapping relationships, and each of the second mapping relationships includes an input element and second conversion data corresponding to the input element; In the second preset conversion table, taking the intermediate private key and the data to be encrypted as the input elements, determining a second target mapping relationship corresponding to the intermediate private key and the data to be encrypted from the plurality of second mapping relationships; The encryption result is obtained according to the second conversion data in the second target mapping relationship.

8. A system for generating a secure private key for implementing the method according to any one of claims 1 to 3, characterized in that: The system comprises: A first conversion module, used to obtain an original private key, and perform a first conversion on the original private key according to a preset rule to obtain an intermediate private key; The second conversion module is used to obtain the hardware identification of the device hardware, and perform a second conversion on the intermediate private key according to the hardware identification to obtain a secure private key.

9. An encryption system, characterized in that: The system comprises: An acquisition module, used to acquire a secure private key, wherein the secure private key is obtained according to the method according to any one of claims 1 to 3; The encryption module is used to encrypt the data to be encrypted according to the security private key and the preset encryption library to obtain an encryption result.

10. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any one of claims 1 to 3 and / or the method described in any one of claims 4 to 7 when executing the computer program.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 and / or the method according to any one of claims 4 to 7 is implemented.