A method and system for implementing identity authentication

By using the second preset algorithm to generate a MAC value for random numbers and device identification, the problem of plaintext transmission risk and high hardware requirements in existing identity authentication technology is solved, and safe and simple one-time authentication and one-device authentication are achieved. , which improves the security and flexibility of identity authentication.

CN118316631BActive Publication Date: 2024-08-27BEIJING HONGSI ELECTRONICS TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410741958.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-08-27
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

Existing identity authentication technology has problems such as plaintext data transmission risks, data length alignment restrictions, high algorithm complexity, and high hardware requirements, resulting in inconvenient use and insufficient security.

Method used

Use a second preset algorithm (such as SM3 or SHA256) to calculate the random number and device identification to generate a unique MAC value, achieving one-at-a-time authentication and one-device authentication without the need to transfer distributed keys, simplifying the authentication process and improving security.

Benefits of technology

It achieves safe and reliable identity authentication, avoids repeated attacks and man-in-the-middle attacks, simplifies the authentication process, and improves the flexibility of key length and authentication security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118316631B
    Figure CN118316631B
Patent Text Reader

Abstract

The present invention discloses an identity authentication implementation method and system, belonging to the field of information security. During the registration process, the master device sends the generated decentralized key and key index to the corresponding slave device for storage; the authentication process includes: the master device sends the calculation MAC instruction to the slave device; the slave device obtains the corresponding decentralized key according to the key index in the calculation MAC instruction, generates a first MAC value according to the second preset algorithm, the decentralized key, the first random number, and the slave device information and returns it to the master device; the master device obtains the slave device information according to the slave device identifier, generates a decentralized key according to the key index and the slave device identifier, generates a second MAC value according to the second preset algorithm, the decentralized key, the first random number, and the slave device information, and determines whether it is consistent with the first MAC value. If it is, the identity authentication is successful, otherwise the identity authentication fails. This solution uses a unique MAC value in the authentication process, does not need to transmit a decentralized key, is safe and reliable to use, and can avoid repeated attacks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security, and in particular to an identity authentication implementation method and system. Background Art

[0002] Based on the development of the Internet, before users use terminal devices (such as mobile phones, laptops, tablets, desktops, etc.) to interact with external devices through the network, they need to authenticate their identities. After authentication, they can perform operations such as online shopping and online transactions, which is convenient and quick to use.

[0003] In the prior art, commonly used identity authentication methods include: PIN authentication, symmetric key authentication, and asymmetric key signature verification. In the PIN authentication method, plain text data is transmitted between devices, which poses a great risk; the symmetric key authentication method requires data length alignment, which is limited and inflexible to use; the asymmetric key signature verification method has a complex algorithm, high requirements for the algorithm in the main device, a long verification time, high power consumption and hardware requirements, and is inconvenient to use. Therefore, it is urgent to provide a safe, reliable, and easy-to-use identity authentication solution. Summary of the invention

[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and to provide a method and system for implementing identity authentication.

[0005] In a first aspect, an embodiment of the present invention provides a method for implementing identity authentication, including:

[0006] When the main device receives the identity registration information triggered by the user, step A1 is executed;

[0007] Step A1: the master device obtains the slave device identification in the slave device, generates a distributed key according to the master key, the key index and the slave device identification, stores the distributed key and the key index in correspondence, and sends the key index and the distributed key to the slave device;

[0008] Step A2: the slave device receives the key index and the distributed key and stores the key index and the distributed key in correspondence;

[0009] When the main device receives the identity authentication information triggered by the user, step S1 is executed;

[0010] Step S1: the master device obtains a slave device identifier and a first random number in the slave device, generates a MAC calculation instruction according to a stored key index and a second preset algorithm identifier, and sends the instruction to the slave device;

[0011] Step S2: the slave device receives and parses the MAC calculation instruction, obtains the corresponding stored distributed key according to the key index obtained by the parse, calculates the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the parse to generate a first MAC value and returns it to the master device;

[0012] Step S3: the master device obtains the corresponding preset slave device information according to the slave device identifier, generates a distributed key according to the master key, the key index and the slave device identifier, and calculates the generated distributed key, the first random number and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value;

[0013] Step S4: The master device determines whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful; otherwise, the identity authentication fails.

[0014] In a second aspect, an embodiment of the present invention further provides an identity authentication implementation system, including a master device and a slave device.

[0015] The master device is used to obtain the slave device identification in the slave device when receiving the identity registration information triggered by the user, generate a distributed key according to the master key, the key index and the slave device identification, store the distributed key and the key index in correspondence, and send the key index and the distributed key to the slave device;

[0016] The slave device is used to receive the key index and the distributed key and store the key index and the distributed key in correspondence;

[0017] The master device is also used to obtain the slave device identifier and the first random number in the slave device when receiving the identity authentication information triggered by the user, generate a MAC calculation instruction according to the stored key index and the second preset algorithm identifier, and send it to the slave device;

[0018] The slave device is further used to receive and parse the MAC calculation instruction, obtain the corresponding stored distributed key according to the key index obtained by the analysis, and calculate the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to generate a first MAC value and return it to the master device;

[0019] The master device is also used to obtain the corresponding preset slave device information according to the slave device identifier, generate a distributed key according to the key index and the slave device identifier, calculate the generated distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value, and determine whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful, otherwise the identity authentication fails.

[0020] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising at least one processor, a memory, and instructions stored in the memory and executable by the at least one processor, wherein the at least one processor executes the instructions to implement the aforementioned identity authentication method.

[0021] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes the aforementioned identity authentication implementation method.

[0022] In a fifth aspect, an embodiment of the present invention further provides a chip system, comprising a chip, wherein the chip is coupled to a memory and is used to execute a computer program stored in the memory to execute the aforementioned identity authentication implementation method.

[0023] Compared with the prior art, the present invention has the following advantages: during the authentication process, the scheme of the present invention adopts a second preset algorithm (such as SM3 or SHA256 algorithm) to calculate the random number and the device identification (such as the device serial number) to generate a unique MAC (message authentication code) value. There is no need to transmit a distributed key during the authentication process, and one-time authentication and one-device-one-authentication can be achieved simply and efficiently. It is safe and reliable to use and can avoid repeated attacks. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 A flowchart of a method for implementing identity authentication provided in Example 1 of the present invention;

[0025] Figure 2 A flowchart of an initialization process in an identity authentication implementation method provided in Embodiment 2 of the present invention;

[0026] Figure 3 A flowchart of the implementation process of the master device performing identity authentication on the slave device in an identity authentication implementation method provided in Embodiment 2 of the present invention;

[0027] Figure 4 A flowchart of the implementation process of identity authentication performed by a slave device on a master device in an identity authentication implementation method provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION

[0028] The present application proposes a method and system for implementing identity authentication. The specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. Examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0029] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.

[0030] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings.

[0031] Embodiment 1

[0032] Embodiment 1 of the present invention provides a method for implementing identity authentication, such as Figure 1 As shown, including:

[0033] When the main device receives the identity registration information triggered by the user, step A1 is executed;

[0034] Step A1: the master device obtains the slave device identification in the slave device, generates a distributed key according to the master key, the key index and the slave device identification, stores the distributed key and the key index in correspondence, and sends the key index and the distributed key to the slave device;

[0035] Specifically, in this embodiment, generating a decentralized key according to a master key, a key index and a slave device identifier includes: splitting the master key into different parts, generating partial decentralized keys according to the partial master keys, key indexes and slave device identifiers obtained by splitting, and splicing all the partial decentralized keys to obtain a complete decentralized key; or, the master device obtains corresponding product description information according to the slave device identifier, splices its own master key, slave device identifier, key index and product description information, and uses a first preset algorithm to calculate the splicing result to obtain a decentralized key;

[0036] Step A2: receiving a key index and a distributed key from a device and storing the key index and the distributed key in correspondence;

[0037] Specifically, in this embodiment, the distributed key and the key index are saved in correspondence, including: taking the key index as a parameter, calling the first function to save the distributed key; specifically: taking the key index as a parameter, calling the first function to multiply the key index by the value of the key allocation space size as an offset value, and saving the distributed key in a corresponding position according to the base address and the offset value;

[0038] Optionally, in this embodiment, step A2 further includes: the slave device returns write success information to the master device;

[0039] After step A2, the method further includes: the master device determines whether to continue writing a new key to the slave device, if yes, the master device obtains a new key index, generates a new distributed key according to the master key, the new key index and the slave device serial number, calls the first function with the new key index as a parameter to save the new distributed key in a corresponding position, sends the new key index and the new distributed key to the slave device, and executes step A2, otherwise the master device sends an initialization completion instruction to the slave device, and the slave device sets the initialization state to completion;

[0040] The slave device sets the initialization state to completion, including: the slave device sets the initialization flag;

[0041] When the main device receives the identity authentication information triggered by the user, step S1 is executed;

[0042] Step S1: The master device obtains the slave device identifier and the first random number in the slave device, generates a MAC calculation instruction according to the stored key index and the second preset algorithm identifier, and sends the instruction to the slave device;

[0043] Specifically, in this embodiment, generating a MAC calculation instruction according to the key index and the second preset algorithm identifier includes: generating a MAC calculation instruction according to the key index, the key length, and the second preset algorithm identifier;

[0044] Optionally, in this embodiment, if multiple key indexes and multiple second preset algorithm identifiers are stored in the master device, the key index and the second preset algorithm identifier used may be selected by default or a key index list and a second preset algorithm identifier list may be displayed, and the key index and the second preset algorithm identifier used may be selected by the user;

[0045] Step S2: The slave device receives and parses the MAC calculation instruction, obtains the corresponding stored distributed key according to the key index obtained by the parse, calculates the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the parse to generate a first MAC value and returns it to the master device;

[0046] Optionally, in the present embodiment, the slave device information includes the slave device serial number and / or product description information, and the first MAC value is generated by calculating the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing, including: obtaining data of corresponding length from the distributed key according to the key length obtained by parsing, splicing the obtained data, the first random number, the slave device serial number and / or the product description information, and calculating the first MAC value on the splicing result using the algorithm corresponding to the second preset algorithm identifier obtained by parsing; or, calculating the first MAC value from the distributed key, the first random number, the slave device serial number and / or the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing;

[0047] Further, the distributed key, the first random number, the slave device serial number and / or the product description information are calculated according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to generate the first MAC value, including: splicing the distributed key, the first random number, the slave device serial number and the product description information, and using the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to calculate the splicing result to obtain the first MAC value;

[0048] Step S3: the master device obtains the corresponding preset slave device information according to the slave device identifier, generates a distributed key according to the master key, the key index and the slave device identifier, and calculates the generated distributed key, the first random number and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value;

[0049] Step S4: The master device determines whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful; otherwise, the identity authentication fails.

[0050] like Figure 1 As shown, the method of this embodiment may also include: the master device and the slave device are both powered on and a connection is established, the master device determines whether the slave device has completed initialization, if yes, then executes step S1 when receiving identity authentication information triggered by the user, otherwise, executes step A1 when receiving identity registration information triggered by the user;

[0051] Further, the master device determines whether the slave device has completed initialization, including: the master device obtains an initialization flag in the slave device, and determines whether the obtained initialization flag is set, if yes, the initialization is completed, otherwise, the initialization is not completed.

[0052] Optionally, in this embodiment, after step A2, the method further includes: the master device sends the master device identifier to the slave device;

[0053] Accordingly, the method of this embodiment further includes: the slave device authenticates the identity of the master device, and after the identity authentication is successful in step S4, the method further includes:

[0054] Step P1: The master device obtains the third random number in the slave device, and uses a third preset algorithm to calculate the master device identifier, the third random number and the generated fourth random number to obtain a first digest value;

[0055] Step P2: The master device sends the identifier of the third preset algorithm, the fourth random number and the first digest value to the slave device;

[0056] Step P3: the slave device searches for a corresponding algorithm according to the received identifier of the third preset algorithm, and uses the found algorithm to calculate the master device identifier, the third random number, and the fourth random number to obtain a second digest value;

[0057] Step P4: The slave device determines that the second digest value is consistent with the received first digest value. If yes, it generates a first response according to the first preset method and returns it to the master device. Otherwise, it generates a second response according to the second preset method and returns it to the master device.

[0058] Specifically, in the present embodiment, generating a first response according to a first preset method includes: performing an XOR operation on a distributed key and a master device identifier to obtain a first XOR result, performing an XOR operation on a third random number and a fourth random number to obtain a second XOR result, concatenating the first preset data, the first XOR result and the second XOR result, and performing a hash operation on the concatenated result to obtain the first response; or, splitting the distributed key into a first part key and a second part key, performing an XOR operation on the first part key, the second part key and the master device identifier to obtain a first XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a second XOR result, concatenating the first preset data, the first XOR result and the second XOR result, and performing a hash operation on the concatenated result to obtain the first response;

[0059] Generating a second response according to a second preset method includes: generating a fifth random number of a fifth preset length, and performing a hash operation on the fifth random number to obtain the second response;

[0060] Step P5: The master device receives the response returned by the slave device, generates comparison data according to the first preset method, and determines whether the received response is consistent with the comparison data. If so, the authentication succeeds, otherwise, the authentication fails;

[0061] Specifically, in the present embodiment, the process of generating comparison data according to the first preset method is the same as the process of generating the first response according to the first preset method, including: performing an XOR operation on the saved distributed key and the main device identifier to obtain a third XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a fourth XOR result, splicing the first preset data, the third XOR result and the fourth XOR result, and performing a hash operation on the spliced ​​result to obtain comparison data; or, splitting the distributed key into a first part key and a second part key, performing an XOR operation on the first part key, the second part key and the main device identifier to obtain a third XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a fourth XOR result, splicing the first preset data, the third XOR result and the fourth XOR result, and performing a hash operation on the spliced ​​result to obtain comparison data.

[0062] Embodiment 2

[0063] Embodiment 2 of the present invention provides a method for implementing identity authentication, including an initialization process and an identity authentication process, such as Figure 2 and Figure 3 As shown, the method of this embodiment includes:

[0064] Step 200: The master device and the slave device system are powered on and a connection is established. The master device determines whether the slave device has completed initialization. If yes, step 301 is executed when the master device receives identity authentication information triggered by the user. Otherwise, step 201 is executed when the master device receives identity registration information triggered by the user.

[0065] Step 201: The master device sends a serial number read instruction to the slave device;

[0066] Specifically, in this embodiment, the master device determines whether the slave device has completed initialization, including: the master device sends an instruction to obtain the initialization status to the slave device, the slave device returns an initialization identifier to the master device after receiving the instruction to obtain the initialization status, and the master device determines whether the slave device has completed initialization according to the received initialization identifier;

[0067] Preferably, the master device determines whether the slave device has completed initialization according to the received initialization flag, if the initialization flag is set, the slave device has completed initialization, otherwise the initialization is not completed;

[0068] Step 202: When the slave device receives the serial number read instruction, the slave device serial number is returned to the master device;

[0069] Step 203: The master device receives the slave device serial number, obtains the key index, generates a distributed key according to the master key, the key index and the slave device serial number, and calls the first function with the key index as a parameter to save the distributed key in a corresponding position;

[0070] In this embodiment, the slave device serial number, key index and distributed key correspond one to one;

[0071] Optionally, generating a decentralized key according to the master key, the key index and the slave device serial number includes: splitting the master key into different parts, generating partial decentralized keys according to the partial master key, the key index and the slave device serial number respectively, and splicing all the partial decentralized keys to obtain a complete decentralized key; the master device may also directly generate a decentralized key according to the master key, the key index and the slave device serial number;

[0072] Preferably, in this embodiment, generating a decentralized key according to the master key, the key index and the slave device serial number includes: the master device obtains the corresponding product description information according to the slave device serial number, concatenates its own master key, the slave device serial number, the key index and the product description information, and uses a first preset algorithm to calculate the concatenation result to obtain the decentralized key;

[0073] Preferably, the first function is FuncKey(KID), the first preset algorithm is SM3, and the length of the distributed key is at least 32 bytes;

[0074] For example, the master device divides the master key into a first half master key and a second half master key, concatenates the first half master key, the key index and the slave device serial number to obtain a first concatenation result, uses a first preset algorithm to calculate the first concatenation result to obtain a first half distributed key, concatenates the second half master key, the key index and the slave device serial number to obtain a second concatenation result, uses the first preset algorithm to calculate the second concatenation result to obtain a second half distributed key, and concatenates the first half distributed key and the second half distributed key to obtain a complete distributed key;

[0075] If the master key is 64 bytes long, the master device divides the master key into two equal parts of 32 bytes each, calculates the 32-byte first half of the distributed key and the 32-byte second half of the distributed key, and finally concatenates them to obtain a 64-byte distributed key;

[0076] Step 204: the master device generates a key write instruction according to the key index and the distributed key and sends it to the slave device;

[0077] Step 205: the slave device parses the received key write instruction to obtain a key index and a distributed key, saves the distributed key through the first function according to the key index, and returns a write success message to the master device;

[0078] Specifically, in this embodiment, saving the distributed key through the first function according to the key index includes: taking the key index as a parameter, calling the first function to multiply the key index by the value of the key allocation space size as an offset value, and saving the distributed key in a corresponding position according to the base address and the offset value;

[0079] For example, the base address is 0x8000, and the storage address of the distributed key is 0x8000 + KID (key index) * KeySize (key allocation space size). Preferably, the key allocation space size is 64 bytes;

[0080] Step 206: The master device determines whether to continue writing a new key to the slave device, if yes, then execute step 207, otherwise, the master device sends an initialization completion instruction to the slave device, then execute step 209;

[0081] Optionally, in this embodiment, the determination of No in step 206 further includes: the master device sending the master device serial number to the slave device;

[0082] Step 207: the master device obtains a new key index, generates a new distributed key according to the master key, the new key index and the slave device serial number, and calls the first function with the new key index as a parameter to save the new distributed key in a corresponding position;

[0083] Step 208: The master device generates a key write instruction according to the new key index and the new distributed key and sends it to the slave device, and returns to step 205;

[0084] Step 209: the slave device sets the initialization state to complete, and the initialization process ends;

[0085] Specifically, setting the initialization state of the slave device to completion includes: the slave device sets an initialization flag;

[0086] In this embodiment, step 301 may be further performed after step 209;

[0087] Step 301: The master device sends a serial number read instruction to the slave device;

[0088] Step 302: After receiving the serial number read instruction, the slave device returns the slave device serial number to the master device;

[0089] Step 303: The master device receives the slave device serial number;

[0090] Step 304: the master device sends a random number acquisition instruction to the slave device;

[0091] Step 305: The slave device generates a first random number of a first preset length and caches the first random number, and returns the first random number to the master device;

[0092] Preferably, the first preset length is 32 bytes;

[0093] Step 306: The master device receives the first random number, generates a calculate MAC instruction according to the key index and the second preset algorithm identifier, and sends the calculate MAC instruction to the slave device;

[0094] Optionally, generating a calculation MAC instruction according to the key index and the second preset algorithm identifier includes: generating a calculation MAC instruction according to the key index, the key length, and the second preset algorithm identifier;

[0095] In this embodiment, if there are multiple key indexes and multiple algorithms in the master device, after the user triggers the identity authentication button, the key index list and the algorithm identifier list are displayed and the user is prompted to select. When the key index and the second preset algorithm selected by the user are received, a calculation MAC instruction is generated according to the selected key index and the second preset algorithm identifier, or a calculation MAC instruction is generated according to the key index, the preset key length and the second preset algorithm identifier; there may also be multiple key lengths. The master device displays a key length list for the user to select which one to use;

[0096] Step 307: The slave device receives and parses the MAC calculation instruction, obtains the corresponding stored distributed key according to the key index obtained by the parse, calculates the distributed key, the cached first random number, the slave device serial number and the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by the parse to generate a first MAC value, deletes the cached first random number and returns the first MAC value to the master device;

[0097] Specifically, the distributed key, the cached first random number, the slave device serial number and the product description information are calculated according to the algorithm corresponding to the second preset algorithm identifier to generate the first MAC value, including: splicing the distributed key, the cached first random number, the slave device serial number and the product description information, and calculating the splicing result using the algorithm corresponding to the second preset algorithm identifier to obtain the first MAC value;

[0098] Optionally, the first MAC value is generated by calculating the distributed key, the cached first random number, the slave device serial number and the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis, including: obtaining data of a corresponding length from the distributed key according to the key length obtained by the analysis, splicing the obtained data, the cached first random number, the slave device serial number and the product description information, calculating the splicing result by using the algorithm corresponding to the second preset algorithm identifier to obtain the first MAC value, deleting the cached first random number and returning the first MAC value to the master device;

[0099] The second preset algorithm in this embodiment is SM3 or SHA256. Preferably, the second preset algorithm is SM3;

[0100] Step 308: The master device receives the first MAC value, obtains the corresponding product information description according to the slave device serial number, generates the corresponding distributed key according to the key index and the slave device serial number, and calculates the distributed key, the received first random number, the slave device serial number and the product description information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value;

[0101] In this embodiment, the process of generating the distributed key in step 308 is the same as step 203, which will not be repeated here, and the process of generating the second MAC value is the same as step 307, which will not be repeated here;

[0102] Step 309: The master device determines whether the first MAC value is consistent with the second MAC value. If so, the authentication is successful; otherwise, the authentication fails.

[0103] Optionally, the authentication process of the method in this embodiment further includes: the slave device authenticates the identity of the master device, such as Figure 4 As shown, after judging yes in step 309, the following further includes:

[0104] Step 310: The master device sends a random number acquisition instruction to the slave device;

[0105] Step 311: after receiving the random number acquisition instruction, the slave device generates and saves a third random number of a third preset length, and returns the third random number to the master device;

[0106] Step 312: The master device receives the third random number and generates a fourth random number of a fourth preset length;

[0107] Step 313: The master device uses a third preset algorithm to calculate the master device serial number, the third random number, and the fourth random number to obtain a first digest value;

[0108] Step 314: The master device sends the identifier of the third preset algorithm, the fourth random number, and the first digest value to the slave device;

[0109] Step 315: the slave device searches for the corresponding third preset algorithm according to the received identifier of the third preset algorithm, and uses the third preset algorithm to calculate the master device serial number, the third random number, and the fourth random number to obtain a second digest value;

[0110] Step 316: The slave device determines whether the second digest value is consistent with the received first digest value. If yes, a first response is generated according to the first preset method and returned to the master device, and step 317 is executed. Otherwise, a second response is generated according to the second preset method and returned to the master device, and step 317 is executed.

[0111] Optionally, in this embodiment, generating a first response according to a first preset method includes: performing an XOR operation on the distributed key and the master device serial number to obtain a first XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splicing the first preset data, the first XOR result and the second XOR result, and performing a hash operation on the spliced ​​result to obtain the first response;

[0112] Further, generating a first response according to a first preset method includes: splitting the distributed key into a first key part and a second key part, performing an XOR operation on the first key part, the second key part and the master device serial number to obtain a first XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splicing the first preset data, the first XOR result and the second XOR result, and performing a hash operation on the spliced ​​result to obtain the first response;

[0113] Generating a second response according to a second preset method includes: generating a fifth random number of a fifth preset length, and performing a hash operation on the fifth random number to obtain the second response;

[0114] For example, in this embodiment, the first preset data is 16 bytes of 00, and the fifth preset length is 80 bytes;

[0115] Step 317: The master device receives the response returned by the slave device and generates comparison data according to the first preset method;

[0116] Step 318: The master device determines whether the received response is consistent with the comparison data, if so, the authentication is successful, otherwise the authentication fails.

[0117] The method of this embodiment adopts SM3 or SHA256 algorithm, introduces random numbers and serial numbers to generate unique MAC values, and does not need to transmit decentralized keys. It can simply and efficiently implement one-time authentication and one-device-one-authentication, which is safe and reliable to use and can avoid repeated attacks; the length of the decentralized key is greater than 32 bytes, which can effectively avoid exhaustive attacks; during the authentication process, the middle data of decentralized keys of different lengths specified by the master device participate in the calculation of the MAC value, which improves the flexible configuration of the key length and enhances the security of the authentication; the authentication result returned by the slave device to the master device is processed data, which is sent by the master device to the slave device for reconfirmation, thereby achieving the confidentiality of the authentication result. Compared with directly transmitting the authentication result (success or failure), it is safer and more reliable and effectively avoids man-in-the-middle attacks.

[0118] Embodiment 3

[0119] Embodiment 3 of the present invention provides an identity authentication implementation system, including a master device and a slave device;

[0120] The master device is used to obtain the slave device identification in the slave device when receiving the identity registration information triggered by the user, generate a distributed key according to the master key, the key index and the slave device identification, store the distributed key and the key index in correspondence, and send the key index and the distributed key to the slave device;

[0121] Specifically, in this embodiment, the master device generates a decentralized key according to the master key, the key index and the slave device identifier, including: the master device splits the master key into different parts, generates partial decentralized keys according to the partial master keys, key indexes and slave device identifiers obtained by splitting, and splices all the partial decentralized keys to obtain a complete decentralized key; or, the master device obtains the corresponding product description information according to the slave device identifier, splices its own master key, slave device identifier, key index and product description information, and uses a first preset algorithm to calculate the splicing result to obtain a decentralized key;

[0122] The slave device is used to receive the key index and the dispersed key and store the key index and the dispersed key correspondingly;

[0123] Specifically, in this embodiment, the slave device saves the distributed key and the key index in correspondence, including: the slave device takes the key index as a parameter and calls the first function to save the distributed key; specifically: takes the key index as a parameter, calls the first function to multiply the key index by the value of the key allocation space size as an offset value, and saves the distributed key in a corresponding position according to the base address and the offset value;

[0124] Optionally, in this embodiment, the slave device is also used to return write success information to the master device;

[0125] The master device is also used to determine whether to continue writing a new key to the slave device, if yes, obtain a new key index, generate a new distributed key according to the master key, the new key index and the slave device serial number, call the first function with the new key index as a parameter to save the new distributed key in the corresponding position, send the new key index and the new distributed key to the slave device, otherwise the master device sends an initialization completion instruction to the current slave device;

[0126] The slave device is also used to set the initialization state to completed after receiving the initialization completion instruction;

[0127] The slave device is further used to set the initialization state to completed after receiving the initialization completion instruction, including: the slave device is further used to set the initialization flag after receiving the initialization completion instruction;

[0128] The master device is also used to obtain the slave device identifier and the first random number in the slave device when receiving the identity authentication information triggered by the user, generate a MAC calculation instruction according to the stored key index and the second preset algorithm identifier, and send it to the slave device;

[0129] Specifically, in this embodiment, the master device generates a calculation MAC instruction according to the stored key index and the second preset algorithm identifier, including: the master device generates a calculation MAC instruction according to the stored key index, key length, and the second preset algorithm identifier;

[0130] The slave device is also used to receive and parse the MAC calculation instruction, obtain the corresponding stored distributed key according to the key index obtained by the analysis, and calculate the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to generate a first MAC value and return it to the master device;

[0131] Optionally, in the present embodiment, the slave device information includes the slave device serial number and / or product description information, and the slave device calculates the distributed key, the first random number, and the slave device information according to an algorithm corresponding to the second preset algorithm identifier obtained by parsing to generate a first MAC value, including: the slave device obtains data of a corresponding length from the distributed key according to the key length obtained by parsing, splices the obtained data, the first random number, the slave device serial number and / or the product description information, and calculates the splicing result using the algorithm corresponding to the second preset algorithm identifier obtained by parsing to obtain the first MAC value; or, the slave device calculates the distributed key, the first random number, the slave device serial number and / or the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing to generate the first MAC value;

[0132] Further, the slave device calculates the distributed key, the first random number, the slave device serial number and / or the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to generate the first MAC value, including: the slave device splices the distributed key, the first random number, the slave device serial number and / or the product description information, and calculates the splicing result using the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to obtain the first MAC value;

[0133] The master device is also used to obtain the corresponding preset slave device information according to the slave device identifier, generate a distributed key according to the master key, the key index and the slave device identifier, calculate the generated distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value, and determine whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful, otherwise the identity authentication fails.

[0134] The master device in this embodiment is also used to establish a connection with the slave device after power-on, and determine whether the slave device has completed initialization. If so, it waits to receive identity authentication information triggered by the user, otherwise, it waits to receive identity registration information triggered by the user;

[0135] Further, the master device determines whether the slave device has completed initialization, including: the master device obtains an initialization flag in the slave device, and determines whether the obtained initialization flag is set, if yes, the initialization is completed, otherwise, the initialization is not completed.

[0136] Optionally, in this embodiment, the master device is further used to send the master device identifier to the current slave device;

[0137] Specifically, in this embodiment,

[0138] The master device is further used to obtain a third random number in the slave device after successfully authenticating the identity of the slave device, calculate the master device identifier, the third random number and the generated fourth random number using a third preset algorithm to obtain a first digest value, and send the identifier of the third preset algorithm, the fourth random number and the first digest value to the slave device;

[0139] The slave device is further used to search for a corresponding algorithm according to the received identifier of the third preset algorithm, use the found algorithm to calculate the master device identifier, the third random number, and the fourth random number to obtain a second digest value, and determine whether the second digest value is consistent with the received first digest value. If so, generate a first response according to the first preset method and return it to the master device; otherwise, generate a second response according to the second preset method and return it to the master device;

[0140] Further, in the present embodiment, the slave device generates a first response according to a first preset method, including: the slave device performs an XOR operation on the distributed key and the master device identifier to obtain a first XOR result, performs an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splices the first preset data, the first XOR result and the second XOR result, and performs a hash operation on the spliced ​​result to obtain the first response; or, the slave device splits the distributed key into a first part key and a second part key, performs an XOR operation on the first part key, the second part key and the master device identifier to obtain a first XOR result, performs an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splices the first preset data, the first XOR result and the second XOR result, and performs a hash operation on the spliced ​​result to obtain the first response;

[0141] The slave device generates a second response according to a second preset method, including: the slave device generates a fifth random number of a fifth preset length, and performs a hash operation on the fifth random number to obtain the second response;

[0142] The master device is further used to receive a response returned by the slave device, generate comparison data according to a first preset method, and determine whether the received response is consistent with the comparison data, if so, the authentication is successful, otherwise the authentication fails;

[0143] In this embodiment, the main device generates comparison data according to the first preset method, specifically: the main device performs an XOR operation on the stored distributed key and the main device identifier to obtain a third XOR result, performs an XOR operation on the third random number and the fourth random number to obtain a fourth XOR result, splices the first preset data, the third XOR result and the fourth XOR result, and performs a hash operation on the spliced ​​result to obtain comparison data; or, splits the distributed key into a first part key and a second part key, performs an XOR operation on the first part key, the second part key and the main device identifier to obtain a third XOR result, performs an XOR operation on the third random number and the fourth random number to obtain a fourth XOR result, splices the first preset data, the third XOR result and the fourth XOR result, and performs a hash operation on the spliced ​​result to obtain comparison data.

[0144] Optionally, an embodiment of the present application further provides an electronic device, the electronic device comprising at least one processor, a memory, and instructions stored in the memory and executable by at least one processor, and at least one processor executes the instructions to implement the identity authentication implementation method in the above embodiment. When the electronic device is a chip system, it can be composed of a chip, or it can include a chip and other discrete devices, which is not specifically limited in the embodiment of the present application; the chip is coupled to the memory and is used to execute a computer program stored in the memory to execute the identity authentication implementation method disclosed in the above embodiment.

[0145] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs. When a computer program is loaded and executed on an electronic device, the process or function described in the embodiment of the present application is generated in whole or in part. The computer program can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a base station, electronic device, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digitAl subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another base station, electronic device, server or data center. The computer-readable storage medium can be any available medium that can be accessed by an electronic device or a data storage device such as a server, data center, etc. that contains one or more servers that can be integrated with a medium. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (solid stAte disk, SSD)), etc. In the embodiment of the present application, the electronic device may include a master device and a slave device in the system described above.

[0146] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in a claim. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0147] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for implementing identity authentication, characterized in that: include: When the main device receives the identity registration information triggered by the user, step A1 is executed; Step A1: the master device obtains the slave device identification in the slave device, generates a distributed key according to the master key, the key index and the slave device identification, stores the distributed key and the key index in correspondence, and sends the key index and the distributed key to the slave device; Step A2: the slave device receives the key index and the distributed key and stores the key index and the distributed key in correspondence; When the main device receives the identity authentication information triggered by the user, step S1 is executed; Step S1: the master device obtains a slave device identifier and a first random number in the slave device, generates a MAC calculation instruction according to a stored key index and a second preset algorithm identifier, and sends the instruction to the slave device; Step S2: the slave device receives and parses the MAC calculation instruction, obtains the corresponding stored distributed key according to the key index obtained by the parse, calculates the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the parse to generate a first MAC value and returns it to the master device; Step S3: the master device obtains the corresponding preset slave device information according to the slave device identifier, generates a distributed key according to the master key, the key index and the slave device identifier, and calculates the generated distributed key, the first random number and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value; Step S4: The master device determines whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful; otherwise, the identity authentication fails.

2. The identity authentication implementation method as claimed in claim 1, characterized in that: Also includes: The master device and the slave device are both powered on and establish a connection. The master device determines whether the slave device has completed initialization. If so, it executes step S1 when receiving identity authentication information triggered by the user, otherwise, it executes step A1 when receiving identity registration information triggered by the user.

3. The identity authentication implementation method as claimed in claim 2, characterized in that: The step A2 further includes: the slave device returns write success information to the master device; The step A2 also includes: the master device determines whether to continue writing a new key to the slave device. If yes, the master device obtains a new key index, generates a new distributed key according to the master key, the new key index and the serial number of the slave device, calls the first function with the new key index as a parameter to save the new distributed key in a corresponding position, sends the new key index and the new distributed key to the slave device, and returns to step A2; otherwise, the master device sends an initialization completion instruction to the slave device, and the slave device sets the initialization status to completion.

4. The identity authentication implementation method as claimed in claim 1, characterized in that: The generating of the distributed key according to the master key, the key index and the slave device identification includes: splitting the master key into different parts, generating partial distributed keys according to the partial master keys, the key index and the slave device identification obtained by splitting, and splicing all the partial distributed keys to obtain a complete distributed key.

5. The identity authentication implementation method as claimed in claim 1, characterized in that: The generating of the distributed key according to the master key, the key index and the slave device identifier includes: the master device obtains the corresponding product description information according to the slave device identifier, splices its own master key, key index, the slave device identifier and the product description information, and uses a first preset algorithm to calculate the splicing result to obtain the distributed key.

6. The identity authentication implementation method as claimed in claim 1, characterized in that: The storing the distributed key and the key index in correspondence includes: taking the key index as a parameter and calling a first function to store the distributed key.

7. The identity authentication implementation method as claimed in claim 6, characterized in that: The method of using the key index as a parameter and calling the first function to save the distributed key includes: using the key index as a parameter, calling the first function to multiply the key index by the value of the key allocation space size as an offset value, and saving the distributed key in a corresponding position according to the base address and the offset value.

8. The identity authentication implementation method as claimed in claim 1, characterized in that: The generating the calculation MAC instruction according to the stored key index and the second preset algorithm identifier includes: generating the calculation MAC instruction according to the stored key index, the key length and the second preset algorithm; The method of calculating the distributed key, the first random number, and the slave device information to generate a first MAC value according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing includes: obtaining data of corresponding length from the distributed key according to the key length obtained by parsing, splicing the obtained data, the first random number, and the slave device information, and using the algorithm corresponding to the second preset algorithm identifier obtained by parsing to calculate the splicing result to obtain the first MAC value.

9. The identity authentication implementation method as claimed in claim 1, characterized in that: The slave device information includes a slave device serial number and / or product description information; The method of calculating the first MAC value from the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing includes: calculating the first MAC value from the distributed key, the first random number, the slave device serial number and / or the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing.

10. The identity authentication implementation method as claimed in claim 9, characterized in that: The method of calculating the distributed key, the first random number, the slave device serial number and / or the product description information according to the algorithm corresponding to the second preset algorithm identifier obtained by parsing to generate the first MAC value includes: splicing the distributed key, the first random number, the slave device serial number and / or the product description information, and using the algorithm corresponding to the second preset algorithm identifier obtained by parsing to calculate the splicing result to obtain the first MAC value.

11. The identity authentication implementation method according to claim 1, characterized in that: After step A2, the method further includes: the master device sending the master device identification to the slave device.

12. The identity authentication implementation method according to claim 11, characterized in that: Also includes: The slave device authenticates the identity of the master device, and after the identity authentication is successful in step S4, the following further comprises: Step P1: the master device obtains the third random number in the slave device, and uses a third preset algorithm to calculate the master device identifier, the third random number and the generated fourth random number to obtain a first digest value; Step P2: the master device sends the identifier of the third preset algorithm, the fourth random number and the first digest value to the slave device; Step P3: the slave device searches for a corresponding algorithm according to the received identifier of the third preset algorithm, and uses the corresponding algorithm to calculate the master device identifier, the third random number, and the fourth random number to obtain a second digest value; Step P4: the slave device determines that the second digest value is consistent with the received first digest value, and if so, generates a first response according to a first preset method and returns it to the master device; otherwise, generates a second response according to a second preset method and returns it to the master device; Step P5: The master device receives the response returned by the slave device, generates comparison data according to the first preset method, and determines whether the received response is consistent with the comparison data. If so, the authentication is successful, otherwise the authentication fails.

13. The identity authentication implementation method as claimed in claim 12, characterized in that: The generating of the first response according to the first preset method includes: performing an XOR operation on the distributed key and the main device identifier to obtain a first XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splicing the first preset data, the first XOR result and the second XOR result, and performing a hash operation on the spliced ​​result to obtain the first response.

14. The identity authentication implementation method according to claim 12, characterized in that: The generating of the first response according to the first preset method includes: splitting the distributed key into a first part key and a second part key, performing an XOR operation on the first part key, the second part key and the main device identifier to obtain a first XOR result, performing an XOR operation on the third random number and the fourth random number to obtain a second XOR result, splicing first preset data, the first XOR result and the second XOR result, and performing a hash operation on the spliced ​​result to obtain the first response.

15. The identity authentication implementation method according to claim 12, characterized in that: The generating the second response according to the second preset method includes: generating a fifth random number of a fifth preset length, and performing a hash operation on the fifth random number to obtain the second response.

16. An identity authentication implementation system, characterized in that: Including master and slave devices, The master device is used to obtain the slave device identification in the slave device when receiving the identity registration information triggered by the user, generate a distributed key according to the master key, the key index and the slave device identification, store the distributed key and the key index in correspondence, and send the key index and the distributed key to the slave device; The slave device is used to receive the key index and the distributed key and store the key index and the distributed key in correspondence; The master device is also used to obtain the slave device identifier and the first random number in the slave device when receiving the identity authentication information triggered by the user, generate a MAC calculation instruction according to the stored key index and the second preset algorithm identifier, and send it to the slave device; The slave device is further used to receive and parse the MAC calculation instruction, obtain the corresponding stored distributed key according to the key index obtained by the analysis, and calculate the distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier obtained by the analysis to generate a first MAC value and return it to the master device; The master device is also used to obtain the corresponding preset slave device information according to the slave device identifier, generate a distributed key according to the key index and the slave device identifier, calculate the generated distributed key, the first random number, and the slave device information according to the algorithm corresponding to the second preset algorithm identifier to generate a second MAC value, and determine whether the first MAC value is consistent with the second MAC value. If so, the identity authentication is successful, otherwise the identity authentication fails.

17. An electronic device, characterized in that: The electronic device includes at least one processor, a memory, and instructions stored in the memory and executable by the at least one processor, and the at least one processor executes the instructions to implement the identity authentication method described in any one of claims 1 to 15.

18. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a computer program, and when the computer program is executed on an electronic device, the electronic device executes the identity authentication implementation method as claimed in any one of claims 1 to 15.

19. A chip system, characterized in that: It comprises a chip, which is coupled to a memory and is used to execute a computer program stored in the memory to execute the identity authentication implementation method described in any one of claims 1 to 15.