WO2022241799A1 - Key generation method and apparatus - Google Patents

Key generation method and apparatus Download PDF

Info

Publication number
WO2022241799A1
WO2022241799A1 PCT/CN2021/095348 CN2021095348W WO2022241799A1 WO 2022241799 A1 WO2022241799 A1 WO 2022241799A1 CN 2021095348 W CN2021095348 W CN 2021095348W WO 2022241799 A1 WO2022241799 A1 WO 2022241799A1
Authority
WO
WIPO (PCT)
Prior art keywords
key
vehicle
message
mounted device
kms
Prior art date
Application number
PCT/CN2021/095348
Other languages
French (fr)
Chinese (zh)
Inventor
盛德
耿峰
殷新星
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN202180098495.4A priority Critical patent/CN117378169A/en
Priority to PCT/CN2021/095348 priority patent/WO2022241799A1/en
Publication of WO2022241799A1 publication Critical patent/WO2022241799A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials

Definitions

  • the present application relates to the technical field of intelligent networked vehicles, in particular to a key generation method and device.
  • the management of the basic key for communication between in-vehicle devices all depends on the key manager system in vehicle (KMS) outside the vehicle in the cloud to manage the keys of each device in the vehicle.
  • KMS key manager system in vehicle
  • the key is filled (that is, preset) into the secure storage area of each component through tools. All the keys needed between the various components in the car are managed in the car factory's cloud KMS.
  • the present application provides a key generation method and device, which are used to improve the management performance of the vehicle key and provide the security of the vehicle key.
  • the present application provides a method for generating a key, which is applied to a vehicle, including:
  • the first vehicle-mounted device obtains the first message; the first message is used to instruct the first vehicle-mounted device to construct the first key; according to the first message, a first request message is generated; the first request message is used for the first key corresponding to the first vehicle-mounted device
  • the secure hardware expansion unit generates a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key.
  • the first on-board device of the vehicle builds a first Key
  • the first key information generated after encryption by the first security hardware expansion unit is returned to the first vehicle-mounted device, so that the first vehicle-mounted device can safely generate the first key inside the vehicle without generating the first key through the cloud.
  • the key also participates in the management of the first key throughout the whole process, which reduces the difficulty and complexity of cloud management of vehicle keys, and at the same time reduces the possibility of leaking vehicle keys through the cloud, improving the security of the first key inside the vehicle.
  • a first response message sent from the first security hardware expansion unit is received.
  • the first vehicle-mounted device can obtain the first key information through the first response message, that is, obtain the encrypted first key through the first response message, so as to ensure the security of the first key.
  • it can be verified by sending the first key information through the first vehicle-mounted equipment, and then fill the first key, so that the first key can be shared between the vehicle-mounted equipment, for example , between the first vehicle-mounted device and the second vehicle-mounted device, the security of transmission and the security of filling are performed.
  • the security of the first key from generation to filling is ensured.
  • a possible implementation manner is to receive the first parameter of the first key sent by the first security hardware expansion unit; the first vehicle-mounted device generates a first key loading message according to the first parameter of the first key; the first The vehicle-mounted device sends a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
  • the first security hardware expansion unit generates the first parameter of the first key, and the first parameter may be a parameter for the second on-vehicle device to perform security verification on the first key, for example, the first key
  • the first parameter of the key can be a parameter for integrity verification, and can also be a first parameter encrypted based on the vehicle's security verification key. Therefore, after receiving the first key loading message, the second vehicle-mounted device can upload the first key. Integrity verification is performed on the parameters of the integrity verification of the first key information. After the integrity verification is successful, the second vehicle-mounted device can decrypt the parameters encrypted based on the security verification key in the first key information to obtain the first key information. key. Thus, the security of the first key filling is ensured.
  • the first vehicle-mounted device after the first vehicle-mounted device obtains the first message, the first vehicle-mounted device sends a status update message to the first security hardware expansion unit; the status update message includes: the construction status of the key in the vehicle; the status update message uses After the first security hardware extension unit successfully verifies the status update message, it updates the construction status of its own in-vehicle key.
  • the first vehicle-mounted device can determine that the in-vehicle key is in the construction state based on the first message, so it can send a status update message to the first security hardware expansion unit, so that the first security hardware expansion unit updates its own in-vehicle key.
  • the build status of the key includes: build complete, not build, build, build failure, etc.
  • a status update message may be used to update the build status of the in-vehicle key to being built.
  • the first security hardware expansion unit may update the construction status of the in-vehicle key to being under construction. Therefore, when the first security hardware expansion unit receives the first request message, it can verify the first request message based on the construction state of the in-vehicle key of the first security hardware expansion unit itself.
  • the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message. For example, when the construction state of the in-vehicle key of the first security hardware expansion unit itself is under construction, if the first request message is received, the first request message may verify the integrity and integrity of the first request message in other ways. After security, generate the first key. And when the construction state of the key in the vehicle of the first safety hardware expansion unit itself is not in construction, if the first request message is received, the first safety hardware expansion unit can refuse to execute the first request message to ensure that the vehicle builds the first request message.
  • One-key security is used by the first security hardware expansion unit to verify the first request message. For example, when the construction state of the in-vehicle key of the first security hardware expansion unit itself is under construction, if the first request message is received, the first request message may verify the integrity and integrity of the first request message in other ways. After security, generate the first key. And when the construction state of the key in the vehicle of the first safety hardware expansion unit
  • a possible implementation is to send a first query request to the first security hardware extension unit after it is determined that the first vehicle-mounted device is restarted; the first query request is used to query the second parameter of the first key; and receive the first security hardware extension unit
  • the first vehicle-mounted device can query the first security hardware expansion unit for the current state of the first key generated by the first security hardware expansion unit, for example, whether the first key has been generated Success, the number of updates of the first key, etc.
  • the first vehicle-mounted device in order to ensure the security of the first query message, can encrypt and integrity protect the first query message, so that after the first security hardware extension unit receives the first query message, it can A query message is verified, for example, including decrypting and integrity verification of the first query message, and after the verification is successful, the second parameter of the first key queried by the first query request is returned to the second query message through the first query response message.
  • a vehicle-mounted device in order to ensure the security of the first query message, the first vehicle-mounted device can encrypt and integrity protect the first query message, so that after the first security hardware extension unit receives the first query message, it can A query message is verified, for example, including decrypting and integrity verification of the first query message, and after the verification is successful, the second parameter of the first key queried
  • the first in-vehicle device may verify the first query response message, and obtain the second parameter of the first key after the verification is successful.
  • the first security hardware expansion unit can also verify the first query message by querying the construction state of the vehicle key of the first security hardware expansion unit itself, so as to ensure that the first security hardware expansion unit
  • the legal source of a query message is in the process of building the key in the vehicle, so as to ensure the security of the first query message.
  • a possible implementation manner is to receive a temporary key sent from the first secure hardware expansion unit; the temporary key is used to encrypt the first request message.
  • the first secure hardware expansion unit can configure a temporary key for the safe transmission of messages between the first vehicle-mounted device and the first secure hardware
  • the first request message considering that the temporary key is limited to the safe transmission of messages between the first vehicle-mounted device and the first security hardware expansion unit, can simplify the setting method of the temporary key, reduce the cost of the first vehicle-mounted device and the first Messages are transmitted between the safety hardware expansion units, which reduces the overhead and complexity of the first vehicle-mounted device and the first safety hardware expansion unit while improving safety.
  • a possible implementation manner is to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key or indicating The second in-vehicle device restarts.
  • the second vehicle-mounted device can send a second message to the first vehicle-mounted device, so that the second vehicle-mounted device can query the second parameter of the first key, and can also request the first vehicle-mounted device Generating the first key can also notify the first vehicle-mounted device to restart the second vehicle-mounted device, so that the first vehicle-mounted device can perform corresponding operations for the restart of the second vehicle-mounted device, so as to reduce the impact of the restart of the second vehicle-mounted device on the first key. For example, before the first vehicle-mounted device determines that the second vehicle-mounted device restarts, the first vehicle-mounted device has sent a loading message of the first key.
  • the first vehicle-mounted device can , it is determined that the second vehicle-mounted device has not been successfully filled with the first key, therefore, the first vehicle-mounted device may send the loading message of the first key again, so as to fill the second vehicle-mounted device with the first key.
  • the possibility of failure to fill the first key in the second vehicle-mounted device due to the restart of the second vehicle-mounted device is reduced, and the success rate of filling the first key in the second vehicle-mounted device is improved.
  • a third message is sent to the second vehicle-mounted device; the third message includes at least one of the following: a second parameter of the first key, and information about the first key.
  • the first vehicle-mounted device can send the third message to the second vehicle-mounted device after performing security verification on the second message, for example, after performing integrity verification on the second message based on the security verification key of the second message,
  • the second vehicle-mounted device can obtain at least one of the second parameter of the first key or the first key information, so that after the second vehicle-mounted device is restarted, it returns to the construction state of the in-vehicle key and the first key before the restart. A key's filling status.
  • the first message is obtained according to any of the following:
  • the first message After receiving the initialization or update information of the shared key between the on-board devices of the vehicle, the first message is obtained.
  • the generation of the first key can be flexibly triggered, so that the first on-board device of the vehicle can generate the first key in various scenarios, and the applicability of key generation in the vehicle can be improved.
  • the present application provides a method for generating a key, which is applied to a vehicle, including: the first security hardware expansion unit receives the first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message For the first vehicle-mounted device to request the first security hardware expansion unit to construct the first key generation; after the first request message is successfully verified, the first key information is generated; the first key information is encrypted by the first key Generated.
  • the first key is constructed for the communication of the vehicle-mounted device in the vehicle, and the first key information generated after being encrypted by the first safety hardware expansion unit is returned to the first key information A vehicle-mounted device, so that the first vehicle-mounted device can safely generate the first key inside the vehicle, without the need to generate the first key through the cloud and participate in the management of the first key throughout the process, reducing the difficulty and complexity of cloud-based vehicle key management At the same time, it avoids the possibility of leaking the vehicle key through the cloud, and improves the security of the first key inside the vehicle.
  • a first response message is sent to the first vehicle-mounted device; the first response message includes: first key information.
  • the first parameter of the first key is generated; the first parameter of the first key is sent to the first vehicle-mounted device; the first parameter of the first key It is used to fill the first key in the second vehicle-mounted device.
  • a possible implementation is to receive a status update message sent by the first vehicle-mounted device; the status update message includes: the build status of the in-vehicle key; after the status update message is successfully verified, update the build status of its own in-vehicle key.
  • the first query request sent by the first vehicle-mounted device is received; the first query request is used to query the second parameter of the first key; and the first query request is verified After that, send the first query response message to the first vehicle-mounted device; the first query response message includes: the second parameter of the first key; the second parameter of the first key is used for the first vehicle-mounted device to generate the first request message;
  • the first key is a key to be generated by the first security hardware expansion unit before restarting.
  • a temporary key is generated; the temporary key is sent to the first vehicle-mounted device; and the temporary key is used to encrypt the first request message.
  • a possible implementation manner is to receive a verification message of a second message from the first vehicle-mounted device; the second message is sent by the first vehicle-mounted device to receive the second message; the second message is used for at least one of the following: querying the first The second parameter of the key requests the first vehicle-mounted device to generate the first key or instructs the second vehicle-mounted device to restart.
  • a possible implementation manner after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device; the response message of the second message is used for the first vehicle-mounted device to send the third message to the second vehicle-mounted device ;
  • the third message includes at least one of the following items: the second parameter of the first key, and the first key information.
  • the present application provides a method for acquiring a key, which is applied to a vehicle, including: the first vehicle-mounted device receives a first message sent by an off-vehicle device; the first message is used to request the first vehicle-mounted device to obtain a first key; According to the verification information of the first message and the first vehicle-mounted device, an identity verification request message is generated, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device; The server sends the identity verification request message; receives the identity verification response message sent by the server; the identity verification response message includes: the verification result of the identity verification request message.
  • the off-vehicle device can trigger the first on-vehicle device to securely obtain the first key, wherein, after the off-vehicle device sends the first message, the first on-vehicle device can based on the first message and the verification information of the first on-vehicle device
  • the first in-vehicle device obtains the authority of the first key
  • the corresponding user of the first in-vehicle device obtains the authority of the first key, etc.
  • generates an identity verification request message sent to the server thereby, through the server, the identity verification request
  • the message is verified, and the first vehicle-mounted device can obtain the first key only after the verification is successful, which improves the security of the first vehicle-mounted device obtaining the first key.
  • the first message may be a personal identification number (personal identification number, PIN) code sent by the off-vehicle device, and the first on-vehicle device may encrypt the PIN code sent for the device according to the plan, and carry it in the identity verification request message, so that The server verifies the encrypted PIN to improve the security of verification.
  • the first in-vehicle device can also obtain the certificate of the out-of-vehicle device through the out-of-vehicle device, or the certificate generated by the first in-vehicle device itself. The certificate can be used to verify the identity of the first in-vehicle device.
  • the server may determine whether the first vehicle-mounted device has the right to obtain the first key based on the verification result of the certificate.
  • the first vehicle-mounted device receives a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the first vehicle-mounted device generates a first request message according to the first message; The first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key of.
  • the server can send the first message to the first vehicle-mounted device, at this time, the first vehicle-mounted device can generate a first request message based on the first message, It is used to instruct the first security hardware expansion unit to generate the first key.
  • the safe generation of the first key in the vehicle is realized, and the process of generating the first key by the first vehicle-mounted device is verified by the server Execution improves the security of generating the first key.
  • the first key may be loaded in the first vehicle-mounted device, or may be loaded in the second vehicle-mounted device.
  • the first key may be loaded in the first vehicle-mounted device, or may be loaded in the second vehicle-mounted device.
  • the first vehicle-mounted device receives the first key sent by the server.
  • the first vehicle-mounted device can securely obtain the first key stored in the server. Improves the security of obtaining the first key maintained by the server.
  • the first on-vehicle device sends the first key to the off-vehicle device when the verification result of the identity verification request message is that the verification is successful.
  • the first on-vehicle device after the first on-vehicle device stores the first key, it can also send the first key to the off-vehicle device based on the verification result of the identity verification request message.
  • the off-vehicle device is a vehicle diagnostic device
  • the vehicle diagnostic device collects and diagnoses vehicle data
  • it can be encrypted with the first key, and therefore, can be encrypted based on the second key.
  • the server verification method verifies that the first vehicle-mounted device obtains the first key legally, and at the same time, it can also verify the legitimacy of the off-vehicle device obtaining the first key through the first vehicle-mounted device. Security of the first key.
  • the first key may be generated by the first on-vehicle device for the off-vehicle device based on the first request message, or may be a key stored by the first on-vehicle device for communication with the off-vehicle device , which is not limited in this application.
  • the vehicle diagnostic device may notify the first on-board device to delete the first key, and the vehicle may also delete the first key for the device.
  • the first key can be regenerated to be used in the current diagnosis process. Improve vehicle data security.
  • the present application provides a method for obtaining a key, which is applied to a server, including:
  • the server receives the identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device; according to the identity verification request message, the server The first in-vehicle device obtains the authority of the first key and the verification information of the first in-vehicle device for verification, and generates an identity verification response message; the identity verification response message includes: a verification result of the identity verification request message.
  • the server sends an identity verification response message to the first in-vehicle device.
  • the identity verification request message is verified by the server.
  • the first vehicle-mounted device can obtain the first key, and the first vehicle-mounted device is triggered by the external device to securely obtain the first key.
  • the server can verify the first message from the off-vehicle device and the verification information of the first vehicle-mounted device.
  • the first vehicle-mounted device obtains the authority of the first key, and the first The in-vehicle device verifies the user's authority to obtain the first key, etc., thereby improving the security of the first in-vehicle device in obtaining the first key.
  • the server sends a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate the first key.
  • the server sends the first key to the first vehicle-mounted device.
  • the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
  • the present application provides a key generation device, the device is an on-board device or KMS in a vehicle, and the device includes:
  • An obtaining unit configured to obtain a first message; the first message is used to instruct the first vehicle-mounted device to construct a first key;
  • the processing unit is configured to generate a first request message according to the first message; the first request message is used for the first security hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: a first key information; the first key information is generated after encrypting the first key.
  • the receiving unit is configured to receive the first response message sent from the first security hardware expansion unit.
  • the receiving unit is configured to receive the first parameter of the first key sent from the first secure hardware expansion unit;
  • a processing unit configured to generate a first key loading message according to a first parameter of the first key
  • the sending unit is configured to send a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
  • the sending unit is further configured to send a status update message to the first security hardware extension unit;
  • the status update message includes: the construction status of the key in the vehicle; the status update message uses
  • the first security hardware extension unit successfully verifies the status update message, it updates the construction status of its own in-vehicle key.
  • the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message.
  • the sending unit sends a first query request to the first security hardware expansion unit; the first query request is used to query the second parameter of the first key;
  • the receiving unit receives the first query response message sent by the first security hardware expansion unit; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first query response message includes: the first password The second parameter of the key; according to the second parameter of the first key and the first message, generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before the restart of the first vehicle-mounted device.
  • the receiving unit is configured to receive the temporary key sent from the first secure hardware extension unit; the temporary key is used to encrypt the first request message.
  • the receiving unit is configured to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate a second A key or instructs the second in-vehicle device to restart.
  • the sending unit sends the third message to the second vehicle-mounted device;
  • the third message includes at least one of the following items: the second parameter of the first key, the first key information.
  • the first message is obtained according to any of the following:
  • the first message After receiving the initialization or update information of the fixed key of the vehicle through the receiving unit, the first message is obtained;
  • the first message is obtained after the receiving unit receives the initialization or update information of the shared key between the on-vehicle devices of the vehicle.
  • the present application provides a key generation device, which is a security hardware expansion unit in a vehicle, and the device includes:
  • the receiving unit is configured to receive a first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key;
  • the processing unit is configured to generate first key information after successfully verifying the first request message; the first key information is generated after encrypting the first key.
  • the key generation device includes a sending unit, configured to send a first response message to the first vehicle-mounted device; the first response message includes: first key information.
  • a possible implementation manner after the processing unit successfully verifies the first request message, generates the first parameter of the first key; sends the first parameter of the first key to the first vehicle-mounted device through the sending unit; the first key The first parameter of the key is used to fill the first key in the second vehicle-mounted device.
  • the receiving unit is also used to receive the status update message sent by the first vehicle-mounted device; the status update message includes: the construction status of the in-vehicle key; the processing unit is also used to verify the status update message successfully. , to update the build status of its own in-vehicle key.
  • the receiving unit is further configured to receive a first query request sent by the first vehicle-mounted device after the first vehicle-mounted device restarts; the first query request is used to query the second parameter of the first key;
  • the processing unit is configured to send a first query response message to the first vehicle-mounted device through the sending unit after verifying the first query request; the first query response message includes: the second parameter of the first key; The second parameter is used for the first vehicle device to generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
  • the processing unit is configured to generate a temporary key after the first request message is verified successfully; send the temporary key to the first vehicle-mounted device through the sending unit; the temporary key is used to encrypt the first request message .
  • the receiving unit is configured to receive a verification message of a second message from the first vehicle-mounted device; the second message is received by the first vehicle-mounted device and sent by the second vehicle-mounted device; the second message is used for at least one of the following: Item: query the second parameter of the first key, request the first vehicle-mounted device to generate the first key, or instruct the second vehicle-mounted device to restart.
  • the processing unit is configured to, after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device through the sending unit; the response message of the second message is used for the first vehicle-mounted device to send
  • the second in-vehicle device sends a third message; the third message includes at least one of the following items: the second parameter of the first key, and information about the first key.
  • the present application provides a key generation device, the device is an on-board device or KMS in a vehicle, the device may include a processor, the processor is connected to the memory, the memory is used to store computer programs, and the processor is used to execute the memory A computer program stored in the device, so that the device executes the method according to any one of the above-mentioned first aspects.
  • the present application provides a key generation device, which is a secure hardware expansion unit in a vehicle.
  • the device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the memory.
  • a computer program stored in the device so that the device executes the method according to any one of the above-mentioned second aspects.
  • the present application provides a vehicle, including the key generation device according to any one of the fifth aspect above and the key generation device according to any one of the sixth aspect.
  • the present application provides a key acquisition device, the device is an on-board device or KMS in a vehicle, and the device includes:
  • the receiving unit is configured to receive the first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain the first key; receive the response message of identity verification sent by the server; the response message of identity verification includes: identity verification Validation result of the request message.
  • the processing unit is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the first vehicle-mounted device The information is verified.
  • the sending unit is configured to send an identity verification request message to the server.
  • the receiving unit is further configured to receive a first message sent by the server; the first message is configured to instruct the first vehicle-mounted device to generate a first key; and the processing unit is further configured to generate a second key according to the first message.
  • a request message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; Generated after key encryption.
  • the receiving unit is further configured to receive the first key sent by the server.
  • the processing unit is further configured to send the first key to the off-vehicle device through the sending unit when the verification result of the identity verification request message is that the verification is successful.
  • the present application provides a key acquisition device, the device is a server, and the device includes:
  • the receiving unit is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
  • the processing unit is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: identity verification Validation result of the request message.
  • a sending unit configured to send a response message of identity verification to the first vehicle-mounted device.
  • the sending unit is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
  • the sending unit is further configured to send the first key to the first vehicle-mounted device.
  • the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
  • the present application provides a key acquisition device, the device is a server, and the device includes: the device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the A computer program stored to cause the device to execute the method according to any one of the third aspect above.
  • the present application provides a key acquisition device, the device is a server, and the device includes: the device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the A computer program stored to cause the device to execute the method according to any one of the fourth aspect above.
  • the present application provides a vehicle, including the key acquisition device according to any of the above tenth or twelfth aspects.
  • the present application provides a key generation system, including the key generation device according to any one of the fifth aspect and the key generation device according to any one of the sixth aspect.
  • off-vehicle equipment may also be included.
  • the present application provides a key acquisition system, including any key acquisition device in the tenth or twelfth aspect and any key acquisition device in the eleventh or thirteenth aspect, which can Optionally, off-vehicle equipment may also be included.
  • the present application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the method according to any one of the above-mentioned first aspects, or the above-mentioned second aspect is implemented.
  • the present application provides a computer program product.
  • the computer program product includes a computer program or an instruction.
  • the method according to any one of the above-mentioned first aspects, or the above-mentioned first aspect is implemented.
  • the embodiment of the present application provides a chip, the chip includes a data interface and a processor, wherein the processor is used to execute the method in the first aspect or any possible implementation of the first aspect, or the above-mentioned The method of any one of the second aspect, or the method of realizing any one of the third aspect above, or the method of realizing any one of the fourth aspect of the above claim.
  • the chip is any chip on which software or firmware is installed on the vehicle.
  • the present application provides a chip system, the chip system includes at least one processor, configured to support the implementation of the functions involved in the above-mentioned first aspect or any possible implementation of the first aspect, the above-mentioned first aspect Any one of the methods, or the function involved in any one of the above-mentioned second aspects, or realize the functions involved in any one of the above-mentioned third aspects, or realize the fourth aspect of the above-mentioned claims The functions involved in any of the. For example, such as receiving or processing data and/or information involved in the methods described above.
  • the chip system further includes a memory, the memory is used to store program instructions and data, and the memory is located inside or outside the processor.
  • the system-on-a-chip may consist of chips, or may include chips and other discrete devices.
  • FIG. 1 is a schematic diagram of a possible system architecture applicable to an embodiment of the present application
  • Fig. 2 exemplarily shows a life cycle diagram of a long-term key in a vehicle provided by an embodiment of the present application
  • Figure 3- Figure 7 exemplarily shows the schematic flow chart corresponding to the key generation method provided by the embodiment of the present application.
  • FIG. 8 is a schematic diagram of a possible system architecture applicable to the embodiment of the present application.
  • FIG. 9 exemplarily shows a schematic flow chart corresponding to a method for obtaining a key provided in an embodiment of the present application.
  • FIG. 10 exemplarily shows a schematic structural diagram corresponding to a key generation device provided in the embodiment of the present application.
  • FIG. 11 exemplarily shows a schematic structural diagram corresponding to a key generation device provided in the embodiment of the present application.
  • FIG. 12 exemplarily shows a schematic structural diagram corresponding to a key acquisition device provided in the embodiment of the present application.
  • FIG. 13 exemplarily shows a schematic structural diagram of a key acquisition device provided in the embodiment of the present application.
  • the solutions in the embodiments of the present application can be applied to the Internet of Vehicles, such as vehicle to everything (V2X), long term evolution-vehicle (LTE-V), vehicle-to-vehicle (vehicle to vehicle, V2V) and so on.
  • V2X vehicle to everything
  • LTE-V long term evolution-vehicle
  • V2V vehicle-to-vehicle
  • the other devices include but are not limited to: vehicle-mounted terminals, vehicle-mounted controllers, vehicle-mounted modules, vehicle-mounted modules, vehicle-mounted components, vehicle-mounted chips, vehicle-mounted units, vehicle-mounted radars, or vehicle-mounted cameras.
  • a vehicle-mounted module implements the key generation method provided by this application.
  • the key generation method in the embodiment of the present application can also be used in other intelligent terminals with key generation functions other than vehicles, or set in other servers with key generation functions other than vehicles, or Set in the components of the smart terminal or server.
  • the smart terminal may be a smart transportation device, a smart home device, a robot, and the like. For example, it includes but is not limited to smart terminals or controllers, chips, radars or cameras and other sensors in the smart terminals, and other components.
  • the server involved in the embodiment of this application can be a local server or a cloud server, and the server can be deployed in various ways.
  • the server can be a separate physical machine, and for another example, the server can also be a physical A certain virtual machine (virtual machine, VM) loaded on the server, for another example, the server can also be a certain container (docker) loaded on a certain physical server, etc.
  • VM virtual machine
  • the server can also be a certain container (docker) loaded on a certain physical server, etc.
  • the following embodiments take the server as a cloud server for exemplary description, and the cloud server may also be referred to as the cloud for short.
  • the vehicle can adopt an electrical/electronic (E/E) architecture, which includes three levels, which are gateway electronic control unit (electronic control unit, ECU), Domain controller ECU and intra-domain ECU.
  • E/E electrical/electronic
  • ECU electronic control unit
  • Domain controller ECU Domain controller ECU
  • intra-domain ECU the vehicle can adopt an electrical/electronic (E/E) architecture, which includes three levels, which are gateway electronic control unit (electronic control unit, ECU), Domain controller ECU and intra-domain ECU.
  • the domain controller ECU is used to manage the intra-domain ECUs in the corresponding domain.
  • the gateway ECU is used to manage the domain controller ECU.
  • it can be divided into four domains, namely, vehicle control system domain, entertainment system domain, diagnostic system domain and intelligent driving domain.
  • Each domain corresponds to a domain controller ECU.
  • the above 4 domains correspond to 4 domain controller ECUs in total.
  • the gateway ECU is used to manage the 4 domain controller
  • Fig. 1 in the whole E/E structure, comprise 4 controller area network (controller area network, CAN) buses, are respectively CAN bus 1, CAN bus 2, CAN bus 3 and CAN bus 4.
  • the four CAN buses in FIG. 2 may correspond to the four fields in FIG. 1 .
  • CAN bus 1 in Figure 1 may correspond to the vehicle control system domain
  • CAN bus 2 may correspond to the entertainment system domain
  • CAN bus 3 may correspond to the diagnostic system domain
  • CAN bus 4 may correspond to the intelligent driving domain, etc.
  • FIG. 1 is only for schematic illustration, and is not intended to limit the embodiment of the present application.
  • the method provided in the embodiment of the present application can be applied to other two-layer or one-layer architectures in addition to the three-layer architecture shown in FIG. 1 above, without limitation.
  • ECU Electronic control unit
  • multiple ECUs can be configured inside the vehicle, such as ECU 1, ECU 2, ..., ECU N shown in Figure 1, where N is a positive integer.
  • each ECU can have its own specific functions, and also supports simple sensor data processing and complex logic calculation.
  • ECUs include but are not limited to: vehicle sensors, vehicle cameras, multi-domain controllers (multi domain controllers, MDCs), automated-driving control units (automated-driving control units, ADCUs), pre-installed intelligent gateways (telematics boxes, T-Box), can also be called vehicle information box, smart cockpit domain controller (cockpit domain controller, CDC), vehicle gateway, vehicle control unit (vehicle control unit, VCU), battery management system (battery management system, BMS) , thermal management system (thermal management system, TMS), power distribution unit (power distribution unit, PDU), etc.
  • vehicle information box smart cockpit domain controller (cockpit domain controller, CDC)
  • vehicle gateway vehicle control unit
  • vehicle control unit vehicle control unit
  • VCU vehicle control unit
  • BMS battery management system
  • thermal management system thermal management system
  • TMS power distribution unit
  • PDU power distribution unit
  • the gateway is the core part of the vehicle architecture.
  • the gateway can transfer CAN, local interconnection network (local interconnection network, LIN), multimedia transmission system (media oriented systems transport, MOST), FlexRay and other network data Routing in different networks.
  • the gateway can manage domain control devices and devices in the domain.
  • the gateway may include a gateway ECU, and the gateway and the gateway ECU are not distinguished from each other.
  • vehicle electronics can be divided into several domains.
  • the power transmission domain the body electronics domain, and the assisted driving domain.
  • There is a domain control device in each domain which is used to manage the devices in the domain.
  • a domain control device may also be referred to as a domain controller.
  • the domain control device includes a domain control ECU, and the domain control device and the domain control device ECU are not distinguished from each other.
  • vehicle electronics can be divided into several domains.
  • the power transmission domain the body electronics domain, and the assisted driving domain.
  • Each domain may include a domain controller and multiple controlled devices, and the devices in the domain may specifically refer to the controlled devices in each domain.
  • the in-domain equipment may include an in-domain ECU, and the in-domain equipment and the in-domain ECU are not distinguished from each other.
  • each ECU in the vehicle can exchange messages depending on the communication technology set when the vehicle leaves the factory.
  • These communication technologies may be, for example, LIN technology or CAN technology, and may also be other communication technologies that realize message interaction.
  • CAN messages can be sent between different ECUs.
  • Each ECU can be connected to the same CAN bus, and any ECU can freely read and send CAN message frames on the CAN bus.
  • Each CAN message frame on the CAN bus generally only has a message identifier, and does not carry a source address or a destination address.
  • Each ECU connected to the CAN bus can select which message frame to receive through the message identifier.
  • Every CAN message frame injected by the attacker may be read by the ECU in the vehicle and considered as a legitimate CAN message frame, so that the attacker can fully control Functions of the vehicle, such as braking or accelerating, which are very unsafe for the user to use the vehicle.
  • each ECU in the vehicle can be configured with its own corresponding long-term key.
  • the ECU can also use a pre-configured long-term key to parse the CAN message frame. If the parsing is unsuccessful, it means that the CAN message frame is likely to belong to an illegal control command injected on the CAN bus by an illegal person, so the ECU may not perform the corresponding control operation to prevent the illegal person from controlling the vehicle. If the parsing is successful, it means that the CAN message frame belongs to a legal control command injected on the CAN bus by a legal person (such as a car owner), so the ECU can perform corresponding control operations. In this way, by presetting the long-term key in each ECU to complete the authentication operation of the CAN message frame, it is helpful to authenticate the control command before actually executing the control, so as to improve the driving safety of the vehicle owner.
  • a KMS may also be configured inside the vehicle.
  • the KMS in the vehicle is mainly responsible for functions such as generating keys, managing keys, and clearing keys. , APP) and other off-vehicle devices to obtain the key. Based on the functions or permissions of KMS, it can be divided into KMS server (Server), KMS agent (Agent) and KMS client (Client).
  • the KMS server can be deployed on the domain controller in the vehicle (such as VDC, CDC, MDC, etc.), or it can be deployed on the gateway, T-BOX, or an independent device.
  • the service end of KMS can include the SHE that supports the key generation method of the present application, and can also include other secure hardware mechanisms such as a hardware security module (hardware security module, HSM) that supports the key verification function corresponding to key generation.
  • the KMS client can be various sensors, ECU components and other devices except the KMS server.
  • the KMS client can include SHE, which can support the key generation process in this application, and can also be used to support the secure storage function of the key.
  • the KMS client may also include other secure hardware mechanisms such as HSM to support secure key storage.
  • the agent (Agent) end of the KMS may be a device for connecting domain controllers, gateways, T-BOXs, sensor devices, and ECU components.
  • the KMS agent can be used as a KMS sub-server (Sub Server) to manage the key generation process of the KMS client connected to the agent.
  • the agent can form an agent domain with at least one KMS client connected to the agent.
  • the KMS server and KMS client can be pre-filled with keys for secure communication with each other.
  • each device can be filled with a fixed key (for example, GLOBAL_FIX_KEY) in advance. It can also be filled with a fixed key used between the KMS server and some KMS clients. This fixed key can be used as a key for secure communication between the KMS server and some KMS clients. , is not limited here.
  • keys include the long-term keys described above. Unlike traditional information and communications technology (ICT), most ECUs in the Internet of Vehicles follow the automotive, cyber security (EVITA) standard and secure hardware extension (SHE) standard. Exemplarily, considering the performance and cost of key setting under the EVITA standard and the SHE standard, the long-term key in the KMS can be set as a symmetric key.
  • ICT information and communications technology
  • EVITA cyber security
  • SHE secure hardware extension
  • Fig. 2 exemplarily shows a life cycle diagram of a long-term key in a vehicle provided by an embodiment of the present application.
  • the entire life cycle of a long-term key in a car involves the , OEM) side, supplier side and vehicle point-of-sale side three communication interaction.
  • the OEM side may specifically include an OEM research and development line and an OEM production line.
  • the supplier side may specifically include chip suppliers and component suppliers. For ease of understanding, whether it is chips provided by chip suppliers or ECUs or vehicle components assembled by component suppliers using these chips, they are collectively referred to as ECUs here.
  • the supplier side can specifically include supplier R&D lines and supplier production lines.
  • the entire life cycle of the long-term key in the car can include the following stages:
  • the OEM R&D line designs a key hierarchy according to business requirements and management requirements, and generates a symmetric key 1 required by the business requirements.
  • the symmetric key 1 may include one or more symmetric keys, and the one or more symmetric keys are used as initial keys for key hierarchy design, and are used to derive other symmetric keys.
  • the OEM R&D line sends the key hierarchy and Symmetric Key 1 to the Supplier R&D line.
  • the sending operation needs to be carried out in a safe and confidential environment.
  • a special person can be arranged to send it secretly, or it can be transmitted through an encrypted peer-to-peer (P2P) method, or it can be sent through other secure communication methods, without limitation.
  • P2P peer-to-peer
  • the supplier R&D line derives the symmetric key 2 provided by the supplier side based on the symmetric key 1 and the key hierarchy.
  • the symmetric key 2 may include a root key of a chip required for assembling an ECU, a root key of an ECU required for assembling a vehicle part or a vehicle, and a root key of a vehicle part assembled from an ECU.
  • the symmetric key 2 can also be configured to be updatable, that is, the symmetric key 2 can be changed according to different production environments.
  • stage 204 the supplier's production line applies for a key from the supplier's R&D line when assembling ECUs or vehicle components.
  • stage 205 the supplier's R&D line returns the symmetric key 1 and symmetric key 2 to the supplier's production line.
  • stage 206 the supplier's production line calls the HSM or SHE standard, and encapsulates the symmetric key 1 and the symmetric key 2 in their corresponding ECU or vehicle components.
  • stage 207 the supplier production line notifies the OEM production line to assemble the vehicle.
  • the OEM production line assembles the vehicle based on the ECU or vehicle parts packaged with the symmetric key 1 and the symmetric key 2, and applies for the key to the OEM R&D line during the assembly process.
  • the OEM R&D line returns the symmetric key 3 to the OEM production line.
  • the symmetric key 3 may include a root key and a work key preset by the OEM side.
  • the symmetric key 3 is suitable for the after-sales stage of the vehicle, such as replacing ECU or vehicle components, or updating software configuration, etc.
  • stage 210 the OEM production line encapsulates the symmetric key 3 in the vehicle, and then provides the vehicle to the vehicle sales point for sale. At this time, the symmetric key 1, the symmetric key 2 and the symmetric key 3 are packaged in the vehicle at the same time.
  • Stage 211 after the vehicle is sold, if the ECU or vehicle components in the vehicle are damaged, or the software configuration of the vehicle needs to be updated, the owner can also place the vehicle at the vehicle sales point, and the vehicle sales point will be based on the symmetric key 3-way The OEM side applies for after-sales.
  • the owner can also preset some owner keys in the vehicle according to the prompt. At this time, the vehicle is packaged with symmetric key 1, symmetric key 2, symmetric key 3 and the owner key.
  • the long-term keys that the KMS in the car needs to manage include but are not limited to: Symmetric keys preset by the OEM R&D line according to business needs 1, The supplier's R&D line derives the symmetric key 2 based on the symmetric key 1, the symmetric key 3 preset on the OEM side, and the owner's key.
  • Symmetric keys preset by the OEM R&D line according to business needs 1
  • the supplier's R&D line derives the symmetric key 2 based on the symmetric key 1
  • the symmetric key 3 preset on the OEM side and the owner's key.
  • These long-term keys can be applied to different scenarios respectively.
  • Table 1 exemplarily shows an application scenario of each long-term key managed by the KMS.
  • the process of a car from the completion of production and assembly to delivery to customers and on-road vehicles may involve multiple communicating data managers or users.
  • the data manager in the vehicle control domain (functional safety) is the car factory, and the intermediate vehicle operating company also needs to manage the data of the vehicle.
  • the managers of the infotainment domain of the vehicle may belong to different drivers or users of the vehicle.
  • the data managers or users in the vehicle in order to realize the safe isolation of information between different services, when data communication is performed through the ECUs of different services of the vehicle, different keys need to be used to protect the information of the respective services between different devices. communication.
  • the long-term keys managed by the KMS in the car will not only be applied to the interactive authentication between the ECUs in the car, but also the interactive authentication between the ECU in the car and the equipment outside the car. . Therefore, the long-term key plays a vital role in the vehicle. If the key for the business communication between the in-vehicle devices managed by the cloud is leaked, it may also lead to the leak of the user's key, which may immediately affect the security of all vehicles. Driving safety (functional safety, information security) may also lead to the leakage of users' private data.
  • the key generation method in this application will be introduced below with specific embodiments. Only a small number of fixed keys are maintained on the car factory cloud and on the user side, and the business communication keys between in-vehicle devices are independently constructed in the car, thereby reducing the number of cloud management keys; for different users and different business communication needs Building an independent business communication key can realize the security isolation of communication between different businesses. All parties or attackers will not be able to illegally monitor the business communication content of other users through the key of one party. It is only possible through formal authorization services access; in the end, even if the cloud key is leaked, it may be difficult to affect the driving safety of the vehicle.
  • system and “network” in the embodiments of the present application may be used interchangeably.
  • “At least one” means one or more, and “plurality” means two or more.
  • “And/or” describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B, which can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A, B can be singular or plural.
  • the character “/” generally indicates that the contextual objects are an “or” relationship.
  • “At least one of the following” or similar expressions refer to any combination of these items, including any combination of single or plural items.
  • At least one item (piece) of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
  • ordinal numerals such as “first” and “second” mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the priority or importance of multiple objects.
  • first in-vehicle device and the second in-vehicle device are only for distinguishing different in-vehicle devices, and do not represent the difference in priority or importance of the two in-vehicle devices.
  • the embodiment of the present application provides a method for generating a key, which is applied to a vehicle, as shown in Figure 3, including:
  • Step 301 the first vehicle-mounted device obtains the first message.
  • the first message is used to instruct the first vehicle-mounted device to construct the first key
  • the first in-vehicle device may be a KMS server or a KMS agent.
  • the first vehicle-mounted device may receive the first message through a non-KMS device.
  • the first vehicle-mounted device may receive the first message sent by the non-KMS device through the server.
  • Step 302 The first vehicle-mounted device generates a first request message according to the first message.
  • the first request message is used for the first SHE corresponding to the first vehicle-mounted device to generate the first response message.
  • the first SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here.
  • the first in-vehicle device may be a KMS for managing keys in the ECU.
  • Step 303 the first vehicle-mounted device sends a first request message to the first SHE.
  • Step 304 the first SHE generates a first response message according to the first request message.
  • the first response message includes: first key information; the first key information is generated after encrypting the first key.
  • the first key information may be an encrypted first key.
  • the first key information may also include other information of the first key, for details, refer to the introduction of the first response message below.
  • Step 305 the first SHE sends a first response message to the first vehicle-mounted device.
  • the key data storage area of a vehicle-mounted device may include the following contents: key name (key name), key address (address or storage slot memory slot), storage area (memory area), for example, as Table 2 shows.
  • the key name can identify the type of key stored in the storage area, for example, GLOBAL_FIX_KEY, which can be used to store the fixed key PSKFix_Global of one vehicle and one secret, and can be used for the ECU to update GLOBAL_FIX_KEY or update other keys of the ECU .
  • This key can also be the same key as the master key of this ECU (for example, MASTER_ECU_KEY in the SHE protocol) or a different key. It can also be used for the ECU to generate a fixed key dedicated to the long-term key in the vehicle, which is not limited in this application.
  • KMS_CFG_MAC can be used to store the security check code of the ECU configuration file update, which is used for security check when initializing or updating the KMS configuration file.
  • MAC_FIX_KEY can be a fixed key used to verify the integrity of the relevant software generated by the key of KMS when the SHE is securely started.
  • the security verification code BOOT_MAC may be a verification code for verifying the integrity of the relevant software generated by the key of the KMS when the SHE is securely started.
  • MAC_FIX_KEY can also be a fixed key used to verify the integrity of other KMS software of the vehicle, for example, the fixed key BOOT_MAC_KEY in the SHE protocol.
  • KEY_1 ⁇ KEY_20 can be used to store the symmetric key (encryption key, or integrity key) for communication between in-vehicle devices.
  • KEY_1 can be used to store the key pair (Pair) of the one-vehicle-one-secret fixed key PSKFix_Global.
  • PSKFix_Global the key pair of the one-vehicle-one-secret fixed key
  • KEY_2 can be used to store the security verification key PSKGlobal of the fixed key of the ECU, that is, it can be a key for security verification of the fixed key on the ECU, so as to enhance the security of the fixed key.
  • KEY_3 can be used to store the key pair (Pair) of the security verification key PSKGlobal of the ECU's fixed key, which is used for pairing with the security verification key.
  • PSKGlobal performs encryption or integrity verification, security verification can be performed based on this key.
  • Other locations may be used to store long-term keys or fixed keys used by the KMS planned for the vehicle equipment.
  • the first key when the first key is a long-term key, the first key may be a long-term key dedicated to the first vehicle-mounted device, the first key may be a long-term key dedicated to the second vehicle-mounted device, and the first key may be a long-term key dedicated to the second vehicle-mounted device.
  • the key may be a long-term key used between the first vehicle-mounted device and the second vehicle-mounted device.
  • the first key may be the corresponding long-term key when user 1 uses the first vehicle-mounted device.
  • the long-term keys of the vehicle equipment generated in this application may be stored in keys KEY_1-KEY_20.
  • the corresponding key address can be used to indicate the identity of the key and the storage location of the key. For example, the value of memory slot and KEY_ID below can be the value of the key address.
  • Other locations of KEY_1 to KEY_20 can also be used to store other keys that are not managed by KMS, such as encryption keys used for encrypted storage of local files.
  • the key data storage area of the ECU can also include other parameters, which can include: KMS role information, wherein the KMS role information can include: key validity period (KMS_CFG_KeyLifetime), KMS configuration file version number (KMS_CFG_Version), The role of KMS (KMS_CFG_Role).
  • KMS_CFG_KeyLifetime KMS_CFG_KeyLifetime
  • KMS configuration file version number KMS_CFG_Version
  • the role of KMS KMS_CFG_Role
  • the key validity period can support reading and writing outside the storage area.
  • the validity period of all long-term keys can be set to be the same, and the unit of the key validity period can be minutes.
  • the version number of the KMS configuration file may be a version number set for the key.
  • the version number after the key in the key system of KMS generated for the first time is 1.0.
  • the length of the version number can also be increased.
  • the version number of the configuration file is the version number combined with the software version number of the KMS.
  • the roles of KMS can include: no role information (the value of role information can be 0), KMS server (the value of role information can be 1), KMS agent (the value of role information can be 2), KMS client (the value of role information can be 2), The value of information can be 3), other values are invalid values.
  • the key data storage area of the ECU can also include: the construction status (KMS_KH_BuildStatus) of the key system, the counter (KMS_KH_BuildCounter) of the key construction success in the KMS key system, the time (KMS_KH_BuildDate) of the KMS key system construction successful completion, KMS The integrity check code (KMS_KH_BuildMac) stored in the construction parameters of the key system and the temporary key KMS_KH_BuildKTemp used in the construction of the KMS key system.
  • the construction of the key system in this application may be expressed as at least one long-term key (first key) constructed by the KMS.
  • the construction status of the key system can include: not constructed, under construction, successful construction, and construction failure.
  • the value of the construction status of the key system may be 0 to 3, wherein 0 indicates that it is not constructed, 1 indicates that it is under construction, 2 indicates that the construction is successful, and 3 indicates that the construction fails.
  • the key construction success counter in the KMS key system can be used to indicate the number of keys that are currently successfully constructed.
  • the time when the construction of the KMS key system is successfully completed When there is a process of constructing the KMS key system, the time when the construction of the KMS key system is successfully completed may indicate the date and time when the construction of the KMS key system was successfully completed last time. The accuracy is stored at the minute level. For example, the successful time of this build is 2020-9-29 10:20:25.
  • KMS_KH_BuildStatus the construction status of the key system
  • KMS_KH_BuildCounter the counter of the key construction success in the KMS key system
  • KMS_KH_BuildDate the time when the KMS key system construction was successfully completed
  • the integrity check code can be stored separately, or stored in a free KEY_ ⁇ n>.
  • the temporary key KMS_KH_BuildKTemp used in the construction of the KMS key system can also be stored separately or in an idle KEY_ ⁇ n>. After the key construction in the key construction system is completed, the temporary key can be deleted .
  • n is less than or equal to 20. The specific value can be determined according to actual needs.
  • the non-volatile storage area (non-volatile) is used to store fixed keys, long-term keys, or security verification codes for secure boot.
  • Volatile storage area (Volatile), which can be used for temporary storage of keys when SHE performs security verification on filled keys when filling keys, and can also be used for temporary storage of non-key data, or temporary data.
  • the ECU can send the CMD_LOAD_KEY command to the SHE in cipher text, and the SHE will perform an integrity check on the input parameters of the command, and then decrypt it to obtain the key carried by the command, and store the key in this location.
  • each key When each key is stored, in addition to the key, it can also contain some other information, such as write-protection (write-protection) flag, secure boot failure (secure boot failure) flag, debugger activation (debugger activation) identification bit, wildcard unique identification item (wildcard UID), key usage identification bit (key-usage), plaintext key identification bit, key update count (counter) identification bit, key construction status An identification bit (buildstatus), a key index (KeyID), etc., a possible implementation manner, may be shown in Table 3.
  • write-protection write-protection
  • secure boot failure secure boot failure
  • debugger activation debugger activation
  • wildcard unique identification item wildcard UID
  • key usage identification bit key-usage
  • plaintext key identification bit key update count (counter) identification bit
  • key construction status An identification bit (buildstatus), a key index (KeyID), etc., a possible implementation manner, may be shown in Table 3.
  • X in Table 3 indicates that when storing the row key or security check code, the content of the column must be included.
  • X/- indicates that when storing the row key or security check code, this content can be included according to the needs of the product or KMS business.
  • a blank means that the content of this column may not be included when storing the row key or security check code.
  • the write-protection identification bit if the value of the write-protection identification bit is 1, the key is not allowed to be updated again. If the value of the write-protect flag is 0, it means that the key allows updates.
  • the secure boot failure (secure boot failure) flag and the debugger activation (debugger activation) flag indicate the state of the key after the SHE is securely booted. Wherein, the secure boot failure flag may also be a boot-protection flag, and the debugger activation flag may be a debugger-protection flag.
  • the wildcard UID (wildcard UID) identification bit is used to indicate, the key usage identification bit (key-usage) is used to identify, and the plaintext key identification bit is used to identify whether the key is stored in plain text.
  • the key update count identification bit is used to identify the number of key update times, and the update can be determined by the value of the key update counter at this time.
  • the maximum length of the number of bits that may be occupied by each key can be shown in the overall data (Overall data) indicator in Table 2, and the block size of each memory slot is constrained not to be less than the maximum value.
  • the UID of the ECU can be the UID corresponding to the ECU, or the default identifier (wildcard UID). For example, when the UID value is 0, the UID can be used as a default identifier. Wherein, the default identifier is used to determine whether any UID is allowed to be used to fill (overwrite update) keys into the corresponding storage area. For example, when the wildcard UID is 1, it is allowed to use any UID to fill the key of the ECU. If the wildcard UID is 0, it is not allowed to use any UID to fill the key of the ECU.
  • the memory slot is used to indicate the key address stored in the ECU storage area to the first key. UID can be 120 bits or 128 bits.
  • the key build status refers to the build status of a key, and the key build status can occupy 1 bit.
  • the value of the key construction status can be 0 to 3, where 0 means not being built, 1 means building in progress, 2 means building successfully, and 3 means building failed.
  • the status information of the key indicates that the key is successfully built in the ECU, and does not involve whether the key is successfully filled on other devices.
  • a possible implementation manner may determine whether all related devices involved in the key hold the key according to the construction status of the key system of the KMS. For example, when the construction status of the key system of the KMS is successfully constructed, it is determined that all relevant devices involved in the key hold the key.
  • the key index may be a key index assigned by the KMS and not related to the key address of the secure storage hardware, or may be a value associated with the key address. For example, can occupy 32 bits, installed with the key.
  • the key system of the vehicle may include: a configuration file, a fixed key, a long-term key, and the like.
  • the fixed key may include a one-vehicle-one-secret fixed key, and may also include a fixed key related to at least one vehicle-mounted device.
  • the fixed key related to the at least one vehicle-mounted device may be limited to be used in relation to the at least one vehicle-mounted device.
  • the long-term key may also include a one-vehicle-one-secret long-term key, and may also include a long-term key involving at least one vehicle-mounted device.
  • the fixed key related to the at least one vehicle-mounted device may be limited to be used in relation to the at least one vehicle-mounted device.
  • the fixed key may be a key obtained from outside the vehicle
  • the long-term key may be a key generated by the vehicle itself.
  • the vehicle-mounted equipment and the corresponding SHE are building the key transmission and key system Related messages need to be encrypted or integrity protected with a security verification key.
  • the first vehicle-mounted device can be used to generate first key.
  • the server and SHE can be set on an ECU, and are used to manage the key of the ECU.
  • the operation between the server and the SHE can be performed through the fixed key of the off-vehicle device (for example, the cloud or a terminal that manages the fixed key (for example, an APP that manages the fixed key))
  • the security verification key, or the fixed key or temporary key provided by the server in the vehicle itself is used as the security verification key.
  • the following uses scenarios 1 to 4 as examples.
  • a configuration file update message (for example, the first message) is initiated to the KMS server of the vehicle through a non-KMS device.
  • the configuration file update message can be encrypted and integrity-protected through the fixed key of the non-KMS device. safety verification.
  • the configuration file update message may include at least one of the following: an updated configuration file, a security verification code of the configuration file, KMS role information, and the like.
  • the non-KMS device can be a cloud server or a terminal that manages the vehicle key.
  • the cloud server or the terminal that manages the vehicle key can encrypt and complete the first message according to the fixed key of the cloud server.
  • Security verification for sex protection can be the non-KMS device.
  • the non-KMS device can be the CDC or the central control panel of the vehicle.
  • the CDC or the central control panel responds to the confirmation operation of the user's configuration file update.
  • the SHE corresponding to the CDC or the central control panel can be based on a vehicle's One secret fixed key generates the first message, that is, the CDC or the central control panel can perform encryption and integrity protection security verification on the first message according to the one car one secret fixed key.
  • the KMS server of the vehicle can initialize or update the relevant information of the configuration file in the SHE corresponding to the server after successful verification.
  • the server can also send a configuration file initialization message or an update message to the agent or client, so that the agent or client can verify the configuration file initialization message or update message successfully, and the agent or client corresponding SHE The relevant information of the configuration file is initialized or updated.
  • the server may not forward the message to the client.
  • the agent After the agent successfully verifies the configuration file initialization message or update message, it may also send the configuration file initialization message or update message to the client, so that the client After the configuration file initialization message or update message is verified successfully, the related information of the configuration file in the SHE corresponding to the client is initialized or updated.
  • the server, agent, and client in KMS perform different functions on the respective SHEs.
  • the SHE on the server side generates the encrypted first key and the security verification key, and cooperates with the KMS server side to manage the construction of the key system in the vehicle.
  • the agent's SHE is used to cooperate with the KMS server to complete the generation and filling of the first key of each client in the agent's domain. Therefore, in this application, different KMS roles can be configured for different vehicle-mounted devices in the KMS, so that the server or agent can better manage the keys of each vehicle-mounted device.
  • the KMS server of the vehicle may determine the initialization or update of the KMS role information and the security verification code of the initialization or update configuration file according to the initialized or updated configuration file. And configure the KMS role information and the security verification code of the corresponding configuration file for each vehicle-mounted device.
  • the following describes the process of generating a configuration message for KMS role information when a configuration file is initialized or updated with a specific scenario example.
  • the KMS when the initialized KMS configuration file is delivered, the KMS can generate a KMS role information configuration message for each vehicle-mounted device (for example, the KMS server of the vehicle, the agent and the client of the vehicle).
  • the KMS role information may include at least one of the following: KMS role (KMS_CFG_Role), configuration file version number (KMS_CFG_Version), validity period of a long-term key constructed by KMS (KMS_CFG_KeyLifetime), and the like.
  • Scenario 1.2 when the KMS configuration file is updated, especially when the definition of the communication security domain changes, it is necessary to re-update the KMS role information of the vehicle, or send a configuration message of the KMS role information to each vehicle-mounted device to update the vehicle internal The KMS role information of each vehicle-mounted device.
  • the KMS server of the vehicle When the KMS server of the vehicle receives the configuration message of the KMS role information, the KMS server of the vehicle forwards the message to the corresponding SHE of the server, and the SHE of the server can verify the KMS role information based on the security verification key outside the vehicle. The configuration message is verified. After the verification is successful, the corresponding KMS role information is stored in the corresponding position in the SHE.
  • the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
  • the vehicle's KMS server After the vehicle's KMS server receives the KMS role information configuration message, the vehicle's KMS server can also forward the message to the agent or client.
  • the agent forwards the message to the SHE corresponding to the agent, and the SHE of the agent can verify the KMS role information based on the security verification key outside the vehicle.
  • the configuration message is verified.
  • the corresponding KMS role information can be stored in the corresponding position in the SHE.
  • the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
  • the agent can also forward the message to each client managed by the agent.
  • the KMS client of the vehicle can receive the configuration message of the KMS role information through the server or agent. At this time, the client forwards the message to the corresponding SHE of the client.
  • the security verification key is used to verify the configuration message of the KMS role information. After the verification is successful, the corresponding KMS role information can be stored in the corresponding position in the SHE.
  • the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
  • modes 1.3 to 1.4 are used as examples below.
  • the key system construction start message (CMD_KMS_KH_BUILD_START) can be used to instruct the SHE to start the construction of the key in the key system, and the SHE can verify the key system construction start message. After the verification is successful, change the key system construction status (KMS_KH_BuildStatus) to under construction.
  • KMS_KH_BuildStatus change the key system construction status
  • the key system construction startup message that can be passed carries the information in the configuration message of the KMS role information.
  • the SHE can verify the key system construction startup message, and the verification succeeds. After that, verify the information in the configuration message of the KMS role information.
  • the specific verification method please refer to the verification of the CMD_KMS_SET_CFG_INFO command below.
  • Mode 1.4 during the key system construction process, if any parameter of KMS in SHE is changed, SHE can determine whether any parameter of KMS meets the update requirements according to whether the key system construction status (KMS_KH_BuildStatus) is "constructing". When the key system construction status is "constructed successfully”, verify the information in the KMS role information configuration message. For the specific verification method, refer to the verification of the CMD_KMS_SET_CFG_INFO command below. When the construction status of the key system is not "under construction", the verification of the configuration message for determining the KMS role information fails.
  • each key affected by the key system construction status (for example, at least one first key involved in the key system construction) will not be available.
  • SHE verifies the construction status of the key system involved in the first key according to the request. After the verification fails, SHE can return "the key status is wrong, and the KMS needs to be rebuilt.”
  • key system status code for example, ERC_KMS_KH_NEED_TO_REBUILD.
  • the KMS may send KMS role information to each vehicle-mounted device in the vehicle.
  • each vehicle-mounted device in the vehicle receives the configuration message of the KMS role information corresponding to each vehicle-mounted device, it can perform security verification on the configuration message of the KMS role information according to the SHE corresponding to the vehicle-mounted device. After the verification is successful, the KMS role information The information is written into SHE, and the corresponding security verification code is written.
  • the configuration message of KMS role information may be a CMD_KMS_SET_CFG_INFO command.
  • the input parameters of the command may be as shown in Table 4.
  • the input parameter can be understood as the incoming parameter, and the input parameter can be used to carry the input parameter when the command is sent to the first SHE through the first vehicle-mounted device to request the first SHE to verify, such as CMD_KMS_SET_CFG_INFO and other commands.
  • the input parameter M1 satisfies:
  • M1 can splice the corresponding bytes of KEY_ID, KMS Role, KMS_CFG_Version, and KMS_CFG_KeyLifetime together.
  • M1 can splice the corresponding bytes of KEY_ID, KMS Role, KMS_CFG_Version, and KMS_CFG_KeyLifetime together.
  • bytes such as KEY_ID, KMS Role, KMS_CFG_Version, and KMS_CFG_KeyLifetime can be transmitted in sequence.
  • the KEY_ID when the initial configuration file is issued, the KEY_ID may be a fixed key of the vehicle.
  • the KMS server configures the KMS role information and the corresponding long-term key for itself according to the KMS configuration file during the generation of the long-term key of the vehicle, it is considered that the first vehicle-mounted device has obtained the corresponding The temporary key generated by SHE, therefore, KEY_ID can be the key address corresponding to the temporary key.
  • M1 is encrypted and integrity protected by entering parameter M2, and the key used to encrypt M1 may be the key corresponding to KEY_ID. Therefore, when the first vehicle-mounted device sends the command to the first SHE corresponding to the first vehicle-mounted device, the SHE can perform security verification on the command according to the KEY_ID. That is, SHE can perform CMAC operation on M1 according to the key corresponding to KEY_ID stored in SHE to obtain M2', and when M2' is determined to be equal to M2, it is determined that the command verification is successful.
  • the KMS server of the vehicle can determine whether the fixed key of the vehicle needs to be updated, that is, when the KMS server of the vehicle determines that the fixed key of the vehicle needs to be updated according to the updated configuration file, A reminder message can be sent to a non-KMS device to remind the non-KMS device to generate a fixed key and initiate a fixed key filling message.
  • the KMS can also determine the long-term key to be generated in the key system of the in-vehicle KMS, thereby triggering the to-be-generated The long-term key generation process.
  • Scenario 2 A non-KMS device initiates a fixed key filling message to the KMS server of the vehicle.
  • the updated fixed key can be encrypted and integrity-protected for security verification using the fixed key of the non-KMS device.
  • the KMS server of the vehicle receives the message of filling the fixed key, it can send the message of filling the fixed key to the SHE corresponding to the server. The key filling message is verified, and after the verification is successful, the updated fixed key is stored.
  • the server when the fixed key is GLOBAL_FIX_KEY, the server stores the fixed key in the position of GLOBAL_FIX_KEY corresponding to the SHE, and when the fixed key is MAC_FIX_KEY, the SHE stores the fixed key in the position of MAC_FIX_KEY.
  • the input parameter of CMD_LOAD_KEY can be generated by the equipment outside the vehicle, which is used for filling the first key in the vehicle. In this application, this method is mainly used in a scenario where the first key is a fixed key, and may also be used in a scenario where the first key is a long-term key, which is not limited here.
  • the external device sends the first key loading message to the first vehicle-mounted device (for example, the server), and the first vehicle-mounted device can load the first key parameter) sent to the corresponding SHE verification of the first vehicle-mounted device.
  • the first key is stored, and according to the first key loading message, a response message for the first key loading is generated (for example, a message that can carry CMD_LOAD_KEY output parameter), the response message of the first key loading is fed back to the off-vehicle device, and the off-vehicle device can verify according to the response message of the first key loading to determine whether the first key loading of the first on-vehicle device is successful.
  • the external device sends the first key loading message to the first vehicle-mounted device (for example, the server), and the server forwards the first key-loading message to each second vehicle-mounted device in the vehicle,
  • the second vehicle-mounted device may be an agent or a client.
  • a possible implementation manner is that the server sends the message to the proxy or the client, or the server forwards the first key loading message through the key management tool.
  • the outgoing parameter can be understood as the parameter sent out when the SHE that receives the command successfully verifies the command, and the outgoing parameter can be used to pass the outgoing parameter to the command.
  • the second vehicle-mounted device (agent or client of KMS) forwards the first key loading message (for example, may carry the input parameter in CMD_LOAD_KEY) to the second SHE (the SHE corresponding to the second vehicle-mounted device, wherein the second SHE It can be the SHE corresponding to the second vehicle-mounted device.
  • the first key loading message for example, may carry the input parameter in CMD_LOAD_KEY
  • the second SHE the SHE corresponding to the second vehicle-mounted device, wherein the second SHE It can be the SHE corresponding to the second vehicle-mounted device.
  • This SHE can be arranged in the ECU corresponding to the second vehicle-mounted device, or it can be set separately by the second vehicle-mounted device, which is not limited here) verification, after the verification is successful, in
  • the first key is stored in the second SHE, and according to the first key loading message, a response message for loading the first key (for example, may carry an output parameter of CMD_LOAD_KEY), and the response message for loading the first key Feedback to the agent or server, and then forwarded to the server, the server will be able to return the response message loaded with the first key to the off-vehicle device, and the off-vehicle device can proceed according to the response message loaded with the first key Verification is to determine whether the first key loading of the second in-vehicle device (each agent or client) is successful.
  • the second SHE After the second SHE stores the first key (for example, a new fixed key), the second SHE can set the key construction state corresponding to the first key. For example, setting the key build status BuildStatus to "1" indicates that the first key is successfully built.
  • the off-vehicle device When the off-vehicle device wants to fill the first key into the first vehicle-mounted device or the second SHE, it can derive the existing key according to the existing key in advance, for example, the current value of GLOBAL_FIX_KEY in the SHE or the original key at this position.
  • the encryption key K1 and the integrity key K2 are used to protect the input parameters of CMD_LOAD_KEY, that is, the input parameters of the constructed CMD_LOAD_KEY command are based on protection.
  • the off-vehicle device when the off-vehicle device wants to fill a new key into the KEY_ ⁇ n> position, the off-vehicle device must know the key stored in the current GLOBAL_FIX_KEY position or the key stored in the KEY_ ⁇ n> position in advance.
  • KEY_ ⁇ n> represents KEY_1 to KEY_10.
  • the specific key to be filled corresponds to the encryption key that protects the input parameter of CMD_LOAD_KEY, as shown in Table 6.
  • X indicates that at least one key on the corresponding column is used as the security verification key for security verification when filling the corresponding key on the row.
  • the GLOBAL_FIX_KEY stored in the SHE should be used as the input parameter of the security verification key construction CMD_LOAD_KEY to realize the security verification of the first key GLOBAL_FIX_KEY filling.
  • the GLOBAL_FIX_KEY or KEY ⁇ n> stored in SHE can be used as the input parameter of the security verification key to construct CMD_LOAD_KEY to realize the security verification of the first key KEY ⁇ n> filling .
  • the first key is RAM_KEY
  • KEY ⁇ n> or SRCERET_KEY or plaintext (plaintext) stored in SHE can be used as the input parameter of the security verification key construction CMD_LOAD_KEY to realize the security verification of the first key RAM_KEY filling.
  • a message authentication code (message authentication code, MAC) generator may also be provided in the SHE, and the message authentication code generator is used to process input information according to a preset generation algorithm to obtain a message authentication code and output.
  • the preset generation algorithm is CMAC
  • the ECU of the first key generates the message authentication code M3 of the command according to the key for encrypting the command.
  • the message authentication code M3 of the command satisfies the following formula:
  • K2 is the key for integrity verification derived from the security verification key corresponding to KEY_ID.
  • the security verification key corresponding to the KEY_ID may be the identifier of the security verification key used corresponding to the first key in Table 3.
  • the security verification key can also be used to derive an encryption key K1 for encrypting the first key.
  • M1 UID
  • the UID is a unique identification item (unique identification item) of the first vehicle-mounted device, which may be a UID corresponding to the first vehicle-mounted device, or may be a default identification (wildcard UID).
  • the UID can be used as a default identifier.
  • the default identifier is used to determine whether any UID is allowed to be used to fill (overwrite update) keys into the corresponding storage area. For example, when the wildcard UID is 1, it is allowed to use any UID to fill the key of the ECU. If the wildcard UID is 0, it is not allowed to use any UID to fill the key of the ECU.
  • the memory slot is used to indicate the key address stored in the ECU storage area to the first key.
  • Counter indicates the key update count corresponding to the first key. After the first key is updated every time, that is, after the first key is loaded successfully, the Counter can be increased by 1, which is used for SHE to verify whether there is a replay attack on the command.
  • the block length is 128 bits, and M2 can be filled with "0...0" 95 , for example, 95 bits of 0 are filled.
  • Flags can be determined according to the information stored in the SHE by the first key, for example, Flags satisfies:
  • Flags write-protection
  • the Key memory slot indicates the first key stored in the memory slot.
  • the command may include three parameters as input parameters.
  • the second SHE can input the 3 input parameters in the CMD_LOAD_KEY command to the message authentication code parser, and then the message authentication code parser uses the M1 and M2 of the input parameters in the command, and the information corresponding to the CMD_LOAD_KEY command stored by the SHE itself.
  • the security verification key for example, the security verification key corresponding to the first key, generates K1 and K2, and correspondingly generates a message authentication code M3'. When it is determined that the message authentication code M3' is the same as M3, it is determined that the verification is successful. And store the first key carried in the command to the location corresponding to the memory slot.
  • K4 is the key used for integrity verification derived from the first key stored in the memory slot.
  • Counter is the value of the update counter set by the SHE corresponding to the first key, which may be 28 bits, and is used to verify the replay attack on the received CMD_LOAD_KEY command.
  • the block length is 128 bits.
  • K3 is an encryption key derived from the first key stored in the memory slot (that is, the Key memory slot ).
  • the KMS server of the vehicle may also determine whether to update the corresponding long-term key according to the scope of use of the fixed key.
  • the fixed key is a vehicle-one-key fixed key, and at this time, the KMS server of the vehicle may determine to update the long-term key generated based on the fixed key.
  • the KMS server of the vehicle can send a long-term key update request to the non-KMS device.
  • the non-KMS device After the non-KMS device receives the long-term key update request, the non-KMS device can verify the long-term key update request. After the verification is successful, a second key update request is generated. a message.
  • scenario 3 For the manner in which the non-KMS device generates the first message, refer to scenario 3.
  • the first key when the first key is a long-term key, the first key can be generated by the SHE of the vehicle. During the process of generating the first key, in order to ensure the security of the message between the vehicle equipment and the SHE, and The message security between the device and the vehicle-mounted device can be verified for the security of the corresponding message.
  • the security verification keys used for the messages that may be involved in the key system construction process of this application may be used. Examples of specific messages are described below.
  • X Indicates that the key can be used as a security verification key.
  • the premise of using the temporary key as the security verification key is to use the temporary key as the security verification key when the temporary key can be obtained when constructing the message.
  • the first vehicle-mounted device generates a corresponding message according to the temporary key, and verifies it through the first SHE.
  • the second on-vehicle device generates a corresponding message according to the temporary key, and verifies it through the second SHE.
  • Y Indicates that the key is preferentially used as the security verification key.
  • the long-term key when used as the security verification key, it may be a security verification key used in messages between the first vehicle-mounted device and the second vehicle-mounted device, and the verification is performed by respective corresponding SHEs.
  • the security verification key KEY_ID in each message refers to the key address (memory slot) of the key used in the calculation of the integrity check code MAC of the command parameter.
  • the security verification key KEY_ID in each message refers to the key address (memory slot) of the key used in the calculation of the integrity check code MAC of the command parameter.
  • the filling method is Mx
  • Mx is 64bits
  • 63bits of 0 need to be filled, so that Mx
  • This kind of filling is either outside the SHE or inside the SHE. In this application, filling in the SHE is taken as an example for illustration.
  • the following uses scenarios 3.1 to 3.2 to illustrate how the first key is generated by the SHE of the vehicle when the first key is a long-term key.
  • a first message is sent to the vehicle's KMS server through a non-KMS device.
  • the non-KMS device may be a cloud server, a key management tool, or a terminal for managing keys, etc.
  • the cloud server may perform encryption and integrity-protected security verification on the first message according to the fixed key of the cloud server as a security verification key.
  • the non-KMS device may be the CDC or the central control panel of the vehicle. Through the CDC or the central control panel, the user's confirmation operation is received, and the CDC or the central control panel responds to the user's confirmation operation.
  • the CDC or the central control panel The SHE corresponding to the screen can generate the first message according to the fixed key of the vehicle, that is, the CDC or the central control screen can encrypt and integrity protect the first message according to the fixed key of the vehicle. verify.
  • the KMS server of the vehicle Initiate the first message to the KMS server of the vehicle through a non-KMS device.
  • a non-KMS device For example, when starting the construction of the key system, and the construction status of the current key system is unconstructed or completed, it can be sent by an external device or a non-KMS device.
  • the KMS device generates the first message, and sends the first message to the KMS server of the vehicle.
  • the first message may be encrypted and integrity-protected security verified by the fixed key of the vehicle.
  • the first message may indicate which keys are the first keys generated by the KMS server of the vehicle.
  • KEY_13 is used to store a long-term key corresponding to a global navigation satellite system (global navigation satellite system, GNSS) module.
  • GNSS global navigation satellite system
  • the CDC or the central control panel can receive the user's response operation and confirm "agree/deny: execute the update of the first key”.
  • Scenario 2 After determining the first key to be generated, the first key generation request message can be sent to the CDC or the central control panel.
  • the CDC or the central control panel After the user confirms through the CDC or the central control panel, in response to the confirmation operation with the user, the CDC or the central control panel
  • the security verification key is used to return the response message to the long-term key update request of the server.
  • the response message can be encrypted and integrity protected with a fixed key of one vehicle and one secret, and the server sends the response message to the SHE of the server. authenticating.
  • the SHE at the server can also determine whether to actively send a first key generation request message to the CDC or the central control panel according to whether the validity period of the first key has expired.
  • the SHE executes the process of generating the first key.
  • the KMS server of the vehicle After the KMS server of the vehicle receives the first message sent by the non-KMS device, it can generate a first request message, and the first request message sends the first request message to the SHE corresponding to the server, wherein the first request message can include the first request message.
  • An identifier of a key, the first request message may be encrypted and integrity-protected based on the security verification key corresponding to the first request message.
  • the SHE verifies the first request message based on the security verification key corresponding to the first request message, and triggers the generation of an encrypted first key after the verification succeeds.
  • the encrypted first key may be encrypted based on a fixed key for one vehicle and one secret stored by the SHE, or may be encrypted by a fixed key stored by the KMS server, and the SHE determines the first When the key is a key used by the KMS server, the first key may be stored. When the SHE determines that the first key is used by the KMS server, it may not store the first key. For example, when the KEYID corresponding to the first key is KEY_13, the SHE stores the first key in the position of KEY_13.
  • the SHE corresponding to the server verifies the first request message according to the security verification key corresponding to the first request message stored by itself, and generates an encrypted first key after the verification succeeds.
  • the encrypted first key may be encrypted based on a fixed key for one vehicle and one secret stored by the SHE, or may be encrypted by a fixed key stored by the KMS server, and the SHE determines the first When the key is a key used by the KMS server, the first key may be stored. When the SHE determines that the first key is used by the KMS server, it may not store the first key. For example, when the first key is KEY_1, the SHE stores the first key in the position of KEY_1.
  • the following uses a specific example to introduce the first request message.
  • the parameters involved in the first request message CMD_BUILD_KEY may be as shown in Table 8.
  • the first request message may carry the following input parameters.
  • the input parameter M1 satisfies:
  • the value of UID can have many kinds, for example, in the first request message, it is used to generate the filling message of the first key sent to the second vehicle-mounted device (carrying the input parameter corresponding to the filling of the first key) , the UID can be the UID of the first vehicle-mounted device or the second SHE, or 0 (ie wildcard UID).
  • the UID may be the UID of the first vehicle-mounted device or the second SHE.
  • Flag can occupy 1 byte, and Flag satisfies:
  • Hold can occupy 1 bit, indicating whether the first SHE holds the first key, that is, whether to store the generated first key in the first SHE. For example, when Hold is 0, it means no storage, and when Hold is 1, it means storage. If yes, after the SHE generates the first key, it first stores it in the memory slot of the SHE, and sets the relevant content of the key, see Table 3 for details. Wherein, the key construction status of the first key may be set as "1-construction successful". If it is not stored, the first key cannot be stored in this SHE.
  • the memory slot is used to indicate the key address of the SHE first key.
  • KEY_ID is used to indicate the security verification key of the first request message.
  • the input parameter of the first request message generated by the non-KMS device may use a fixed key as the security verification key.
  • the temporary key in the first request message generated after the first vehicle-mounted device obtains the temporary key, the temporary key may be used as the security verification key of the first request message.
  • the value of Counter is the same as the KMS_KH_BuildCounter value of this SHE, which is used for SHE verification replay attacks.
  • Key index KeyID can be 4 bytes, used to indicate the key index of the newly generated first key this time. Among them, "[]" means optional.
  • the key indexes corresponding to the on-vehicle devices involved in the secure storage mechanisms of different hardware may be allocated based on services, for example, the corresponding key indexes may be allocated based on KMS.
  • "0...0" m Indicates that the value "0" occupies m bits, so as to meet the integer multiple of 128 bits for M1 as a whole. If the key index KeyID is not included, fill 76 bits with 0. If it contains the key index KeyID, fill 44 bits with 0.
  • Key is the security verification key corresponding to KEY_ID.
  • the first SHE After the first SHE successfully verifies the input parameters of the first request message, it can correspondingly generate the following output parameters and return a first response message to the first vehicle-mounted device.
  • the first response message can include the first Parameters, for example, can carry the following outgoing parameters M3-M7.
  • the UID is the same as the UID in the input parameter M1, and the memory slot and KEY_ID are the same as the corresponding values in the input parameter M1.
  • Counter is the KMS_KH_BuildCounter value stored by SHE.
  • Flags write-protection
  • the information of Flags can also be carried in the input parameter Flag.
  • the SHE determines the carried content according to the classification of the first key.
  • the output parameter M4 satisfies:
  • the KeyID is the same as the KeyID in the input parameter. If the input parameter carries the KeyID, the output parameter also carries the KeyID.
  • Key1 can use a fixed key, such as GLOBAL_FIX_KEY, MAC_FIX_KEY and any other key except the temporary key in the first SHE, so as to ensure that it cannot be read by the outside.
  • key1 may be the key corresponding to the key address memory slot1 added in the input parameter of the first request message, and the key may be specified by the user.
  • Solution 2 If the random number is secure enough, the generated random number can also be directly used to generate the first key.
  • the output parameter M5 satisfies:
  • the output parameter M6 satisfies:
  • M6 UID
  • the output parameter M7 satisfies:
  • the output parameters M3, M4, and M5 carried in the first response message are respectively the input parameters M1, M2, and M3 of the filling message of the first key.
  • the output parameters M6 and M7 carried in the first response message are respectively the same as the output parameters M4 and M5 in the filling message of the first key. That is, through the first request message, the SHE can obtain the input parameters required to fill the first key and verify the output parameters loaded by the first key. For details, please refer to the input parameters carried in the filling message of the first key and the output parameters after SHE executes the filling message of the first key below.
  • the outgoing parameter M6 and outgoing parameter M7 can be sent in the first response message, or can be stored in the non-volatile storage area of the SHE, for example, pre-set in the non-volatile storage area of the SHE Reserved for the construction process of the KMS key system, the temporary storage server or agent is the storage location of the shared key between the second vehicle-mounted devices, and the first vehicle-mounted device (for example, the server or agent) receives the first When the filling response message of the first key is returned by the second vehicle-mounted device, the first vehicle-mounted device can obtain M6 and M7 stored in the SHE by verifying the key message.
  • a first request message may be generated correspondingly according to each first key to be generated.
  • the first key may be a long-term key dedicated to the first vehicle-mounted device
  • the first key may be a long-term key dedicated to the second vehicle-mounted device
  • the first key may be a key between the first vehicle-mounted device and the second vehicle-mounted device.
  • the first key may be the long-term key corresponding to user 1 using the first vehicle-mounted device, and the first key may be the corresponding long-term key when user 2 uses the first vehicle-mounted device and the second vehicle-mounted device. long term key.
  • the first request message for the long-term key may be correspondingly generated.
  • the first vehicle-mounted device (for example, the server) can also share a temporary key between the first vehicle-mounted device and the first SHE key, as the security verification key of the first request message.
  • the temporary key can be used for the security verification key between the server and the SHE corresponding to the server during the construction process.
  • a temporary key K Temp may be shared between the agent and the SHE corresponding to the agent, and the temporary key K Temp may be used as a security verification key between the agent and the SHE corresponding to the agent during the construction process.
  • a temporary key may be shared between the client and the SHE corresponding to the client, and the temporary key may be used for a security verification key between the client and the SHE corresponding to the client during the construction process.
  • the temporary key can be based on the first message received by the first vehicle-mounted device from the non-KMS device (the first message is encrypted by a trusted security verification key between the non-KMS device and the server), and the SHE Generated after the first message is validated.
  • the non-KMS device initiates a long-term key generation message (for example, the first message) to the KMS server of the vehicle, and the non-KMS device can use the fixed key of the non-KMS device to generate a long-term key for the first message.
  • the first message may instruct the KMS server of the vehicle to start a long-term key generation process.
  • the KMS server of the vehicle can send a first request message to the SHE of the server according to the first message, and the first request message can be used to request to obtain the temporary key. After the SHE generates the temporary key, it may send a response message to the first message to the first vehicle device, and the response message may carry the temporary key.
  • the temporary key can use the key shared by the server and the SHE corresponding to the server for integrity verification.
  • a message verification code is generated for the temporary key by means of a fixed key for one vehicle, one secret, or the fixed key of the first vehicle device. Therefore, the first vehicle-mounted device can obtain the temporary key after successfully verifying the response message of the first message.
  • the temporary key is used by the server to verify the first response message sent by SHE.
  • the first request message generated by the vehicle server may also include requesting the SHE to generate an encrypted first key.
  • the server needs to generate the first key multiple times, or verify other messages through the server or agent, which may involve the use of temporary keys.
  • the temporary key should be generated before the corresponding SHE of the vehicle-mounted device (server or agent or client) executes operations such as generating the first key, and the vehicle-mounted device is made to obtain the temporary key. If the temporary key is generated or sent to the vehicle device every time, the security of the temporary key will be affected (API interface monitoring, etc.).
  • the start message for key system construction should be received before the corresponding SHE of the on-vehicle device performs operations such as generating the first key, so that the SHE can update the key system construction status.
  • a possible implementation manner of generating a temporary key is specifically introduced below, that is, the first SHE is triggered to generate a temporary key through a key system construction start message.
  • the server receives the key system construction start message generated by the non-KMS device, and distributes the parameters of the key system construction start message to the agent or the vehicle-mounted device of the client. After the vehicle-mounted device receives the key system construction start message, it forwards it to the SHE of the vehicle-mounted device.
  • the SHE can start the construction of the key system according to the key system construction start message.
  • the KMS_KH_BuildCounter value of each vehicle-mounted device is synchronized to prevent encryption
  • the replay attack of the key system construction start message updates the key system construction status message, and makes the SHE of the on-board equipment generate a temporary key accordingly, providing a security verification key for subsequent messages such as the generation of the first key.
  • the off-vehicle device constructs a start message for key system construction.
  • Method 2 After the CDC or the central control panel in the car responds to the user's operation of "confirming and agreeing to perform the first key update", the CDC or the central control panel constructs a key system construction start message. At this time, in order to ensure the safe construction of the startup message of the key system construction, it can be realized in the following ways:
  • Method 2.1 on the CDC or the central control screen, through other security environments (security environments that do not rely on SHE), such as deploying a trusted execution environment (Trusted execution environment, TEE), or HSM, etc., using a long-term key or a fixed key, to generate the message.
  • security environments security environments that do not rely on SHE
  • TEE trusted execution environment
  • HSM HSM
  • the long-term key is also stored, for example, a long-term key for one secret per vehicle or a fixed key for one secret per vehicle, etc. are stored.
  • the CDC or the SHE of the central control panel responds to the request message to start the construction of the key system sent by the server or the agent, and returns the response message to the request to start the construction of the key system, such as CMD_KMS_KH_PREPARE_START, so that the CDC or the central
  • the SHE of the control screen generates and returns the start message of building the key system to the server, and the server obtains the start message of building the key system, thereby starting and managing the update of the first key.
  • the response message (CMD_KMS_KH_PREPARE_START) to the request to start the construction of the key system cannot provide a key as the security verification key of the message. Therefore, it is necessary to strictly control the use of this message, such as through identity and access management (IAM), security enhanced Linux (SELinux), process or container security isolation, and mandatory checks when the vehicle stops, etc. only allowed to use.
  • IAM identity and access management
  • SELinux security enhanced Linux
  • process or container security isolation
  • the following example illustrates a possible implementation of the start message constructed by the key system, for example, as shown in Table 9, the parameters that may be involved in the start message constructed for the key system. Among them, m and n are positive integers.
  • the key system construction start message may carry the following parameters.
  • the key system for the construction of the key system initiated outside the car, it must be the KEY_ID corresponding to the fixed key.
  • the KEY_ID for the long-term key update triggered after confirmation by the CDC or the central control screen in the car, it can be the KEY_ID corresponding to the long-term key, such as a KEY_ID of the long-term key of Che Yi Mi.
  • Key is the Key corresponding to KEY_ID.
  • KMS_KH_BuildCounter is the value of the key system construction counter.
  • the SHE After successfully verifying the startup message of the key system construction, the SHE can generate an output parameter of the startup message of the key system construction, and return a response message of the startup message of the key system construction to the first vehicle-mounted device, in the response message Carry out ginseng.
  • the output parameters meet:
  • KMS_KH_BuildKTemp is a temporary key KTemp generated by SHE after the command is executed successfully, which is used for the security verification key when the on-board equipment directly operates SHE.
  • the key system construction start message can be designed as a two-layer command.
  • the message can also carry the parameters of other messages, so that after SHE receives the key system construction start message, according to the encryption
  • the key system construction start message is verified, the instruction information for starting the key system construction is obtained, and the key system construction status is updated.
  • the SHE at the server or agent can generate a temporary key accordingly.
  • the message is verified according to the parameters of other messages and then corresponding operations are performed.
  • the other message is the first request message
  • the first vehicle-mounted device carries the first request message through the key system construction start message.
  • the first SHE may determine that the key system construction status is under construction after verifying the key system construction start message, and generate a temporary key accordingly.
  • the first request message is verified, and after the verification is successful, the encrypted first key is generated, and the encrypted first key is returned to the first vehicle-mounted device and temporary key.
  • the following example illustrates a possible implementation of the start message for key system construction, as shown in Table 10, for example.
  • m and n are positive integers.
  • the start message of the key system construction can carry the following parameters and nest parameters corresponding to other messages.
  • the input parameters meet:
  • KEY_ID is a security verification key used for security verification of the message.
  • the security verification key For the startup message of the key system construction initiated by the device outside the vehicle, the security verification key must be the KEY_ID corresponding to the fixed key; for the long-term key update triggered after confirmation by the CDC or the central control screen in the vehicle, it can be a long-term key
  • the corresponding KEY_ID is, for example, the KEY_ID of the long-term key of one car one secret.
  • Key is the security verification key corresponding to KEY_ID.
  • KMS_KH_BuildCounter value is greater than the KMS_KH_BuildCounter value in the first SHE, it means that the replay attack verification is successful, and at this time, M2 can be verified.
  • CMD_TYPE indicates the message type of the message.
  • CMD_KMS_KH_BUILD_START and CMD_KMS_KH_BUILD_CONTINUE do not carry other messages
  • CMD_TYPE can be filled with 0.
  • other messages that can be carried in the startup message constructed by the key system of this application can be shown in Table 11.
  • the key system building start message can be sent to the server and the agent through the KMS business message, and the key system building start message can also be sent to the server and the agent whether it needs to be distributed, Information such as which clients are distributed to, whether the server and the agent need to be processed.
  • the message received by the first SHE contains a message that cannot be processed
  • the message is directly ignored, and an error message ENC_CANNOT_PROCESS_INNER_CMD is returned.
  • the security verification key KEY_ID of the startup message constructed by the key system may be the same as or different from the security verification key KEY_ID' used in other messages carried in the message.
  • the security verification key KEY_ID' used in other messages carried in the message can be selected according to the requirements of the message or actual needs.
  • CMD_TYPE can occupy 1 byte, indicating whether the start message of the key system construction carries other messages.
  • CMD_TYPE_IN_Parameters CMD_TYPE corresponds to all input parameters of other messages. At this time, the CMD_TYPE value is not 0.
  • the SHE After successfully verifying the startup message of the key system construction, the SHE can generate an output parameter of the startup message of the key system construction, and return a response message of the startup message of the key system construction to the first vehicle-mounted device, in the response message Carry out ginseng.
  • the output parameters M3 ⁇ M5 can meet:
  • CMD_TYPE_OUT_Parameters are all output parameters of the message corresponding to CMD_TYPE.
  • KMS_KH_BuildKTemp is a temporary key KTemp generated by SHE after the startup message verification of key system construction is successful. The security authentication key for the keyload message. At the same time, SHE can set KMS_KH_BuildStatus to "Building" after successfully verifying the message. SHE sets Counter to the latest value of KMS_KH_BuildCounter.
  • the startup message constructed by the key system carries the first request message
  • the parameters of the first request message can send the first query request to the SHE through the server
  • the first query message CMD_KMS_KH_GET_BUILD_STATUS can be used to query status data such as input parameters of KMS_KH_BuildCounter and CMD_BUILD_KEY.
  • the security verification of the first query message can be performed through the temporary key.
  • a possible implementation of the first query message (CMD_KMS_KH_GET_BUILD_STATUS) is described below as an example.
  • the relevant parameters of the first query message may be shown in Table 12.
  • the first query message may be initiated by a device outside the vehicle, or may be initiated by a vehicle-mounted device such as a first vehicle-mounted device or a second vehicle-mounted device in the vehicle.
  • the first vehicle-mounted device may check the construction status of the key system when starting, so that the first vehicle-mounted device can determine the next operation according to the current construction status of the key system, for example, the current construction status If part of the first key has been constructed, the first vehicle-mounted device may initiate a first request message for other first keys to be generated to the SHE. In the current construction state, a part of the first key has been constructed, including the successful construction of the first key 1 and the failed construction of the first key 2, then the first on-board device can initiate the generation of the first key 2 to the SHE The first request message for .
  • the first vehicle-mounted device when it determines that the first key is a key to be updated, it may send a first query message to the first SHE for querying information such as KMS_KH_BuildCounter and corresponding message input parameters, Used to generate corresponding messages. For example, the first vehicle-mounted device can send a first query message to the first SHE, and read the current key system construction status, construction count, date of the last successful construction, and the verification code MAC of the construction status data from the SHE. .
  • the first query message may carry the following parameters M1 and M2.
  • KEY_ID is the security verification key used for the first query message. Therefore, for the first query message initiated by the device outside the vehicle, the KEY_ID is a fixed key; when a non-KMS device in the vehicle, such as a CDC or a central control panel, triggers a long-term key update, for example, when sending the first
  • the query initiated before the message can be a long-term key or a fixed key.
  • the first query message initiated by the first vehicle-mounted device or the second vehicle-mounted device may use a temporary key generated by the corresponding SHE as the security verification key.
  • KEY_ID can be 0. If it is 0, it means that there is no key query. At this time, M1 in the input parameter does not contain MAC (that is, does not contain M2). Correspondingly, M4 is not included in the output parameters.
  • Key is the security verification key corresponding to KEY_ID.
  • the SHE After the SHE successfully verifies the input parameters in the first query message, it can generate corresponding output parameters and return the first query response message. For example, taking the first SHE as an example, the first vehicle-mounted device sends a first query message to the first SHE, and after the first SHE successfully verifies the input parameters in the first query message, it can generate corresponding output parameters M3 and M4, And return the first query response message to the first vehicle-mounted device.
  • the output parameter M3 satisfies:
  • the output parameter M4 satisfies:
  • the first vehicle-mounted device may verify the output parameters in the first query response message, and obtain the query content in the output parameters after the verification is successful, for example, KMS_KH_BuildStatus, KMS_KH_BuildCounter, KMS_KH_BuildDate, KMS_KH_BuildMac.
  • the first vehicle-mounted device may correspond to the filled vehicle-mounted device according to the first key, for example, may be the second vehicle-mounted device.
  • the second vehicle-mounted device may be the first vehicle-mounted device, or other vehicle-mounted devices in the vehicle.
  • the second in-vehicle device may be a server, an agent, or a client, which is not limited here.
  • the following takes the second vehicle-mounted device as another vehicle-mounted device other than the first vehicle-mounted device as an example for description. As shown in Figure 4, the following steps are included:
  • Step 401 the first vehicle-mounted device receives the first parameter of the first key sent from the first SHE.
  • the first vehicle-mounted device obtains the first parameter of the first key according to the received first response message.
  • first parameters reference may be made to M3-M5 in the above-mentioned first response message, which will not be repeated here.
  • Step 402 The first vehicle-mounted device generates a first key loading message according to the first parameter of the first key.
  • the first key loading message is used for filling the first key after the second in-vehicle device successfully verifies the first key loading message.
  • Step 403 the first vehicle-mounted device sends a first key loading message to the second vehicle-mounted device.
  • the first vehicle-mounted device may be a KMS server or a KMS agent.
  • the second in-vehicle device may be a KMS client or a KMS agent.
  • the first vehicle-mounted device may send a first key loading message to the second vehicle-mounted device, or the first vehicle-mounted device may send a first key loading message to the agent.
  • the key loading message, and the agent forwards the first key loading message to the second vehicle-mounted device.
  • the first vehicle-mounted device when the first vehicle-mounted device is a server and the second vehicle-mounted device is an agent, the first vehicle-mounted device may send a first key loading message to the second vehicle-mounted device.
  • the second vehicle-mounted device may also deliver the first key loading message to the client managed by the second vehicle-mounted device.
  • the first vehicle-mounted device when the first vehicle-mounted device is an agent, can receive the first key loading message forwarded by the server, and can also send the first key to the second vehicle-mounted device managed by the first vehicle-mounted device Load the message.
  • the first vehicle-mounted device when the first vehicle-mounted device is an agent, the first vehicle-mounted device may generate a first key loading message, and send the first key loading message to a second vehicle-mounted device that may be managed by the first vehicle-mounted device.
  • Step 404 The second vehicle-mounted device sends the first key loading message to the second SHE according to the received first key loading message.
  • Step 405 After successfully verifying the first key loading message, the second SHE generates a first key loading response message.
  • Step 406 The second SHE sends a response message of loading the first key to the second vehicle-mounted device, and the second vehicle-mounted device forwards the response message of loading the first key to the first vehicle-mounted device.
  • Step 407 The first vehicle-mounted device generates a filling verification message of the first key according to the response message loaded with the first key.
  • Step 408 the first vehicle-mounted device sends a filling verification message of the first key to the first SHE.
  • Step 409 After successfully verifying the first key loading verification message, the first SHE feeds back the verification result to the first vehicle-mounted device.
  • Step 4010 The first vehicle-mounted device updates the state information of the first key according to the verification result fed back by the first SHE, and generates a verification code of the state data accordingly.
  • Step 4011 the first vehicle-mounted device sends a status update message to the first security hardware expansion unit.
  • the state update message includes: the construction state of the in-vehicle key; the state update message is used for the first security hardware expansion unit to update the construction state of its own in-vehicle key after the verification of the state update message is successful.
  • construction state of the in-vehicle key may be the construction state of the key system or the construction state of the first key, which is not limited here.
  • Step 4012 The first SHE verifies the status update message, and updates the security verification code of the status data after the verification is successful.
  • the first response message received by the first vehicle-mounted device may carry the input parameters and output parameters of the first key loading message, that is, the output parameters carried in the first response message include M1-M7.
  • the output parameters M3-M5 are the first parameters of the first key, that is, the input parameters M1-M3 corresponding to the first key loading message.
  • the input parameters corresponding to the first key loading message satisfy:
  • the UID when the UID is 8 bits in the Memory Slot, the UID can be 128 bits.
  • the first key loading message is used to store the exclusive key of the first vehicle-mounted device in the SHE of the first vehicle-mounted device, such as GLOBAL_FIX_KEY, when other vehicle-mounted devices do not obtain the key, the UID may not be 0, and the UID It is the special identifier of the first vehicle-mounted device.
  • the UID should be 0 (ie wildcard UID).
  • Key memory slot is the first key.
  • the memory slot is used to indicate the key address of the first key storage.
  • KEY_ID is used to indicate the security verification key of the first key loading message, and is used to derive the key identifier of the key of K1 and K2.
  • K1 and K2 are the encryption key and integrity calculation key derived from the key corresponding to KEY_ID.
  • the derivation method refers to the existing SHE specification and will not be repeated here.
  • the selection of the security verification key can be determined based on Table 7.
  • the input parameters M1-M3 of the first key loading message (that is, the output parameters M3-M5 of the first response message) are generated by the first SHE, then the security verification
  • the key can be a fixed key for one vehicle, one secret, a long-term key for one vehicle, or the first key before updating, etc.
  • Counter is a key update count value corresponding to the first key, which may be 28 bits. During SHE processing, it may first be checked whether this value is greater than the Counter value of the first key to be updated in the storage area corresponding to the memory slot. If the KMS key system is currently being built, that is, the KMS_KH_BuildStatus value is "1-under construction", it is also necessary to check whether this value is the same as the KMS_KH_BuildCounter value in SHE.
  • KeyID can also be included, which is used to indicate the key index of the key corresponding to the memory slot (not the Memory Slot). If this field is included, it cannot be 0. "0...0"m: Fill the field with 0, used for block encryption alignment. Since the block length is 128 bits during AES_CBC_128 encryption, if the KeyID is not included, "0...0"m needs to be filled with 94 bits of 0. If KeyID is included, "0...0"m needs to be filled with 62 bits of 0.
  • step 405 after the second SHE successfully verifies the input parameters carried in the first key loading message, it can correspondingly generate a first key loading response message, and the first key loading response message can carry the first The output parameters of the key loading message, where the output parameters M4 and M5 satisfy:
  • M4 UID
  • the UID in M4 is the same as the description of the input parameter, and the value of M4 is also the same as the input parameter.
  • the memory slot and KEY_ID are also the same as the values in the input parameters.
  • the key corresponding to the KEY_ID is not used for encryption and/or integrity calculation of the output parameters of the response message loaded with the first key.
  • the output parameters may be encrypted and/or integrity calculated according to the updated first key, see the description below.
  • K3 is an encryption key derived from the first key.
  • Counter is the same as the Counter value of the input parameter.
  • “1" 1 indicates that the value "1" occupies 1 bit
  • "0...0” n indicates that the value "0" occupies n bits.
  • KeyID is optional and is used to indicate the key index of the first key. If this field is included in the input parameter, it must be included here. 32 bits.
  • the block length is 128 bits. For example, if KeyID is not included, 99 bits of 0 are filled. When KeyID is included, 67 bits of 0 are filled.
  • K4 is the integrity calculation key derived from the first key.
  • For the derivation method refer to the description of the existing SHE specification. After the first key loading message is successfully verified, the second SHE sets the build status BuildStatus of the first key to "1—build successfully".
  • step 406 the parameters of the filling verification message of the first key may be as shown in Table 13.
  • the filling verification message of the first key may carry an output parameter of the filling response message of the first key. That is, the input parameters satisfy:
  • M1 UID
  • the first vehicle-mounted device passes the M4 and M5 of the output parameters of the filling response message of the first key from the second vehicle-mounted device to the SHE for verification through the filling verification message of the first key, and confirms the identity of the second vehicle-mounted device. Whether the filling of the first key is successfully completed, and return the verification result to the first vehicle-mounted device.
  • the security verification key of the filling response message of the first key may be a temporary key between the first vehicle-mounted device and the first SHE.
  • step 409 the first vehicle-mounted device updates the state information of the first key according to the verification result fed back by the first SHE, and generates an integrity verification code MAC of the state data accordingly.
  • the first vehicle-mounted device or the second vehicle-mounted device needs to continuously update the state data in the process of building the current key system, for example, the state data of the first key or the state data of the key system , safely stored in non-volatile memory.
  • the stored status data of the first key may include: the construction status of the key, the construction type, the communication security domain to which the first key is currently constructed, the in-vehicle device corresponding to the constructed first key, and the like.
  • stored state data may include:
  • the flag KMSBuildStatusFlag of the build status is used to mark the build status of the key system, such as unbuilt, under construction, and completed.
  • KMSBuildTypeFlag is used to mark the current initial key system construction, long-term key update, or key system reconstruction for vehicle equipment replacement. This flag is only useful if KMSBuildStatusFlag is building.
  • the mark KMSBuildStageFlag of the construction stage is used to mark the current one-vehicle-one-key fixed key filling, one-vehicle-one-key long-term construction or update, the construction stage or update stage of each communication security domain, etc.;
  • the integrity protection of the state data can be protected, and the encryption protection is optional.
  • the state data without encryption protection, the integrity key and the integrity MAC can be stored in a secure Store scene.
  • the integrity check code MAC that can be generated for the above updated state data can be stored in the SHE after being verified by the temporary key.
  • a temporary key KTemp can be generated by the SHE through the startup message constructed by the key system, and returned to the on-vehicle device.
  • the temporary key K Temp is jointly held by the KMS and the SHE.
  • the temporary key KTemp may use a symmetric key. It can avoid KMS (ordinary operating environment, if it is a trusted operating environment, it is better, such as isolated operation) key during the operation process that SHE may not trust, and improve the security of state data storage.
  • an asymmetric signature algorithm can be used to temporarily generate a pair of public and private keys, and the temporary public key is returned to KMS. Considering that the key may be obtained by other attacker software, the asymmetric algorithm will not enhance security, but will reduce the calculation performance of MAC.
  • Integrity protection through the temporary key can enable the SHE to perform integrity protection through the temporary key when updating the relevant information of the first key (for example, integrity MAC, status data, etc.), and improve tamper-resistant performance.
  • relevant information of the first key for example, integrity MAC, status data, etc.
  • the temporary key KTemp can also be stored in the non-volatile storage area of the SHE. For example, during the key construction process, if the device restarts abnormally, when the vehicle device restarts to continue the key system construction, it needs to complete the verification with SHE again. At this time, SHE can return the originally allocated KTemp to KMS. It is of course also possible to assign a new temporary key. That is, during a key system construction process, KTemp can remain unchanged or can be changed as needed.
  • the storage of the state data during the construction of the key system can be encrypted and stored in a common storage area.
  • the KMS server or agent agent in the car uses the KTemp derives the encryption key and integrity key, encrypts the state data, and stores it in the common storage area. Generate a new MAC based on the encrypted data, and then use CMD_KMS_KH_UPDATE_BUILDSTATUS to store it in KMS_KH_BuildMac of SHE.
  • the key state data in the KMS key construction process can also be directly and securely stored inside the SHE. For example, it is enough to expand and reserve the storage area for storing the process state data of KMS in SHE, for example, reserve 100 Bytes. SHE may not perceive the specific meaning of the state data.
  • the first vehicle-mounted device may send a status update message to the first SHE.
  • the following example illustrates the parameters that can be involved in the status update message CMD_KMS_KH_UPDATE_BUILDSTATUS. As shown in Table 14.
  • Key is a security verification key whose KEY_ID is a status update message, such as a temporary key.
  • KEY_ID may be the key address of the temporary key.
  • KMS_KH_BuildCounter is the KMS_KH_BuildCounter value in SHE to prevent replay attacks of this command. For example, if the KMS_KH_BuildCounter value is not equal to the value in the first SHE, ignore the status update message and return ERC_INVALID_PARAMETER. If the current saved value of KMS_KH_BuildMac in MAC and SHE is the same, it indicates that the state data does not need to be updated. At this time, ignore the state update message and return ENC_REPEAT_STORE_SAME_DATA.
  • the first vehicle-mounted device or the second vehicle-mounted device may restart abnormally.
  • the first vehicle-mounted device or the second vehicle-mounted device can Re-verified by SHE to obtain a temporary key, which can be a temporary key generated before restarting, or a temporary key regenerated for the on-board device.
  • the integrity of the stored state data can be verified, and then the construction of the key system can be continued to avoid the failure of the first or second vehicle-mounted device.
  • Restarting causes the construction of the key system to be restarted, improving the robustness of the key system construction.
  • the first query message may also be sent to the first SHE through the first vehicle-mounted device (for example, the server or agent) to notify the SHE to verify the restart.
  • the first vehicle-mounted device for example, the server or agent
  • the MAC that previously stored the key state data, after the verification is successful, securely reads the progress of the key system construction before the restart from the SHE, that is, returns the state data of the key system construction.
  • the temporary key generated by the SHE for this build can be used for security verification.
  • the first query request can be sent to the server to obtain the construction status of the key system; when the first vehicle-mounted device is the server, then confirm the construction of the key system If it fails, you can restart the construction of the key system.
  • the parameters of the first query message can be referred to in Table 12, and will not be repeated here.
  • FIG. 5 it is a schematic flowchart of a method for generating a key in a restart scenario provided by the present application. Taking the restart of the first vehicle-mounted device as an example, the following steps are included:
  • Step 501 After the first vehicle-mounted device determines to restart, it sends a first query request to the first SHE; the first query request is used to query the second parameter of the first key.
  • the first vehicle-mounted device may be a KMS server or a KMS agent.
  • the first vehicle-mounted device may send a first query request to the first SHE.
  • the first SHE is the SHE corresponding to the first vehicle-mounted device.
  • the first vehicle-mounted device when the first vehicle-mounted device is an agent, can send a first query request to the SHE corresponding to the first vehicle-mounted device, and after verifying the first query request through the SHE corresponding to the first vehicle-mounted device, return First query response.
  • the first vehicle-mounted device may send the first query request to the server, and return the first query response after verifying the first query request through the SHE of the server.
  • the first SHE is the SHE corresponding to the server.
  • Step 502 The first SHE generates a first query response message according to the first query request; the first query response message is returned after the first security hardware extension unit verifies the first query request; the first query response message includes: The second parameter of a key.
  • Step 503 the first SHE sends a first query response message to the first vehicle-mounted device.
  • the first query message of the first vehicle-mounted device can also be used to obtain a temporary key, that is, the first security hardware expansion unit sends the temporary key to the first vehicle-mounted device; where the temporary key is used to encrypt the first request message .
  • the first SHE When verifying the message, the first SHE can judge whether the current key system construction status KMS_KH_BuildStatus is "under construction". Reject if not. After verifying the restart message and the first query message, the first SHE may return a restart response message constructed by the key system, and the restart response message constructed by the key system carries the first query response message. Wherein, the first query response message may carry a temporary key.
  • the first vehicle-mounted device determines, according to the first query response, that the operation of generating the first key is currently being performed.
  • the first vehicle-mounted device generates the first request message according to the second parameter of the first key and the first message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
  • the first secure hardware expansion unit generates an encrypted first key according to the first request message.
  • the first vehicle-mounted device may notify the first SHE of the restart status of the first vehicle-mounted device, and notify the first SHE to continue building the key system before restarting, At this time, a restart message of key system construction may be sent to the first SHE. It is used for the first in-vehicle device to reacquire the security verification key and the state of the key system construction. For example, for the server, the restart message can use a fixed key as the security verification key, which can be found in the startup message of the key system construction, and will not be repeated here.
  • the restart message can use a fixed key or a temporary key used in the current period as the security verification key, and the security verification key can come from the key sent from the server to the agent.
  • the restart message can use a fixed key or a temporary key used in the current period as the security verification key, and the security verification key can come from the key sent to the client by the server or the agent.
  • the first query request may be sent in a manner referring to the first query request above, or may be sent in a manner in which a restart message constructed through a key system carries the first query request.
  • the first on-vehicle device may send a restart message of key system construction to the first SHE, carrying the first query message.
  • the first SHE may send the ephemeral key in the first query response.
  • the first vehicle-mounted device may send a restart message of key system construction to the first SHE, carrying the first request message.
  • the restart message of key system construction must be executed after the start message of key system construction and before the end message of key system construction. Specifically, it can be verified through the parameters of the key system construction. As shown in Table 15, the restart message for key system construction may involve the following parameters.
  • the first vehicle-mounted device can trigger a restart message constructed by the key system through an external device.
  • the restart message generated by the server, APP, CDC or the central control screen can The parameters are required and passed to the server.
  • the server generates the restart message of the key system construction from the message and sends it to the first SHE.
  • the first SHE verifies the restart message of the key system construction. After verification, the key system is generated.
  • the output parameters corresponding to the restart message of the construction, and correspondingly generate the restart response message of the key system construction, and the response message carries the output parameters corresponding to the restart message of the key system construction.
  • the restart message may or may not carry other messages.
  • the parameters carried in the restart message of key system construction may include M1 and M2.
  • the input parameter M1 satisfies:
  • the input parameter M2 satisfies:
  • Key is the security verification key, that is, the key corresponding to KEY_ID.
  • the KEY_ID is the KEY_ID corresponding to the fixed key.
  • the long-term key update triggered later may be the KEY_ID corresponding to the long-term key, for example, the KEY_ID of the long-term key for one car one encryption.
  • CMD_TYPE indicates whether the restart message of the key system construction carries other messages. For details, refer to Table 11, which is an example of the startup message of the key system construction carrying other messages. CMD_TYPE_IN_Parameters: CMD_TYPE corresponds to all input parameters of other messages. At this time, the value of CMD_TYPE cannot be 0.
  • KMS_KH_BuildCounter is the value of the key system build count.
  • the value of KMS_KH_BuildCounter in the restart message of the key system construction must be equal to the value of KMS_KH_BuildCounter in the first SHE, and the KMS_KH_BuildStatus in the SHE must be "Building", it is determined that the first SHE corresponding to the first vehicle device successfully verifies the restart message of the key system construction; otherwise, the first SHE corresponding to the first vehicle device fails to verify the restart message of the key system construction.
  • KMS_KH_BuildCounter value in the key system construction restart message is not equal to the KMS_KH_BuildCounter value in the first SHE, ignore the key system construction restart message and return ERC_INVALID_PARAMETER.
  • ERC_INVALID_PARAMETER please refer to the verification method of the startup message of the key system construction, which will not be repeated here.
  • the first SHE corresponding to the first vehicle-mounted device After the first SHE corresponding to the first vehicle-mounted device successfully verifies the restart message of the key system construction, the first SHE corresponding to the first vehicle-mounted device can generate a response message for the restart of the key system construction, and the response message can carry the following information: Refer to M3 ⁇ M5.
  • the output parameter M3 satisfies:
  • CMD_TYPE_OUT_Parameters is all the output parameters corresponding to CMD_TYPE.
  • KMS_KH_BuildKTemp may be a temporary key KTemp generated by the start message of key system construction before restart, or a new temporary key generated by the first SHE for the restart message of key system construction.
  • the corresponding SHE will increase the locally stored KMS_KH_BuildCounter by 1 when starting the key system construction.
  • the Counter field corresponding to the first key is set to the value of KMS_KH_BuildCounter. Therefore, after the first vehicle-mounted device or the second vehicle-mounted device is restarted, the state of key generation can be determined by obtaining the state data of the key system, especially for the first key that has been generated but not yet loaded before the restart.
  • the server or agent can obtain the first parameter of the first key from the corresponding SHE, generate the first key loading message, and continue to send the first key to each client or agent that has not obtained the first key. distribution without having to restart the operation that built the first key.
  • FIG. 6 it is a schematic flowchart of a method for generating a key in a restart scenario provided by the present application. Taking the restart of the second in-vehicle device as an example, the following steps are included:
  • Step 601 The second vehicle-mounted device sends a second message to the first vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key, or instructing the first vehicle-mounted device to Second, the on-board equipment restarts.
  • the second in-vehicle device may be a KMS client or a KMS proxy.
  • the second vehicle-mounted device can send a second message to the first vehicle-mounted device, or the second vehicle-mounted device can send a second message to the agent, and The proxy end forwards the second message to the first vehicle-mounted device.
  • the second vehicle-mounted device may send the second message to the first vehicle-mounted device.
  • the second vehicle-mounted device may also receive a second message from a client managed by the second vehicle-mounted device.
  • Step 602 the first vehicle-mounted device sends a verification message of the second message to the first SHE.
  • the first SHE is the SHE corresponding to the first vehicle-mounted device.
  • Step 603 After verifying the verification message of the second message, the first SHE returns a verification response message of the second message to the first vehicle-mounted device.
  • the verification of the second message by the first in-vehicle device is realized through steps 602 and 603 .
  • Step 604 The first vehicle-mounted device sends a third message to the second vehicle-mounted device according to the verification response message of the second message; the third message includes at least one of the following items: the second parameter of the first key and the information of the first key.
  • the first vehicle-mounted device when the first vehicle-mounted device is a server and the second vehicle-mounted device is a client, the first vehicle-mounted device can send a third message to the second vehicle-mounted device, or the first vehicle-mounted device can send a third message to the agent , and forward the third message to the second in-vehicle device by the agent.
  • the first vehicle-mounted device when the first vehicle-mounted device is the server and the second vehicle-mounted device is the agent, the first vehicle-mounted device may send the third message to the second vehicle-mounted device.
  • the second vehicle-mounted device may also send a third message to the client managed by the second vehicle-mounted device.
  • the first vehicle-mounted device may receive the third message forwarded by the server, and may also send the third message to the second vehicle-mounted device managed by the first vehicle-mounted device.
  • the first vehicle-mounted device may generate a third message, and send the third message to a second vehicle-mounted device that may be managed by the first vehicle-mounted device.
  • the second message sent by the second vehicle-mounted device to the first vehicle-mounted device is the first query message.
  • the first in-vehicle device for example, an agent or server
  • the first in-vehicle device generates a message sent to the first SHE according to the input parameters of the first query message.
  • the verification message of the first query message the verification message of the first query message carries the input parameter of the first query message, and after passing the first SHE verification, returns the output parameter of the first query response message (that is, the verification response of the second message information).
  • the security verification key of the first query message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device
  • the security verification key of the verification message of the second message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device.
  • the first vehicle-mounted device may generate a third message to be sent to the second vehicle-mounted device according to the output parameter of the first query response message, the third message carries the output parameter of the first query response message, and sends the third message to
  • the second vehicle-mounted device obtains the output parameters of the first query response message after verifying the third message.
  • the security verification key of the third message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device
  • the security verification key of the verification response message of the second message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device.
  • the key used between the first SHEs For specific input parameters and output parameters of the first query response message, refer to the first query response message above.
  • the second message sent by the second vehicle-mounted device to the first vehicle-mounted device is a request message for the first key.
  • the restarted agent can send the first query message to the first in-vehicle device (server) to trigger the service end to return the first query response message, and the agent can report to the agent managed by the agent.
  • the client sends the first query response message, so that each client completes the verification with the SHE corresponding to the client, and obtains the corresponding temporary key or status data, etc., to continue the construction of the key system.
  • the first vehicle-mounted device generates a first key loading message according to the first key request message.
  • the first key may have been generated during the restart process of the second vehicle-mounted device, or it has not been generated after the restart of the second vehicle-mounted device, the following uses scenarios 5.2.1 to 5.2.2 as examples for illustration.
  • the first vehicle-mounted device generates a first key loading message according to the second parameter of the first key and the first message; the first key is the first secure hardware expansion unit before restarting generated key. Therefore, the first vehicle-mounted device can send the first key loading message to the second vehicle-mounted device.
  • the second vehicle-mounted device may carry the first query message in the restart message constructed by the key system.
  • the first vehicle-mounted device generates the first request message according to the second parameter of the first key and the first message; and sends the first request message to the first SHE, and the SHE verifies the first request message.
  • a first response message is generated, where the first response message carries a first parameter of the first key. Therefore, after the first vehicle-mounted device receives the first response message, it generates a first key loading message according to the first parameter of the first key, and sends it to the second vehicle-mounted device, so that the second vehicle-mounted device loads the first key key.
  • the first request message may be carried in the restart message of key system construction and sent.
  • the first vehicle-mounted device executes the second query message to query the state data of the key
  • the state data of the key may include: the key of the key information such as marking, querying whether the key forms a pair, etc.
  • the second query message cannot query the content of the key.
  • the server may not know whether the second on-vehicle device has been loaded or filled.
  • the user can trigger the key verification process through the key management tool.
  • the off-vehicle device can trigger the server to send the SHE A second query message is sent to obtain the loading status of the first key.
  • the first vehicle-mounted device or the second vehicle-mounted device checks whether the construction state of the key is completed. For example, if the construction status of the key is not completed, report to the police, prohibit the vehicle from driving, etc.
  • the first vehicle-mounted device or the second vehicle-mounted device sends a second query message to query the loading status of the first key.
  • the parameters that may be involved in the second query message are introduced with examples below. For example, as shown in Table 16.
  • the first vehicle-mounted device may generate an input parameter of the second query message.
  • the input parameter M1 satisfies:
  • memory slot1 is used to represent the key of the query corresponding to the second query message.
  • KEY_ID is the security verification key of the second query message
  • Key is a key corresponding to KEY_ID.
  • KEY_ID is the key address of the temporary key. If the KEY_ID is 0, it means that the second query message has no verification information, and the following M2 and M4 are ignored.
  • the first SHE After the first SHE verifies that the second query message is successful, it may correspondingly generate a second query response message, wherein the second query response message may include the following parameters. Among them, the output parameter M3 satisfies:
  • Key1 Info is the key information corresponding to the key address of memory slot1, for example, Key1 Info satisfies:
  • Key1 Info KeyFlags
  • KeyFlags WRITE-PROTECTION(1bit)
  • PairSlot is used to identify whether the key Key1 of the query forms a pair, or Slave, that is, whether it contains "memory slot2" and "Key2Info". For example, if the PairSlot value is 0, it does not contain; if the PairSlot value is 1, it is a Pair; if the PairSlot value is 2, it is a Slave.
  • the first in-vehicle device unlocks the second query response message, it can verify the parameters in the second query response message, and then obtain the query result of the key.
  • a non-KMS device may send a key system construction completion message to the first vehicle-mounted device, and the first SHE verifies the message. It is used to inform SHE that the construction of the key system of this KMS is completed, and the completion of the construction of the key system includes the successful generation of all the first keys of the key system, the success of the key loading verification of the key system, etc. It should be noted that the message may not include other messages, and may contain an encrypted and integrity-protected state information: the construction of the KMS key system is completed, and the result is success or failure.
  • the embodiment of the present application provides a method for generating a key, including the following steps:
  • Step 701 The first vehicle-mounted device obtains a key system construction completion message.
  • the start message for key system construction may be generated by an off-vehicle device and sent to the first on-vehicle device (for example, a server or agent) (for example, by The key system construction start message initiated by the server, key management tool or APP outside the vehicle), and the completion message of the key system construction is also generated by the device outside the vehicle.
  • a server or agent for example, by The key system construction start message initiated by the server, key management tool or APP outside the vehicle
  • the completion message of the key system construction is also generated by the device outside the vehicle.
  • the start message of the key system construction is generated by the in-vehicle device and sent to the server (for example, the long-term key update initiated by the in-vehicle CDC or the central control panel ), the completion message of the key system construction can also be generated by the in-vehicle device or by the off-vehicle device, which is not limited here.
  • key system construction completion message can use the same security verification key as the key system construction start message, and the details can be found in Table 11, which will not be repeated here.
  • the first vehicle-mounted device may be a KMS server or a KMS agent.
  • the first vehicle-mounted device may send a key system construction completion message to the client, or the first vehicle-mounted device may send a key system construction completion message to the agent, and the agent sends a key system construction completion message to the client.
  • the client forwards the key system construction completion message.
  • the first vehicle-mounted device is an agent, the first vehicle-mounted device may receive a key system construction completion message forwarded by the server, and may also send a key system construction completion message to a client managed by the first vehicle-mounted device.
  • Step 702 The first vehicle-mounted device sends a verification message of the key system construction completion message to the first SHE according to the key system construction completion message.
  • the first SHE is the SHE corresponding to the first vehicle-mounted device.
  • the first SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here.
  • the first in-vehicle device may be a KMS for managing keys in the ECU.
  • Step 703 The first SHE verifies the verification message of the key system construction completion message, and sends the verification result to the first vehicle-mounted device.
  • Step 704 the first vehicle-mounted device sends a key system construction completion message to the second vehicle-mounted device.
  • the second vehicle-mounted device may be a KMS client or a KMS agent.
  • the second vehicle-mounted device can receive the key system construction completion message sent by the first vehicle-mounted device, and can also forward the key sent by the first vehicle-mounted device through the agent of the second vehicle-mounted device. System build complete message.
  • the second vehicle-mounted device is an agent, the second vehicle-mounted device can receive the key system construction completion message sent by the first vehicle-mounted device, and can also send a key system construction completion message to the client managed by the second vehicle-mounted device.
  • Step 705 The second vehicle device sends a verification message of the key system construction completion message to the second SHE according to the key system construction completion message.
  • the second SHE is the SHE corresponding to the second vehicle-mounted device.
  • the second SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here.
  • the second in-vehicle device may be a KMS for managing keys in the ECU.
  • Step 706 The second SHE verifies the verification message of the key system construction completion message, and sends the verification result to the second vehicle-mounted device.
  • Step 707 the second vehicle-mounted device sends the verification result of the second vehicle-mounted device to the first vehicle-mounted device.
  • the key system construction completion message may be used to inform the corresponding SHE that the key system construction of the KMS is completed, and the date when the key system construction is completed.
  • Key is the key corresponding to KEY_ID.
  • KEY_ID is the key address of the security verification key corresponding to the key system construction completion message.
  • the value must be the KEY_ID of the fixed key (because the construction of the command message must also be completed outside the vehicle);
  • the long-term key update initiated by the CDC or the central control panel in the vehicle it can be the KEY_ID corresponding to the long-term key, for example, the KEY_ID of the long-term key for one car one secret.
  • the input parameter M1 can satisfy:
  • the BuildStatus in the key system construction completion message indicates the construction status of the key system, for example, 0—indicates that the construction is successful, and other values—indicates that the construction fails.
  • the SHE successfully verifies the key system construction completion message, it can update the KMS_KH_BuildStatus value in the SHE according to the BuildStatus in the key system construction completion message.
  • BuildCounter is the value of the build count for this key system construction.
  • the KMS_KH_BuildStatus in the SHE must be "1-under construction", otherwise the key system construction completion message is ignored and the error message ERC_KMS_KH_STATUS_INVALID is returned.
  • the SHE After the SHE successfully verifies the key system construction completion message, the SHE checks whether all the first keys affected by KMS_KH_BuildStatus have been constructed. For example, including BuildStatus, Counter checks for each key. Only when all the first key checks pass, the key system construction completion message returns the verification result ERC_NO_ERROR. Otherwise, return the verification result ERC_KMS_KH_NOT_FINISHED.
  • the SHE After the SHE has successfully verified the key system construction completion message, at this time, the SHE sets KMS_KH_BuildStatus to "2-build successfully", and refreshes the KMS_KH_BuildDate. That is, when the key system is built each time, the date and time when the key system is built are stored in KMS_KH_BuildDate of the SHE.
  • the SHE determines that the BuildStatus indicates that the build is successful (for example, the value of the BuildStatus is 0), it updates the completion time of the key system construction.
  • BuildDate indicates the completion time of the key system construction completion message.
  • this parameter can be ignored, and the SHE directly reads the current time from the system as the key system construction completion time, and updates it to KMS_KH_BuildDate.
  • SHE cannot read the system time from the system, you can check this parameter first, for example, whether the parameter BuildDate is greater than the value of KMS_KH_BuildDate in SHE.
  • the second vehicle-mounted device executes the key system construction completion message. That is, the server needs to distribute the parameters of the key system construction completion message to each agent and client, and the agent distributes it to each client it acts as an agent for synchronizing the status data such as the KMS_KH_BuildCounter value of each second vehicle-mounted device.
  • the first vehicle-mounted device and the second vehicle-mounted device should notify SHE to set the build status KMS_KH_BuildStatus to "build successfully" or "build failed", and update the build date.
  • FIG. 8 is a schematic diagram of a possible system architecture applicable to the embodiment of the present application.
  • the system architecture shown in FIG. 8 includes a vehicle and a diagnostic device.
  • the vehicle may be any vehicle having a key authentication function.
  • the diagnosis device may refer to a diagnosis instrument, may also refer to a diagnosis server, and may also refer to a diagnosis server cluster. It should be understood that the embodiment of the present application does not limit the number of vehicles and diagnostic devices in the system architecture. For example, one diagnostic device may perform information interaction with only one vehicle, or may perform information interaction with multiple vehicles.
  • system architecture applicable to the embodiment of the present application may also include other equipment, such as supplier equipment, manufacturer equipment, production line equipment, and sales equipment, etc., and this embodiment of the application also Not limited.
  • diagnostic device in the embodiment of the present application may integrate all functions on one independent physical device, or distribute the functions on multiple independent physical devices, which is not limited in the embodiment of the present application.
  • the vehicle diagnosis may be implemented in a wired manner or in a wireless manner.
  • the diagnostic equipment usually has a diagnostic line, and the vehicle is preset with a diagnostic interface.
  • the diagnostic personnel can directly insert one end of the diagnostic line of the diagnostic equipment into the diagnostic interface of the vehicle. Enter the diagnostic command on the device so that the diagnostic command is sent to the vehicle through the diagnostic line.
  • the diagnostic interface may refer to a unified diagnostic service (unified diagnostic services, UDS) interface, may also refer to an on-board diagnostics (OBD) interface, or may refer to other interfaces capable of realizing command transmission functions, without limitation. .
  • UDS unified diagnostic services
  • OBD on-board diagnostics
  • the diagnostic equipment and the vehicle can have near-field communication functions such as Bluetooth or wireless local area network (WLAN), and the diagnostic personnel can first connect the diagnostic equipment through the near-field communication function of the diagnostic equipment and the vehicle. and the vehicle, and then enter the diagnostic command on the diagnostic device so that the diagnostic command is transmitted to the vehicle wirelessly.
  • the diagnostic equipment can also be provided with a liquid crystal display, and after obtaining the diagnostic results, the diagnostic equipment can also synchronously display the diagnostic results on the liquid crystal display, so as to remind the diagnostic personnel to check the diagnostic results in time and quickly find out the fault location and cause of failure.
  • the present application provides a method for obtaining an in-vehicle key, including:
  • Step 901 The off-vehicle device sends a first message to the first on-vehicle device.
  • the first on-vehicle device receives the first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain the first key.
  • the first key may be a long-term key that triggers the generation of the first vehicle-mounted device, or a fixed key stored in advance by the vehicle, or a fixed key of the vehicle stored on a cloud server. This is not limited.
  • the off-vehicle device may be a diagnostic device, and the diagnostic device may establish a secure tunnel with the vehicle to send a first message to the first vehicle-mounted device, where the first message may include a certificate corresponding to the diagnostic device, a PIN code, and the like.
  • the device may also send the first message through the gateway, which is not limited here.
  • Step 902 The first vehicle-mounted device generates a role verification request message according to the first message and the verification information of the first vehicle-mounted device, and the role verification request message is used for the server to obtain the authority of the first key for the first vehicle-mounted device and the first vehicle-mounted device Verify the verification information;
  • the first vehicle-mounted device can encrypt the PIN code obtained after encrypting the PIN code, and generate the verification information of the first vehicle-mounted device according to the authority information of the first key, which is used by the server to verify the first key. Therefore, the first vehicle-mounted device can generate a role verification request message through the certificate corresponding to the diagnostic device, the encrypted PIN code, and the encrypted permission information of the first key.
  • Step 903 the first vehicle-mounted device sends a role verification request message to the server.
  • the first vehicle-mounted device may send the role verification request message to the server in an encrypted manner, and the specific encryption manner is not limited in this application.
  • Step 904 the server verifies the role verification request message, and generates a role verification response message.
  • the response message of the role verification includes: the verification result of the role verification request message.
  • the server may verify the encrypted PIN code, verify the certificate corresponding to the diagnostic device, and also verify the authority information of the first key. For example, when the first message is used to request the first vehicle-mounted device to generate the first key, it may be verified whether the first vehicle-mounted device has the authority and capability to generate the first key. When the first message is used to request the server to send the first key to the first vehicle-mounted device, it may be verified whether the first vehicle-mounted device has the authority to obtain the first key. When the first message is used to request the diagnostic device to obtain the first key on the first vehicle-mounted device for diagnosis, it may be verified whether the first vehicle-mounted device and the diagnostic device have the authority to obtain the first key.
  • Step 905 the server sends a response message of role verification to the first vehicle-mounted device.
  • the first vehicle-mounted device receives the response message of the role verification sent by the server.
  • the response message of the role verification may include agreeing or denying the first vehicle-mounted device to obtain the first key.
  • the response message of role verification may also include other information.
  • the information may also be sent by the server, which is not limited here.
  • the first vehicle-mounted device may generate a first key of the first vehicle-mounted device or the second vehicle-mounted device.
  • the first vehicle-mounted device receives a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the first vehicle-mounted device generates a first request message according to the first message; the first request message uses The first security hardware expansion unit corresponding to the first vehicle-mounted device generates a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key.
  • the way the first vehicle-mounted device determines to generate the first key of the first vehicle-mounted device or the second vehicle-mounted device may be determined by the first message sent by the server, or it may be the response of the first vehicle-mounted device according to the role verification If the message is determined, at this time, the response message of the role verification may include the content in the first message.
  • the server may send the encrypted first key to the first vehicle-mounted device.
  • the first vehicle-mounted device receives the first key sent by the server.
  • the method for the server to send the encrypted first key can refer to the method in scenario 2 of the above-mentioned embodiment, where the off-vehicle device initiates sending the first key loading message to the first vehicle-mounted device, so that the first vehicle-mounted device transmits the first Key Loading message, filling the first key.
  • the server may send the encrypted first key to the first in-vehicle device through a message sent separately, or it may be carried in the response message of the role verification, which is not limited in this application.
  • step 905 when the verification result of the role verification request message is that the verification is successful, the first on-vehicle device sends the first key to the off-vehicle device.
  • the server may indicate to the first vehicle-mounted device that the first vehicle-mounted device agrees to send the first key through a message sent separately, or it may also be indicated by a response message of role verification, so that the first vehicle-mounted device The device may determine to send the first key to the off-vehicle device.
  • the first in-vehicle device may send the first key to the out-of-vehicle device.
  • the way the first on-vehicle device sends the first key to the off-vehicle device may also be sent by referring to the first key loading message, so that the off-vehicle device can After verification, the first key is obtained.
  • the first key may also be sent to the off-vehicle device through other secure transmission methods.
  • FIG 10 is a schematic structural diagram of a key generation device provided by the embodiment of the present application.
  • the chip or circuit in the first vehicle-mounted device is another example of a chip or circuit that can be set in the first security expansion unit, and another example is a chip or circuit that can be set in the first security expansion unit.
  • the key generation device 1001 may further include a bus system, wherein the processor 1002, the memory 1004, and the transceiver 1003 may be connected through the bus system.
  • the above processor 1002 may be a chip.
  • the processor 1002 may be a field programmable gate array (field programmable gate array, FPGA), may be an application specific integrated circuit (ASIC), may also be a system chip (system on chip, SoC), or It can be a central processing unit (central processor unit, CPU), or a network processor (network processor, NP), or a digital signal processing circuit (digital signal processor, DSP), or a microcontroller (micro controller) unit, MCU), it can also be a programmable controller (programmable logic device, PLD) or other integrated chips.
  • FPGA field programmable gate array
  • ASIC application specific integrated circuit
  • SoC system on chip
  • CPU central processing unit
  • NP network processor
  • DSP digital signal processing circuit
  • microcontroller micro controller
  • MCU microcontroller
  • PLD programmable logic device
  • each step of the above-mentioned method may be completed by an integrated logic circuit of hardware in the processor 1002 or instructions in the form of software.
  • the steps of the methods disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor 1002 .
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 1004, and the processor 1002 reads the information in the memory 1004, and completes the steps of the above method in combination with its hardware.
  • the processor 1002 in the embodiment of the present application may be an integrated circuit chip, which has a signal processing capability.
  • each step of the above-mentioned method embodiments may be completed by an integrated logic circuit of hardware in a processor or instructions in the form of software.
  • the above-mentioned processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components .
  • DSP digital signal processor
  • ASIC application-specific integrated circuit
  • FPGA field-programmable gate array
  • Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the memory 1004 in this embodiment of the present application may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory can be random access memory (RAM), which acts as external cache memory.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • DRAM synchronous dynamic random access memory
  • SDRAM double data rate synchronous dynamic random access memory
  • ESDRAM enhanced synchronous dynamic random access memory
  • SLDRAM direct memory bus random access memory
  • direct rambus RAM direct rambus RAM
  • the key generation device 1001 may include a processor 1002 , a transceiver 1003 and a memory 1004 .
  • the memory 1004 is used to store instructions
  • the processor 1002 is used to execute the instructions stored in the memory 1004, so as to implement any one or any number of corresponding methods shown in FIGS. 1 to 8 above. related programs.
  • the key generating device 1001 may be used to execute the key generating method performed by the first vehicle-mounted device in any one of the above-mentioned embodiments.
  • the transceiver 1003 obtains a first message; the first message is used to instruct the first vehicle-mounted device to construct a first key; the processor 1002 generates a first request message according to the first message ; The first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is encrypted by the first key Generated.
  • the key generation device 1001 may be used to execute the key generation method performed by the first secure hardware extension unit in any of the above embodiments.
  • the transceiver 1003 is used to receive the first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key; process After the device 1002 successfully verifies the first request message, it generates first key information; the first key information is generated after encrypting the first key.
  • FIG. 11 is a schematic diagram of a key generation device provided in an embodiment of the present application.
  • the key generation device 1100 may be a first vehicle-mounted device or a first security hardware expansion unit, It can also be a chip or a circuit, such as a chip or a circuit that can be set in the first vehicle-mounted device or the first security hardware expansion unit.
  • the key generation device may correspond to the first vehicle-mounted device or the first secure hardware expansion unit in the above method.
  • the key generation device may implement the steps performed by the first vehicle-mounted device or the first secure hardware expansion unit in any one or any multiple of the corresponding methods shown in FIG. 1 to FIG. 8 above.
  • the key generation device may include an acquisition unit 1101 and a processing unit 1102 .
  • a receiving unit 1103 and a sending unit 1104 may also be included.
  • the obtaining unit 1101 is used to obtain the first message; the first message is used to indicate Construct the first key; the processing unit 1102 generates a first request message according to the first message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: First key information; the first key information is generated after encrypting the first key.
  • the receiving unit 1103 is configured to receive the first response message sent from the first security hardware extension unit.
  • the receiving unit 1103 is configured to receive the first parameter of the first key sent from the first secure hardware extension unit;
  • a processing unit 1102 configured to generate a first key loading message according to a first parameter of the first key
  • the sending unit 1104 is configured to send a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
  • the sending unit 1104 is further configured to send a status update message to the first security hardware extension unit;
  • the status update message includes: the construction status of the in-vehicle key;
  • the status update message is used for the first security hardware expansion unit to update the construction status of its own in-vehicle key after the verification of the status update message is successful.
  • the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message.
  • the processing unit 1102 sends a first query request to the first security hardware expansion unit through the sending unit 1104 after determining that the first vehicle-mounted device is restarted; the first query request is used to query the second parameter of the first key ; Receive the first query response message sent by the first security hardware expansion unit through the receiving unit 1103; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first query response message includes: The second parameter of the first key; according to the second parameter of the first key and the first message, generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before the restart of the first vehicle-mounted device key.
  • the receiving unit 1103 is configured to receive the temporary key sent from the first security hardware extension unit; the temporary key is used to encrypt the first request message.
  • the receiving unit 1103 is configured to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate The first key may instruct the second on-vehicle device to restart.
  • the sending unit 1104 sends a third message to the second in-vehicle device; the third message includes at least one of the following: the second parameter of the first key, First key information.
  • the first message is obtained according to any of the following:
  • the first message After receiving the initialization or update information of the configuration file through the receiving unit 1103, the first message is obtained;
  • the first message After receiving the initialization or update information of the fixed key of the vehicle through the receiving unit 1103, the first message is obtained;
  • the receiving unit 1103 After the receiving unit 1103 receives the initialization or update information of the shared key between the on-vehicle devices of the vehicle, the first message is obtained.
  • the key generating device may be a security hardware expansion unit in the vehicle, and the device includes:
  • the receiving unit 1103 is configured to receive a first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key;
  • the processing unit 1102 is configured to generate first key information after successfully verifying the first request message; the first key information is generated after encrypting the first key.
  • the sending unit 1104 is configured to send a first response message to the first vehicle-mounted device; the first response message includes: first key information.
  • a possible implementation manner after the processing unit 1102 successfully verifies the first request message, generates the first parameter of the first key; sends the first parameter of the first key to the first vehicle-mounted device through the sending unit 1104; The first parameter of a key is used to fill the first key in the second on-vehicle device.
  • the receiving unit 1103 is also configured to receive a status update message sent by the first vehicle-mounted device; the status update message includes: the construction status of the in-vehicle key; the processing unit 1102 is also configured to verify the status update message After success, update the build status of your own in-vehicle key.
  • the receiving unit 1104 is further configured to receive a first query request sent by the first vehicle-mounted device after the first vehicle-mounted device restarts; the first query request is used to query the second parameter of the first key;
  • the processing unit 1102 is configured to send a first query response message to the first vehicle-mounted device through the sending unit 1104 after verifying the first query request; the first query response message includes: the second parameter of the first key; the first key The second parameter of the key is used for the first vehicle device to generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
  • the processing unit 1102 is configured to generate a temporary key after the first request message is verified successfully; send the temporary key to the first vehicle-mounted device through the sending unit 1104; the temporary key is used to encrypt the first request message.
  • the receiving unit 1103 is configured to receive a verification message of a second message from the first vehicle-mounted device; the second message is received by the first vehicle-mounted device and sent by the second vehicle-mounted device; the second message is used for at least the following One item: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key, or instructing the second vehicle-mounted device to restart.
  • the processing unit 1102 is configured to, after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device through the sending unit; the response message of the second message is used by the first vehicle-mounted device Sending a third message to the second vehicle-mounted device; the third message includes at least one of the following items: the second parameter of the first key, and information about the first key.
  • the sending unit 1104 and the receiving unit 1103 can be a sending unit or a transmitter when sending information
  • the receiving unit 1103 can be a receiving unit or a receiver when receiving information
  • the sending unit 1104 and the receiving unit 1103 can be transceivers, this transceiver
  • the transmitter or receiver may be a radio frequency circuit.
  • the key generating device 1100 includes a storage unit
  • the storage unit is used to store computer instructions
  • the processing unit 1103 is connected to the storage unit in communication
  • the processing unit 1103 executes the computer instructions stored in the storage unit.
  • the key generation apparatus 1100 can be used to execute the method executed by the first vehicle-mounted device or the first secure hardware expansion unit in the above embodiment.
  • the processing unit 1103 may be a general central processing unit (CPU), a microprocessor, or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC).
  • the sending unit 1104 and the receiving unit 1103 may be input and/or output interfaces, pins or circuits, and the like.
  • the processing unit 1103 may execute the computer-executable instructions stored in the storage unit, so that the chip in the key generation device 1100 executes the method performed in any one of the embodiments.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit may also be a storage unit located outside the chip in the key generation device 1100, such as a read-only memory (Read Only Memory, ROM) Or other types of static storage devices that can store static information and instructions, random access memory (Random Access Memory, RAM), etc.
  • Fig. 12 is a schematic structural diagram of a key acquisition device provided in the embodiment of the present application.
  • the device can be a first vehicle-mounted device or server, or a chip or a circuit, for example, it can be set in the first vehicle-mounted device
  • a chip or a circuit in a device another example is a chip or a circuit that can be installed in a server, and another example is a chip or a circuit that can be installed in a server.
  • the key acquisition device 1201 may further include a bus system, wherein the processor 1202, the memory 1204, and the transceiver 1203 may be connected through the bus system.
  • the above processor 1202 may be a chip.
  • the processor 1202 may be a field programmable gate array (field programmable gate array, FPGA), may be an application specific integrated circuit (ASIC), may also be a system chip (system on chip, SoC), or It can be a central processing unit (central processor unit, CPU), or a network processor (network processor, NP), or a digital signal processing circuit (digital signal processor, DSP), or a microcontroller (micro controller) unit, MCU), it can also be a programmable controller (programmable logic device, PLD) or other integrated chips.
  • FPGA field programmable gate array
  • ASIC application specific integrated circuit
  • SoC system on chip
  • CPU central processing unit
  • NP network processor
  • DSP digital signal processing circuit
  • microcontroller micro controller
  • MCU microcontroller
  • PLD programmable logic device
  • each step of the above method may be implemented by an integrated logic circuit of hardware in the processor 1202 or instructions in the form of software.
  • the steps of the methods disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor 1202 .
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 1204, and the processor 1202 reads the information in the memory 1204, and completes the steps of the above method in combination with its hardware.
  • the processor 1202 in the embodiment of the present application may be an integrated circuit chip, which has a signal processing capability.
  • each step of the above-mentioned method embodiments may be completed by an integrated logic circuit of hardware in a processor or instructions in the form of software.
  • the above-mentioned processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components .
  • DSP digital signal processor
  • ASIC application-specific integrated circuit
  • FPGA field-programmable gate array
  • Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the memory 1204 in this embodiment of the present application may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory can be random access memory (RAM), which acts as external cache memory.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • DRAM synchronous dynamic random access memory
  • SDRAM double data rate synchronous dynamic random access memory
  • ESDRAM enhanced synchronous dynamic random access memory
  • SLDRAM direct memory bus random access memory
  • direct rambus RAM direct rambus RAM
  • the key obtaining device 1201 corresponds to the first vehicle-mounted device in the above method
  • the key obtaining device may include a processor 1202 , a transceiver 1203 and a memory 1204 .
  • the memory 1204 is used to store instructions
  • the processor 1202 is used to execute the instructions stored in the memory 1204, so as to implement the related solution of the first vehicle-mounted device in the method shown in FIG. 9 above.
  • the key obtaining device 1201 When the key obtaining device 1201 is the above-mentioned first vehicle-mounted device, the key obtaining device 1201 may be used to execute the method performed by the first vehicle-mounted device in the above-mentioned embodiment.
  • the key acquisition device 1201 is the above-mentioned first vehicle-mounted device, and when the embodiment in FIG. 9 is executed:
  • the transceiver 1203 is configured to receive the first message sent by the off-vehicle device; and send an identity verification request message to the server.
  • the first message is used to request the first on-vehicle device to obtain the first key; the identity verification response message sent by the server is received; the identity verification response message includes: the verification result of the identity verification request message.
  • the processor 1202 is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the first vehicle-mounted device The information is verified.
  • the transceiver 1203 is further configured to receive a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the processor 1202 is further configured to generate a second key according to the first message.
  • the transceiver 1203 is also configured to receive the first key sent by the server.
  • the processor 1202 is further configured to send the first key to the off-vehicle device through the transceiver 1203 when the verification result of the identity verification request message is that the verification is successful.
  • the key obtaining device 1201 corresponds to the server in the above method
  • the key obtaining device may include a processor 1202, a transceiver 1203, and a memory 1204.
  • the memory 1204 is used to store instructions
  • the processor 1202 is used to execute the instructions stored in the memory 1204, so as to realize the related solution of the server in the method shown in FIG. 9 above.
  • the key obtaining device 1201 may be used to execute the method performed by the first vehicle-mounted device in the above embodiment.
  • the transceiver 1203 is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
  • the processor 1202 is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: identity verification Validation result of the request message.
  • the transceiver 1203 is configured to send a response message of identity verification to the first vehicle-mounted device.
  • the transceiver 1203 is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
  • the transceiver 1203 is also configured to send the first key to the first vehicle-mounted device.
  • the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
  • Fig. 13 is a schematic diagram of a key obtaining device provided in the embodiment of the present application.
  • the key obtaining device 1300 can be a first vehicle-mounted device or a server, or can be a chip or a circuit, for example, it can be set in the first Chips or circuits in in-vehicle devices or servers.
  • the first vehicle-mounted device may be any ECU in the vehicle.
  • the key acquisition device may correspond to the first vehicle-mounted device in the above method.
  • the key acquisition device may implement the steps performed by the first vehicle-mounted device in any one or multiple corresponding methods shown in FIG. 9 above.
  • the device for obtaining a key may include an obtaining unit 1301 , a processing unit 1302 , a sending unit 1303 and a receiving unit 1304 .
  • the key acquisition device 1300 is the above-mentioned first vehicle-mounted device, and implements the steps performed by the above-mentioned first vehicle-mounted device in FIG. 9 ,
  • the receiving unit 1304 is configured to receive a first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain a first key; receive an identity verification response message sent by the server; the identity verification response message includes: Validation result of the validation request message.
  • the processing unit 1302 is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to obtain the authority of the first key for the first vehicle-mounted device and the authentication information of the first vehicle-mounted device. Verify the information for verification.
  • the sending unit 1303 is configured to send an identity verification request message to the server.
  • the receiving unit 1304 is further configured to receive a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the processing unit 1302 is further configured to, according to the first message, Generate a first request message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is for the first Generated after encryption with a key.
  • the receiving unit 1304 is further configured to receive the first key sent by the server.
  • the processing unit 1302 is further configured to send the first key to the off-vehicle device through the sending unit 1303 when the verification result of the identity verification request message is that the verification is successful.
  • the key acquisition device 1300 is the above-mentioned server and implements the steps performed by the first vehicle-mounted device in FIG. 9 above,
  • the receiving unit 1304 is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
  • the processing unit 1302 is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: Validation result of the validation request message.
  • the sending unit 1303 is configured to send a response message of identity verification to the first vehicle-mounted device.
  • the sending unit 1303 is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
  • the sending unit 1303 is further configured to send the first key to the first vehicle-mounted device.
  • the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
  • the sending unit 1303 can be a transceiver unit or a transmitter when sending information
  • the receiving unit 1304 can be a transceiver unit or a receiver when receiving information
  • the sending unit 1303 and the receiving unit 1304 can be transceivers
  • the transceiver, transmitter or receiver The device can be a radio frequency circuit.
  • the key acquisition device 1300 includes a storage unit
  • the storage unit is used to store computer instructions.
  • the acquisition unit or the processing unit can be respectively connected to the storage unit in communication, and the acquisition unit or the processing unit executes the computer stored in the storage unit.
  • An instruction, so that the key acquisition device can be used to execute the method executed by the first vehicle-mounted device or the server in any of the above embodiments.
  • the acquiring unit or processing unit may be a general central processing unit (CPU), a microprocessor, or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC).
  • the sending unit 1303 and the receiving unit 1304 may be input and/or output interfaces, pins or circuits, and the like.
  • the acquisition unit or the processing unit may execute the computer-executed instructions stored in the storage unit, so that the chip in the key acquisition device 1300 executes the method performed by the first vehicle-mounted device or the server in the embodiment.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit may also be a storage unit located outside the chip in the key acquisition device 1300, such as a read-only memory (Read Only Memory, ROM) Or other types of static storage devices that can store static information and instructions, random access memory (Random Access Memory, RAM), etc.
  • the present application also provides a computer program product, the computer program product including: computer program code, when the computer program code is run on the computer, the computer is made to execute the computer program described in Fig. 1 to Fig. 9 .
  • the method of any one of the embodiments is illustrated.
  • the present application also provides a computer-readable storage medium, the computer-readable medium stores program code, and when the program code is run on the computer, the computer is made to execute the steps shown in Figures 1 to 9. The method of any of the illustrated embodiments.
  • the present application further provides a key generation system, which includes at least two of the foregoing first vehicle-mounted device, the first secure hardware expansion unit, or the server.
  • the embodiment of the present application also provides a vehicle, the vehicle includes at least one unit to be diagnosed mentioned in the above-mentioned embodiments of the present application, or the vehicle includes at least one of the first vehicle-mounted equipment and the first safety hardware expansion unit mentioned in the above-mentioned embodiments of the present application .
  • the embodiment of the present application also provides a vehicle, the vehicle includes at least one unit to be diagnosed mentioned in the above-mentioned embodiments of the present application, or the vehicle includes at least one first vehicle-mounted device and the server mentioned in the above-mentioned embodiments of the present application.
  • a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer.
  • an application running on a computing device and the computing device can be components.
  • One or more components can reside within a process and/or thread of execution and a component can be localized on one computer and/or distributed between two or more computers.
  • these components can execute from various computer readable media having various data structures stored thereon.
  • a component may, for example, be based on a signal having one or more packets of data (e.g., data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet via a signal interacting with other systems). Communicate through local and/or remote processes.
  • packets of data e.g., data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet via a signal interacting with other systems.
  • the disclosed systems, devices and methods may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disc and other media that can store program codes. .
  • the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Lock And Its Accessories (AREA)

Abstract

The present application discloses a key generation method and apparatus, which are applied to a vehicle, the method comprising: a first vehicle-mounted device obtains a first message, the first message being used to instruct the first vehicle-mounted device to construct a first key; and generates a first request message according to the first message, the first request message being used by a first security hardware extension unit corresponding to the first vehicle-mounted device to generate a first response message, wherein the first response message comprises: first key information, the first key information being generated after the first key is encrypted.

Description

一种密钥生成方法及装置A method and device for generating a key 技术领域technical field
本申请涉及智能网联车技术领域,尤其涉及一种密钥生成方法及装置。The present application relates to the technical field of intelligent networked vehicles, in particular to a key generation method and device.
背景技术Background technique
当前在车载领域,车内设备间通信的基础密钥的管理,全部依赖车外在云端的车内密钥管理系统(key manager system in vehicle,KMS)对车内各设备的密钥进行管理。比如在产线上,通过工具将密钥灌装(即预置)到各部件的安全存储区中。车内各部件间需要的所有密钥都在车厂云端KMS进行管理。At present, in the field of vehicles, the management of the basic key for communication between in-vehicle devices all depends on the key manager system in vehicle (KMS) outside the vehicle in the cloud to manage the keys of each device in the vehicle. For example, on the production line, the key is filled (that is, preset) into the secure storage area of each component through tools. All the keys needed between the various components in the car are managed in the car factory's cloud KMS.
随着车辆智能化的演进,新的业务逐渐增加,会逐步要求车内不同通信业务进行信息安全隔离,此时密钥将逐步增多,也就意味着车厂要为每辆车管理越来越多的密钥。管理难度增加,另外,从安全的角度来看,如果云端管理的车内设备间业务通信密钥发生密钥泄露,则可能会立即影响车辆的行驶安全。With the evolution of vehicle intelligence, new services are gradually increasing, which will gradually require information security isolation of different communication services in the vehicle. At this time, the number of keys will gradually increase, which means that the car factory has to manage more and more key. The difficulty of management increases. In addition, from a security point of view, if the key of the business communication key between the in-vehicle devices managed by the cloud is leaked, it may immediately affect the driving safety of the vehicle.
发明内容Contents of the invention
本申请提供一种密钥生成方法及装置,用于提高车辆密钥的管理性能,提供车辆密钥的安全性。The present application provides a key generation method and device, which are used to improve the management performance of the vehicle key and provide the security of the vehicle key.
第一方面,本申请提供一种密钥生成方法,应用于车辆,包括:In the first aspect, the present application provides a method for generating a key, which is applied to a vehicle, including:
第一车载设备获得第一消息;第一消息用于指示第一车载设备构建第一密钥;根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。The first vehicle-mounted device obtains the first message; the first message is used to instruct the first vehicle-mounted device to construct the first key; according to the first message, a first request message is generated; the first request message is used for the first key corresponding to the first vehicle-mounted device The secure hardware expansion unit generates a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key.
通过上述方法,实现车辆的第一车载设备在车辆内部基于第一车载设备的第一安全硬件扩展单元为车辆中的车载设备的通信(例如,车辆中的车载设备之间的通信)构建第一密钥,并通过第一安全硬件扩展单元加密后生成的第一密钥信息返回给第一车载设备,使得第一车载设备可以安全的在车辆内部生成第一密钥,无需通过云端生成第一密钥并全程参与第一密钥的管理,降低了云端管理车辆密钥的难度和复杂度,同时降低了通过云端泄露车辆密钥的可能,提高了车辆内部第一密钥的安全性。Through the above method, it is realized that the first on-board device of the vehicle builds a first Key, and the first key information generated after encryption by the first security hardware expansion unit is returned to the first vehicle-mounted device, so that the first vehicle-mounted device can safely generate the first key inside the vehicle without generating the first key through the cloud. The key also participates in the management of the first key throughout the whole process, which reduces the difficulty and complexity of cloud management of vehicle keys, and at the same time reduces the possibility of leaking vehicle keys through the cloud, improving the security of the first key inside the vehicle.
一种可能的实现方式,接收来自第一安全硬件扩展单元发送的第一响应消息。In a possible implementation manner, a first response message sent from the first security hardware expansion unit is received.
通过上述方法,可以使得第一车载设备通过第一响应消息获得第一密钥信息,即通过第一响应消息获得加密后的第一密钥,保证第一密钥的安全,在车辆的车载设备对第一密钥进行灌装时,可以通过第一车载设备发送第一密钥信息的方式进行验证后,灌装第一密钥,实现了第一密钥在车辆的车载设备之间,例如,在车辆的第一车载设备和第二车载设备之间,进行传输的安全性及灌装的安全性。从而,保证了第一密钥从生成到灌装的安全性。Through the above method, the first vehicle-mounted device can obtain the first key information through the first response message, that is, obtain the encrypted first key through the first response message, so as to ensure the security of the first key. When filling the first key, it can be verified by sending the first key information through the first vehicle-mounted equipment, and then fill the first key, so that the first key can be shared between the vehicle-mounted equipment, for example , between the first vehicle-mounted device and the second vehicle-mounted device, the security of transmission and the security of filling are performed. Thus, the security of the first key from generation to filling is ensured.
一种可能的实现方式,接收来自第一安全硬件扩展单元发送的第一密钥的第一参数;第一车载设备根据第一密钥的第一参数,生成第一密钥加载消息;第一车载设备向第二车载设备发送第一密钥加载消息;第一密钥加载消息用于第二车载设备对第一密钥加载消息 进行验证成功后,灌装第一密钥。A possible implementation manner is to receive the first parameter of the first key sent by the first security hardware expansion unit; the first vehicle-mounted device generates a first key loading message according to the first parameter of the first key; the first The vehicle-mounted device sends a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
通过上述方法,由第一安全硬件扩展单元生成第一密钥的第一参数,该第一参数可以是用于第二车载设备对第一密钥进行安全性验证的参数,例如,第一密钥的第一参数可以为完整性验证的参数,还可以为基于车辆的安全验证密钥加密后的第一参数,从而,第二车载设备在接收都第一密钥加载消息后,可以对第一密钥信息的完整性验证的参数进行完整性验证,在完整性验证成功后,第二车载设备可以对第一密钥信息中基于安全验证密钥加密后的参数进行解密,获得第一密钥。从而,保证了第一密钥灌装的安全性。Through the above method, the first security hardware expansion unit generates the first parameter of the first key, and the first parameter may be a parameter for the second on-vehicle device to perform security verification on the first key, for example, the first key The first parameter of the key can be a parameter for integrity verification, and can also be a first parameter encrypted based on the vehicle's security verification key. Therefore, after receiving the first key loading message, the second vehicle-mounted device can upload the first key. Integrity verification is performed on the parameters of the integrity verification of the first key information. After the integrity verification is successful, the second vehicle-mounted device can decrypt the parameters encrypted based on the security verification key in the first key information to obtain the first key information. key. Thus, the security of the first key filling is ensured.
一种可能的实现方式,第一车载设备获得第一消息之后,第一车载设备向第一安全硬件扩展单元发送状态更新消息;状态更新消息包括:车内密钥的构建状态;状态更新消息用于第一安全硬件扩展单元对状态更新消息验证成功后,更新自身的车内密钥的构建状态。In a possible implementation, after the first vehicle-mounted device obtains the first message, the first vehicle-mounted device sends a status update message to the first security hardware expansion unit; the status update message includes: the construction status of the key in the vehicle; the status update message uses After the first security hardware extension unit successfully verifies the status update message, it updates the construction status of its own in-vehicle key.
通过上述方法,第一车载设备可以基于第一消息,确定车内密钥处于构建状态,因此,可以向第一安全硬件扩展单元发送状态更新消息,使得第一安全硬件扩展单元更新自身的车内密钥的构建状态。例如,车内密钥的构建状态包括:构建完成,未构建,构建中,构建失败等。状态更新消息可以用于将车内密钥的构建状态更新为构建中。此时,在接收到状态更新消息后,第一安全硬件扩展单元可以将车内密钥的构建状态更新为构建中。从而,在第一安全硬件扩展单元接收到第一请求消息时,可以基于第一安全硬件扩展单元自身的车内密钥的构建状态,对第一请求消息进行验证。Through the above method, the first vehicle-mounted device can determine that the in-vehicle key is in the construction state based on the first message, so it can send a status update message to the first security hardware expansion unit, so that the first security hardware expansion unit updates its own in-vehicle key. The build status of the key. For example, the build status of the in-vehicle key includes: build complete, not build, build, build failure, etc. A status update message may be used to update the build status of the in-vehicle key to being built. At this time, after receiving the status update message, the first security hardware expansion unit may update the construction status of the in-vehicle key to being under construction. Therefore, when the first security hardware expansion unit receives the first request message, it can verify the first request message based on the construction state of the in-vehicle key of the first security hardware expansion unit itself.
一种可能的实现方式,车内密钥的构建状态用于第一安全硬件扩展单元对第一请求消息进行验证。例如,在第一安全硬件扩展单元自身的车内密钥的构建状态为构建中时,接收到第一请求消息的,则第一请求消息可以根据其他方式验证第一请求消息中的完整性和安全性后,生成第一密钥。而在第一安全硬件扩展单元自身的车内密钥的构建状态不是构建中时,接收到第一请求消息的,则第一安全硬件扩展单元可以拒绝执行第一请求消息,以保证车辆构建第一密钥的安全性。In a possible implementation manner, the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message. For example, when the construction state of the in-vehicle key of the first security hardware expansion unit itself is under construction, if the first request message is received, the first request message may verify the integrity and integrity of the first request message in other ways. After security, generate the first key. And when the construction state of the key in the vehicle of the first safety hardware expansion unit itself is not in construction, if the first request message is received, the first safety hardware expansion unit can refuse to execute the first request message to ensure that the vehicle builds the first request message. One-key security.
一种可能的实现方式,确定第一车载设备重启后,向第一安全硬件扩展单元发送第一查询请求;第一查询请求用于查询第一密钥的第二参数;接收第一安全硬件扩展单元发送的第一查询响应消息;第一查询响应消息为第一安全硬件扩展单元对第一查询请求进行验证后返回的;第一查询响应消息包括:第一密钥的第二参数;根据第一密钥的第二参数和第一消息,生成第一请求消息;第一密钥为第一车载设备重启前第一安全硬件扩展单元待生成的密钥。A possible implementation is to send a first query request to the first security hardware extension unit after it is determined that the first vehicle-mounted device is restarted; the first query request is used to query the second parameter of the first key; and receive the first security hardware extension unit The first query response message sent by the unit; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first query response message includes: the second parameter of the first key; The second parameter of a key and the first message generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before the restart of the first vehicle-mounted device.
通过上述方法,在第一车载设备重启后,第一车载设备可以向第一安全硬件扩展单元查询当前第一安全硬件扩展单元生成的第一密钥的状态,例如,第一密钥是否已生成成功,第一密钥的更新次数等。其中,为保证第一查询消息的安全性,第一车载设备可以对第一查询消息进行加密和完整性保护,从而,在第一安全硬件扩展单元接收到该第一查询消息后,可以对第一查询消息进行验证,例如,包括对第一查询消息进行解密和完整性验证,在验证成功后,将第一查询请求查询的第一密钥的第二参数通过第一查询响应消息返回给第一车载设备。第一车载设备可以对第一查询响应消息进行验证,在验证成功后,获得第一密钥的第二参数。通过上述方法,可以实现第一车载设备重启后,获得第一密钥的第二参数,以便后续继续执行第一密钥的构建过程,降低第一车载设备重启对第一密钥生成、加载过程的影响。其中,第一安全硬件扩展单元在对第一查询消息进行验证的过程中,还可以通过查询第一安全硬件扩展单元自身的车内密钥的构建状态,对第一查询消息进行验 证,保证第一查询消息的合法来源是在车内密钥的构建过程中的,以保证第一查询消息的安全性。Through the above method, after the first vehicle-mounted device is restarted, the first vehicle-mounted device can query the first security hardware expansion unit for the current state of the first key generated by the first security hardware expansion unit, for example, whether the first key has been generated Success, the number of updates of the first key, etc. Wherein, in order to ensure the security of the first query message, the first vehicle-mounted device can encrypt and integrity protect the first query message, so that after the first security hardware extension unit receives the first query message, it can A query message is verified, for example, including decrypting and integrity verification of the first query message, and after the verification is successful, the second parameter of the first key queried by the first query request is returned to the second query message through the first query response message. A vehicle-mounted device. The first in-vehicle device may verify the first query response message, and obtain the second parameter of the first key after the verification is successful. Through the above method, it is possible to obtain the second parameter of the first key after the restart of the first vehicle-mounted device, so as to continue to execute the construction process of the first key and reduce the impact of the restart of the first vehicle-mounted device on the first key generation and loading process Impact. Wherein, in the process of verifying the first query message, the first security hardware expansion unit can also verify the first query message by querying the construction state of the vehicle key of the first security hardware expansion unit itself, so as to ensure that the first security hardware expansion unit The legal source of a query message is in the process of building the key in the vehicle, so as to ensure the security of the first query message.
一种可能的实现方式,接收来自第一安全硬件扩展单元发送的临时密钥;临时密钥用于加密第一请求消息。A possible implementation manner is to receive a temporary key sent from the first secure hardware expansion unit; the temporary key is used to encrypt the first request message.
通过上述方法,第一安全硬件扩展单元可以为第一车载设备和第一安全硬件扩展单元之间进行消息的安全传输配置临时密钥,避免其他车载设备或其他车载设备的安全硬件扩展单元可能发起第一请求消息,考虑到临时密钥是限定在第一车载设备和第一安全硬件扩展单元之间进行消息的安全传输的,可以简化临时密钥的设置方式,降低第一车载设备和第一安全硬件扩展单元之间进行消息的传输,提高安全性的同时,降低第一车载设备和第一安全硬件扩展单元的开销和复杂度。Through the above method, the first secure hardware expansion unit can configure a temporary key for the safe transmission of messages between the first vehicle-mounted device and the first secure hardware The first request message, considering that the temporary key is limited to the safe transmission of messages between the first vehicle-mounted device and the first security hardware expansion unit, can simplify the setting method of the temporary key, reduce the cost of the first vehicle-mounted device and the first Messages are transmitted between the safety hardware expansion units, which reduces the overhead and complexity of the first vehicle-mounted device and the first safety hardware expansion unit while improving safety.
一种可能的实现方式,接收第二车载设备发送的第二消息;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。A possible implementation manner is to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key or indicating The second in-vehicle device restarts.
通过上述方法,在第二车载设备重启后,第二车载设备可以向第一车载设备发送第二消息,使得第二车载设备可以查询第一密钥的第二参数,还可以请求第一车载设备生成第一密钥,还可以通知第一车载设备第二车载设备重启,使得第一车载设备可以针对第二车载设备的重启,执行相应的操作,以降低第二车载设备重启对第一密钥的灌装带来的影响,例如,在第一车载设备确定第二车载设备重启之前,第一车载设备已发送了第一密钥的加载消息,此时,第一车载设备可以根据第二消息,确定第二车载设备未成功灌装第一密钥,因此,第一车载设备可以再次发送第一密钥的加载消息,实现对第二车载设备灌装第一密钥。降低由于第二车载设备的重启,导致第二车载设备可能的灌装第一密钥失败的可能,提高第二车载设备灌装第一密钥的成功率。Through the above method, after the second vehicle-mounted device is restarted, the second vehicle-mounted device can send a second message to the first vehicle-mounted device, so that the second vehicle-mounted device can query the second parameter of the first key, and can also request the first vehicle-mounted device Generating the first key can also notify the first vehicle-mounted device to restart the second vehicle-mounted device, so that the first vehicle-mounted device can perform corresponding operations for the restart of the second vehicle-mounted device, so as to reduce the impact of the restart of the second vehicle-mounted device on the first key. For example, before the first vehicle-mounted device determines that the second vehicle-mounted device restarts, the first vehicle-mounted device has sent a loading message of the first key. At this time, the first vehicle-mounted device can , it is determined that the second vehicle-mounted device has not been successfully filled with the first key, therefore, the first vehicle-mounted device may send the loading message of the first key again, so as to fill the second vehicle-mounted device with the first key. The possibility of failure to fill the first key in the second vehicle-mounted device due to the restart of the second vehicle-mounted device is reduced, and the success rate of filling the first key in the second vehicle-mounted device is improved.
一种可能的实现方式,对第二消息进行验证后,向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。In a possible implementation manner, after the second message is verified, a third message is sent to the second vehicle-mounted device; the third message includes at least one of the following: a second parameter of the first key, and information about the first key.
通过上述方法,第一车载设备可以对第二消息进行安全性验证后,例如,基于第二消息的安全验证密钥对第二消息进行完整性验证后,向第二车载设备发送第三消息,使得第二车载设备可以获得第一密钥的第二参数或第一密钥信息中的至少一项,使得第二车载设备在重启后,恢复到重启前的车内密钥的构建状态及第一密钥的灌装的状态。Through the above method, the first vehicle-mounted device can send the third message to the second vehicle-mounted device after performing security verification on the second message, for example, after performing integrity verification on the second message based on the security verification key of the second message, The second vehicle-mounted device can obtain at least one of the second parameter of the first key or the first key information, so that after the second vehicle-mounted device is restarted, it returns to the construction state of the in-vehicle key and the first key before the restart. A key's filling status.
一种可能的实现方式,根据以下任一项获得第一消息:A possible implementation, the first message is obtained according to any of the following:
接收车内设备或车外设备发送的第一消息;Receive the first message sent by the in-vehicle device or the out-of-vehicle device;
接收配置文件的初始化或更新信息后,获得第一消息;After receiving the initialization or update information of the configuration file, obtain the first message;
接收车辆的固定密钥的初始化或更新信息后,获得第一消息;Obtain the first message after receiving the initialization or update information of the fixed key of the vehicle;
接收车辆的车载设备之间的共享密钥的初始化或更新信息后,获得第一消息。After receiving the initialization or update information of the shared key between the on-board devices of the vehicle, the first message is obtained.
通过上述方法,可以灵活的触发第一密钥的生成,实现车辆的第一车载设备在多种场景下生成第一密钥的方式,提高车内密钥生成的适用性。Through the above method, the generation of the first key can be flexibly triggered, so that the first on-board device of the vehicle can generate the first key in various scenarios, and the applicability of key generation in the vehicle can be improved.
第二方面,本申请提供一种密钥生成方法,应用于车辆,包括:第一安全硬件扩展单元接收第一安全硬件扩展单元对应的第一车载设备发送的第一请求消息;第一请求消息为第一车载设备请求第一安全硬件扩展单元构建第一密钥生成的;对第一请求消息进行验证成功后,生成第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a second aspect, the present application provides a method for generating a key, which is applied to a vehicle, including: the first security hardware expansion unit receives the first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message For the first vehicle-mounted device to request the first security hardware expansion unit to construct the first key generation; after the first request message is successfully verified, the first key information is generated; the first key information is encrypted by the first key Generated.
通过上述方法,基于第一车载设备的第一安全硬件扩展单元为车辆中的车载设备的通 信构建第一密钥,并通过第一安全硬件扩展单元加密后生成的第一密钥信息返回给第一车载设备,使得第一车载设备可以安全的在车辆内部生成第一密钥,无需通过云端生成第一密钥并全程参与第一密钥的管理,降低了云端管理车辆密钥的难度和复杂度,同时避免了通过云端泄露车辆密钥的可能,提高了车辆内部第一密钥的安全性。Through the above method, based on the first safety hardware expansion unit of the first vehicle-mounted device, the first key is constructed for the communication of the vehicle-mounted device in the vehicle, and the first key information generated after being encrypted by the first safety hardware expansion unit is returned to the first key information A vehicle-mounted device, so that the first vehicle-mounted device can safely generate the first key inside the vehicle, without the need to generate the first key through the cloud and participate in the management of the first key throughout the process, reducing the difficulty and complexity of cloud-based vehicle key management At the same time, it avoids the possibility of leaking the vehicle key through the cloud, and improves the security of the first key inside the vehicle.
一种可能的实现方式,向第一车载设备发送第一响应消息;第一响应消息包括:第一密钥信息。In a possible implementation manner, a first response message is sent to the first vehicle-mounted device; the first response message includes: first key information.
一种可能的实现方式,对第一请求消息进行验证成功后,生成第一密钥的第一参数;向第一车载设备发送第一密钥的第一参数;第一密钥的第一参数用于第二车载设备灌装第一密钥。In a possible implementation, after the first request message is verified successfully, the first parameter of the first key is generated; the first parameter of the first key is sent to the first vehicle-mounted device; the first parameter of the first key It is used to fill the first key in the second vehicle-mounted device.
一种可能的实现方式,接收第一车载设备发送的状态更新消息;状态更新消息包括:车内密钥的构建状态;对状态更新消息验证成功后,更新自身的车内密钥的构建状态。A possible implementation is to receive a status update message sent by the first vehicle-mounted device; the status update message includes: the build status of the in-vehicle key; after the status update message is successfully verified, update the build status of its own in-vehicle key.
一种可能的实现方式,在第一车载设备重启后,接收第一车载设备发送的第一查询请求;第一查询请求用于查询第一密钥的第二参数;对第一查询请求进行验证后,向第一车载设备发送第一查询响应消息;第一查询响应消息包括:第一密钥的第二参数;第一密钥的第二参数用于第一车载设备生成第一请求消息;第一密钥为重启前第一安全硬件扩展单元待生成的密钥。In a possible implementation, after the first vehicle-mounted device is restarted, the first query request sent by the first vehicle-mounted device is received; the first query request is used to query the second parameter of the first key; and the first query request is verified After that, send the first query response message to the first vehicle-mounted device; the first query response message includes: the second parameter of the first key; the second parameter of the first key is used for the first vehicle-mounted device to generate the first request message; The first key is a key to be generated by the first security hardware expansion unit before restarting.
一种可能的实现方式,对第一请求消息进行验证成功后,生成临时密钥;向第一车载设备发送临时密钥;临时密钥用于加密第一请求消息。In a possible implementation manner, after the verification of the first request message is successful, a temporary key is generated; the temporary key is sent to the first vehicle-mounted device; and the temporary key is used to encrypt the first request message.
一种可能的实现方式,接收来自第一车载设备的第二消息的验证消息;第二消息为第一车载设备接收第二车载设备发送的;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。A possible implementation manner is to receive a verification message of a second message from the first vehicle-mounted device; the second message is sent by the first vehicle-mounted device to receive the second message; the second message is used for at least one of the following: querying the first The second parameter of the key requests the first vehicle-mounted device to generate the first key or instructs the second vehicle-mounted device to restart.
一种可能的实现方式,对第二消息进行验证后,向第一车载设备发送第二消息的验证响应消息;第二消息的响应消息用于第一车载设备向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。A possible implementation manner, after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device; the response message of the second message is used for the first vehicle-mounted device to send the third message to the second vehicle-mounted device ; The third message includes at least one of the following items: the second parameter of the first key, and the first key information.
上述可能的实现方式,可以参见第一方面中的有益效果的描述,在此不再赘述。For the possible implementation manners above, reference may be made to the description of beneficial effects in the first aspect, which will not be repeated here.
第三方面,本申请提供一种密钥获取方法,应用于车辆,包括:第一车载设备接收车外设备发送的第一消息;第一消息用于请求第一车载设备获得第一密钥;根据第一消息和第一车载设备的验证信息,生成身份验证请求消息,身份验证请求消息用于服务器对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证;向服务器发送身份验证请求消息;接收服务器发送的身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。In a third aspect, the present application provides a method for acquiring a key, which is applied to a vehicle, including: the first vehicle-mounted device receives a first message sent by an off-vehicle device; the first message is used to request the first vehicle-mounted device to obtain a first key; According to the verification information of the first message and the first vehicle-mounted device, an identity verification request message is generated, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device; The server sends the identity verification request message; receives the identity verification response message sent by the server; the identity verification response message includes: the verification result of the identity verification request message.
通过上述方法,可以使得车外设备触发第一车载设备安全的获得第一密钥,其中,车外设备发送第一消息后,第一车载设备可以基于第一消息及第一车载设备的验证信息,例如,第一车载设备获得第一密钥的权限,第一车载设备对应使用的用户获得第一密钥的权限等,生成向服务器发送的身份验证请求消息,从而,通过服务器对身份验证请求消息进行验证,在验证成功后,第一车载设备才可以获得第一密钥,提高了第一车载设备获得第一密钥的安全性。其中,第一消息可以是车外设备发送的个人识别码(personal identification number,PIN)码,第一车载设备可以根据策划为设备发送的PIN码进行加密后,携带在身份验证请求消息中,使得服务器对加密的PIN进行验证,提高验证的安全性。另外,第一车载设备还可以通过车外设备获得车外设备的证书,或者是第一车载设备自身生成的证 书,该证书可以是用于对第一车载设备的身份进行验证的,在验证成功后,服务器可以基于证书的验证结果,确定第一车载设备是否有权限获得第一密钥。Through the above method, the off-vehicle device can trigger the first on-vehicle device to securely obtain the first key, wherein, after the off-vehicle device sends the first message, the first on-vehicle device can based on the first message and the verification information of the first on-vehicle device For example, the first in-vehicle device obtains the authority of the first key, and the corresponding user of the first in-vehicle device obtains the authority of the first key, etc., and generates an identity verification request message sent to the server, thereby, through the server, the identity verification request The message is verified, and the first vehicle-mounted device can obtain the first key only after the verification is successful, which improves the security of the first vehicle-mounted device obtaining the first key. Wherein, the first message may be a personal identification number (personal identification number, PIN) code sent by the off-vehicle device, and the first on-vehicle device may encrypt the PIN code sent for the device according to the plan, and carry it in the identity verification request message, so that The server verifies the encrypted PIN to improve the security of verification. In addition, the first in-vehicle device can also obtain the certificate of the out-of-vehicle device through the out-of-vehicle device, or the certificate generated by the first in-vehicle device itself. The certificate can be used to verify the identity of the first in-vehicle device. Afterwards, the server may determine whether the first vehicle-mounted device has the right to obtain the first key based on the verification result of the certificate.
一种可能的实现方式,第一车载设备接收服务器发送的第一消息;第一消息用于指示第一车载设备生成第一密钥;第一车载设备根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a possible implementation manner, the first vehicle-mounted device receives a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the first vehicle-mounted device generates a first request message according to the first message; The first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key of.
通过上述方法,在第一密钥可以是第一车载设备自身生成时,服务器可以向第一车载设备发送第一消息,此时,第一车载设备可以基于第一消息,生成第一请求消息,用于指示第一安全硬件扩展单元生成第一密钥。在该方式中,通过第一车载设备和第一安全硬件扩展单元,实现了安全的在车内生成第一密钥,并使得第一车载设备生成第一密钥的过程是经过通过服务器验证后执行的,提高了生成第一密钥的安全性。需要说明的是,在该方式中,具体第一车载设备生成的第一密钥的方式,可以参考第一方面中的密钥生成方法中的实施方式,在此不再赘述。第一密钥可以加载在第一车载设备,也可以加载在第二车载设备中,具体参见本申请实施例部分的详细描述。Through the above method, when the first key can be generated by the first vehicle-mounted device itself, the server can send the first message to the first vehicle-mounted device, at this time, the first vehicle-mounted device can generate a first request message based on the first message, It is used to instruct the first security hardware expansion unit to generate the first key. In this way, through the first vehicle-mounted device and the first security hardware expansion unit, the safe generation of the first key in the vehicle is realized, and the process of generating the first key by the first vehicle-mounted device is verified by the server Execution improves the security of generating the first key. It should be noted that, in this manner, for the specific manner of the first key generated by the first vehicle-mounted device, reference may be made to the implementation manner of the key generation method in the first aspect, which will not be repeated here. The first key may be loaded in the first vehicle-mounted device, or may be loaded in the second vehicle-mounted device. For details, refer to the detailed description in the embodiments of this application.
一种可能的实现方式,第一车载设备接收服务器发送的第一密钥。In a possible implementation manner, the first vehicle-mounted device receives the first key sent by the server.
通过上述方法,可以使得第一车载设备安全的获得服务器中存储的第一密钥。提高获得服务器维护的第一密钥的安全性。Through the above method, the first vehicle-mounted device can securely obtain the first key stored in the server. Improves the security of obtaining the first key maintained by the server.
一种可能的实现方式,第一车载设备在身份验证请求消息的验证结果为验证成功时,向车外设备发送第一密钥。In a possible implementation manner, the first on-vehicle device sends the first key to the off-vehicle device when the verification result of the identity verification request message is that the verification is successful.
通过上述方法,在第一车载设备自身存储第一密钥后,还可以基于身份验证请求消息的验证结果,向车外设备发送第一密钥。例如,在车外设备为车辆诊断设备时,为保证车辆的数据的安全性,在车辆诊断设备对车辆的数据进行采集和诊断时,可以通过第一密钥进行加密,因此,可以基于第二方面中的服务器验证的方式,验证第一车载设备合法获得第一密钥的同时,也可以验证车外设备通过第一车载设备获得第一密钥的合法性,从而,提高了车外设备获得第一密钥的安全性。可选的,第一密钥可以是第一车载设备基于第一请求消息为车外设备生成的,也可以是第一车载设备已存储的,用于与车外设备之间进行通信的密钥,本申请不做限定。可选的,在车外设备使用完该第一密钥,例如,车辆诊断设备完成车辆诊断过程后,可以通知第一车载设备删除第一密钥,车辆针对设备也可以删除第一密钥。在下一次诊断时,可以再重新生成第一密钥,用于当前的诊断过程。提高车辆数据的安全性。Through the above method, after the first on-vehicle device stores the first key, it can also send the first key to the off-vehicle device based on the verification result of the identity verification request message. For example, when the off-vehicle device is a vehicle diagnostic device, in order to ensure the security of vehicle data, when the vehicle diagnostic device collects and diagnoses vehicle data, it can be encrypted with the first key, and therefore, can be encrypted based on the second key. The server verification method in the aspect verifies that the first vehicle-mounted device obtains the first key legally, and at the same time, it can also verify the legitimacy of the off-vehicle device obtaining the first key through the first vehicle-mounted device. Security of the first key. Optionally, the first key may be generated by the first on-vehicle device for the off-vehicle device based on the first request message, or may be a key stored by the first on-vehicle device for communication with the off-vehicle device , which is not limited in this application. Optionally, after the off-vehicle device finishes using the first key, for example, the vehicle diagnostic device may notify the first on-board device to delete the first key, and the vehicle may also delete the first key for the device. During the next diagnosis, the first key can be regenerated to be used in the current diagnosis process. Improve vehicle data security.
第四方面,本申请提供一种密钥获取方法,应用于服务器,包括:In a fourth aspect, the present application provides a method for obtaining a key, which is applied to a server, including:
服务器接收第一车载设备发送的身份验证请求消息;身份验证请求消息为第一车载设备根据车外设备发送的第一消息和第一车载设备的验证信息生成的;服务器根据身份验证请求消息,对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证,生成身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。服务器向第一车载设备发送身份验证的响应消息。The server receives the identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device; according to the identity verification request message, the server The first in-vehicle device obtains the authority of the first key and the verification information of the first in-vehicle device for verification, and generates an identity verification response message; the identity verification response message includes: a verification result of the identity verification request message. The server sends an identity verification response message to the first in-vehicle device.
通过上述方法,通过服务器对身份验证请求消息进行验证,在验证成功后,第一车载设备才可以获得第一密钥,并且,通过车外设备触发第一车载设备安全的获得第一密钥,使得服务器在对第一车载设备进行验证时,可以通过车外设备的第一消息进行验证,及对第一车载设备的验证信息,例如,第一车载设备获得第一密钥的权限,第一车载设备对应 使用的用户获得第一密钥的权限等进行验证,从而,提高了第一车载设备获得第一密钥的安全性。Through the above method, the identity verification request message is verified by the server. After the verification is successful, the first vehicle-mounted device can obtain the first key, and the first vehicle-mounted device is triggered by the external device to securely obtain the first key. When verifying the first vehicle-mounted device, the server can verify the first message from the off-vehicle device and the verification information of the first vehicle-mounted device. For example, the first vehicle-mounted device obtains the authority of the first key, and the first The in-vehicle device verifies the user's authority to obtain the first key, etc., thereby improving the security of the first in-vehicle device in obtaining the first key.
一种可能的实现方式,服务器向第一车载设备发送第一消息;第一消息用于指示第一车载设备生成第一密钥。In a possible implementation manner, the server sends a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate the first key.
一种可能的实现方式,服务器向第一车载设备发送第一密钥。In a possible implementation manner, the server sends the first key to the first vehicle-mounted device.
一种可能的实现方式,身份验证请求消息用于指示第一车载设备向车外设备发送第一密钥。In a possible implementation manner, the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
上述可能的实现方式,可以参见第三方面中的有益效果的描述,在此不再赘述。For the possible implementation manners above, reference may be made to the description of beneficial effects in the third aspect, which will not be repeated here.
第五方面,本申请提供一种密钥生成装置,该装置为车辆中的车载设备或KMS,该装置包括:In a fifth aspect, the present application provides a key generation device, the device is an on-board device or KMS in a vehicle, and the device includes:
获得单元,用于获得第一消息;第一消息用于指示第一车载设备构建第一密钥;An obtaining unit, configured to obtain a first message; the first message is used to instruct the first vehicle-mounted device to construct a first key;
处理单元,用于根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。The processing unit is configured to generate a first request message according to the first message; the first request message is used for the first security hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: a first key information; the first key information is generated after encrypting the first key.
一种可能的实现方式,接收单元,用于接收来自第一安全硬件扩展单元发送的第一响应消息。In a possible implementation manner, the receiving unit is configured to receive the first response message sent from the first security hardware expansion unit.
一种可能的实现方式,接收单元,用于接收来自第一安全硬件扩展单元发送的第一密钥的第一参数;A possible implementation manner, the receiving unit is configured to receive the first parameter of the first key sent from the first secure hardware expansion unit;
处理单元,用于根据第一密钥的第一参数,生成第一密钥加载消息;a processing unit, configured to generate a first key loading message according to a first parameter of the first key;
发送单元,用于向第二车载设备发送第一密钥加载消息;第一密钥加载消息用于第二车载设备对第一密钥加载消息进行验证成功后,灌装第一密钥。The sending unit is configured to send a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
一种可能的实现方式,获得单元获得第一消息之后,发送单元,还用于向第一安全硬件扩展单元发送状态更新消息;状态更新消息包括:车内密钥的构建状态;状态更新消息用于第一安全硬件扩展单元对状态更新消息验证成功后,更新自身的车内密钥的构建状态。In a possible implementation manner, after the obtaining unit obtains the first message, the sending unit is further configured to send a status update message to the first security hardware extension unit; the status update message includes: the construction status of the key in the vehicle; the status update message uses After the first security hardware extension unit successfully verifies the status update message, it updates the construction status of its own in-vehicle key.
一种可能的实现方式,车内密钥的构建状态用于第一安全硬件扩展单元对第一请求消息进行验证。In a possible implementation manner, the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message.
一种可能的实现方式,处理单元确定第一车载设备重启后,通过发送单元向第一安全硬件扩展单元发送第一查询请求;第一查询请求用于查询第一密钥的第二参数;通过接收单元接收第一安全硬件扩展单元发送的第一查询响应消息;第一查询响应消息为第一安全硬件扩展单元对第一查询请求进行验证后返回的;第一查询响应消息包括:第一密钥的第二参数;根据第一密钥的第二参数和第一消息,生成第一请求消息;第一密钥为第一车载设备重启前第一安全硬件扩展单元待生成的密钥。In a possible implementation manner, after the processing unit determines that the first vehicle-mounted device is restarted, the sending unit sends a first query request to the first security hardware expansion unit; the first query request is used to query the second parameter of the first key; The receiving unit receives the first query response message sent by the first security hardware expansion unit; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first query response message includes: the first password The second parameter of the key; according to the second parameter of the first key and the first message, generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before the restart of the first vehicle-mounted device.
一种可能的实现方式,接收单元,用于接收来自第一安全硬件扩展单元发送的临时密钥;临时密钥用于加密第一请求消息。In a possible implementation manner, the receiving unit is configured to receive the temporary key sent from the first secure hardware extension unit; the temporary key is used to encrypt the first request message.
一种可能的实现方式,接收单元,用于接收第二车载设备发送的第二消息;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。In a possible implementation manner, the receiving unit is configured to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate a second A key or instructs the second in-vehicle device to restart.
一种可能的实现方式,处理单元对第二消息进行验证后,通过发送单元向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。In a possible implementation, after the processing unit verifies the second message, the sending unit sends the third message to the second vehicle-mounted device; the third message includes at least one of the following items: the second parameter of the first key, the first key information.
一种可能的实现方式,根据以下任一项获得第一消息:A possible implementation, the first message is obtained according to any of the following:
通过接收单元接收车内设备或车外设备发送的第一消息;receiving the first message sent by the in-vehicle device or the out-of-vehicle device through the receiving unit;
通过接收单元接收配置文件的初始化或更新信息后,获得第一消息;Obtain the first message after receiving the initialization or update information of the configuration file through the receiving unit;
通过接收单元接收车辆的固定密钥的初始化或更新信息后,获得第一消息;After receiving the initialization or update information of the fixed key of the vehicle through the receiving unit, the first message is obtained;
通过接收单元接收车辆的车载设备之间的共享密钥的初始化或更新信息后,获得第一消息。The first message is obtained after the receiving unit receives the initialization or update information of the shared key between the on-vehicle devices of the vehicle.
第六方面,本申请提供一种密钥生成装置,该装置为车辆中的安全硬件扩展单元,该装置包括:In a sixth aspect, the present application provides a key generation device, which is a security hardware expansion unit in a vehicle, and the device includes:
接收单元,用于接收第一安全硬件扩展单元对应的第一车载设备发送的第一请求消息;第一请求消息为第一车载设备请求第一安全硬件扩展单元构建第一密钥生成的;The receiving unit is configured to receive a first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key;
处理单元,用于对第一请求消息进行验证成功后,生成第一密钥信息;第一密钥信息为对第一密钥加密后生成的。The processing unit is configured to generate first key information after successfully verifying the first request message; the first key information is generated after encrypting the first key.
一种可能的实现方式,密钥生成装置包括发送单元,发送单元,用于向第一车载设备发送第一响应消息;第一响应消息包括:第一密钥信息。In a possible implementation manner, the key generation device includes a sending unit, configured to send a first response message to the first vehicle-mounted device; the first response message includes: first key information.
一种可能的实现方式,处理单元对第一请求消息进行验证成功后,生成第一密钥的第一参数;通过发送单元向第一车载设备发送第一密钥的第一参数;第一密钥的第一参数用于第二车载设备灌装第一密钥。A possible implementation manner, after the processing unit successfully verifies the first request message, generates the first parameter of the first key; sends the first parameter of the first key to the first vehicle-mounted device through the sending unit; the first key The first parameter of the key is used to fill the first key in the second vehicle-mounted device.
一种可能的实现方式,接收单元,还用于接收第一车载设备发送的状态更新消息;状态更新消息包括:车内密钥的构建状态;处理单元,还用于对状态更新消息验证成功后,更新自身的车内密钥的构建状态。In a possible implementation, the receiving unit is also used to receive the status update message sent by the first vehicle-mounted device; the status update message includes: the construction status of the in-vehicle key; the processing unit is also used to verify the status update message successfully. , to update the build status of its own in-vehicle key.
一种可能的实现方式,接收单元,还用于在第一车载设备重启后,接收第一车载设备发送的第一查询请求;第一查询请求用于查询第一密钥的第二参数;In a possible implementation manner, the receiving unit is further configured to receive a first query request sent by the first vehicle-mounted device after the first vehicle-mounted device restarts; the first query request is used to query the second parameter of the first key;
处理单元,用于对第一查询请求进行验证后,通过发送单元向第一车载设备发送第一查询响应消息;第一查询响应消息包括:第一密钥的第二参数;第一密钥的第二参数用于第一车载设备生成第一请求消息;第一密钥为重启前第一安全硬件扩展单元待生成的密钥。The processing unit is configured to send a first query response message to the first vehicle-mounted device through the sending unit after verifying the first query request; the first query response message includes: the second parameter of the first key; The second parameter is used for the first vehicle device to generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
一种可能的实现方式,处理单元,用于对第一请求消息进行验证成功后,生成临时密钥;通过发送单元向第一车载设备发送临时密钥;临时密钥用于加密第一请求消息。A possible implementation manner, the processing unit is configured to generate a temporary key after the first request message is verified successfully; send the temporary key to the first vehicle-mounted device through the sending unit; the temporary key is used to encrypt the first request message .
一种可能的实现方式,接收单元,用于接收来自第一车载设备的第二消息的验证消息;第二消息为第一车载设备接收第二车载设备发送的;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。In a possible implementation, the receiving unit is configured to receive a verification message of a second message from the first vehicle-mounted device; the second message is received by the first vehicle-mounted device and sent by the second vehicle-mounted device; the second message is used for at least one of the following: Item: query the second parameter of the first key, request the first vehicle-mounted device to generate the first key, or instruct the second vehicle-mounted device to restart.
一种可能的实现方式,处理单元,用于对第二消息进行验证后,通过发送单元向第一车载设备发送第二消息的验证响应消息;第二消息的响应消息用于第一车载设备向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。In a possible implementation manner, the processing unit is configured to, after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device through the sending unit; the response message of the second message is used for the first vehicle-mounted device to send The second in-vehicle device sends a third message; the third message includes at least one of the following items: the second parameter of the first key, and information about the first key.
第七方面,本申请提供一种密钥生成装置,该装置为车辆中的车载设备或KMS,该装置可以包括处理器,处理器与存储器相连,存储器用于存储计算机程序,处理器用于执行存储器中存储的计算机程序,以使得装置执行如上述第一方面中任一项的方法。In the seventh aspect, the present application provides a key generation device, the device is an on-board device or KMS in a vehicle, the device may include a processor, the processor is connected to the memory, the memory is used to store computer programs, and the processor is used to execute the memory A computer program stored in the device, so that the device executes the method according to any one of the above-mentioned first aspects.
第八方面,本申请提供一种密钥生成装置,该装置为车辆中的安全硬件扩展单元,该装置可以包括处理器,处理器与存储器相连,存储器用于存储计算机程序,处理器用于执行存储器中存储的计算机程序,以使得装置执行如上述第二方面中任一项的方法。In an eighth aspect, the present application provides a key generation device, which is a secure hardware expansion unit in a vehicle. The device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the memory. A computer program stored in the device, so that the device executes the method according to any one of the above-mentioned second aspects.
第九方面,本申请提供一种车辆,包括如上述第五方面任意一项的密钥生成装置和第六方面任意一项的密钥生成装置。In a ninth aspect, the present application provides a vehicle, including the key generation device according to any one of the fifth aspect above and the key generation device according to any one of the sixth aspect.
第十方面,本申请提供一种密钥获取装置,该装置为车辆中的车载设备或KMS,该装置包括:In a tenth aspect, the present application provides a key acquisition device, the device is an on-board device or KMS in a vehicle, and the device includes:
接收单元,用于接收车外设备发送的第一消息;第一消息用于请求第一车载设备获得第一密钥;接收服务器发送的身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The receiving unit is configured to receive the first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain the first key; receive the response message of identity verification sent by the server; the response message of identity verification includes: identity verification Validation result of the request message.
处理单元,用于根据第一消息和第一车载设备的验证信息,生成身份验证请求消息,身份验证请求消息用于服务器对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证。The processing unit is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the first vehicle-mounted device The information is verified.
发送单元,用于向服务器发送身份验证请求消息。The sending unit is configured to send an identity verification request message to the server.
一种可能的实现方式,接收单元,还用于接收服务器发送的第一消息;第一消息用于指示第一车载设备生成第一密钥;处理单元,还用于根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a possible implementation manner, the receiving unit is further configured to receive a first message sent by the server; the first message is configured to instruct the first vehicle-mounted device to generate a first key; and the processing unit is further configured to generate a second key according to the first message. A request message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; Generated after key encryption.
一种可能的实现方式,接收单元,还用于接收服务器发送的第一密钥。In a possible implementation manner, the receiving unit is further configured to receive the first key sent by the server.
一种可能的实现方式,处理单元还用于在身份验证请求消息的验证结果为验证成功时,通过发送单元向车外设备发送第一密钥。In a possible implementation manner, the processing unit is further configured to send the first key to the off-vehicle device through the sending unit when the verification result of the identity verification request message is that the verification is successful.
第十一方面,本申请提供一种密钥获取装置,该装置为服务器,该装置包括:In an eleventh aspect, the present application provides a key acquisition device, the device is a server, and the device includes:
接收单元,用于接收第一车载设备发送的身份验证请求消息;身份验证请求消息为第一车载设备根据车外设备发送的第一消息和第一车载设备的验证信息生成的;The receiving unit is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
处理单元,用于根据身份验证请求消息,对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证,生成身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The processing unit is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: identity verification Validation result of the request message.
发送单元,用于向第一车载设备发送身份验证的响应消息。A sending unit, configured to send a response message of identity verification to the first vehicle-mounted device.
一种可能的实现方式,发送单元,还用于向第一车载设备发送第一消息;第一消息用于指示第一车载设备生成第一密钥。In a possible implementation manner, the sending unit is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
一种可能的实现方式,发送单元,还用于向第一车载设备发送第一密钥。In a possible implementation manner, the sending unit is further configured to send the first key to the first vehicle-mounted device.
一种可能的实现方式,身份验证请求消息用于指示第一车载设备向车外设备发送第一密钥。In a possible implementation manner, the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
第十二方面,本申请提供一种密钥获取装置,该装置为服务器,该装置包括:该装置可以包括处理器,处理器与存储器相连,存储器用于存储计算机程序,处理器用于执行存储器中存储的计算机程序,以使得装置执行如上述第三方面中任一项的方法。In a twelfth aspect, the present application provides a key acquisition device, the device is a server, and the device includes: the device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the A computer program stored to cause the device to execute the method according to any one of the third aspect above.
第十三方面,本申请提供一种密钥获取装置,该装置为服务器,该装置包括:该装置可以包括处理器,处理器与存储器相连,存储器用于存储计算机程序,处理器用于执行存储器中存储的计算机程序,以使得装置执行如上述第四方面中任一项的方法。In a thirteenth aspect, the present application provides a key acquisition device, the device is a server, and the device includes: the device may include a processor, the processor is connected to a memory, the memory is used to store computer programs, and the processor is used to execute the A computer program stored to cause the device to execute the method according to any one of the fourth aspect above.
第十四方面,本申请提供一种车辆,包括如上述第十方面或第十二方面任意的密钥获取装置。In a fourteenth aspect, the present application provides a vehicle, including the key acquisition device according to any of the above tenth or twelfth aspects.
第十五方面,本申请提供一种密钥生成系统,包括如上述第五方面任意一项的密钥生成装置和第六方面任意一项的密钥生成装置。可选的,还可以包括车外设备。In a fifteenth aspect, the present application provides a key generation system, including the key generation device according to any one of the fifth aspect and the key generation device according to any one of the sixth aspect. Optionally, off-vehicle equipment may also be included.
第十六方面,本申请提供一种密钥获取系统,包括如上述第十方面或第十二方面任意的密钥获取装置和第十一方面或第十三方面任意的密钥获取装置,可选的,还可以包括车 外设备。In the sixteenth aspect, the present application provides a key acquisition system, including any key acquisition device in the tenth or twelfth aspect and any key acquisition device in the eleventh or thirteenth aspect, which can Optionally, off-vehicle equipment may also be included.
第十七方面,本申请提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,当计算机程序被运行时,实现如上述第一方面中任一项的方法、或上述第二方面中任一项的方法、或实现如上述第三方面中任一项的方法、或实现如上述权利要求第四方面中任一项的方法。In a seventeenth aspect, the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is run, the method according to any one of the above-mentioned first aspects, or the above-mentioned second aspect is implemented. The method of any one of the above aspects, or the method of realizing any one of the third aspect above, or the method of realizing any one of the fourth aspect of the above claim.
第十八方面,本申请提供一种计算机程序产品,计算机程序产品包括计算机程序或指令,当计算机程序或指令被通信装置执行时,实现如上述第一方面中任一项的方法、或上述第二方面中任一项的方法、或实现如上述第三方面中任一项的方法、或实现如上述权利要求第四方面中任一项的方法。In an eighteenth aspect, the present application provides a computer program product. The computer program product includes a computer program or an instruction. When the computer program or instruction is executed by a communication device, the method according to any one of the above-mentioned first aspects, or the above-mentioned first aspect is implemented. The method of any one of the two aspects, or the method for realizing any one of the third aspect above, or the method for realizing any one of the fourth aspect of the above claim.
第十九方面,本申请实施例提供了一种芯片,该芯片包括数据接口和处理器,其中,所述处理器用于执行第一方面或第一方面的任意可能实现方式中的方法、或上述第二方面中任一项的方法、或实现如上述第三方面中任一项的方法、或实现如上述权利要求第四方面中任一项的方法。例如,该芯片为车辆上安装有软件或固件的任意芯片。In a nineteenth aspect, the embodiment of the present application provides a chip, the chip includes a data interface and a processor, wherein the processor is used to execute the method in the first aspect or any possible implementation of the first aspect, or the above-mentioned The method of any one of the second aspect, or the method of realizing any one of the third aspect above, or the method of realizing any one of the fourth aspect of the above claim. For example, the chip is any chip on which software or firmware is installed on the vehicle.
第二十方面,本申请提供了一种芯片系统,该芯片系统包括至少一个处理器,用于支持实现上述第一方面或第一方面的任意可能实现方式中所涉及的功能,上述第一方面中任一项的方法、或上述第二方面中任一项的中所涉及的功能、或实现如上述第三方面中任一项的中所涉及的功能、或实现如上述权利要求第四方面中任一项的中所涉及的功能。例如,例如接收或处理上述方法中所涉及的数据和/或信息。In a twentieth aspect, the present application provides a chip system, the chip system includes at least one processor, configured to support the implementation of the functions involved in the above-mentioned first aspect or any possible implementation of the first aspect, the above-mentioned first aspect Any one of the methods, or the function involved in any one of the above-mentioned second aspects, or realize the functions involved in any one of the above-mentioned third aspects, or realize the fourth aspect of the above-mentioned claims The functions involved in any of the. For example, such as receiving or processing data and/or information involved in the methods described above.
在一种可能的设计中,所述芯片系统还包括存储器,所述存储器,用于保存程序指令和数据,存储器位于处理器之内或处理器之外。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。In a possible design, the chip system further includes a memory, the memory is used to store program instructions and data, and the memory is located inside or outside the processor. The system-on-a-chip may consist of chips, or may include chips and other discrete devices.
上述第五方面至第二十方面的有益效果,具体请参照上述第一方面至第四方面中相应设计可以达到的技术效果,这里不再重复赘述。For the beneficial effects of the fifth aspect to the twentieth aspect above, please refer to the technical effects that can be achieved by the corresponding designs in the first aspect to the fourth aspect above, and will not be repeated here.
附图说明Description of drawings
图1为本申请实施例适用的一种可能的系统架构示意图;FIG. 1 is a schematic diagram of a possible system architecture applicable to an embodiment of the present application;
图2示例性示出本申请实施例提供的一种车内长期密钥的生命周期图;Fig. 2 exemplarily shows a life cycle diagram of a long-term key in a vehicle provided by an embodiment of the present application;
图3-图7示例性示出本申请实施例提供的密钥生成方法对应的流程示意图;Figure 3-Figure 7 exemplarily shows the schematic flow chart corresponding to the key generation method provided by the embodiment of the present application;
图8为本申请实施例适用的一种可能的系统架构示意图;FIG. 8 is a schematic diagram of a possible system architecture applicable to the embodiment of the present application;
图9示例性示出本申请实施例提供的一种密钥获取方法对应的流程示意图;FIG. 9 exemplarily shows a schematic flow chart corresponding to a method for obtaining a key provided in an embodiment of the present application;
图10示例性示出本申请实施例提供的一种密钥生成装置对应的结构示意图;FIG. 10 exemplarily shows a schematic structural diagram corresponding to a key generation device provided in the embodiment of the present application;
图11示例性示出本申请实施例提供的一种密钥生成装置对应的结构示意图;FIG. 11 exemplarily shows a schematic structural diagram corresponding to a key generation device provided in the embodiment of the present application;
图12示例性示出本申请实施例提供的一种密钥获取装置对应的结构示意图;FIG. 12 exemplarily shows a schematic structural diagram corresponding to a key acquisition device provided in the embodiment of the present application;
图13示例性示出本申请实施例提供的一种密钥获取装置对应的结构示意图。FIG. 13 exemplarily shows a schematic structural diagram of a key acquisition device provided in the embodiment of the present application.
具体实施方式Detailed ways
需要说明的是,本申请实施例中的方案可以应用于车联网,如车辆外联(vehicle to everything,V2X)、车间通信长期演进技术(long term evolution-vehicle,LTE-V)、车辆-车辆(vehicle to vehicle,V2V)等。例如可以应用于具有密钥生成、密钥认证功能的车辆, 或者车辆中具有密钥生成、密钥认证功能的其它装置。该其它装置包括但不限于:车载终端、车载控制器、车载模块、车载模组、车载部件、车载芯片、车载单元、车载雷达或车载摄像头等其他传感器,车辆可通过该车载终端、车载控制器、车载模块、车载模组、车载部件、车载芯片、车载单元、车载雷达或车载摄像头,实施本申请提供的密钥生成方法。当然,本申请实施例中的密钥生成方法还可以用于除了车辆之外的其它具有密钥生成功能的智能终端,或设置在除了车辆之外的其它具有密钥生成功能的服务器中,或设置于该智能终端或服务器的部件中。该智能终端可以为智能运输设备、智能家居设备、机器人等。例如包括但不限于智能终端或智能终端内的控制器、芯片、雷达或摄像头等其它传感器、以及其它部件等。It should be noted that the solutions in the embodiments of the present application can be applied to the Internet of Vehicles, such as vehicle to everything (V2X), long term evolution-vehicle (LTE-V), vehicle-to-vehicle (vehicle to vehicle, V2V) and so on. For example, it can be applied to vehicles with key generation and key authentication functions, or other devices in vehicles with key generation and key authentication functions. The other devices include but are not limited to: vehicle-mounted terminals, vehicle-mounted controllers, vehicle-mounted modules, vehicle-mounted modules, vehicle-mounted components, vehicle-mounted chips, vehicle-mounted units, vehicle-mounted radars, or vehicle-mounted cameras. , a vehicle-mounted module, a vehicle-mounted module, a vehicle-mounted component, a vehicle-mounted chip, a vehicle-mounted unit, a vehicle-mounted radar, or a vehicle-mounted camera, implement the key generation method provided by this application. Of course, the key generation method in the embodiment of the present application can also be used in other intelligent terminals with key generation functions other than vehicles, or set in other servers with key generation functions other than vehicles, or Set in the components of the smart terminal or server. The smart terminal may be a smart transportation device, a smart home device, a robot, and the like. For example, it includes but is not limited to smart terminals or controllers, chips, radars or cameras and other sensors in the smart terminals, and other components.
本申请实施例中涉及的服务器可以为本地服务器、也可以为云端服务器,服务器可通过多种方式进行部署,例如,服务器可以为单独的一台物理机,又如,服务器还可以为某台物理服务器上加载的某个虚拟机(virtual machine,VM),再如,服务器还可以为某台物理服务器上加载的某个容器(docker)等等。如下实施例以服务器为云端服务器进行示例性说明,云端服务器也可以简称为云端。The server involved in the embodiment of this application can be a local server or a cloud server, and the server can be deployed in various ways. For example, the server can be a separate physical machine, and for another example, the server can also be a physical A certain virtual machine (virtual machine, VM) loaded on the server, for another example, the server can also be a certain container (docker) loaded on a certain physical server, etc. The following embodiments take the server as a cloud server for exemplary description, and the cloud server may also be referred to as the cloud for short.
在本申请实施例中,如图1所示,车辆可采用电子电气(electrical/electronic,E/E)架构,该架构包括三个层级,分别为网关电子控制单元(electronic control unit,ECU)、域控制器ECU和域内ECU。其中,根据功能不同,可划分为不同的域,每个域有一个域控制器ECU。域控制器ECU用于管理对应域内的域内ECU。网关ECU用于对域控制器ECU进行管理。例如,参照图1所示,根据功能不同,可划分4个域,分别为整车控制系统域、娱乐系统域、诊断系统域以及智能驾驶域。每个域对应于一个域控制器ECU。上述4个域,总共对应于4个域控制器ECU。网关ECU用于对4个域控制器ECU进行管理。In the embodiment of the present application, as shown in FIG. 1, the vehicle can adopt an electrical/electronic (E/E) architecture, which includes three levels, which are gateway electronic control unit (electronic control unit, ECU), Domain controller ECU and intra-domain ECU. Among them, according to different functions, it can be divided into different domains, and each domain has a domain controller ECU. The domain controller ECU is used to manage the intra-domain ECUs in the corresponding domain. The gateway ECU is used to manage the domain controller ECU. For example, as shown in Figure 1, according to different functions, it can be divided into four domains, namely, vehicle control system domain, entertainment system domain, diagnostic system domain and intelligent driving domain. Each domain corresponds to a domain controller ECU. The above 4 domains correspond to 4 domain controller ECUs in total. The gateway ECU is used to manage the 4 domain controller ECUs.
例如,在本申请实施例中,仍可参照图1,整个E/E架构中,包括4个控制器局域网络(controller area network,CAN)总线,分别为CAN总线1、CAN总线2、CAN总线3以及CAN总线4。可选的,图2中的4个CAN总线可与图1中的4个域存在对应关系。比如,图1中的CAN总线1可对应于整车控制系统域,CAN总线2可对应于娱乐系统域,CAN总线3可对应于诊断系统域,CAN总线4可对应于智能驾驶域等。For example, in the embodiment of the present application, still can refer to Fig. 1, in the whole E/E structure, comprise 4 controller area network (controller area network, CAN) buses, are respectively CAN bus 1, CAN bus 2, CAN bus 3 and CAN bus 4. Optionally, the four CAN buses in FIG. 2 may correspond to the four fields in FIG. 1 . For example, CAN bus 1 in Figure 1 may correspond to the vehicle control system domain, CAN bus 2 may correspond to the entertainment system domain, CAN bus 3 may correspond to the diagnostic system domain, CAN bus 4 may correspond to the intelligent driving domain, etc.
可以理解的是,图1所示架构,仅为示意性说明,并不作为对本申请实施例的限定。比如,本申请实施例所提供的方法,除可利用于上述图1所示的三层架构外,还可利用于其它两层或一层架构中等,不作限定。It can be understood that the architecture shown in FIG. 1 is only for schematic illustration, and is not intended to limit the embodiment of the present application. For example, the method provided in the embodiment of the present application can be applied to other two-layer or one-layer architectures in addition to the three-layer architecture shown in FIG. 1 above, without limitation.
下面基于图1所示意的系统架构,先对本申请所涉及到的部分术语进行介绍。Based on the system architecture shown in FIG. 1 , some terms involved in this application will be introduced first.
(1)电子控制单元(electronic control unit,ECU)。(1) Electronic control unit (ECU).
本申请实施例中,车辆的内部可以配置有多个ECU,如图1所示意出的ECU 1、ECU 2、……、ECU N,N为正整数。其中,每个ECU都可以具有自己特定的功能,且还支持简单的传感器数据处理和复杂的逻辑计算。目前常见的ECU包括但不限于:车载传感器、车载摄像头、多域控制器(multi domain controller,MDC)、自动驾驶域控制单元(automated-driving control unit,ADCU)、前装智能网关(telematics box,T-Box),也可以叫车载信息盒子、智能座舱域控制器(cockpit domain controller,CDC)、车载网关、整车控制单元(vehicle control unit,VCU)、电池管理系统(battery management system,BMS)、热管理系统(thermal management system,TMS)、配电单元(power distribution unit,PDU)等。In the embodiment of the present application, multiple ECUs can be configured inside the vehicle, such as ECU 1, ECU 2, ..., ECU N shown in Figure 1, where N is a positive integer. Among them, each ECU can have its own specific functions, and also supports simple sensor data processing and complex logic calculation. Currently common ECUs include but are not limited to: vehicle sensors, vehicle cameras, multi-domain controllers (multi domain controllers, MDCs), automated-driving control units (automated-driving control units, ADCUs), pre-installed intelligent gateways (telematics boxes, T-Box), can also be called vehicle information box, smart cockpit domain controller (cockpit domain controller, CDC), vehicle gateway, vehicle control unit (vehicle control unit, VCU), battery management system (battery management system, BMS) , thermal management system (thermal management system, TMS), power distribution unit (power distribution unit, PDU), etc.
(2)网关(gateway)(2) Gateway (gateway)
网关是车辆架构中的核心部分,其作为整车网络的数据交互枢纽,可将CAN、本地互联网络(local interconnection network,LIN)、多媒体传输系统(media oriented systems transport,MOST)、FlexRay等网络数据在不同网络中进行路由。网关可对域控制设备和域内设备等进行管理。在本申请实施例中,网关内可包括网关ECU,网关与网关ECU不作相互区分。The gateway is the core part of the vehicle architecture. As the data exchange hub of the vehicle network, the gateway can transfer CAN, local interconnection network (local interconnection network, LIN), multimedia transmission system (media oriented systems transport, MOST), FlexRay and other network data Routing in different networks. The gateway can manage domain control devices and devices in the domain. In the embodiment of the present application, the gateway may include a gateway ECU, and the gateway and the gateway ECU are not distinguished from each other.
(3)域控制设备(3) Domain control device
根据车辆电子各部分的功能不同,可将车辆电子划分为几个域。比如,动力传动域、车身电子域以及辅助驾驶域等。每个域内设有一个域控制设备,用于对该域内的域内设备进行管理。域控制设备也可称为域控制器。在本申请实施例中,域控制设备内包括域控制ECU,域控制设备与域控制设备ECU不作相互区分。According to the different functions of each part of vehicle electronics, vehicle electronics can be divided into several domains. For example, the power transmission domain, the body electronics domain, and the assisted driving domain. There is a domain control device in each domain, which is used to manage the devices in the domain. A domain control device may also be referred to as a domain controller. In the embodiment of the present application, the domain control device includes a domain control ECU, and the domain control device and the domain control device ECU are not distinguished from each other.
(4)域内设备(4) Devices in the domain
根据车辆电子各部分的功能不同,可将车辆电子划分为几个域。比如,动力传动域、车身电子域以及辅助驾驶域等。每个域内可包括一个域控制器和多个被控制设备,域内设备可具体指每个域内的被控制设备等。在本申请实施例中,域内设备中可包括域内ECU,域内设备与域内ECU不作相互区分。According to the different functions of each part of vehicle electronics, vehicle electronics can be divided into several domains. For example, the power transmission domain, the body electronics domain, and the assisted driving domain. Each domain may include a domain controller and multiple controlled devices, and the devices in the domain may specifically refer to the controlled devices in each domain. In the embodiment of the present application, the in-domain equipment may include an in-domain ECU, and the in-domain equipment and the in-domain ECU are not distinguished from each other.
其中,在图1所示的架构中,本申请实施例中,车辆中的各个ECU可以依赖于车辆出厂时所设置好的通信技术来交互消息。这些通信技术例如可以为LIN技术或CAN技术,还可以为其它实现消息交互的通信技术。当依赖于CAN技术来交互消息时,不同ECU之间可发送CAN消息。各个ECU可以连接在同一根CAN总线上,任一个ECU都可以自由地在该CAN总线上读取和发送CAN消息帧。CAN总线上的每个CAN消息帧中一般只具有消息标识,而不携带源地址或目的地址,连接到该CAN总线上的各个ECU可以通过消息标识来选择接收哪个消息帧。虽然基于CAN技术的消息交互方式具有较强的实时性和可靠性,但是CAN技术中并没有内置任何的安全功能。这种情况下,一旦攻击者破译了CAN总线,则攻击者注入的每个CAN消息帧都可能会被车辆中的ECU读取并认为是合法的CAN消息帧,这样,攻击者就能够完全控制车辆的功能,例如制动或加速,这对于用户使用车辆来说是非常不安全的。Wherein, in the architecture shown in FIG. 1 , in the embodiment of the present application, each ECU in the vehicle can exchange messages depending on the communication technology set when the vehicle leaves the factory. These communication technologies may be, for example, LIN technology or CAN technology, and may also be other communication technologies that realize message interaction. When relying on CAN technology to exchange messages, CAN messages can be sent between different ECUs. Each ECU can be connected to the same CAN bus, and any ECU can freely read and send CAN message frames on the CAN bus. Each CAN message frame on the CAN bus generally only has a message identifier, and does not carry a source address or a destination address. Each ECU connected to the CAN bus can select which message frame to receive through the message identifier. Although the message interaction method based on CAN technology has strong real-time and reliability, there is no built-in security function in CAN technology. In this case, once the attacker deciphers the CAN bus, every CAN message frame injected by the attacker may be read by the ECU in the vehicle and considered as a legitimate CAN message frame, so that the attacker can fully control Functions of the vehicle, such as braking or accelerating, which are very unsafe for the user to use the vehicle.
因此,可以为车辆中的各个ECU配置各自对应的长期密钥。当某个ECU根据消息标识从CAN总线上获取到一个CAN消息帧时,该ECU还可以使用预先配置的长期密钥来解析该CAN消息帧。如果解析不成功,则说明该CAN消息帧大概率属于非法人员注入在CAN总线上的非法的控制命令,因此该ECU可以不执行对应的控制操作,以避免非法人员控制车辆。如果解析成功,则说明该CAN消息帧属于合法人员(例如车主)注入在CAN总线上的合法的控制命令,因此该ECU可以执行对应的控制操作。如此,通过在各个ECU中预设长期密钥来完成CAN消息帧的认证操作,有助于在真正执行控制之前先对控制命令进行认证,以提高车主的行车安全。Therefore, each ECU in the vehicle can be configured with its own corresponding long-term key. When an ECU obtains a CAN message frame from the CAN bus according to the message identifier, the ECU can also use a pre-configured long-term key to parse the CAN message frame. If the parsing is unsuccessful, it means that the CAN message frame is likely to belong to an illegal control command injected on the CAN bus by an illegal person, so the ECU may not perform the corresponding control operation to prevent the illegal person from controlling the vehicle. If the parsing is successful, it means that the CAN message frame belongs to a legal control command injected on the CAN bus by a legal person (such as a car owner), so the ECU can perform corresponding control operations. In this way, by presetting the long-term key in each ECU to complete the authentication operation of the CAN message frame, it is helpful to authenticate the control command before actually executing the control, so as to improve the driving safety of the vehicle owner.
(5)KMS。(5) KMS.
本申请实施例中,车辆的内部还可以配置有KMS。KMS在车辆中主要负责生成密钥、管理密钥和清除密钥等功能,该KMS还可以从云端服务器(例如,车厂密钥管理中心,或用户密钥管理中心)或用户的应用程序(application,APP)等车外设备获得密钥。基于KMS的功能或权限,可以分为KMS的服务端(Server)、KMS的代理(Agent)端和KMS 的客户端(Client)。In the embodiment of the present application, a KMS may also be configured inside the vehicle. The KMS in the vehicle is mainly responsible for functions such as generating keys, managing keys, and clearing keys. , APP) and other off-vehicle devices to obtain the key. Based on the functions or permissions of KMS, it can be divided into KMS server (Server), KMS agent (Agent) and KMS client (Client).
KMS的服务端可以部署在车内的域控制器上(比如VDC、CDC、MDC等),也可以部署在网关、T-BOX、或一个独立的设备上。KMS的服务端上可以包括支持本申请的密钥生成方法的SHE,也可以包括支持密钥生成对应的密钥验证功能的硬件安全模块(hardware security module,HSM)等其他安全硬件机制。KMS的客户端可以是除KMS服务端之外的各传感器、ECU部件等设备。KMS的客户端可以包括SHE,可以支持本申请中的密钥生成过程,也可以用于支持密钥的安全存储功能。KMS客户端也可以包括HSM等其他安全硬件机制,用于支持密钥的安全存储功能。其中,KMS的代理(Agent)端可以是用于连接域控制器、网关、T-BOX与传感器设备、ECU部件的设备。KMS的代理端可以作为KMS子服务端(Sub Server),用于管理与该代理端连接的KMS的客户端的密钥生成过程。代理端可以和与代理端连接的至少一个KMS的客户端之间组成代理域。The KMS server can be deployed on the domain controller in the vehicle (such as VDC, CDC, MDC, etc.), or it can be deployed on the gateway, T-BOX, or an independent device. The service end of KMS can include the SHE that supports the key generation method of the present application, and can also include other secure hardware mechanisms such as a hardware security module (hardware security module, HSM) that supports the key verification function corresponding to key generation. The KMS client can be various sensors, ECU components and other devices except the KMS server. The KMS client can include SHE, which can support the key generation process in this application, and can also be used to support the secure storage function of the key. The KMS client may also include other secure hardware mechanisms such as HSM to support secure key storage. Wherein, the agent (Agent) end of the KMS may be a device for connecting domain controllers, gateways, T-BOXs, sensor devices, and ECU components. The KMS agent can be used as a KMS sub-server (Sub Server) to manage the key generation process of the KMS client connected to the agent. The agent can form an agent domain with at least one KMS client connected to the agent.
KMS的服务端、KMS的客户端之间可以预先灌装了用于相互之间进行安全通信的密钥,比如各设备可以提前灌装一车一密的固定密钥(比如,GLOBAL_FIX_KEY)。也可以是灌装了用于KMS的服务端和部分KMS的客户端之间的固定密钥,该固定密钥可以用于KMS的服务端和部分KMS的客户端之间进行安全通信的密钥,在此不做限定。The KMS server and KMS client can be pre-filled with keys for secure communication with each other. For example, each device can be filled with a fixed key (for example, GLOBAL_FIX_KEY) in advance. It can also be filled with a fixed key used between the KMS server and some KMS clients. This fixed key can be used as a key for secure communication between the KMS server and some KMS clients. , is not limited here.
这些密钥包括上述介绍的长期密钥。不同于传统的信息与技术(information and communications technology,ICT),车联网中的ECU大都遵循汽车网络安全(automotive,cyber security,EVITA)标准和安全硬件扩展(secure hardware extension,SHE)标准。示例性地,考虑到EVITA标准和SHE标准下设置密钥的性能和成本,KMS中的长期密钥可以设置为对称密钥。These keys include the long-term keys described above. Unlike traditional information and communications technology (ICT), most ECUs in the Internet of Vehicles follow the automotive, cyber security (EVITA) standard and secure hardware extension (SHE) standard. Exemplarily, considering the performance and cost of key setting under the EVITA standard and the SHE standard, the long-term key in the KMS can be set as a symmetric key.
图2示例性示出本申请实施例提供的一种车内长期密钥的生命周期图,如图2所示,车内长期密钥的整个生命周期内涉及到原设备制造商(original equipment manufacturer,OEM)侧、供应商侧和车辆售卖点侧三者的通信交互。其中,OEM侧具体可以包括OEM研发线和OEM产线。供应商侧具体可以包括芯片供应商和部件供应商,为了便于理解,无论是芯片供应商提供的芯片,还是部件供应商利用这些芯片组装的ECU或车辆部件,这里统称为ECU。供应商侧具体可以包括供应商研发线和供应商产线。如图2所示,车内长期密钥的整个生命周期可以包括如下几个阶段:Fig. 2 exemplarily shows a life cycle diagram of a long-term key in a vehicle provided by an embodiment of the present application. As shown in Fig. 2, the entire life cycle of a long-term key in a car involves the , OEM) side, supplier side and vehicle point-of-sale side three communication interaction. Wherein, the OEM side may specifically include an OEM research and development line and an OEM production line. The supplier side may specifically include chip suppliers and component suppliers. For ease of understanding, whether it is chips provided by chip suppliers or ECUs or vehicle components assembled by component suppliers using these chips, they are collectively referred to as ECUs here. The supplier side can specifically include supplier R&D lines and supplier production lines. As shown in Figure 2, the entire life cycle of the long-term key in the car can include the following stages:
阶段201,OEM研发线根据业务需求和管理需求设计密钥层次结构,并生成业务需求所需的对称密钥1。其中,对称密钥1中可以包括一个或多个对称密钥,这一个或多个对称密钥作为密钥层次结构设计的初始密钥,用于派生得到其它对称密钥。In stage 201, the OEM R&D line designs a key hierarchy according to business requirements and management requirements, and generates a symmetric key 1 required by the business requirements. Wherein, the symmetric key 1 may include one or more symmetric keys, and the one or more symmetric keys are used as initial keys for key hierarchy design, and are used to derive other symmetric keys.
阶段202,OEM研发线将密钥层次结构和对称密钥1发送给供应商研发线。其中,该发送操作需要在安全保密的环境下进行,例如可以安排专人秘密派送,也可以通过加密的点对点(peer to peer,P2P)方式传输,还可以通过其它安全的通信方式发送,不作限定。Stage 202, the OEM R&D line sends the key hierarchy and Symmetric Key 1 to the Supplier R&D line. Among them, the sending operation needs to be carried out in a safe and confidential environment. For example, a special person can be arranged to send it secretly, or it can be transmitted through an encrypted peer-to-peer (P2P) method, or it can be sent through other secure communication methods, without limitation.
阶段203,供应商研发线基于对称密钥1和密钥层次结构派生出供应商侧自提供的对称密钥2。其中,对称密钥2中可以包括组装ECU所需的芯片的根密钥、组装车辆部件或车辆所需的ECU的根密钥、以及ECU组装成的车辆部件的根密钥。对称密钥2还可以配置为可更新,即对称密钥2可以根据不同的生产环境进行变更。In stage 203, the supplier R&D line derives the symmetric key 2 provided by the supplier side based on the symmetric key 1 and the key hierarchy. Among them, the symmetric key 2 may include a root key of a chip required for assembling an ECU, a root key of an ECU required for assembling a vehicle part or a vehicle, and a root key of a vehicle part assembled from an ECU. The symmetric key 2 can also be configured to be updatable, that is, the symmetric key 2 can be changed according to different production environments.
阶段204,供应商产线在组装ECU或车辆部件时,向供应商研发线申请密钥。In stage 204, the supplier's production line applies for a key from the supplier's R&D line when assembling ECUs or vehicle components.
阶段205,供应商研发线将对称密钥1和对称密钥2返回给供应商产线。In stage 205, the supplier's R&D line returns the symmetric key 1 and symmetric key 2 to the supplier's production line.
阶段206,供应商产线调用HSM或SHE标准,将对称密钥1和对称密钥2封装在各 自对应的ECU或车辆部件中。In stage 206, the supplier's production line calls the HSM or SHE standard, and encapsulates the symmetric key 1 and the symmetric key 2 in their corresponding ECU or vehicle components.
阶段207,供应商产线通知OEM产线进行整车组装。In stage 207, the supplier production line notifies the OEM production line to assemble the vehicle.
阶段208,OEM产线基于封装了对称密钥1和对称密钥2的ECU或车辆部件组装整车,并在组装过程中向OEM研发线申请密钥。In stage 208, the OEM production line assembles the vehicle based on the ECU or vehicle parts packaged with the symmetric key 1 and the symmetric key 2, and applies for the key to the OEM R&D line during the assembly process.
阶段209,OEM研发线将对称密钥3返回给OEM产线。其中,对称密钥3中可以包括OEM侧预设的根密钥和工作密钥等。对称密钥3适用于车辆售后阶段,例如用于更换ECU或车辆部件,或者更新软件配置等。In stage 209, the OEM R&D line returns the symmetric key 3 to the OEM production line. Wherein, the symmetric key 3 may include a root key and a work key preset by the OEM side. The symmetric key 3 is suitable for the after-sales stage of the vehicle, such as replacing ECU or vehicle components, or updating software configuration, etc.
阶段210,OEM产线将对称密钥3封装在车辆中,之后将车辆提供给车辆售卖点进行售卖。此时,车辆中同时封装有对称密钥1、对称密钥2和对称密钥3。In stage 210, the OEM production line encapsulates the symmetric key 3 in the vehicle, and then provides the vehicle to the vehicle sales point for sale. At this time, the symmetric key 1, the symmetric key 2 and the symmetric key 3 are packaged in the vehicle at the same time.
阶段211,车辆售出后,如果车辆中的ECU或车辆部件损坏,或者需要对车辆的软件配置进行更新,则车主还可以将车辆放置在车辆售卖点,由车辆售卖点基于对称密钥3向OEM侧申请售后。此外,车辆售出后,车主还可以根据提示在车辆中预置一些车主密钥,此时车辆中同时封装有对称密钥1、对称密钥2、对称密钥3和车主密钥。 Stage 211, after the vehicle is sold, if the ECU or vehicle components in the vehicle are damaged, or the software configuration of the vehicle needs to be updated, the owner can also place the vehicle at the vehicle sales point, and the vehicle sales point will be based on the symmetric key 3-way The OEM side applies for after-sales. In addition, after the vehicle is sold, the owner can also preset some owner keys in the vehicle according to the prompt. At this time, the vehicle is packaged with symmetric key 1, symmetric key 2, symmetric key 3 and the owner key.
应理解,上述各阶段中OEM研发线侧的全部操作均可以经由OEM侧设置的管理员和OEM侧的密钥管理系统来完成,供应商研发线侧的全部操作均可以经由供应商侧设置的管理员和供应商研发线侧的密钥管理系统来完成,本申请对此不作具体说明。It should be understood that all the operations on the OEM R&D line side in the above stages can be completed through the administrator set on the OEM side and the key management system on the OEM side, and all operations on the supplier’s R&D line side can be done through the key management system set on the supplier side. Administrators and suppliers develop key management systems on the line side to complete this, which is not specifically described in this application.
按照图2所示意的内容可知,在车内长期密钥的整个生命周期中,车内的KMS需要管理的长期密钥包括但不限于:OEM研发线按照业务需求预置的对称密钥1、供应商研发线根据对称密钥1派生得到的对称密钥2、OEM侧预设的对称密钥3和车主密钥等。这些长期密钥可以分别应用于不同的场景。例如,表1示例性示出一种KMS所管理的各个长期密钥的应用场景示意。According to the content shown in Figure 2, in the entire life cycle of the long-term key in the car, the long-term keys that the KMS in the car needs to manage include but are not limited to: Symmetric keys preset by the OEM R&D line according to business needs 1, The supplier's R&D line derives the symmetric key 2 based on the symmetric key 1, the symmetric key 3 preset on the OEM side, and the owner's key. These long-term keys can be applied to different scenarios respectively. For example, Table 1 exemplarily shows an application scenario of each long-term key managed by the KMS.
表1Table 1
Figure PCTCN2021095348-appb-000001
Figure PCTCN2021095348-appb-000001
如表1所示,而一辆车从生产组装完成,到交付给客户,以及车辆上路的过程中,可能涉及多个进行通信的数据管理者或使用者。比如车辆控制域(功能安全)中的数据的管理者为车厂,中间车辆运营公司也会有对车辆的数据管理的需要,例如,对车辆进行诊断时,也需要对车辆进行控制,以获得相应车辆的诊断数据。另外,车辆的信息娱乐域的管理者可能归属不同的驾驶员或车辆的使用用户。对于车内这些数据管理者或使用者,为实现不同业务之间的信息的安全隔离,在通过车辆的不同业务的ECU进行数据通信时,需 要使用不同的密钥保护各自业务在不同设备间的通信。另外,随着车辆智能化的演进,新的业务逐渐增加,针对不同的业务之间的信息安全,相应设置对应的密钥,可能导致密钥逐步增多,根据上述方案,车厂要为每辆车生成并管理越来越多的密钥,管理困难。As shown in Table 1, the process of a car from the completion of production and assembly to delivery to customers and on-road vehicles may involve multiple communicating data managers or users. For example, the data manager in the vehicle control domain (functional safety) is the car factory, and the intermediate vehicle operating company also needs to manage the data of the vehicle. For example, when diagnosing the vehicle, it also needs to control the vehicle to obtain the corresponding Vehicle diagnostic data. In addition, the managers of the infotainment domain of the vehicle may belong to different drivers or users of the vehicle. For these data managers or users in the vehicle, in order to realize the safe isolation of information between different services, when data communication is performed through the ECUs of different services of the vehicle, different keys need to be used to protect the information of the respective services between different devices. communication. In addition, with the evolution of vehicle intelligence, new services are gradually increasing. For the information security between different services, corresponding keys are set accordingly, which may lead to a gradual increase in keys. According to the above scheme, the car factory needs to provide Generate and manage more and more keys, management is difficult.
另外,从安全的角度来看,车内的KMS所管理的各个长期密钥不仅会应用于车内各个ECU之间的交互认证,还会应用于车内ECU和车外设备之间的交互认证。因此,长期密钥在车辆中起到至关重要的作用,如果云端管理的车内设备间业务通信密钥,发生密钥泄露,也可能导致用户的密钥泄露,可能会立即影响所有车辆的行驶安全(功能安全、信息安全),还可能导致用户的隐私数据泄露的问题。In addition, from a security point of view, the long-term keys managed by the KMS in the car will not only be applied to the interactive authentication between the ECUs in the car, but also the interactive authentication between the ECU in the car and the equipment outside the car. . Therefore, the long-term key plays a vital role in the vehicle. If the key for the business communication between the in-vehicle devices managed by the cloud is leaked, it may also lead to the leak of the user's key, which may immediately affect the security of all vehicles. Driving safety (functional safety, information security) may also lead to the leakage of users' private data.
下面以具体的实施例来介绍本申请中的密钥生成方法。通过在车厂云端、用户侧仅维持少量的固定密钥,而车内设备间的业务通信密钥在车内自主构建,从而,减少云端管理密钥的数量;为不同用户的不同业务的通信需求构建独立的业务通信密钥,就可以实现不同业务间通信安全隔离,各方或攻击者就无法通过掌握的某一方的密钥非法监听其他用户的业务通信内容,只可能通过正式的授权服务来访问;最后即便云端密钥发生泄露,可能也难影响车辆行驶安全。The key generation method in this application will be introduced below with specific embodiments. Only a small number of fixed keys are maintained on the car factory cloud and on the user side, and the business communication keys between in-vehicle devices are independently constructed in the car, thereby reducing the number of cloud management keys; for different users and different business communication needs Building an independent business communication key can realize the security isolation of communication between different businesses. All parties or attackers will not be able to illegally monitor the business communication content of other users through the key of one party. It is only possible through formal authorization services access; in the end, even if the cloud key is leaked, it may be difficult to affect the driving safety of the vehicle.
需要说明的是,本申请实施例中的术语“系统”和“网络”可被互换使用。“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a和b,a和c,b和c,或a和b和c,其中a,b,c可以是单个,也可以是多个。It should be noted that the terms "system" and "network" in the embodiments of the present application may be used interchangeably. "At least one" means one or more, and "plurality" means two or more. "And/or" describes the association relationship of associated objects, indicating that there may be three types of relationships, for example, A and/or B, which can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A, B can be singular or plural. The character "/" generally indicates that the contextual objects are an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one item (piece) of a, b, or c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
以及,除非有特别说明,本申请实施例提及“第一”、“第二”等序数词是用于对多个对象进行区分,不用于限定多个对象的优先级或者重要程度。例如,第一车载设备、第二车载设备,只是为了区分不同的车载设备,而并不是表示这两个车载设备的优先级或者重要程度等的不同。And, unless otherwise specified, ordinal numerals such as "first" and "second" mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the priority or importance of multiple objects. For example, the first in-vehicle device and the second in-vehicle device are only for distinguishing different in-vehicle devices, and do not represent the difference in priority or importance of the two in-vehicle devices.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。The following will describe the technical solutions in the embodiments of the application with reference to the drawings in the embodiments of the application. Apparently, the described embodiments are only some of the embodiments of the application, not all of them.
本申请实施例提供一种密钥生成方法,应用于车辆,如图3所示,包括:The embodiment of the present application provides a method for generating a key, which is applied to a vehicle, as shown in Figure 3, including:
步骤301:第一车载设备获得第一消息。Step 301: the first vehicle-mounted device obtains the first message.
其中,第一消息用于指示第一车载设备构建第一密钥;Wherein, the first message is used to instruct the first vehicle-mounted device to construct the first key;
在一些实施例中,第一车载设备可以是KMS的服务端或KMS的代理端。例如,在第一车载设备为服务端时,第一车载设备可以通过非KMS设备接收第一消息。在第一车载设备为代理端时,第一车载设备可以通过服务端接收非KMS设备发送的第一消息。具体实施方式可以参见下文中场景1~场景4的描述。In some embodiments, the first in-vehicle device may be a KMS server or a KMS agent. For example, when the first vehicle-mounted device is a server, the first vehicle-mounted device may receive the first message through a non-KMS device. When the first vehicle-mounted device is an agent, the first vehicle-mounted device may receive the first message sent by the non-KMS device through the server. For specific implementation manners, reference may be made to the description of Scenario 1 to Scenario 4 below.
步骤302:第一车载设备根据第一消息,生成第一请求消息。Step 302: The first vehicle-mounted device generates a first request message according to the first message.
第一请求消息用于第一车载设备对应的第一SHE生成第一响应消息。The first request message is used for the first SHE corresponding to the first vehicle-mounted device to generate the first response message.
其中,第一SHE可以是设置与第一车载设备设置在同一ECU中的,也可以是单独设置的,在此不做限定。第一车载设备可以是用于管理该ECU中的密钥的KMS。Wherein, the first SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here. The first in-vehicle device may be a KMS for managing keys in the ECU.
步骤303:第一车载设备向第一SHE发送第一请求消息。Step 303: the first vehicle-mounted device sends a first request message to the first SHE.
步骤304:第一SHE根据第一请求消息,生成第一响应消息。Step 304: the first SHE generates a first response message according to the first request message.
其中,第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。Wherein, the first response message includes: first key information; the first key information is generated after encrypting the first key.
在一些实施例中,第一密钥信息可以是加密后的第一密钥。当然,第一密钥信息还可以包括第一密钥的其他信息,具体参见下文中的第一响应消息的介绍。In some embodiments, the first key information may be an encrypted first key. Certainly, the first key information may also include other information of the first key, for details, refer to the introduction of the first response message below.
步骤305:第一SHE向第一车载设备发送第一响应消息。Step 305: the first SHE sends a first response message to the first vehicle-mounted device.
本申请实施例中,一个车载设备的关键数据存储区可以包括以下内容:密钥名称(key name)、密钥地址(address或存储槽位memory slot)、存储区(memory area),例如,如表2所示。In the embodiment of the present application, the key data storage area of a vehicle-mounted device may include the following contents: key name (key name), key address (address or storage slot memory slot), storage area (memory area), for example, as Table 2 shows.
表2Table 2
Figure PCTCN2021095348-appb-000002
Figure PCTCN2021095348-appb-000002
其中,密钥名称可以标识在该存储区存储的密钥类型,例如,GLOBAL_FIX_KEY,可以用于存储一车一密的固定密钥PSKFix_Global,可以用于该ECU更新GLOBAL_FIX_KEY或更新该ECU的其他密钥。该密钥还可以是与该ECU的主密钥(例如, SHE协议中的MASTER_ECU_KEY)相同的密钥或不同的密钥。还可以是用于该ECU生成车内的长期密钥专用的固定密钥,本申请不做限定。KMS_CFG_MAC可以用于存储该ECU的配置文件更新的安全校验码,用于初始化或更新KMS的配置文件时进行安全校验。Among them, the key name can identify the type of key stored in the storage area, for example, GLOBAL_FIX_KEY, which can be used to store the fixed key PSKFix_Global of one vehicle and one secret, and can be used for the ECU to update GLOBAL_FIX_KEY or update other keys of the ECU . This key can also be the same key as the master key of this ECU (for example, MASTER_ECU_KEY in the SHE protocol) or a different key. It can also be used for the ECU to generate a fixed key dedicated to the long-term key in the vehicle, which is not limited in this application. KMS_CFG_MAC can be used to store the security check code of the ECU configuration file update, which is used for security check when initializing or updating the KMS configuration file.
MAC_FIX_KEY可以是SHE安全启动时,用于校验KMS的密钥生成的相关软件完整性的固定密钥。安全校验码BOOT_MAC可以是SHE安全启动时,用于校验KMS的密钥生成的相关软件完整性的校验码。其中,MAC_FIX_KEY还可以是用于校验车辆的其他KMS软件完整性的固定密钥,例如,SHE协议中的固定密钥BOOT_MAC_KEY。MAC_FIX_KEY can be a fixed key used to verify the integrity of the relevant software generated by the key of KMS when the SHE is securely started. The security verification code BOOT_MAC may be a verification code for verifying the integrity of the relevant software generated by the key of the KMS when the SHE is securely started. Wherein, MAC_FIX_KEY can also be a fixed key used to verify the integrity of other KMS software of the vehicle, for example, the fixed key BOOT_MAC_KEY in the SHE protocol.
KEY_1~KEY_20:可用于存储车内设备间通信的对称密钥(加密密钥、或者完整性密钥)。KEY_1~KEY_20: can be used to store the symmetric key (encryption key, or integrity key) for communication between in-vehicle devices.
在一车一密的固定密钥为非对称密钥时,KEY_1可以用于存储一车一密的固定密钥PSKFix_Global的密钥对(Pair)。例如,在支持在线更新时,即在通过云端服务器对一车一密的固定密钥进行更新时,可以根据一车一密的固定密钥PSKFix_Global的密钥对进行安全验证。KEY_2可以用于存储该ECU的固定密钥的安全验证密钥PSKGlobal,即可以是对该ECU上的固定密钥进行安全验证的密钥,以增强固定密钥的安全性。在安全验证密钥PSKGlobal为非对称密钥时,KEY_3可以用于存储该ECU的固定密钥的安全验证密钥PSKGlobal的密钥对(Pair),用于与安全验证密钥配对使用,在使用安全验证密钥PSKGlobal进行加密或完整性验证时,可以根据该密钥进行安全性验证。其他位置可用于存储该车载设备规划的KMS所使用的长期密钥或固定密钥等。举例来说,在第一密钥为长期密钥时,第一密钥可以为第一车载设备专用的长期密钥,第一密钥可以为第二车载设备专用的长期密钥,第一密钥可以为第一车载设备和第二车载设备之间使用的长期密钥,第一密钥可以为用户1使用第一车载设备时对应的长期密钥,第一密钥可以为用户2使用第一车载设备和第二车载设备时对应的长期密钥。在一些实施例中,本申请中生成的车载设备的长期密钥可以是存储在密钥KEY_1~KEY_20中。相应的密钥地址可以用于表示密钥的标识和密钥的存储位置,例如,下文中的memory slot、KEY_ID的取值可以是该密钥地址的值。KEY_1~KEY_20的其他位置还可以用于存储不受KMS管理的其他密钥,比如本地文件加密存储用的加密密钥等。When the one-vehicle-one-secret fixed key is an asymmetric key, KEY_1 can be used to store the key pair (Pair) of the one-vehicle-one-secret fixed key PSKFix_Global. For example, when online update is supported, that is, when the one-vehicle-one-secret fixed key is updated through the cloud server, security verification can be performed according to the key pair of the one-vehicle-one-secret fixed key PSKFix_Global. KEY_2 can be used to store the security verification key PSKGlobal of the fixed key of the ECU, that is, it can be a key for security verification of the fixed key on the ECU, so as to enhance the security of the fixed key. When the security verification key PSKGlobal is an asymmetric key, KEY_3 can be used to store the key pair (Pair) of the security verification key PSKGlobal of the ECU's fixed key, which is used for pairing with the security verification key. When the security verification key PSKGlobal performs encryption or integrity verification, security verification can be performed based on this key. Other locations may be used to store long-term keys or fixed keys used by the KMS planned for the vehicle equipment. For example, when the first key is a long-term key, the first key may be a long-term key dedicated to the first vehicle-mounted device, the first key may be a long-term key dedicated to the second vehicle-mounted device, and the first key may be a long-term key dedicated to the second vehicle-mounted device. The key may be a long-term key used between the first vehicle-mounted device and the second vehicle-mounted device. The first key may be the corresponding long-term key when user 1 uses the first vehicle-mounted device. A long-term key corresponding to a vehicle-mounted device and a second vehicle-mounted device. In some embodiments, the long-term keys of the vehicle equipment generated in this application may be stored in keys KEY_1-KEY_20. The corresponding key address can be used to indicate the identity of the key and the storage location of the key. For example, the value of memory slot and KEY_ID below can be the value of the key address. Other locations of KEY_1 to KEY_20 can also be used to store other keys that are not managed by KMS, such as encryption keys used for encrypted storage of local files.
可选的,ECU的关键数据存储区还可以包括其他参数,该参数可以包括:KMS角色信息,其中,KMS角色信息可以包括:密钥有效期(KMS_CFG_KeyLifetime),KMS的配置文件版本号(KMS_CFG_Version),KMS的角色(KMS_CFG_Role)。密钥有效期,可以支持存储区外部的读写,例如,所有长期密钥的有效期可以设置为相同,该密钥有效期的单位可以为分钟。KMS的配置文件版本号可以是针对密钥设置的版本号。例如,在第一次生成KMS的密钥体系中的密钥后的版本号为1.0。当然也可以增加版本号的长度,比如该配置文件的版本号是与KMS的软件版本号联合后的版本号。KMS的角色可以包括:无角色信息(角色信息的值可以为0),KMS服务端(角色信息的值可以为1),KMS代理端(角色信息的值可以为2),KMS客户端(角色信息的值可以为3),其他值为无效值。Optionally, the key data storage area of the ECU can also include other parameters, which can include: KMS role information, wherein the KMS role information can include: key validity period (KMS_CFG_KeyLifetime), KMS configuration file version number (KMS_CFG_Version), The role of KMS (KMS_CFG_Role). The key validity period can support reading and writing outside the storage area. For example, the validity period of all long-term keys can be set to be the same, and the unit of the key validity period can be minutes. The version number of the KMS configuration file may be a version number set for the key. For example, the version number after the key in the key system of KMS generated for the first time is 1.0. Of course, the length of the version number can also be increased. For example, the version number of the configuration file is the version number combined with the software version number of the KMS. The roles of KMS can include: no role information (the value of role information can be 0), KMS server (the value of role information can be 1), KMS agent (the value of role information can be 2), KMS client (the value of role information can be 2), The value of information can be 3), other values are invalid values.
ECU的关键数据存储区还可以包括:密钥体系的构建状态(KMS_KH_BuildStatus),KMS密钥体系中的密钥构建成功的计数器(KMS_KH_BuildCounter),KMS密钥体系构建成功完成的时间(KMS_KH_BuildDate),KMS密钥体系的构建参数存储的完整性校验码(KMS_KH_BuildMac)和KMS密钥体系的构建采用的临时密钥KMS_KH_BuildKTemp。本申请中的密钥体系的构建可以表示为KMS构建的至少一个长期密钥(第一密钥)。密钥 体系的构建状态可以包括:未构建、构建中、构建成功、构建失败。例如,密钥体系的构建状态的取值可以为0~3,其中,0表示未构建,1表示构建中,2表示构建成功,3表示构建失败。KMS密钥体系中的密钥构建成功的计数器,可以用于表示当前构建成功的密钥的数量。KMS密钥体系构建成功完成的时间,在当前存在KMS密钥体系构建的过程时,KMS密钥体系构建成功完成的时间可以表示上一次KMS密钥体系构建成功完成的日期和时间。精度存储到分钟级,比如本次构建成功的时间为2020-9-29 10:20:25,将该时间从0000年0点0分计算,实际经过多少分钟,注意闰年等处理。当然也可以采用其他方式。需要说明的是,密钥体系的构建状态(KMS_KH_BuildStatus),KMS密钥体系中的密钥构建成功的计数器(KMS_KH_BuildCounter),KMS密钥体系构建成功完成的时间(KMS_KH_BuildDate)是用于该ECU在KMS的密钥体系构建过程中确定该ECU的密钥构建的相关信息的,因此,这些参数只能是该ECU进行写入,外部的设备没有写入的权限。The key data storage area of the ECU can also include: the construction status (KMS_KH_BuildStatus) of the key system, the counter (KMS_KH_BuildCounter) of the key construction success in the KMS key system, the time (KMS_KH_BuildDate) of the KMS key system construction successful completion, KMS The integrity check code (KMS_KH_BuildMac) stored in the construction parameters of the key system and the temporary key KMS_KH_BuildKTemp used in the construction of the KMS key system. The construction of the key system in this application may be expressed as at least one long-term key (first key) constructed by the KMS. The construction status of the key system can include: not constructed, under construction, successful construction, and construction failure. For example, the value of the construction status of the key system may be 0 to 3, wherein 0 indicates that it is not constructed, 1 indicates that it is under construction, 2 indicates that the construction is successful, and 3 indicates that the construction fails. The key construction success counter in the KMS key system can be used to indicate the number of keys that are currently successfully constructed. The time when the construction of the KMS key system is successfully completed. When there is a process of constructing the KMS key system, the time when the construction of the KMS key system is successfully completed may indicate the date and time when the construction of the KMS key system was successfully completed last time. The accuracy is stored at the minute level. For example, the successful time of this build is 2020-9-29 10:20:25. Calculate the time from 0:00 in 0000, how many minutes have actually passed, and pay attention to leap year and other processing. Of course, other methods can also be used. It should be noted that the construction status of the key system (KMS_KH_BuildStatus), the counter of the key construction success in the KMS key system (KMS_KH_BuildCounter), and the time when the KMS key system construction was successfully completed (KMS_KH_BuildDate) are used for the ECU in the KMS The relevant information of the ECU's key construction is determined during the construction of the key system. Therefore, these parameters can only be written by the ECU, and external devices do not have permission to write.
需要说明的是,在密钥体系构建过程中,生成的构建状态、密钥的生成状态等数据进行固化存储时,可以通过用于存储KMS密钥体系的构建参数的完整性校验码进行验证。该完整性校验码可以单独存储,也可以是存储在空闲的KEY_<n>中。It should be noted that during the construction process of the key system, when data such as the generated construction status and key generation status are solidified and stored, they can be verified by the integrity check code used to store the construction parameters of the KMS key system . The integrity check code can be stored separately, or stored in a free KEY_<n>.
KMS密钥体系的构建采用的临时密钥KMS_KH_BuildKTemp,也可以单独存储,也可以是存储在空闲的KEY_<n>中,在密钥构建体系中的密钥构建完成后,该临时密钥可以删除。在该示例中,n小于或等于20。具体值可以根据实际的需要确定。The temporary key KMS_KH_BuildKTemp used in the construction of the KMS key system can also be stored separately or in an idle KEY_<n>. After the key construction in the key construction system is completed, the temporary key can be deleted . In this example, n is less than or equal to 20. The specific value can be determined according to actual needs.
非易失性存储区(non-volatile),用于存储固定密钥、长期密钥、或安全启动的安全校验码。易失性存储区(Volatile),可以用于在灌装密钥时,SHE对灌装的密钥进行安全验证时进行临时存储的密钥,还可以用于临时存放非密钥数据、或临时数据。例如,ECU可以通过CMD_LOAD_KEY的命令,以密文方式发送给SHE,SHE会对该命令的入参进行完整性校验,然后解密,获得该命令携带的密钥,并向该位置存储密钥。The non-volatile storage area (non-volatile) is used to store fixed keys, long-term keys, or security verification codes for secure boot. Volatile storage area (Volatile), which can be used for temporary storage of keys when SHE performs security verification on filled keys when filling keys, and can also be used for temporary storage of non-key data, or temporary data. For example, the ECU can send the CMD_LOAD_KEY command to the SHE in cipher text, and the SHE will perform an integrity check on the input parameters of the command, and then decrypt it to obtain the key carried by the command, and store the key in this location.
每个密钥在存储时,除密钥外,还可以会包含一些其他的信息,比如,写保护(write-protection)标识位、安全启动失败(secure boot failure)标识位、调试器激活(debugger activation)标识位、通配符唯一角色标识(wildcard unique identification item,wildcard UID)、密钥使用标识位(key-usage)、明文密钥标识位、密钥更新计数(counter)标识位、密钥构建状态标识位(buildstatus)、密钥索引(KeyID)等,一种可能的实现方式,可以如表3所示。When each key is stored, in addition to the key, it can also contain some other information, such as write-protection (write-protection) flag, secure boot failure (secure boot failure) flag, debugger activation (debugger activation) identification bit, wildcard unique identification item (wildcard UID), key usage identification bit (key-usage), plaintext key identification bit, key update count (counter) identification bit, key construction status An identification bit (buildstatus), a key index (KeyID), etc., a possible implementation manner, may be shown in Table 3.
表3table 3
Figure PCTCN2021095348-appb-000003
Figure PCTCN2021095348-appb-000003
Figure PCTCN2021095348-appb-000004
Figure PCTCN2021095348-appb-000004
其中,表3中的X表示在存储该行密钥或安全校验码时,必须包含有该列的内容。X/-表示在存储该行密钥或安全校验码时,可以根据产品或KMS业务的需要包含该项内容。空白表示在存储该行密钥或安全校验码时,可以不含该列的内容。Wherein, X in Table 3 indicates that when storing the row key or security check code, the content of the column must be included. X/- indicates that when storing the row key or security check code, this content can be included according to the needs of the product or KMS business. A blank means that the content of this column may not be included when storing the row key or security check code.
写保护(write-protection)标识位中,如果写保护标识位的值为1,则不允许该密钥的再次更新。如果写保护标识为的值为0,则表示该密钥允许更新。安全启动失败(secure boot failure)标识位和调试器激活(debugger activation)标识位表示SHE安全启动后的该密钥的状态。其中,安全启动失败标识位还可以是启动保护(boot-protection)标识位,调试器激活标识位可以是调试保护(debugger-protection)标识位。通配符UID(wildcard UID)标识位用于表示、密钥使用标识位(key-usage)用于标识、明文密钥标识位用于标识该密钥是否明文存储。密钥更新计数标识位用于标识密钥更新次数,该更新此时可以通过密钥更新计数器的取值确定。每个密钥可能的占用的比特位数的最大长度可以如表2中的全部数据(Overall data)指示位所示,约束了每个memory slot的块的大小不能小于最大值。In the write-protection identification bit, if the value of the write-protection identification bit is 1, the key is not allowed to be updated again. If the value of the write-protect flag is 0, it means that the key allows updates. The secure boot failure (secure boot failure) flag and the debugger activation (debugger activation) flag indicate the state of the key after the SHE is securely booted. Wherein, the secure boot failure flag may also be a boot-protection flag, and the debugger activation flag may be a debugger-protection flag. The wildcard UID (wildcard UID) identification bit is used to indicate, the key usage identification bit (key-usage) is used to identify, and the plaintext key identification bit is used to identify whether the key is stored in plain text. The key update count identification bit is used to identify the number of key update times, and the update can be determined by the value of the key update counter at this time. The maximum length of the number of bits that may be occupied by each key can be shown in the overall data (Overall data) indicator in Table 2, and the block size of each memory slot is constrained not to be less than the maximum value.
ECU的UID,可以是本ECU对应的UID,也可能是缺省标识(wildcard UID)。例如,UID取值为0时,UID可以作为缺省标识。其中,缺省标识用于确定是否允许使用任意UID来向对应存储区灌装(覆盖式更新)密钥。例如,wildcard UID为1时,允许使用任意UID来灌装该ECU的密钥,wildcard UID如果为0,则不允许使用任意UID来灌装该ECU的密钥。memory slot用于指示向第一密钥在ECU存储区中存储的密钥地址。UID可以是120 bits,也可以为128 bits。The UID of the ECU can be the UID corresponding to the ECU, or the default identifier (wildcard UID). For example, when the UID value is 0, the UID can be used as a default identifier. Wherein, the default identifier is used to determine whether any UID is allowed to be used to fill (overwrite update) keys into the corresponding storage area. For example, when the wildcard UID is 1, it is allowed to use any UID to fill the key of the ECU. If the wildcard UID is 0, it is not allowed to use any UID to fill the key of the ECU. The memory slot is used to indicate the key address stored in the ECU storage area to the first key. UID can be 120 bits or 128 bits.
密钥构建状态(BuildStatus)是针对一个密钥的构建状态,该密钥构建状态可以占用1bit。密钥构建状态的取值可以为0~3,其中,0表示未构建,1表示构建中,2表示构建成功,3表示构建失败。需要说明的是,该密钥的状态信息表示在该ECU中构建成功,并不涉及该密钥在其他设备上是否成功灌装。一种可能的实现方式,可以根据KMS的密钥体系的构建状态,确定该密钥涉及的所有相关设备是否都持有了该密钥。例如,在KMS的密钥体系的构建状态为构建成功时,确定该密钥涉及的所有相关设备都持有了该密钥。The key build status (BuildStatus) refers to the build status of a key, and the key build status can occupy 1 bit. The value of the key construction status can be 0 to 3, where 0 means not being built, 1 means building in progress, 2 means building successfully, and 3 means building failed. It should be noted that the status information of the key indicates that the key is successfully built in the ECU, and does not involve whether the key is successfully filled on other devices. A possible implementation manner may determine whether all related devices involved in the key hold the key according to the construction status of the key system of the KMS. For example, when the construction status of the key system of the KMS is successfully constructed, it is determined that all relevant devices involved in the key hold the key.
密钥索引(KeyID),可以是由KMS分配的、与安全存储硬件的密钥地址无关的密钥索引,也可以是与密钥地址相关联的值。例如,可以占用32 bits,与密钥一起安装。The key index (KeyID) may be a key index assigned by the KMS and not related to the key address of the secure storage hardware, or may be a value associated with the key address. For example, can occupy 32 bits, installed with the key.
本申请中,车辆的密钥体系可以包括:配置文件、固定密钥、长期密钥等。其中,固定密钥可以包括一车一密的固定密钥,还可以包括涉及至少一个车载设备的固定密钥。涉及至少一个车载设备的固定密钥可以是限定在涉及至少一个车载设备中使用。长期密钥也可以包括一车一密的长期密钥,还可以包括涉及至少一个车载设备的长期密钥。涉及至少一个车载设备的固定密钥可以是限定在涉及至少一个车载设备中使用。本申请中,固定密钥可以为从车外获取的密钥,长期密钥可以是车辆自身生成的密钥。在进行车辆的密钥体系构建过程中,为保证车辆内的车载设备对密钥体系的构建和管理的安全可信,车辆内的车载设备及对应的SHE在构建密钥传输的与密钥体系相关的消息,都需要采用安全验证密钥进行加密或完整性保护。In this application, the key system of the vehicle may include: a configuration file, a fixed key, a long-term key, and the like. Wherein, the fixed key may include a one-vehicle-one-secret fixed key, and may also include a fixed key related to at least one vehicle-mounted device. The fixed key related to the at least one vehicle-mounted device may be limited to be used in relation to the at least one vehicle-mounted device. The long-term key may also include a one-vehicle-one-secret long-term key, and may also include a long-term key involving at least one vehicle-mounted device. The fixed key related to the at least one vehicle-mounted device may be limited to be used in relation to the at least one vehicle-mounted device. In this application, the fixed key may be a key obtained from outside the vehicle, and the long-term key may be a key generated by the vehicle itself. In the process of building the key system of the vehicle, in order to ensure the security and credibility of the vehicle-mounted equipment on the construction and management of the key system, the vehicle-mounted equipment and the corresponding SHE are building the key transmission and key system Related messages need to be encrypted or integrity protected with a security verification key.
下面介绍触发车辆的密钥体系构建的多种场景,即触发第一车载设备获得第一消息的 场景可能有多种,以第一车载设备为服务端为例,该第一SHE可以用于生成第一密钥。在一些实施例中,服务端和SHE可以设置在一个ECU上,用于管理该ECU的密钥。在该ECU包括服务端和SHE时,服务端与SHE之间的操作,可以通过车外设备(例如,云端或管理固定密钥的终端(例如,管理固定密钥的APP)的固定密钥作为安全验证密钥、或车内的服务端自身提供的固定密钥或临时密钥作为安全验证密钥。下面以场景1~场景4举例说明。The following introduces various scenarios for triggering the construction of the key system of the vehicle, that is, there may be various scenarios for triggering the first vehicle-mounted device to obtain the first message. Taking the first vehicle-mounted device as the server as an example, the first SHE can be used to generate first key. In some embodiments, the server and SHE can be set on an ECU, and are used to manage the key of the ECU. When the ECU includes the server and the SHE, the operation between the server and the SHE can be performed through the fixed key of the off-vehicle device (for example, the cloud or a terminal that manages the fixed key (for example, an APP that manages the fixed key)) The security verification key, or the fixed key or temporary key provided by the server in the vehicle itself is used as the security verification key. The following uses scenarios 1 to 4 as examples.
场景1,通过非KMS设备向车辆的KMS服务端发起配置文件更新消息(例如,第一消息),此时,可以通过非KMS设备的固定密钥对配置文件更新消息进行加密和完整性保护的安全验证。该配置文件更新消息可以包括以下至少一项:更新的配置文件、配置文件的安全验证码、KMS角色信息等。Scenario 1: A configuration file update message (for example, the first message) is initiated to the KMS server of the vehicle through a non-KMS device. At this time, the configuration file update message can be encrypted and integrity-protected through the fixed key of the non-KMS device. safety verification. The configuration file update message may include at least one of the following: an updated configuration file, a security verification code of the configuration file, KMS role information, and the like.
在一些实施例中,非KMS设备可以是云端服务器或管理车辆密钥的终端,此时,云端服务器或管理车辆密钥的终端可以根据云端服务器的固定密钥对该第一消息进行加密和完整性保护的安全验证。在另一些实施例中,非KMS设备可以是车辆的CDC或中控屏,CDC或中控屏响应于用户的配置文件更新的确认操作,CDC或中控屏对应的SHE可以根据车辆的一车一密的固定密钥生成第一消息,即CDC或中控屏可以根据一车一密的固定密钥对该第一消息进行加密和完整性保护的安全验证。In some embodiments, the non-KMS device can be a cloud server or a terminal that manages the vehicle key. At this time, the cloud server or the terminal that manages the vehicle key can encrypt and complete the first message according to the fixed key of the cloud server. Security verification for sex protection. In some other embodiments, the non-KMS device can be the CDC or the central control panel of the vehicle. The CDC or the central control panel responds to the confirmation operation of the user's configuration file update. The SHE corresponding to the CDC or the central control panel can be based on a vehicle's One secret fixed key generates the first message, that is, the CDC or the central control panel can perform encryption and integrity protection security verification on the first message according to the one car one secret fixed key.
可选的,在车辆的KMS服务端接收到配置文件初始化消息或更新消息后,可以经过验证成功后,对服务端对应的SHE中的配置文件的相关信息进行初始化或更新。另外,服务端还可以向代理端或客户端发送配置文件初始化消息或更新消息,使得代理端或客户端在对配置文件初始化消息或更新消息验证成功后,对代理端或客户端对应的SHE中的配置文件的相关信息进行初始化或更新。可选的,服务端也可以不向客户端转发该消息,通过代理端在对配置文件初始化消息或更新消息验证成功后,也可以向客户端发送配置文件初始化消息或更新消息,使得客户端在对配置文件初始化消息或更新消息验证成功后,对客户端对应的SHE中的配置文件的相关信息进行初始化或更新。Optionally, after the KMS server of the vehicle receives the configuration file initialization message or update message, it can initialize or update the relevant information of the configuration file in the SHE corresponding to the server after successful verification. In addition, the server can also send a configuration file initialization message or an update message to the agent or client, so that the agent or client can verify the configuration file initialization message or update message successfully, and the agent or client corresponding SHE The relevant information of the configuration file is initialized or updated. Optionally, the server may not forward the message to the client. After the agent successfully verifies the configuration file initialization message or update message, it may also send the configuration file initialization message or update message to the client, so that the client After the configuration file initialization message or update message is verified successfully, the related information of the configuration file in the SHE corresponding to the client is initialized or updated.
考虑到KMS中的服务端、代理端和客户端各自对应的SHE执行的功能不同。例如,服务端的SHE对应生成加密的第一密钥及生成安全验证密钥,及配合KMS服务端对车内密钥体系的构建进行管理。代理端的SHE用于配合KMS的服务端完成代理端的域内的各客户端的第一密钥的生成及灌装。因此,本申请中,可以为KMS中的不同车载设备配置不同的KMS角色,以使服务端或代理端可以更好的对各车载设备的密钥进行管理。Considering that the server, agent, and client in KMS perform different functions on the respective SHEs. For example, the SHE on the server side generates the encrypted first key and the security verification key, and cooperates with the KMS server side to manage the construction of the key system in the vehicle. The agent's SHE is used to cooperate with the KMS server to complete the generation and filling of the first key of each client in the agent's domain. Therefore, in this application, different KMS roles can be configured for different vehicle-mounted devices in the KMS, so that the server or agent can better manage the keys of each vehicle-mounted device.
在一些实施例中,车辆的KMS服务端可以根据初始化或更新的配置文件,确定KMS角色信息的初始化或更新,及初始化或更新配置文件的安全验证码。并为各车载设备配置KMS角色信息和相应的配置文件的安全验证码。下面以具体的场景示例介绍配置文件初始化或更新时,生成KMS角色信息的配置消息的过程。In some embodiments, the KMS server of the vehicle may determine the initialization or update of the KMS role information and the security verification code of the initialization or update configuration file according to the initialized or updated configuration file. And configure the KMS role information and the security verification code of the corresponding configuration file for each vehicle-mounted device. The following describes the process of generating a configuration message for KMS role information when a configuration file is initialized or updated with a specific scenario example.
场景1.1,在初始化的KMS配置文件下发时,KMS可以为各车载设备(例如,车辆的KMS服务端、车辆的代理端和客户端)生成KMS角色信息的配置消息。KMS角色信息可以包括以下至少一项:KMS角色(KMS_CFG_Role)、配置文件版本号(KMS_CFG_Version)、KMS构建的长期密钥的有效期(KMS_CFG_KeyLifetime)等。Scenario 1.1, when the initialized KMS configuration file is delivered, the KMS can generate a KMS role information configuration message for each vehicle-mounted device (for example, the KMS server of the vehicle, the agent and the client of the vehicle). The KMS role information may include at least one of the following: KMS role (KMS_CFG_Role), configuration file version number (KMS_CFG_Version), validity period of a long-term key constructed by KMS (KMS_CFG_KeyLifetime), and the like.
场景1.2,在KMS的配置文件更新时,尤其是通信安全域的定义发生变化时,需要重新对车辆的KMS角色信息更新,也可以向各车载设备发送KMS角色信息的配置消息,以更新车辆内的各车载设备的KMS角色信息。Scenario 1.2, when the KMS configuration file is updated, especially when the definition of the communication security domain changes, it is necessary to re-update the KMS role information of the vehicle, or send a configuration message of the KMS role information to each vehicle-mounted device to update the vehicle internal The KMS role information of each vehicle-mounted device.
在车辆的KMS服务端接收到该KMS角色信息的配置消息时,车辆的KMS服务端转发该消息至服务端对应的SHE,服务端的SHE可以基于车外的安全验证密钥,对该KMS角色信息的配置消息进行验证,验证成功后,存储相应的KMS角色信息到SHE中的相应位置上。可选的,在该KMS角色信息的配置消息携带配置文件的初始化或更新的安全验证码时,SHE还可以在验证成功后,存储更新的配置文件的安全验证码到SHE中的KMS_CFG_MAC的位置上。When the KMS server of the vehicle receives the configuration message of the KMS role information, the KMS server of the vehicle forwards the message to the corresponding SHE of the server, and the SHE of the server can verify the KMS role information based on the security verification key outside the vehicle. The configuration message is verified. After the verification is successful, the corresponding KMS role information is stored in the corresponding position in the SHE. Optionally, when the configuration message of the KMS role information carries the initialization or updated security verification code of the configuration file, the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
在车辆的KMS服务端接收到该KMS角色信息的配置消息后,车辆的KMS服务端还可以转发该消息至代理端或客户端。After the vehicle's KMS server receives the KMS role information configuration message, the vehicle's KMS server can also forward the message to the agent or client.
从而,在车辆的KMS代理端接收到该KMS角色信息的配置消息后,代理端向代理端对应的SHE转发该消息,代理端的SHE可以基于车外的安全验证密钥,对该KMS角色信息的配置消息进行验证,验证成功后,可以存储相应的KMS角色信息到SHE中的相应位置上。可选的,在该KMS角色信息的配置消息携带配置文件的初始化或更新的安全验证码时,SHE还可以在验证成功后,存储更新的配置文件的安全验证码到SHE中的KMS_CFG_MAC的位置上。Therefore, after the KMS agent of the vehicle receives the configuration message of the KMS role information, the agent forwards the message to the SHE corresponding to the agent, and the SHE of the agent can verify the KMS role information based on the security verification key outside the vehicle. The configuration message is verified. After the verification is successful, the corresponding KMS role information can be stored in the corresponding position in the SHE. Optionally, when the configuration message of the KMS role information carries the initialization or updated security verification code of the configuration file, the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
相应的,在车辆的KMS代理端接收到该KMS角色信息的配置消息后,代理端还可以将该消息转发给代理端管理的各客户端。Correspondingly, after the KMS agent of the vehicle receives the configuration message of the KMS role information, the agent can also forward the message to each client managed by the agent.
相应的,在车辆的KMS客户端可以通过服务端或代理端接收到该KMS角色信息的配置消息,此时,客户端向客户端对应的SHE转发该消息,客户端对应的SHE可以基于车外的安全验证密钥,对该KMS角色信息的配置消息进行验证,验证成功后,可以存储相应的KMS角色信息到SHE中的相应位置上。可选的,在该KMS角色信息的配置消息携带配置文件的初始化或更新的安全验证码时,SHE还可以在验证成功后,存储更新的配置文件的安全验证码到SHE中的KMS_CFG_MAC的位置上。Correspondingly, the KMS client of the vehicle can receive the configuration message of the KMS role information through the server or agent. At this time, the client forwards the message to the corresponding SHE of the client. The security verification key is used to verify the configuration message of the KMS role information. After the verification is successful, the corresponding KMS role information can be stored in the corresponding position in the SHE. Optionally, when the configuration message of the KMS role information carries the initialization or updated security verification code of the configuration file, the SHE can also store the updated security verification code of the configuration file in the position of KMS_CFG_MAC in the SHE after the verification is successful .
具体的,针对不同的场景,SHE验证KMS角色信息的配置消息方式也可以有多种,下面以方式1.3~方式1.4举例说明。Specifically, for different scenarios, there may be multiple configuration message modes for the SHE to verify the KMS role information, and modes 1.3 to 1.4 are used as examples below.
方式1.3,在密钥体系构建开始时,可以通过密钥体系构建启动消息(CMD_KMS_KH_BUILD_START),指示SHE开启密钥体系中的密钥的构建,SHE可以通过对密钥体系构建启动消息进行验证,在验证成功后,将密钥体系构建状态(KMS_KH_BuildStatus)修改为构建中。在密钥体系构建状态为未构建时,可以通过的密钥体系构建启动消息携带KMS角色信息的配置消息中的信息,此时,SHE可以通过对密钥体系构建启动消息进行验证,在验证成功后,再对KMS角色信息的配置消息中的信息进行验证。具体验证方式可以参见下文中的CMD_KMS_SET_CFG_INFO命令的验证。Mode 1.3, when the key system construction starts, the key system construction start message (CMD_KMS_KH_BUILD_START) can be used to instruct the SHE to start the construction of the key in the key system, and the SHE can verify the key system construction start message. After the verification is successful, change the key system construction status (KMS_KH_BuildStatus) to under construction. When the key system construction status is unconstructed, the key system construction startup message that can be passed carries the information in the configuration message of the KMS role information. At this time, the SHE can verify the key system construction startup message, and the verification succeeds. After that, verify the information in the configuration message of the KMS role information. For the specific verification method, please refer to the verification of the CMD_KMS_SET_CFG_INFO command below.
方式1.4,在密钥体系构建过程中,SHE中的KMS的任何参数的变更,SHE都可以根据密钥体系构建状态(KMS_KH_BuildStatus)是否为“构建中”,确定KMS的任何参数是否满足更新要求。当密钥体系构建状态是“构建成功”的状态时,对KMS角色信息的配置消息中的信息进行验证,具体验证方式可以参见下文中的CMD_KMS_SET_CFG_INFO命令的验证。当密钥体系构建状态不是“构建中”的状态时,确定KMS角色信息的配置消息验证失败。Mode 1.4, during the key system construction process, if any parameter of KMS in SHE is changed, SHE can determine whether any parameter of KMS meets the update requirements according to whether the key system construction status (KMS_KH_BuildStatus) is "constructing". When the key system construction status is "constructed successfully", verify the information in the KMS role information configuration message. For the specific verification method, refer to the verification of the CMD_KMS_SET_CFG_INFO command below. When the construction status of the key system is not "under construction", the verification of the configuration message for determining the KMS role information fails.
另外,当密钥体系构建状态不是“构建成功”的状态时,受密钥体系构建状态影响的各密钥(例如,密钥体系构建涉及的至少一个第一密钥)将不可使用。例如,在车载设备请求使用第一密钥时,SHE针对该请求对第一密钥涉及的密钥体系构建状态进行验证, 在验证失败后,SHE可以返回“密钥状态错误,需重新构建KMS的密钥体系”的状态码,比如,ERC_KMS_KH_NEED_TO_REBUILD。In addition, when the key system construction status is not "construction successful", each key affected by the key system construction status (for example, at least one first key involved in the key system construction) will not be available. For example, when the on-board device requests to use the first key, SHE verifies the construction status of the key system involved in the first key according to the request. After the verification fails, SHE can return "the key status is wrong, and the KMS needs to be rebuilt." key system" status code, for example, ERC_KMS_KH_NEED_TO_REBUILD.
例如,KMS向车载设备发送加密的第一密钥的灌装消息时,KMS可以向车辆内的各车载设备发送KMS角色信息。车辆内的各车载设备接收到各车载设备对应的KMS角色信息的配置消息后,可以根据该车载设备对应的SHE对该KMS角色信息的配置消息进行安全验证,在验证成功后,将该KMS角色信息写入SHE中,并写入相应的安全验证码。For example, when the KMS sends an encrypted filling message of the first key to the vehicle-mounted device, the KMS may send KMS role information to each vehicle-mounted device in the vehicle. After each vehicle-mounted device in the vehicle receives the configuration message of the KMS role information corresponding to each vehicle-mounted device, it can perform security verification on the configuration message of the KMS role information according to the SHE corresponding to the vehicle-mounted device. After the verification is successful, the KMS role information The information is written into SHE, and the corresponding security verification code is written.
举例来说KMS角色信息的配置消息可以为CMD_KMS_SET_CFG_INFO命令。该命令的入参可以如表4所示。入参可以理解为传入的参数,入参可以用于在命令通过第一车载设备向第一SHE发送,请求第一SHE验证时携带入参,例如CMD_KMS_SET_CFG_INFO等命令。For example, the configuration message of KMS role information may be a CMD_KMS_SET_CFG_INFO command. The input parameters of the command may be as shown in Table 4. The input parameter can be understood as the incoming parameter, and the input parameter can be used to carry the input parameter when the command is sent to the first SHE through the first vehicle-mounted device to request the first SHE to verify, such as CMD_KMS_SET_CFG_INFO and other commands.
表4Table 4
Figure PCTCN2021095348-appb-000005
Figure PCTCN2021095348-appb-000005
其中,入参M1满足:Among them, the input parameter M1 satisfies:
M1=KEY_ID|KMS Role|KMS_CFG_Version|KMS_CFG_KeyLifetimeM1=KEY_ID|KMS Role|KMS_CFG_Version|KMS_CFG_KeyLifetime
其中“|”可以理解为拼接,例如M1可以为将KEY_ID、KMS Role、KMS_CFG_Version以及KMS_CFG_KeyLifetime的对应的字节拼接到一起。例如,当传输M1的过程中,可以依次传输KEY_ID、KMS Role、KMS_CFG_Version以及KMS_CFG_KeyLifetime等字节。Among them, "|" can be understood as splicing. For example, M1 can splice the corresponding bytes of KEY_ID, KMS Role, KMS_CFG_Version, and KMS_CFG_KeyLifetime together. For example, in the process of transmitting M1, bytes such as KEY_ID, KMS Role, KMS_CFG_Version, and KMS_CFG_KeyLifetime can be transmitted in sequence.
一种可能的场景中,在初始配置文件下发时,KEY_ID可以是车辆的固定密钥。另一种可能的场景中,在车辆的长期密钥的生成过程中,KMS服务端根据KMS的配置文件为自身配置KMS角色信息及相应的长期密钥时,考虑到第一车载设备已获得相应的SHE生成的临时密钥,因此,KEY_ID可以为临时密钥对应的密钥地址。In a possible scenario, when the initial configuration file is issued, the KEY_ID may be a fixed key of the vehicle. In another possible scenario, when the KMS server configures the KMS role information and the corresponding long-term key for itself according to the KMS configuration file during the generation of the long-term key of the vehicle, it is considered that the first vehicle-mounted device has obtained the corresponding The temporary key generated by SHE, therefore, KEY_ID can be the key address corresponding to the temporary key.
入参M2满足:M2=CMAC(Key,M1)The input parameter M2 satisfies: M2=CMAC(Key,M1)
即通过入参M2对M1进行加密和完整性保护,对M1进行加密的密钥可以是KEY_ID对应的密钥。从而,在第一车载设备向第一车载设备对应的第一SHE发送该命令时,SHE可以根据KEY_ID对该命令进行安全验证。即SHE可以根据SHE存储的KEY_ID对应的密钥对M1进行CMAC运算,获得M2’,在确定M2’与M2相等时,则确定该命令验证成功。That is, M1 is encrypted and integrity protected by entering parameter M2, and the key used to encrypt M1 may be the key corresponding to KEY_ID. Therefore, when the first vehicle-mounted device sends the command to the first SHE corresponding to the first vehicle-mounted device, the SHE can perform security verification on the command according to the KEY_ID. That is, SHE can perform CMAC operation on M1 according to the key corresponding to KEY_ID stored in SHE to obtain M2', and when M2' is determined to be equal to M2, it is determined that the command verification is successful.
可选的,在配置文件更新后,车辆的KMS服务端可以确定是否需要更新车辆的固定密钥,即在车辆的KMS服务端确定根据更新后的配置文件确定需要更新车辆的固定密钥时,可以向非KMS设备发送提醒消息,提醒非KMS设备生成固定密钥,并发起固定密钥灌装的消息。Optionally, after the configuration file is updated, the KMS server of the vehicle can determine whether the fixed key of the vehicle needs to be updated, that is, when the KMS server of the vehicle determines that the fixed key of the vehicle needs to be updated according to the updated configuration file, A reminder message can be sent to a non-KMS device to remind the non-KMS device to generate a fixed key and initiate a fixed key filling message.
可选的,在KMS的配置文件初始化或更新后,根据更新后或初始化后的KMS角色信息,KMS还可以确定车内KMS的密钥体系中待生成的长期密钥,从而,触发待生成的长期密钥的生成过程。Optionally, after the KMS configuration file is initialized or updated, according to the updated or initialized KMS role information, the KMS can also determine the long-term key to be generated in the key system of the in-vehicle KMS, thereby triggering the to-be-generated The long-term key generation process.
场景2,通过非KMS设备向车辆的KMS服务端发起固定密钥灌装的消息,此时,可以通过非KMS设备的固定密钥对更新的固定密钥进行加密和完整性保护的安全验证。在车辆的KMS服务端接收到该固定密钥灌装的消息时,可以向服务端对应的SHE发送固定密钥灌装的消息,服务端对应SHE基于车外的安全验证密钥,对该固定密钥灌装的消息进 行验证,验证成功后,存储更新的固定密钥。例如,在该固定密钥为GLOBAL_FIX_KEY时,服务端对应SHE存储该固定密钥到GLOBAL_FIX_KEY的位置上,在该固定密钥为MAC_FIX_KEY时,SHE存储该固定密钥到MAC_FIX_KEY的位置上。在一些实施例中,可由车外设备,生成CMD_LOAD_KEY的入参,用于车辆灌装第一密钥。本申请中,该方式主要用于第一密钥为固定密钥的场景,也可以用于第一密钥为长期密钥的场景,在此不做限定。Scenario 2: A non-KMS device initiates a fixed key filling message to the KMS server of the vehicle. At this time, the updated fixed key can be encrypted and integrity-protected for security verification using the fixed key of the non-KMS device. When the KMS server of the vehicle receives the message of filling the fixed key, it can send the message of filling the fixed key to the SHE corresponding to the server. The key filling message is verified, and after the verification is successful, the updated fixed key is stored. For example, when the fixed key is GLOBAL_FIX_KEY, the server stores the fixed key in the position of GLOBAL_FIX_KEY corresponding to the SHE, and when the fixed key is MAC_FIX_KEY, the SHE stores the fixed key in the position of MAC_FIX_KEY. In some embodiments, the input parameter of CMD_LOAD_KEY can be generated by the equipment outside the vehicle, which is used for filling the first key in the vehicle. In this application, this method is mainly used in a scenario where the first key is a fixed key, and may also be used in a scenario where the first key is a long-term key, which is not limited here.
一种可能的实现方式,外部设备通过向第一车载设备(例如,服务端)发送第一密钥加载消息,第一车载设备可以将第一密钥加载消息(例如,可以携带CMD_LOAD_KEY中的入参)发送给第一车载设备对应的SHE验证,在验证成功后,存储该第一密钥,并根据第一密钥加载消息,生成第一密钥加载的响应消息(例如,可以携带CMD_LOAD_KEY的出参),通过第一密钥加载的响应消息反馈给车外设备,车外设备可以根据第一密钥加载的响应消息进行验证,确定第一车载设备的第一密钥加载是否成功。In a possible implementation, the external device sends the first key loading message to the first vehicle-mounted device (for example, the server), and the first vehicle-mounted device can load the first key parameter) sent to the corresponding SHE verification of the first vehicle-mounted device. After the verification is successful, the first key is stored, and according to the first key loading message, a response message for the first key loading is generated (for example, a message that can carry CMD_LOAD_KEY output parameter), the response message of the first key loading is fed back to the off-vehicle device, and the off-vehicle device can verify according to the response message of the first key loading to determine whether the first key loading of the first on-vehicle device is successful.
另一种可能的实现方式,外部设备通过向第一车载设备(例如,服务端)发送第一密钥加载消息,服务端将第一密钥加载消息,转发给车内各第二车载设备,其中,第二车载设备可以为代理端或客户端。其中,一种可能的实现方式为服务端发送给代理端或客户端,或者,服务端通过密钥管理工具转发该第一密钥加载消息。出参可以理解为在接收到命令的SHE对该命令进行验证成功后,返回时传出的参数,出参可以用于将传出的参数传递给命令使用。In another possible implementation, the external device sends the first key loading message to the first vehicle-mounted device (for example, the server), and the server forwards the first key-loading message to each second vehicle-mounted device in the vehicle, Wherein, the second vehicle-mounted device may be an agent or a client. Wherein, a possible implementation manner is that the server sends the message to the proxy or the client, or the server forwards the first key loading message through the key management tool. The outgoing parameter can be understood as the parameter sent out when the SHE that receives the command successfully verifies the command, and the outgoing parameter can be used to pass the outgoing parameter to the command.
第二车载设备(KMS的代理端或客户端)将第一密钥加载消息(例如,可以携带CMD_LOAD_KEY中的入参)转发给第二SHE(第二车载设备对应的SHE,其中,第二SHE可以是第二车载设备对应的SHE。该SHE可以是设置在第二车载设备对应的ECU中,也可以是第二车载设备单独设置的,在此不做限定)验证,在验证成功后,在第二SHE中存储该第一密钥,并根据第一密钥加载消息,生成第一密钥加载的响应消息(例如,可以携带CMD_LOAD_KEY的出参),并将第一密钥加载的响应消息反馈给代理端或服务端,从而,再转发给服务端,服务端将可以将该第一密钥加载的响应消息返回给车外设备,车外设备可以根据第一密钥加载的响应消息进行验证,确定第二车载设备(各代理端或客户端)的第一密钥加载是否成功。The second vehicle-mounted device (agent or client of KMS) forwards the first key loading message (for example, may carry the input parameter in CMD_LOAD_KEY) to the second SHE (the SHE corresponding to the second vehicle-mounted device, wherein the second SHE It can be the SHE corresponding to the second vehicle-mounted device. This SHE can be arranged in the ECU corresponding to the second vehicle-mounted device, or it can be set separately by the second vehicle-mounted device, which is not limited here) verification, after the verification is successful, in The first key is stored in the second SHE, and according to the first key loading message, a response message for loading the first key (for example, may carry an output parameter of CMD_LOAD_KEY), and the response message for loading the first key Feedback to the agent or server, and then forwarded to the server, the server will be able to return the response message loaded with the first key to the off-vehicle device, and the off-vehicle device can proceed according to the response message loaded with the first key Verification is to determine whether the first key loading of the second in-vehicle device (each agent or client) is successful.
在第二SHE存储第一密钥(例如,新的固定密钥)后,第二SHE可以设置该第一密钥对应的密钥构建状态。例如,将密钥构建状态BuildStatus设置为“1”,表示该第一密钥为构建成功的状态。After the second SHE stores the first key (for example, a new fixed key), the second SHE can set the key construction state corresponding to the first key. For example, setting the key build status BuildStatus to "1" indicates that the first key is successfully built.
下面具体介绍CMD_LOAD_KEY命令,该命令可以向SHE中的密钥地址(例如,memory slot)指定的存储区安全存储第一密钥。如表5所示。The following specifically introduces the CMD_LOAD_KEY command, which can safely store the first key to the storage area specified by the key address (for example, memory slot) in the SHE. As shown in Table 5.
表5table 5
参数ParameterParameterParameter 参数方向DirectionParameter direction Direction 宽度Width(bit)Width(bit)
M1M1 入参(IN)Input (IN) 128128
M2M2 入参(IN)Input (IN) 256256
M3M3 入参(IN)Input (IN) 128128
M4M4 出参(OUT)OUT parameter (OUT) 256256
M5M5 出参(OUT)OUT parameter (OUT) 128128
车外设备要向第一车载设备或第二SHE中灌装第一密钥时,可以根据提前掌握的已有密钥,例如,SHE中GLOBAL_FIX_KEY的当前值或该位置上的原始密钥,派生出加密密钥K1和完整性密钥K2,来保护CMD_LOAD_KEY的入参,即构造的CMD_LOAD_KEY命令入参为基于保护的。或者,车外设备要向KEY_<n>位置灌装新密钥时,车外设备必须提前知道当前GLOBAL_FIX_KEY的位置上存储的密钥、或者KEY_<n>位置存储的密钥。例如,KEY_<n>表示KEY_1~KEY_10。向某个位置灌装密钥时,必须提前知道该位置存储的原始密钥,或者GLOBAL_FIX_KEY。例如,具体的待灌装密钥对应保护CMD_LOAD_KEY的入参的加密密钥,可以如表6所示。When the off-vehicle device wants to fill the first key into the first vehicle-mounted device or the second SHE, it can derive the existing key according to the existing key in advance, for example, the current value of GLOBAL_FIX_KEY in the SHE or the original key at this position. The encryption key K1 and the integrity key K2 are used to protect the input parameters of CMD_LOAD_KEY, that is, the input parameters of the constructed CMD_LOAD_KEY command are based on protection. Or, when the off-vehicle device wants to fill a new key into the KEY_<n> position, the off-vehicle device must know the key stored in the current GLOBAL_FIX_KEY position or the key stored in the KEY_<n> position in advance. For example, KEY_<n> represents KEY_1 to KEY_10. When filling a key to a location, the original key stored at that location, or the GLOBAL_FIX_KEY, must be known in advance. For example, the specific key to be filled corresponds to the encryption key that protects the input parameter of CMD_LOAD_KEY, as shown in Table 6.
表6Table 6
Figure PCTCN2021095348-appb-000006
Figure PCTCN2021095348-appb-000006
表6中,“X”表示在灌装该行上对应的密钥时,通过相应列上的至少一个密钥作为安全验证密钥进行安全验证。例如,第一密钥为GLOBAL_FIX_KEY时,应通过存储在SHE中的GLOBAL_FIX_KEY作为安全验证密钥构造CMD_LOAD_KEY的入参,实现第一密钥GLOBAL_FIX_KEY灌装的安全性验证。第一密钥为KEY<n>时,可以通过存储在SHE中的GLOBAL_FIX_KEY或KEY<n>作为安全验证密钥构造CMD_LOAD_KEY的入参,实现第一密钥KEY<n>灌装的安全性验证。第一密钥为RAM_KEY时,可以通过存储在SHE中的KEY<n>或SRCERET_KEY或明文(plaintext)作为安全验证密钥构造CMD_LOAD_KEY的入参,实现第一密钥RAM_KEY灌装的安全性验证。In Table 6, "X" indicates that at least one key on the corresponding column is used as the security verification key for security verification when filling the corresponding key on the row. For example, when the first key is GLOBAL_FIX_KEY, the GLOBAL_FIX_KEY stored in the SHE should be used as the input parameter of the security verification key construction CMD_LOAD_KEY to realize the security verification of the first key GLOBAL_FIX_KEY filling. When the first key is KEY<n>, the GLOBAL_FIX_KEY or KEY<n> stored in SHE can be used as the input parameter of the security verification key to construct CMD_LOAD_KEY to realize the security verification of the first key KEY<n> filling . When the first key is RAM_KEY, KEY<n> or SRCERET_KEY or plaintext (plaintext) stored in SHE can be used as the input parameter of the security verification key construction CMD_LOAD_KEY to realize the security verification of the first key RAM_KEY filling.
在一种可选地实施方式中,SHE中还可以设置有消息认证码(message authentication code,MAC)生成器,消息认证码生成器用于按照预设的生成算法处理输入信息以得到消息认证码并输出。当预设的生成算法为CMAC时,第一密钥的ECU根据加密该命令的密钥生成该命令的消息认证码M3,一种可能的实现方式,该命令的消息认证码M3满足以下公式:In an optional implementation manner, a message authentication code (message authentication code, MAC) generator may also be provided in the SHE, and the message authentication code generator is used to process input information according to a preset generation algorithm to obtain a message authentication code and output. When the preset generation algorithm is CMAC, the ECU of the first key generates the message authentication code M3 of the command according to the key for encrypting the command. In a possible implementation, the message authentication code M3 of the command satisfies the following formula:
M3=CMAC(K2,M1|M2)M3=CMAC(K2,M1|M2)
其中,K2为使用KEY_ID对应的安全验证密钥派生出的完整性验证的密钥。KEY_ID对应的安全验证密钥可以是如表3中第一密钥对应使用的安全验证密钥的标识。该安全验证密钥还可以用于派生出对第一密钥进行加密的加密密钥K1。Wherein, K2 is the key for integrity verification derived from the security verification key corresponding to KEY_ID. The security verification key corresponding to the KEY_ID may be the identifier of the security verification key used corresponding to the first key in Table 3. The security verification key can also be used to derive an encryption key K1 for encrypting the first key.
参数M1满足:M1=UID|memory slot|KEY_IDThe parameter M1 satisfies: M1=UID|memory slot|KEY_ID
其中,UID为第一车载设备的唯一角色标识(unique identification item),可以是第一车载设备对应的UID,也可能是缺省标识(wildcard UID)。例如,UID取值为0时,UID可以作为缺省标识。其中,缺省标识用于确定是否允许使用任意UID来向对应存储区灌装(覆盖式更新)密钥。例如,wildcard UID为1时,允许使用任意UID来灌装该ECU的密钥,wildcard UID如果为0,则不允许使用任意UID来灌装该ECU的密钥。memory slot用于指示向第一密钥在ECU存储区中存储的密钥地址。Wherein, the UID is a unique identification item (unique identification item) of the first vehicle-mounted device, which may be a UID corresponding to the first vehicle-mounted device, or may be a default identification (wildcard UID). For example, when the UID value is 0, the UID can be used as a default identifier. Wherein, the default identifier is used to determine whether any UID is allowed to be used to fill (overwrite update) keys into the corresponding storage area. For example, when the wildcard UID is 1, it is allowed to use any UID to fill the key of the ECU. If the wildcard UID is 0, it is not allowed to use any UID to fill the key of the ECU. The memory slot is used to indicate the key address stored in the ECU storage area to the first key.
入参的参数M2满足:M2=ENC CBC,K1,IV=0(Counter|Flags|“0…0” 95|Key memory slot) The input parameter M2 satisfies: M2=ENC CBC, K1, IV=0 (Counter|Flags|“0…0” 95 |Key memory slot )
其中,加密函数ENC CBC,K1,IV=0,表示使用AES的CBC模式加密,初始化向量(initialization vector,IV)值为0,使用K1作为加密密钥。 Wherein, the encryption function ENC CBC,K1,IV=0 means that the CBC mode of AES is used for encryption, the initialization vector (initialization vector, IV) value is 0, and K1 is used as the encryption key.
Counter表示第一密钥对应的密钥更新计数,在第一密钥每更新一次后,即第一密钥加载成功后,Counter可以增加1,用于SHE验证该命令是否存在重放攻击。在使用AES_CBC_128加密时,块长度为128 bits,M2可以通过“0…0” 95进行补位,例如,填充95 bit的0。 Counter indicates the key update count corresponding to the first key. After the first key is updated every time, that is, after the first key is loaded successfully, the Counter can be increased by 1, which is used for SHE to verify whether there is a replay attack on the command. When using AES_CBC_128 encryption, the block length is 128 bits, and M2 can be filled with "0...0" 95 , for example, 95 bits of 0 are filled.
Flags可以是根据第一密钥在SHE中存储的信息确定的,例如,Flags满足:Flags can be determined according to the information stored in the SHE by the first key, for example, Flags satisfies:
Flags=write-protection|boot-protection|debugger-protection|key-usage|wildcard。Flags=write-protection|boot-protection|debugger-protection|key-usage|wildcard.
Flags中的参数详见表3中的取值。For the parameters in Flags, see the values in Table 3 for details.
Key memory slot表示向memory slot位置存储的第一密钥。 The Key memory slot indicates the first key stored in the memory slot.
以第二车载设备为例,第二SHE在接收到该CMD_LOAD_KEY命令后,该命令可以包括入参的3个参数。第二SHE可以将CMD_LOAD_KEY命令中的3个入参输入至消息认证码解析器,则消息认证码解析器根据该命令中的入参的M1和M2,及根据SHE自身存储的该CMD_LOAD_KEY命令对应的安全验证密钥,例如,第一密钥对应的安全验证密钥,生成K1和K2,并相应生成消息认证码M3’,在确定消息认证码M3’与M3相同时,确定验证成功。并将命令中携带的第一密钥存储到memory slot对应的位置。Taking the second vehicle-mounted device as an example, after the second SHE receives the CMD_LOAD_KEY command, the command may include three parameters as input parameters. The second SHE can input the 3 input parameters in the CMD_LOAD_KEY command to the message authentication code parser, and then the message authentication code parser uses the M1 and M2 of the input parameters in the command, and the information corresponding to the CMD_LOAD_KEY command stored by the SHE itself. The security verification key, for example, the security verification key corresponding to the first key, generates K1 and K2, and correspondingly generates a message authentication code M3'. When it is determined that the message authentication code M3' is the same as M3, it is determined that the verification is successful. And store the first key carried in the command to the location corresponding to the memory slot.
相应的,第二SHE还可以根据CMD_LOAD_KEY命令中的3个入参,获得该命令的出参,即M4和完整性校验的消息认证码M5,消息认证码M5满足:M5=CMAC(K4,M4)。Correspondingly, the second SHE can also obtain the output parameter of the command according to the 3 input parameters in the CMD_LOAD_KEY command, that is, M4 and the message authentication code M5 of the integrity check, and the message authentication code M5 satisfies: M5=CMAC(K4, M4).
其中,K4是由memory slot存储的第一密钥派生得到的完整性验证使用的密钥。参数M4满足以下公式:M4=M1|EncyptedValue。Among them, K4 is the key used for integrity verification derived from the first key stored in the memory slot. The parameter M4 satisfies the following formula: M4=M1|EncyptedValue.
其中,EncyptedValue=ENC CBC,K3,IV=0(Counter|“1” 1|“0…0” 99),“1” 1表示数值“1”占用1bit,“0…0” 99表示数值“0”占用99个比特位。Counter为SHE针对该第一密钥对应设置的更新计数器的值,可以为28 bits,用于对接收到的CMD_LOAD_KEY命令进行重放攻击的验证。在使用AES_CBC_128加密时,块长度为128 bits。K3是由memory slot中存储的第一密钥(即Key memory slot)派生的加密密钥。 Among them, EncyptedValue=ENC CBC, K3, IV=0 (Counter|“1” 1 |“0…0” 99 ), “1” 1 means the value “1” occupies 1 bit, “0…0” 99 means the value “0” " occupies 99 bits. Counter is the value of the update counter set by the SHE corresponding to the first key, which may be 28 bits, and is used to verify the replay attack on the received CMD_LOAD_KEY command. When using AES_CBC_128 encryption, the block length is 128 bits. K3 is an encryption key derived from the first key stored in the memory slot (that is, the Key memory slot ).
可选的,在固定密钥灌装完成后,车辆的KMS服务端,还可以根据固定密钥的使用范围,确定是否需要更新相应的长期密钥。例如,该固定密钥为车辆的一车一密的固定密钥,此时,车辆的KMS服务端可以确定基于该固定密钥生成的长期密钥更新。车辆的KMS服务端可以向非KMS设备发送长期密钥更新请求,非KMS设备接收到该长期密钥更新请求后,非KMS设备可以对该长期密钥更新请求进行验证,验证成功后,生成第一消息。非KMS设备生成第一消息的方式可以参见场景3。Optionally, after the filling of the fixed key is completed, the KMS server of the vehicle may also determine whether to update the corresponding long-term key according to the scope of use of the fixed key. For example, the fixed key is a vehicle-one-key fixed key, and at this time, the KMS server of the vehicle may determine to update the long-term key generated based on the fixed key. The KMS server of the vehicle can send a long-term key update request to the non-KMS device. After the non-KMS device receives the long-term key update request, the non-KMS device can verify the long-term key update request. After the verification is successful, a second key update request is generated. a message. For the manner in which the non-KMS device generates the first message, refer to scenario 3.
场景3,第一密钥为长期密钥时,可以通过车辆的SHE生成第一密钥,在生成第一密钥的过程中,为保证车载设备与SHE之间的消息的安全性,及车载设备与车载设备之间的消息安全性,可以针对相应的消息进行安全性验证。例如,可以如表7所示,本申请在密钥体系构建过程中,可能涉及到的消息所对应使用的安全验证密钥。具体消息的示例下文中描述。Scenario 3, when the first key is a long-term key, the first key can be generated by the SHE of the vehicle. During the process of generating the first key, in order to ensure the security of the message between the vehicle equipment and the SHE, and The message security between the device and the vehicle-mounted device can be verified for the security of the corresponding message. For example, as shown in Table 7, the security verification keys used for the messages that may be involved in the key system construction process of this application may be used. Examples of specific messages are described below.
表7Table 7
Figure PCTCN2021095348-appb-000007
Figure PCTCN2021095348-appb-000007
X:表示可以使用该密钥作为安全验证密钥。例如,将临时密钥作为安全验证密钥的前提是构造消息时,在能获得该临时密钥时,使用临时密钥作为安全验证密钥。例如,第一车载设备根据临时密钥生成相应的消息,并通过第一SHE进行验证。第二车载设备根据临时密钥生成相应的消息,并通过第二SHE进行验证。Y:表示优先使用该密钥作为安全验证密钥。例如,在长期密钥作为安全验证密钥时,可以是第一车载设备和第二车载设备之间的消息采用的安全验证密钥,并通过各自对应的SHE进行验证。Z:表示仅当通过非KMS设备生成相应消息后发送给对应的第一车载设备或第二车载设备后,该密钥才可用作该消息发送给SHE的安全验证密钥。X: Indicates that the key can be used as a security verification key. For example, the premise of using the temporary key as the security verification key is to use the temporary key as the security verification key when the temporary key can be obtained when constructing the message. For example, the first vehicle-mounted device generates a corresponding message according to the temporary key, and verifies it through the first SHE. The second on-vehicle device generates a corresponding message according to the temporary key, and verifies it through the second SHE. Y: Indicates that the key is preferentially used as the security verification key. For example, when the long-term key is used as the security verification key, it may be a security verification key used in messages between the first vehicle-mounted device and the second vehicle-mounted device, and the verification is performed by respective corresponding SHEs. Z: indicates that the key can be used as the security verification key for sending the message to the SHE only after the corresponding message is generated by the non-KMS device and sent to the corresponding first or second vehicle-mounted device.
需要说明的是,每个消息中的安全验证密钥KEY_ID是指该命令参数的完整性校验码MAC计算时所用密钥的密钥地址(memory slot)。It should be noted that the security verification key KEY_ID in each message refers to the key address (memory slot) of the key used in the calculation of the integrity check code MAC of the command parameter.
每个消息中安全验证密钥KEY_ID是指该命令参数的完整性校验码MAC计算时所用密钥的密钥地址(memory slot)。The security verification key KEY_ID in each message refers to the key address (memory slot) of the key used in the calculation of the integrity check code MAC of the command parameter.
每个消息对应的入参或出参数中,涉及CMAC计算时,参数的非128bits整数倍的部分,可以根据RFC4493进行填充处理。比如Mx是M1、M2组合后(Mx=M1|M2)要进行CMAC计算的bit流,如果Mx的bit长度不是128 bit的整数倍,则需要按照RFC4493的定义进行填充处理,填充方式为Mx|"1"|"0...0"m,即Mx后跟1个bit的1,然后在填充最少bit的0,达到128 bit的整数倍。比如Mx为64bits,则需要填充63bit的0,即可 使Mx|"1"|"0...0"m达到128bits的整数倍。这种填充或者在SHE外填充,还可以是在SHE中填充。本申请中以在SHE内填充为例进行说明。Among the input or output parameters corresponding to each message, when CMAC calculation is involved, the part of the parameter that is not an integer multiple of 128 bits can be filled according to RFC4493. For example, Mx is the bit stream to be calculated by CMAC after the combination of M1 and M2 (Mx=M1|M2). If the bit length of Mx is not an integer multiple of 128 bits, it needs to be filled according to the definition of RFC4493. The filling method is Mx| "1"|"0...0"m, that is, Mx followed by 1 bit of 1, and then filled with 0 of the least bit, reaching an integer multiple of 128 bits. For example, if Mx is 64bits, 63bits of 0 need to be filled, so that Mx|"1"|"0...0"m can reach an integer multiple of 128bits. This kind of filling is either outside the SHE or inside the SHE. In this application, filling in the SHE is taken as an example for illustration.
下面通过场景3.1~场景3.2,举例说明第一密钥为长期密钥时,通过车辆的SHE生成第一密钥的方式。The following uses scenarios 3.1 to 3.2 to illustrate how the first key is generated by the SHE of the vehicle when the first key is a long-term key.
场景3.1,通过非KMS设备向车辆的KMS服务端发起第一消息。In scenario 3.1, a first message is sent to the vehicle's KMS server through a non-KMS device.
在一些实施例中,非KMS设备可以是云端服务器或密钥管理工具或管理密钥的终端等。云端服务器可以根据云端服务器的固定密钥作为安全验证密钥对该第一消息进行加密和完整性保护的安全验证。在另一些实施例中,非KMS设备可以是车辆的CDC或中控屏,通过CDC或中控屏,接收到用户的确认操作,CDC或中控屏响应于用户的确认操作,CDC或中控屏对应的SHE可以根据车辆的一车一密的固定密钥生成第一消息,即CDC或中控屏可以根据一车一密的固定密钥对该第一消息进行加密和完整性保护的安全验证。In some embodiments, the non-KMS device may be a cloud server, a key management tool, or a terminal for managing keys, etc. The cloud server may perform encryption and integrity-protected security verification on the first message according to the fixed key of the cloud server as a security verification key. In some other embodiments, the non-KMS device may be the CDC or the central control panel of the vehicle. Through the CDC or the central control panel, the user's confirmation operation is received, and the CDC or the central control panel responds to the user's confirmation operation. The CDC or the central control panel The SHE corresponding to the screen can generate the first message according to the fixed key of the vehicle, that is, the CDC or the central control screen can encrypt and integrity protect the first message according to the fixed key of the vehicle. verify.
通过非KMS设备向车辆的KMS服务端发起第一消息,例如,在启动密钥体系的构建时,及当前的密钥体系的构建状态为未构建或构建完成中,可以由车外设备或非KMS设备生成第一消息,并向车辆的KMS服务端发送第一消息。例如,可以通过车辆的固定密钥对该第一消息进行加密和完整性保护的安全验证。其中,第一消息中可以指示车辆的KMS服务端生成的第一密钥是哪些密钥。例如,KEY_13用于存储全球导航卫星系统(global navigation satellite system,GNSS)模块对应的长期密钥。Initiate the first message to the KMS server of the vehicle through a non-KMS device. For example, when starting the construction of the key system, and the construction status of the current key system is unconstructed or completed, it can be sent by an external device or a non-KMS device. The KMS device generates the first message, and sends the first message to the KMS server of the vehicle. For example, the first message may be encrypted and integrity-protected security verified by the fixed key of the vehicle. Wherein, the first message may indicate which keys are the first keys generated by the KMS server of the vehicle. For example, KEY_13 is used to store a long-term key corresponding to a global navigation satellite system (global navigation satellite system, GNSS) module.
例如,为防止CDC或中控屏被攻击,可以由CDC或中控屏接收用户的响应操作,确认“同意/拒绝:执行第一密钥的更新”,此时,在服务端通过场景1和场景2确定待生成的第一密钥后,可以向CDC或中控屏发送第一密钥生成请求消息,用户通过CDC或中控屏确认后,响应与用户的确认操作,CDC或中控屏通过该安全验证密钥返回给服务端长期密钥更新请求的响应消息,该响应消息可以使用一车一密的固定密钥进行加密和完整性保护,服务端将该响应消息发送给服务端的SHE进行验证。可选的,在服务端的SHE还可以根据第一密钥的有效期是否超时,确定是否主动向CDC或中控屏发送生成第一密钥生成请求消息。在接收到向CDC或中控屏发送的第一密钥生成请求的响应消息为同意时,该SHE执行对第一密钥的生成过程。For example, in order to prevent the CDC or the central control panel from being attacked, the CDC or the central control panel can receive the user's response operation and confirm "agree/deny: execute the update of the first key". Scenario 2 After determining the first key to be generated, the first key generation request message can be sent to the CDC or the central control panel. After the user confirms through the CDC or the central control panel, in response to the confirmation operation with the user, the CDC or the central control panel The security verification key is used to return the response message to the long-term key update request of the server. The response message can be encrypted and integrity protected with a fixed key of one vehicle and one secret, and the server sends the response message to the SHE of the server. authenticating. Optionally, the SHE at the server can also determine whether to actively send a first key generation request message to the CDC or the central control panel according to whether the validity period of the first key has expired. When receiving the response message of the first key generation request sent to the CDC or the central control panel as yes, the SHE executes the process of generating the first key.
车辆的KMS服务端接收到非KMS设备发送的第一消息后,可以生成第一请求消息,该第一请求消息向服务端对应的SHE发送第一请求消息,其中,第一请求消息可以包括第一密钥的标识,第一请求消息可以是基于第一请求消息对应的安全验证密钥对该第一请求消息进行加密和完整性保护。After the KMS server of the vehicle receives the first message sent by the non-KMS device, it can generate a first request message, and the first request message sends the first request message to the SHE corresponding to the server, wherein the first request message can include the first request message. An identifier of a key, the first request message may be encrypted and integrity-protected based on the security verification key corresponding to the first request message.
SHE基于第一请求消息对应的安全验证密钥,对该第一请求消息进行验证,验证成功后,触发生成加密的第一密钥。其中,加密的第一密钥可以是基于SHE存储的一车一密的固定密钥进行加密的,也可以是通过该KMS服务端存储的固定密钥进行加密的,该SHE在确定该第一密钥为KMS服务端使用的密钥时,可以存储该第一密钥。该SHE在确定该第一密钥为KMS服务端使用的密钥时,可以不存储该第一密钥。例如,在该第一密钥对应的KEYID为KEY_13时,SHE存储第一密钥到KEY_13的位置上。The SHE verifies the first request message based on the security verification key corresponding to the first request message, and triggers the generation of an encrypted first key after the verification succeeds. Wherein, the encrypted first key may be encrypted based on a fixed key for one vehicle and one secret stored by the SHE, or may be encrypted by a fixed key stored by the KMS server, and the SHE determines the first When the key is a key used by the KMS server, the first key may be stored. When the SHE determines that the first key is used by the KMS server, it may not store the first key. For example, when the KEYID corresponding to the first key is KEY_13, the SHE stores the first key in the position of KEY_13.
服务端对应的SHE根据自身存储的第一请求消息对应的安全验证密钥验证第一请求消息,在验证成功后,生成加密的第一密钥。其中,加密的第一密钥可以是基于SHE存储的一车一密的固定密钥进行加密的,也可以是通过该KMS服务端存储的固定密钥进行加密的,该SHE在确定该第一密钥为KMS服务端使用的密钥时,可以存储该第一密钥。该 SHE在确定该第一密钥为KMS服务端使用的密钥时,可以不存储该第一密钥。例如,在该第一密钥为KEY_1时,SHE将该第一密钥存储到KEY_1的位置上。The SHE corresponding to the server verifies the first request message according to the security verification key corresponding to the first request message stored by itself, and generates an encrypted first key after the verification succeeds. Wherein, the encrypted first key may be encrypted based on a fixed key for one vehicle and one secret stored by the SHE, or may be encrypted by a fixed key stored by the KMS server, and the SHE determines the first When the key is a key used by the KMS server, the first key may be stored. When the SHE determines that the first key is used by the KMS server, it may not store the first key. For example, when the first key is KEY_1, the SHE stores the first key in the position of KEY_1.
下面以具体的示例举例介绍第一请求消息。第一请求消息CMD_BUILD_KEY涉及的参数可以如表8所示。The following uses a specific example to introduce the first request message. The parameters involved in the first request message CMD_BUILD_KEY may be as shown in Table 8.
表8Table 8
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 256256
M2M2 ININ 128128
M3M3 OUTout 144144
M4M4 OUTout 256256
M5M5 OUTout 128128
M6M6 OUTout 272272
M7M7 OUTout 128128
以第一车载设备向第一SHE发送第一请求消息为例,该第一请求消息中可以携带以下入参。Taking the first vehicle-mounted device sending a first request message to the first SHE as an example, the first request message may carry the following input parameters.
其中,入参M1满足:Among them, the input parameter M1 satisfies:
M1=UID|Flag|memory slot|KEY_ID|Counter[|KeyID]|“0…0”mM1=UID|Flag|memory slot|KEY_ID|Counter[|KeyID]|“0…0”m
其中,UID的取值可以有多种,例如,在第一请求消息用于生成向第二车载设备发送的第一密钥的灌装消息(携带第一密钥的灌装对应的入参)时,该UID可以是第一车载设备或第二SHE的UID,也可以是0(即wildcard UID)。在第一请求消息用于生成向第一车载设备灌装的第一密钥的入参时,该UID可以是第一车载设备或第二SHE的UID。Among them, the value of UID can have many kinds, for example, in the first request message, it is used to generate the filling message of the first key sent to the second vehicle-mounted device (carrying the input parameter corresponding to the filling of the first key) , the UID can be the UID of the first vehicle-mounted device or the second SHE, or 0 (ie wildcard UID). When the first request message is used to generate an input parameter of the first key filled in the first vehicle-mounted device, the UID may be the UID of the first vehicle-mounted device or the second SHE.
Flag可以占用1字节,Flag满足:Flag can occupy 1 byte, and Flag satisfies:
Flag=“0...0” 6|Hold Flag="0...0" 6 |Hold
其中,Hold可以占用1 bit,表示第一SHE是否持有第一密钥,即是否在第一SHE中存储生成的第一密钥。例如,Hold为0时,表示不存储,Hold为1时,表示存储。如果是,则SHE在生成第一密钥后,先存储在本SHE中的memory slot位置,并设置该密钥相关内容,具体参见表3。其中,第一密钥的密钥构建状态可以设置为“1-构建成功”。如果不存储,则不可以在本SHE存储该第一密钥。Among them, Hold can occupy 1 bit, indicating whether the first SHE holds the first key, that is, whether to store the generated first key in the first SHE. For example, when Hold is 0, it means no storage, and when Hold is 1, it means storage. If yes, after the SHE generates the first key, it first stores it in the memory slot of the SHE, and sets the relevant content of the key, see Table 3 for details. Wherein, the key construction status of the first key may be set as "1-construction successful". If it is not stored, the first key cannot be stored in this SHE.
memory slot用于指示SHE第一密钥的密钥地址。The memory slot is used to indicate the key address of the SHE first key.
KEY_ID用于指示该第一请求消息的安全验证密钥。例如,结合场景3.1,通过非KMS设备生成的第一请求消息的入参(即携带在第一消息中),可以通过固定密钥作为该安全验证密钥。结合场景3.2,在第一车载设备获得临时密钥后生成的第一请求消息,可以将临时密钥作为第一请求消息的安全验证密钥。Counter的取值与本SHE的KMS_KH_BuildCounter值相同,用于SHE验证重放攻击。KEY_ID is used to indicate the security verification key of the first request message. For example, in conjunction with scenario 3.1, the input parameter of the first request message generated by the non-KMS device (that is, carried in the first message) may use a fixed key as the security verification key. In combination with scenario 3.2, in the first request message generated after the first vehicle-mounted device obtains the temporary key, the temporary key may be used as the security verification key of the first request message. The value of Counter is the same as the KMS_KH_BuildCounter value of this SHE, which is used for SHE verification replay attacks.
密钥索引KeyID:可以4字节,用于指明本次新生成的第一密钥的密钥索引。其中,“[]”表示可选的。例如,在不同硬件的安全存储机制涉及的车载设备之间对应的密钥索引可以是基于业务分配的,例如,可以基于KMS分配相应的密钥的索引。“0…0”m:表示数值“0”占用m bits,以便满足M1整体达到128 bits的整数倍。如果不含密钥索引KeyID,则填充76 bits的0。如果含有密钥索引KeyID,则填充44 bits的0。Key index KeyID: can be 4 bytes, used to indicate the key index of the newly generated first key this time. Among them, "[]" means optional. For example, the key indexes corresponding to the on-vehicle devices involved in the secure storage mechanisms of different hardware may be allocated based on services, for example, the corresponding key indexes may be allocated based on KMS. "0...0" m: Indicates that the value "0" occupies m bits, so as to meet the integer multiple of 128 bits for M1 as a whole. If the key index KeyID is not included, fill 76 bits with 0. If it contains the key index KeyID, fill 44 bits with 0.
入参M2满足:M2=CMAC(Key,M1)The input parameter M2 satisfies: M2=CMAC(Key,M1)
其中,Key是KEY_ID对应的安全验证密钥。Among them, Key is the security verification key corresponding to KEY_ID.
在第一SHE对第一请求消息的入参进行验证成功后,可以相应生成以下出参,并向第一车载设备返回第一响应消息,该第一响应消息可以包括第一密钥的第一参数,例如,可以携带以下出参M3~M7。After the first SHE successfully verifies the input parameters of the first request message, it can correspondingly generate the following output parameters and return a first response message to the first vehicle-mounted device. The first response message can include the first Parameters, for example, can carry the following outgoing parameters M3-M7.
出参M3满足:M3=UID|memory slot|KEY_IDThe output parameter M3 satisfies: M3=UID|memory slot|KEY_ID
UID同入参M1中的UID,memory slot和KEY_ID同入参M1中的对应值。Counter为SHE存储的KMS_KH_BuildCounter值。The UID is the same as the UID in the input parameter M1, and the memory slot and KEY_ID are the same as the corresponding values in the input parameter M1. Counter is the KMS_KH_BuildCounter value stored by SHE.
Flags=write-protection|boot-protection|debugger-protection|key-usage|wildcard,也可以在入参Flag中携带Flags的信息。或者,SHE根据第一密钥的分类来决定携带的内容。Flags=write-protection|boot-protection|debugger-protection|key-usage|wildcard, the information of Flags can also be carried in the input parameter Flag. Alternatively, the SHE determines the carried content according to the classification of the first key.
出参M4满足:The output parameter M4 satisfies:
M4=ENC CBC,K1,IV=0(Counter|KeyFlags[|KeyID]|“0…0”m|Key memory slot) M4=ENC CBC, K1,IV=0 (Counter|KeyFlags[|KeyID]|“0…0”m|Key memory slot )
KeyID同入参中的KeyID,如果入参携带了KeyID,则出参中也携带该KeyID。The KeyID is the same as the KeyID in the input parameter. If the input parameter carries the KeyID, the output parameter also carries the KeyID.
Key memory slot是第一SHE为memory slot生成的第一密钥的密钥值,由于第一密钥是要通过第一车载设备向第二SHE加密后分发的,第二车载设备不需要知道该第一密钥是如何生成的。因此,第一SHE在生成第一密钥时,可以有多种方案,举例来说,具体方案可有如下两种:方案一:使用SHE中的随机数功能生成一个随机数R1(128 bits),然后利用一个SHE持有可用的安全的Key1,进行CMAC计算,得到Key memory slot。例如,Key memory  slot=CMAC(Key1,R1)。其中,Key1可以使用固定密钥,比如GLOBAL_FIX_KEY、MAC_FIX_KEY等第一SHE中的任意一个除临时密钥之外的密钥,保证外部不可读取。或者,key1可以是该第一请求消息的入参中增加的密钥地址memory slot1对应的密钥,该密钥可以由用户来指定。方案二:如果随机数足够安全,也可以直接使用生成的随机数生成第一密钥。 Key memory slot is the key value of the first key generated by the first SHE for the memory slot. Since the first key is to be encrypted and distributed by the first vehicle-mounted device to the second SHE, the second vehicle-mounted device does not need to know the value of the key. How the first key is generated. Therefore, when the first SHE generates the first key, there can be various schemes. For example, there are two specific schemes as follows: Scheme 1: Use the random number function in the SHE to generate a random number R1 (128 bits) , and then use a SHE to hold the available secure Key1 to perform CMAC calculation to obtain the Key memory slot . For example, Key memory slot = CMAC(Key1, R1). Among them, Key1 can use a fixed key, such as GLOBAL_FIX_KEY, MAC_FIX_KEY and any other key except the temporary key in the first SHE, so as to ensure that it cannot be read by the outside. Alternatively, key1 may be the key corresponding to the key address memory slot1 added in the input parameter of the first request message, and the key may be specified by the user. Solution 2: If the random number is secure enough, the generated random number can also be directly used to generate the first key.
出参M5满足:The output parameter M5 satisfies:
M5=CMAC(K2,M3|M4)M5=CMAC(K2,M3|M4)
出参M6满足:The output parameter M6 satisfies:
M6=UID|memory slot|KEY_ID|EncyptedValueM6=UID|memory slot|KEY_ID|EncyptedValue
出参M7满足:The output parameter M7 satisfies:
M7=CMAC(K4,M6)M7=CMAC(K4,M6)
其中,第一响应消息携带的出参M3、M4、M5分别为第一密钥的灌装消息的入参M1、M2、M3。第一响应消息携带的出参M6、M7分别同第一密钥的灌装消息的出参M4、M5。即SHE通过第一请求消息,可以获得灌装第一密钥所需的入参,和验证第一密钥加载的出参。具体可以参见下文中的第一密钥的灌装消息中携带的入参和SHE执行第一密钥的灌装消息后的出参。Wherein, the output parameters M3, M4, and M5 carried in the first response message are respectively the input parameters M1, M2, and M3 of the filling message of the first key. The output parameters M6 and M7 carried in the first response message are respectively the same as the output parameters M4 and M5 in the filling message of the first key. That is, through the first request message, the SHE can obtain the input parameters required to fill the first key and verify the output parameters loaded by the first key. For details, please refer to the input parameters carried in the filling message of the first key and the output parameters after SHE executes the filling message of the first key below.
需要说明的是,出参M6和出参M7可以携带在第一响应消息中发送,也可以是存储在SHE的非易失性存储区中,例如,在SHE的非易失性存储区中预留专门用于KMS密钥体系构建过程中,临时存储服务端或代理端为第二车载设备之间共享密钥的存储位置,在第一车载设备(例如,服务端或代理端)接收到第二车载设备返回的第一密钥的灌装响应消息时,第一车载设备可以通过验证密钥消息,获得存储在SHE中的M6和M7。It should be noted that the outgoing parameter M6 and outgoing parameter M7 can be sent in the first response message, or can be stored in the non-volatile storage area of the SHE, for example, pre-set in the non-volatile storage area of the SHE Reserved for the construction process of the KMS key system, the temporary storage server or agent is the storage location of the shared key between the second vehicle-mounted devices, and the first vehicle-mounted device (for example, the server or agent) receives the first When the filling response message of the first key is returned by the second vehicle-mounted device, the first vehicle-mounted device can obtain M6 and M7 stored in the SHE by verifying the key message.
场景3.2,在车内密钥体系构建过程中,例如,第一车载设备在确定当前密钥体系构 建状态为构建中时,例如,第一车载设备在确定密钥体系中待生成的第一密钥包括多个后,可以根据各个待生成的第一密钥,相应生成第一请求消息。举例来说,第一密钥可以为第一车载设备专用的长期密钥,第一密钥可以为第二车载设备专用的长期密钥,第一密钥可以为第一车载设备和第二车载设备之间使用的长期密钥,第一密钥可以为用户1使用第一车载设备时对应的长期密钥,第一密钥可以为用户2使用第一车载设备和第二车载设备时对应的长期密钥。在生成相应的长期密钥时,可以相应生成该长期密钥的第一请求消息。Scenario 3.2, during the construction of the in-vehicle key system, for example, when the first vehicle-mounted device determines that the current key system construction status is under construction, for example, the first vehicle-mounted device determines the first key to be generated in the key system After multiple keys are included, a first request message may be generated correspondingly according to each first key to be generated. For example, the first key may be a long-term key dedicated to the first vehicle-mounted device, the first key may be a long-term key dedicated to the second vehicle-mounted device, and the first key may be a key between the first vehicle-mounted device and the second vehicle-mounted device. A long-term key used between devices. The first key may be the long-term key corresponding to user 1 using the first vehicle-mounted device, and the first key may be the corresponding long-term key when user 2 uses the first vehicle-mounted device and the second vehicle-mounted device. long term key. When generating the corresponding long-term key, the first request message for the long-term key may be correspondingly generated.
第一车载设备(例如,服务端)除通过非KMS设备生成第一消息来携带第一请求消息的安全验证密钥之外,还可以通过第一车载设备与第一SHE之间共享一个临时密钥,作为第一请求消息的安全验证密钥。In addition to generating the first message through the non-KMS device to carry the security verification key of the first request message, the first vehicle-mounted device (for example, the server) can also share a temporary key between the first vehicle-mounted device and the first SHE key, as the security verification key of the first request message.
该临时密钥可以用于构建过程中服务端与服务端对应的SHE之间的安全验证密钥。也可以是通过代理端与代理端对应的SHE之间共享一个临时密钥K Temp,该临时密钥K Temp可以用于构建过程中代理端与代理端对应的SHE之间的安全验证密钥。也可以是通过客户端与客户端对应的SHE之间共享一个临时密钥,该临时密钥可以用于构建过程中客户端与客户端对应的SHE之间的安全验证密钥。 The temporary key can be used for the security verification key between the server and the SHE corresponding to the server during the construction process. Alternatively, a temporary key K Temp may be shared between the agent and the SHE corresponding to the agent, and the temporary key K Temp may be used as a security verification key between the agent and the SHE corresponding to the agent during the construction process. Alternatively, a temporary key may be shared between the client and the SHE corresponding to the client, and the temporary key may be used for a security verification key between the client and the SHE corresponding to the client during the construction process.
该临时密钥可以是基于第一车载设备从非KMS设备接收到的第一消息(该第一消息通过非KMS设备与服务端之间可信的安全验证密钥进行加密的),通过SHE对第一消息进行验证后生成的。The temporary key can be based on the first message received by the first vehicle-mounted device from the non-KMS device (the first message is encrypted by a trusted security verification key between the non-KMS device and the server), and the SHE Generated after the first message is validated.
一种可能的实现方式,通过非KMS设备向车辆的KMS服务端发起长期密钥的生成消息(例如,第一消息),非KMS设备可以通过非KMS设备的固定密钥对该第一消息进行加密和完整性保护的安全验证。其中,第一消息中可以指示车辆的KMS服务端启动长期密钥的生成过程。车辆的KMS服务端可以根据该第一消息,向服务端的SHE发送第一请求消息,该第一请求消息可以用于请求获得临时密钥。SHE生成临时密钥后,可以向第一车载设备发送第一消息的响应消息,在该响应消息中可以携带该临时密钥。此处临时密钥可以使用服务端与服务端对应的SHE共享的密钥进行完整性验证。例如,通过一车一密的固定密钥,或第一车载设备的固定密钥对该临时密钥生成消息校验码。从而,第一车载设备在对第一消息的响应消息进行验证成功后,可以获得该临时密钥。该临时密钥用于服务端验证SHE发送的第一响应消息。同时,车辆的服务端生成的第一请求消息还可以包括请求SHE生成加密的第一密钥。In a possible implementation, the non-KMS device initiates a long-term key generation message (for example, the first message) to the KMS server of the vehicle, and the non-KMS device can use the fixed key of the non-KMS device to generate a long-term key for the first message. Security authentication with encryption and integrity protection. Wherein, the first message may instruct the KMS server of the vehicle to start a long-term key generation process. The KMS server of the vehicle can send a first request message to the SHE of the server according to the first message, and the first request message can be used to request to obtain the temporary key. After the SHE generates the temporary key, it may send a response message to the first message to the first vehicle device, and the response message may carry the temporary key. Here, the temporary key can use the key shared by the server and the SHE corresponding to the server for integrity verification. For example, a message verification code is generated for the temporary key by means of a fixed key for one vehicle, one secret, or the fixed key of the first vehicle device. Therefore, the first vehicle-mounted device can obtain the temporary key after successfully verifying the response message of the first message. The temporary key is used by the server to verify the first response message sent by SHE. At the same time, the first request message generated by the vehicle server may also include requesting the SHE to generate an encrypted first key.
考虑到在密钥体系构建过程中,很可能需要服务端多次生成第一密钥,或通过服务端或代理端对其他消息进行验证等操作,都可能涉及到使用临时密钥,此时,应在车载设备(服务端或代理端或客户端)相应的SHE执行第一密钥的生成等操作之前生成临时密钥,并使得车载设备获得该临时密钥。如果每次都生成或者向车载设备发送临时密钥,则会影响临时密钥的安全性(API接口监听等)。另外,针对密钥体系构建启动消息,应在车载设备相应的SHE执行第一密钥的生成等操作之前接收到,以便SHE更新密钥体系构建状态。Considering that during the construction of the key system, it is likely that the server needs to generate the first key multiple times, or verify other messages through the server or agent, which may involve the use of temporary keys. At this time, The temporary key should be generated before the corresponding SHE of the vehicle-mounted device (server or agent or client) executes operations such as generating the first key, and the vehicle-mounted device is made to obtain the temporary key. If the temporary key is generated or sent to the vehicle device every time, the security of the temporary key will be affected (API interface monitoring, etc.). In addition, the start message for key system construction should be received before the corresponding SHE of the on-vehicle device performs operations such as generating the first key, so that the SHE can update the key system construction status.
下面具体介绍生成临时密钥的一种可能的实现方式,即通过密钥体系构建启动消息触发该第一SHE生成临时密钥。服务端接收非KMS设备生成的密钥体系构建启动消息,并将该密钥体系构建启动消息的参数分发到代理端或客户端的车载设备,代理端也需要代理分发到其代理的各客户端,在车载设备接收到密钥体系构建启动消息后,转发给车载设备的SHE,SHE可以根据密钥体系构建启动消息,启动密钥体系的构建,例如,同步各车载设备的KMS_KH_BuildCounter值,以防止密钥体系构建启动消息的重放攻击,更新密钥 体系构建状态消息,并使得车载设备的SHE相应生成临时密钥,为后续第一密钥的生成等消息提供安全验证密钥。A possible implementation manner of generating a temporary key is specifically introduced below, that is, the first SHE is triggered to generate a temporary key through a key system construction start message. The server receives the key system construction start message generated by the non-KMS device, and distributes the parameters of the key system construction start message to the agent or the vehicle-mounted device of the client. After the vehicle-mounted device receives the key system construction start message, it forwards it to the SHE of the vehicle-mounted device. The SHE can start the construction of the key system according to the key system construction start message. For example, the KMS_KH_BuildCounter value of each vehicle-mounted device is synchronized to prevent encryption The replay attack of the key system construction start message updates the key system construction status message, and makes the SHE of the on-board equipment generate a temporary key accordingly, providing a security verification key for subsequent messages such as the generation of the first key.
下面通过以下方式1~方式2举例介绍密钥体系构建的启动消息中可能的方式。The following methods 1 to 2 are used as examples to introduce the possible methods in the startup message of the key system construction.
方式1,在车外设备响应于用户“确认同意进行第一密钥更新”的操作后,车外设备构建密钥体系构建的启动消息。Mode 1, after the off-vehicle device responds to the user's operation of "confirming and agreeing to perform the first key update", the off-vehicle device constructs a start message for key system construction.
方式2,在车内的CDC或中控屏响应于用户“确认同意进行第一密钥更新”操作后,由CDC或中控屏来构建密钥体系构建的启动消息。此时,为保证可安全的构建密钥体系构建的启动消息,可以通过以下方式实现:Method 2: After the CDC or the central control panel in the car responds to the user's operation of "confirming and agreeing to perform the first key update", the CDC or the central control panel constructs a key system construction start message. At this time, in order to ensure the safe construction of the startup message of the key system construction, it can be realized in the following ways:
方式2.1,在CDC或中控屏上,通过其他安全环境(不依赖SHE的安全环境),比如部署有可信执行环境(Trusted execution environment,TEE)、或者HSM等的安全环境,使用长期密钥或固定密钥,来生成该消息。需要说明的是,在该安全环境中,同样存储该长期密钥,比如存储一车一密的长期密钥或一车一密的固定密钥等。Method 2.1, on the CDC or the central control screen, through other security environments (security environments that do not rely on SHE), such as deploying a trusted execution environment (Trusted execution environment, TEE), or HSM, etc., using a long-term key or a fixed key, to generate the message. It should be noted that, in this secure environment, the long-term key is also stored, for example, a long-term key for one secret per vehicle or a fixed key for one secret per vehicle, etc. are stored.
方式2.2,CDC或中控屏的SHE对服务端或代理端发送的启动密钥体系的构建的请求消息进行响应,返回启动密钥体系的构建的请求的响应消息,比如CMD_KMS_KH_PREPARE_START,使得CDC或中控屏的SHE生成并向服务端返回密钥体系的构建启动消息,服务端获得该密钥体系的构建启动消息,从而启动和管理第一密钥的更新。需要说明的是,启动密钥体系的构建的请求的响应消息(CMD_KMS_KH_PREPARE_START)无法提供密钥作为该消息的安全验证密钥。因此需要严格控制该消息的使用,比如通过身份识别与访问管理(identity and access management,IAM)、安全强化Linux(security enhanced linux,SELinux)、进程或容器安全隔离,并且强制检查在车辆停止等情况下,才允许使用。Mode 2.2, the CDC or the SHE of the central control panel responds to the request message to start the construction of the key system sent by the server or the agent, and returns the response message to the request to start the construction of the key system, such as CMD_KMS_KH_PREPARE_START, so that the CDC or the central The SHE of the control screen generates and returns the start message of building the key system to the server, and the server obtains the start message of building the key system, thereby starting and managing the update of the first key. It should be noted that the response message (CMD_KMS_KH_PREPARE_START) to the request to start the construction of the key system cannot provide a key as the security verification key of the message. Therefore, it is necessary to strictly control the use of this message, such as through identity and access management (IAM), security enhanced Linux (SELinux), process or container security isolation, and mandatory checks when the vehicle stops, etc. only allowed to use.
下面举例说明密钥体系构建的启动消息的一种可能的实现方式,例如,如表9所示,为密钥体系构建的启动消息可能涉及的参数。其中,m和n为正整数。The following example illustrates a possible implementation of the start message constructed by the key system, for example, as shown in Table 9, the parameters that may be involved in the start message constructed for the key system. Among them, m and n are positive integers.
表9Table 9
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ mm
M2M2 ININ 128128
M3M3 OUTout nno
M4M4 OUTout 128128
M5M5 OUTout 128128
以第一车载设备向第一SHE发送密钥体系构建的启动消息为例,该密钥体系构建的启动消息可以携带下列入参。Taking the first vehicle-mounted device sending a key system construction start message to the first SHE as an example, the key system construction start message may carry the following parameters.
其中,入参满足:Among them, the input parameters meet:
M1=KEY_ID|KMS_KH_BuildCounterM1=KEY_ID|KMS_KH_BuildCounter
M2=CMAC(Key,M1)M2=CMAC(Key,M1)
其中,对于车外发起的密钥体系构建,必须是固定密钥对应的KEY_ID,对于内车CDC或中控屏确认后触发的长期密钥更新,可以是长期密钥对应的KEY_ID,比如是一车一密的长期密钥的KEY_ID。Key是KEY_ID对应的Key。KMS_KH_BuildCounter为密钥体系构建计数器的值,各车载设备的SHE在执行该密钥体系构建的启动消息时,该值必须大于、或等于本车载设备的SHE中KMS_KH_BuildCounter的值,以防止该密钥体系构建的启动 消息被重放使用。如果KMS_KH_BuildCounter值小于本设备SHE中的值,则忽略该命令,返回ERC_INVALID_PARAMETER。Among them, for the construction of the key system initiated outside the car, it must be the KEY_ID corresponding to the fixed key. For the long-term key update triggered after confirmation by the CDC or the central control screen in the car, it can be the KEY_ID corresponding to the long-term key, such as a KEY_ID of the long-term key of Che Yi Mi. Key is the Key corresponding to KEY_ID. KMS_KH_BuildCounter is the value of the key system construction counter. When the SHE of each vehicle-mounted device executes the start message of the key system construction, this value must be greater than or equal to the value of KMS_KH_BuildCounter in the SHE of the vehicle-mounted device to prevent the key system The build's startup message is used by the replay. If the value of KMS_KH_BuildCounter is less than the value in SHE of this device, ignore this command and return ERC_INVALID_PARAMETER.
在对密钥体系构建的启动消息验证成功后,SHE可以生成密钥体系构建的启动消息的出参,并向第一车载设备返回密钥体系构建的启动消息的响应消息,在该响应消息中携带出参。其中,出参满足:After successfully verifying the startup message of the key system construction, the SHE can generate an output parameter of the startup message of the key system construction, and return a response message of the startup message of the key system construction to the first vehicle-mounted device, in the response message Carry out ginseng. Among them, the output parameters meet:
M3=KEY_ID|KMS_KH_BuildCounter1M3=KEY_ID|KMS_KH_BuildCounter1
M4=CMAC(Key,M3)M4=CMAC(Key,M3)
M5=KMS_KH_BuildKTempM5 = KMS_KH_BuildKTemp
其中:KMS_KH_BuildCounter1是执行该命令后,SHE中KMS_KH_BuildCounter的最新值。实际应该是KMS_KH_BuildCounter1=KMS_KH_BuildCounter+1。该命令执行后,SHE将KMS_KH_BuildStatus设置为“构建中”。Among them: KMS_KH_BuildCounter1 is the latest value of KMS_KH_BuildCounter in SHE after executing this command. Actually it should be KMS_KH_BuildCounter1=KMS_KH_BuildCounter+1. After this command is executed, SHE will set KMS_KH_BuildStatus to "Building".
KMS_KH_BuildKTemp是该命令执行成功后,SHE生成的一个临时密钥KTemp,用于本车载设备直接操作SHE时的安全验证密钥。KMS_KH_BuildKTemp is a temporary key KTemp generated by SHE after the command is executed successfully, which is used for the security verification key when the on-board equipment directly operates SHE.
为简化消息发送的复杂度,可以将密钥体系构建启动消息设计为两层命令,该消息中,还可以携带其他消息的参数,使得SHE接收到该密钥体系构建启动消息后,根据对密钥体系构建启动消息的验证,获得启动密钥体系构建的指示信息,并更新密钥体系构建状态。可选的,在服务端或代理端的SHE接收到该消息后,可以相应生成临时密钥。进一步的,根据密钥体系构建启动消息携带的其他消息的参数后,根据其他消息的参数,对该消息进行验证后执行相应的操作。In order to simplify the complexity of message sending, the key system construction start message can be designed as a two-layer command. The message can also carry the parameters of other messages, so that after SHE receives the key system construction start message, according to the encryption The key system construction start message is verified, the instruction information for starting the key system construction is obtained, and the key system construction status is updated. Optionally, after receiving the message, the SHE at the server or agent can generate a temporary key accordingly. Further, after constructing the parameters of other messages carried in the startup message according to the key system, the message is verified according to the parameters of other messages and then corresponding operations are performed.
例如,其他消息为第一请求消息,此时,第一车载设备通过密钥体系构建启动消息携带第一请求消息。可以使得第一SHE通过对密钥体系构建启动消息进行验证后,确定密钥体系构建状态为构建中,并相应生成临时密钥。之后,根据通过密钥体系构建启动消息携带第一请求消息,对第一请求消息进行验证,在验证成功后,生成加密的第一密钥,并向第一车载设备返回加密的第一密钥和临时密钥。For example, the other message is the first request message, and at this time, the first vehicle-mounted device carries the first request message through the key system construction start message. The first SHE may determine that the key system construction status is under construction after verifying the key system construction start message, and generate a temporary key accordingly. Afterwards, according to the first request message carried in the startup message of the key system construction, the first request message is verified, and after the verification is successful, the encrypted first key is generated, and the encrypted first key is returned to the first vehicle-mounted device and temporary key.
下面举例说明密钥体系构建的启动消息的一种可能的实现方式,例如,如表10所示。其中,m和n为正整数。The following example illustrates a possible implementation of the start message for key system construction, as shown in Table 10, for example. Among them, m and n are positive integers.
表10Table 10
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ mm
M2M2 ININ 128128
M3M3 OUTout nno
M4M4 OUTout 128128
M5M5 OUTout 128128
以第一车载设备向第一SHE发送密钥体系构建的启动消息为例,该密钥体系构建的启动消息可以携带下列入参,并嵌套其他消息对应的参数。Taking the first on-vehicle device sending the start message of the key system construction to the first SHE as an example, the start message of the key system construction can carry the following parameters and nest parameters corresponding to other messages.
入参满足:The input parameters meet:
M1=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_IN_ParametersM1=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_IN_Parameters
M2=CMAC(Key,M1)M2=CMAC(Key,M1)
其中,KEY_ID为用于对该消息进行安全验证的安全验证密钥。对于车外设备发起的密钥体系构建的启动消息,该安全验证密钥必须是固定密钥对应的KEY_ID;对于内车CDC 或中控屏确认后触发的长期密钥更新,可以是长期密钥对应的KEY_ID,比如是一车一密的长期密钥的KEY_ID。Key是KEY_ID对应的安全验证密钥。Wherein, KEY_ID is a security verification key used for security verification of the message. For the startup message of the key system construction initiated by the device outside the vehicle, the security verification key must be the KEY_ID corresponding to the fixed key; for the long-term key update triggered after confirmation by the CDC or the central control screen in the vehicle, it can be a long-term key The corresponding KEY_ID is, for example, the KEY_ID of the long-term key of one car one secret. Key is the security verification key corresponding to KEY_ID.
在KMS_KH_BuildCounter值小于第一SHE中的KMS_KH_BuildCounter值时,确定密钥体系构建的启动消息验证失败,忽略该密钥体系构建的启动消息,返回错误消息ERC_INVALID_PARAMETER。When the KMS_KH_BuildCounter value is smaller than the KMS_KH_BuildCounter value in the first SHE, it is determined that the verification of the start message of the key system construction fails, and the start message of the key system construction is ignored, and the error message ERC_INVALID_PARAMETER is returned.
在KMS_KH_BuildCounter值大于第一SHE中的KMS_KH_BuildCounter值时,说明重放攻击验证成功,此时,可以对M2进行验证。When the KMS_KH_BuildCounter value is greater than the KMS_KH_BuildCounter value in the first SHE, it means that the replay attack verification is successful, and at this time, M2 can be verified.
CMD_TYPE表示消息的消息类型,当CMD_KMS_KH_BUILD_START、CMD_KMS_KH_BUILD_CONTINUE不携带其他消息时,CMD_TYPE可以填充0。举例来说,本申请密钥体系构建的启动消息可携带的其他消息可以如表11所示。CMD_TYPE indicates the message type of the message. When CMD_KMS_KH_BUILD_START and CMD_KMS_KH_BUILD_CONTINUE do not carry other messages, CMD_TYPE can be filled with 0. For example, other messages that can be carried in the startup message constructed by the key system of this application can be shown in Table 11.
表11Table 11
Figure PCTCN2021095348-appb-000008
Figure PCTCN2021095348-appb-000008
需要说明的是,该密钥体系构建启动消息含有的其他消息,可能只是发给特定的车载设备、或车辆内的部分车载设备的,其他车载设备不处理,此时,可以使用特定范围共享、 或特定车载设备持有的固定密钥对该含有的业务功能的消息进行安全验证。在构建该业务功能的消息时,可以通过KMS业务消息,向服务端、代理端发送该密钥体系构建启动消息、还可以向服务端、代理端发送该密钥体系构建启动消息是否需要分发、向哪些客户端分发、服务端、代理端是否需要处理等信息。It should be noted that other messages contained in the key system construction startup message may only be sent to a specific on-board device or some on-board devices in the vehicle, and other on-board devices will not process it. At this time, specific range sharing, Or a fixed key held by a specific on-vehicle device performs security verification on the message containing the business function. When constructing the message of the business function, the key system building start message can be sent to the server and the agent through the KMS business message, and the key system building start message can also be sent to the server and the agent whether it needs to be distributed, Information such as which clients are distributed to, whether the server and the agent need to be processed.
在一些实施例中,在第一SHE收到的消息含有无法处理的消息时,则该消息直接忽略,并返回错误消息ENC_CANNOT_PROCESS_INNER_CMD。In some embodiments, when the message received by the first SHE contains a message that cannot be processed, the message is directly ignored, and an error message ENC_CANNOT_PROCESS_INNER_CMD is returned.
在一些实施例中,密钥体系构建的启动消息的安全验证密钥KEY_ID与携带在该消息中的其他消息中使用的安全验证密钥KEY_ID’可以一样,也可以不一样。其中,携带在该消息中的其他消息中使用的安全验证密钥KEY_ID’可以根据该消息的要求或实际需要选择KEY_ID’。In some embodiments, the security verification key KEY_ID of the startup message constructed by the key system may be the same as or different from the security verification key KEY_ID' used in other messages carried in the message. Wherein, the security verification key KEY_ID' used in other messages carried in the message can be selected according to the requirements of the message or actual needs.
CMD_TYPE可以占用1字节,表示密钥体系构建的启动消息是否携带其他消息。CMD_TYPE_IN_Parameters:是CMD_TYPE对应其他消息的所有入参。此时,CMD_TYPE值不为0。CMD_TYPE can occupy 1 byte, indicating whether the start message of the key system construction carries other messages. CMD_TYPE_IN_Parameters: CMD_TYPE corresponds to all input parameters of other messages. At this time, the CMD_TYPE value is not 0.
在对密钥体系构建的启动消息验证成功后,SHE可以生成密钥体系构建的启动消息的出参,并向第一车载设备返回密钥体系构建的启动消息的响应消息,在该响应消息中携带出参。其中,出参M3~M5可以满足:After successfully verifying the startup message of the key system construction, the SHE can generate an output parameter of the startup message of the key system construction, and return a response message of the startup message of the key system construction to the first vehicle-mounted device, in the response message Carry out ginseng. Among them, the output parameters M3~M5 can meet:
M3=KEY_ID|KMS_KH_BuildCounter1|CMD_TYPE|CMD_TYPE_OUT_ParametersM3=KEY_ID|KMS_KH_BuildCounter1|CMD_TYPE|CMD_TYPE_OUT_Parameters
M4=CMAC(Key,M3)M4=CMAC(Key,M3)
M5=KMS_KH_BuildKTempM5 = KMS_KH_BuildKTemp
其中,KMS_KH_BuildCounter1是对密钥体系构建的启动消息验证后,对SHE中KMS_KH_BuildCounter更新后的值。例如,KMS_KH_BuildCounter1满足:KMS_KH_BuildCounter1=KMS_KH_BuildCounter+1。Among them, KMS_KH_BuildCounter1 is the updated value of KMS_KH_BuildCounter in SHE after verifying the startup message of key system construction. For example, KMS_KH_BuildCounter1 satisfies: KMS_KH_BuildCounter1=KMS_KH_BuildCounter+1.
CMD_TYPE_OUT_Parameters是CMD_TYPE对应的消息的所有出参。CMD_TYPE_OUT_Parameters are all output parameters of the message corresponding to CMD_TYPE.
KMS_KH_BuildKTemp是密钥体系构建的启动消息验证成功后,SHE生成的一个临时密钥KTemp,用于第一车载设备直接操作SHE时的安全验证密钥,但不用于向第二车载设备发送第一密钥加载消息的安全验证密钥。同时,SHE在对该消息验证成功后,可以将KMS_KH_BuildStatus设置为“构建中”。SHE将Counter设置为KMS_KH_BuildCounter的最新值。KMS_KH_BuildKTemp is a temporary key KTemp generated by SHE after the startup message verification of key system construction is successful. The security authentication key for the keyload message. At the same time, SHE can set KMS_KH_BuildStatus to "Building" after successfully verifying the message. SHE sets Counter to the latest value of KMS_KH_BuildCounter.
在密钥体系构建的启动消息携带第一请求消息的场景,考虑第一车载设备生成第一请求消息的一些实施例中,即第一请求消息的参数可以通过服务端向SHE发送第一查询请求获取,比如,可以用第一查询消息CMD_KMS_KH_GET_BUILD_STATUS来查询KMS_KH_BuildCounter以及CMD_BUILD_KEY的入参等状态数据。该第一查询消息,可以通过临时密钥进行安全性验证。下面举例介绍第一查询消息(CMD_KMS_KH_GET_BUILD_STATUS)的一种可能的实现方式,第一查询消息的相关参数可以如表12所示。In the scenario where the startup message constructed by the key system carries the first request message, consider some embodiments where the first vehicle-mounted device generates the first request message, that is, the parameters of the first request message can send the first query request to the SHE through the server To obtain, for example, the first query message CMD_KMS_KH_GET_BUILD_STATUS can be used to query status data such as input parameters of KMS_KH_BuildCounter and CMD_BUILD_KEY. The security verification of the first query message can be performed through the temporary key. A possible implementation of the first query message (CMD_KMS_KH_GET_BUILD_STATUS) is described below as an example. The relevant parameters of the first query message may be shown in Table 12.
表12Table 12
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 88
M2M2 ININ 128128
M3M3 OUTout 208208
M4M4 OUTout 128128
该第一查询消息可以是车外设备发起的,也可以是车内的第一车载设备、第二车载设备等车载设备发起的。The first query message may be initiated by a device outside the vehicle, or may be initiated by a vehicle-mounted device such as a first vehicle-mounted device or a second vehicle-mounted device in the vehicle.
在一些实施例中,可以是第一车载设备在启动时检查密钥体系的构建状态,以便第一车载设备根据当前的密钥体系的构建状态,确定下一步的操作,例如,当前的构建状态为已构建部分第一密钥,则第一车载设备可以向SHE发起其他待生成的第一密钥的第一请求消息。在当前的构建状态为已构建部分第一密钥,其中,包括构建成功的第一密钥1,构建失败的第一密钥2,则第一车载设备可以向SHE发起生成第一密钥2的第一请求消息。In some embodiments, the first vehicle-mounted device may check the construction status of the key system when starting, so that the first vehicle-mounted device can determine the next operation according to the current construction status of the key system, for example, the current construction status If part of the first key has been constructed, the first vehicle-mounted device may initiate a first request message for other first keys to be generated to the SHE. In the current construction state, a part of the first key has been constructed, including the successful construction of the first key 1 and the failed construction of the first key 2, then the first on-board device can initiate the generation of the first key 2 to the SHE The first request message for .
在一些实施例中,可以是第一车载设备在确定第一密钥为待更新的密钥时,可以向第一SHE发送第一查询消息,用于查询KMS_KH_BuildCounter及相应消息的入参等信息,用于生成相应消息。例如,第一车载设备可以向第一SHE发送第一查询消息,从SHE中读取当前的密钥体系构建状态、构建计数、上一次构建成功的日期,以及构建状态数据的校验码MAC等。In some embodiments, when the first vehicle-mounted device determines that the first key is a key to be updated, it may send a first query message to the first SHE for querying information such as KMS_KH_BuildCounter and corresponding message input parameters, Used to generate corresponding messages. For example, the first vehicle-mounted device can send a first query message to the first SHE, and read the current key system construction status, construction count, date of the last successful construction, and the verification code MAC of the construction status data from the SHE. .
以第一车载设备向第一SHE发送第一查询消息为例,该第一查询消息可以携带下列入参M1和M2。Taking the first query message sent by the first vehicle-mounted device to the first SHE as an example, the first query message may carry the following parameters M1 and M2.
入参M1满足:M1=KEY_IDThe input parameter M1 satisfies: M1=KEY_ID
其中,KEY_ID为用于该第一查询消息的安全验证密钥。因此,对于车外设备发起的第一查询消息,该KEY_ID为是固定密钥;在车内的非KMS设备,例如,CDC或中控屏,触发长期密钥更新时,例如,在发送第一消息之前,发起的查询,可以是长期密钥,也可以是固定密钥。在另一些实施例中,第一车载设备或第二车载设备发起的第一查询消息,可以使用相应的SHE生成的临时密钥作为该安全验证密钥。需要说明的是,KEY_ID可以为0。如果为0,表示无密钥查询,此时入参中的M1中不含MAC(即不含M2)。相应的,出参中不含M4。Wherein, KEY_ID is the security verification key used for the first query message. Therefore, for the first query message initiated by the device outside the vehicle, the KEY_ID is a fixed key; when a non-KMS device in the vehicle, such as a CDC or a central control panel, triggers a long-term key update, for example, when sending the first The query initiated before the message can be a long-term key or a fixed key. In some other embodiments, the first query message initiated by the first vehicle-mounted device or the second vehicle-mounted device may use a temporary key generated by the corresponding SHE as the security verification key. It should be noted that KEY_ID can be 0. If it is 0, it means that there is no key query. At this time, M1 in the input parameter does not contain MAC (that is, does not contain M2). Correspondingly, M4 is not included in the output parameters.
入参M2满足:M2=CMAC(Key,M1)The input parameter M2 satisfies: M2=CMAC(Key,M1)
即通过入参M2作为安全校验码,Key是KEY_ID对应的安全验证密钥。That is, enter the parameter M2 as the security verification code, and Key is the security verification key corresponding to KEY_ID.
在SHE对第一查询消息中的入参进行验证成功后,可以相应生成出参,并返回第一查询响应消息。例如,以第一SHE为例,第一车载设备向第一SHE发送第一查询消息,则第一SHE对第一查询消息中的入参进行验证成功后,可以相应生成出参M3和M4,并向第一车载设备返回第一查询响应消息。After the SHE successfully verifies the input parameters in the first query message, it can generate corresponding output parameters and return the first query response message. For example, taking the first SHE as an example, the first vehicle-mounted device sends a first query message to the first SHE, and after the first SHE successfully verifies the input parameters in the first query message, it can generate corresponding output parameters M3 and M4, And return the first query response message to the first vehicle-mounted device.
其中,出参M3满足:Among them, the output parameter M3 satisfies:
M3=KEY_ID|KMS_KH_BuildStatus|KMS_KH_BuildCounter|KMS_KH_BuildDate|KMS_KH_BuildMacM3=KEY_ID|KMS_KH_BuildStatus|KMS_KH_BuildCounter|KMS_KH_BuildDate|KMS_KH_BuildMac
出参M4满足:The output parameter M4 satisfies:
M4=CMAC(Key,M3)M4=CMAC(Key,M3)
第一车载设备接收到第一查询响应消息后,可以对第一查询响应消息中的出参进行验证,在验证成功后,获得出参中的查询内容,例如,KMS_KH_BuildStatus,KMS_KH_BuildCounter,KMS_KH_BuildDate,KMS_KH_BuildMac。After receiving the first query response message, the first vehicle-mounted device may verify the output parameters in the first query response message, and obtain the query content in the output parameters after the verification is successful, for example, KMS_KH_BuildStatus, KMS_KH_BuildCounter, KMS_KH_BuildDate, KMS_KH_BuildMac.
在步骤304之后,第一车载设备接收到第一SHE的第一响应消息后,可以根据第一密钥对应灌装的车载设备,例如,可以是第二车载设备。其中,第二车载设备可以是第一车载设备,也可以是车辆内的其他车载设备。第二车载设备可以是服务端,也可以是代理端, 还可以是客户端,在此不做限定。After step 304, after receiving the first response message from the first SHE, the first vehicle-mounted device may correspond to the filled vehicle-mounted device according to the first key, for example, may be the second vehicle-mounted device. Wherein, the second vehicle-mounted device may be the first vehicle-mounted device, or other vehicle-mounted devices in the vehicle. The second in-vehicle device may be a server, an agent, or a client, which is not limited here.
下面以第二车载设备为除第一车载设备之外的其他车载设备为例进行说明。如图4所示,包括以下步骤:The following takes the second vehicle-mounted device as another vehicle-mounted device other than the first vehicle-mounted device as an example for description. As shown in Figure 4, the following steps are included:
步骤401:第一车载设备接收来自第一SHE发送的第一密钥的第一参数。Step 401: the first vehicle-mounted device receives the first parameter of the first key sent from the first SHE.
其中,第一车载设备根据接收到的第一响应消息,获得第一密钥的第一参数。具体第一参数可以参见上述第一响应消息中的M3~M5,在此不再赘述。Wherein, the first vehicle-mounted device obtains the first parameter of the first key according to the received first response message. For specific first parameters, reference may be made to M3-M5 in the above-mentioned first response message, which will not be repeated here.
步骤402:第一车载设备根据第一密钥的第一参数,生成第一密钥加载消息。Step 402: The first vehicle-mounted device generates a first key loading message according to the first parameter of the first key.
其中,第一密钥加载消息用于第二车载设备对第一密钥加载消息进行验证成功后,灌装第一密钥。Wherein, the first key loading message is used for filling the first key after the second in-vehicle device successfully verifies the first key loading message.
步骤403:第一车载设备向第二车载设备发送第一密钥加载消息。Step 403: the first vehicle-mounted device sends a first key loading message to the second vehicle-mounted device.
举例来说,第一车载设备可以是KMS的服务端或KMS的代理端。第二车载设备可以是KMS的客户端或KMS的代理端。例如,在第一车载设备为服务端,第二车载设备为客户端时,第一车载设备可以向第二车载设备发送第一密钥加载消息,或者第一车载设备可以向代理端发送第一密钥加载消息,并由代理端向第二车载设备转发第一密钥加载消息。For example, the first vehicle-mounted device may be a KMS server or a KMS agent. The second in-vehicle device may be a KMS client or a KMS agent. For example, when the first vehicle-mounted device is a server and the second vehicle-mounted device is a client, the first vehicle-mounted device may send a first key loading message to the second vehicle-mounted device, or the first vehicle-mounted device may send a first key loading message to the agent. The key loading message, and the agent forwards the first key loading message to the second vehicle-mounted device.
再比如,在第一车载设备为服务端,第二车载设备为代理端时,第一车载设备可以向第二车载设备发送第一密钥加载消息。可选的,第二车载设备还可以向第二车载设备所管理的客户端下发第一密钥加载消息。For another example, when the first vehicle-mounted device is a server and the second vehicle-mounted device is an agent, the first vehicle-mounted device may send a first key loading message to the second vehicle-mounted device. Optionally, the second vehicle-mounted device may also deliver the first key loading message to the client managed by the second vehicle-mounted device.
再比如,在第一车载设备为代理端时,第一车载设备可以接收服务端转发的第一密钥加载消息,还可以向第一车载设备所管理的第二车载设备下发第一密钥加载消息。再比如,在第一车载设备为代理端时,第一车载设备可以生成第一密钥加载消息,并向可以向第一车载设备所管理的第二车载设备下发第一密钥加载消息。For another example, when the first vehicle-mounted device is an agent, the first vehicle-mounted device can receive the first key loading message forwarded by the server, and can also send the first key to the second vehicle-mounted device managed by the first vehicle-mounted device Load the message. For another example, when the first vehicle-mounted device is an agent, the first vehicle-mounted device may generate a first key loading message, and send the first key loading message to a second vehicle-mounted device that may be managed by the first vehicle-mounted device.
步骤404:第二车载设备根据接收到的第一密钥加载消息,向第二SHE发送该第一密钥加载消息。Step 404: The second vehicle-mounted device sends the first key loading message to the second SHE according to the received first key loading message.
步骤405:第二SHE对该第一密钥加载消息验证成功后,生成第一密钥加载的响应消息。Step 405: After successfully verifying the first key loading message, the second SHE generates a first key loading response message.
步骤406:第二SHE向第二车载设备发送第一密钥加载的响应消息,第二车载设备向第一车载设备转发第一密钥加载的响应消息。Step 406: The second SHE sends a response message of loading the first key to the second vehicle-mounted device, and the second vehicle-mounted device forwards the response message of loading the first key to the first vehicle-mounted device.
步骤407:第一车载设备根据第一密钥加载的响应消息,生成第一密钥的灌装验证消息。Step 407: The first vehicle-mounted device generates a filling verification message of the first key according to the response message loaded with the first key.
步骤408:第一车载设备向第一SHE发送第一密钥的灌装验证消息。Step 408: the first vehicle-mounted device sends a filling verification message of the first key to the first SHE.
步骤409:第一SHE在对第一密钥加载验证消息验证成功后,向第一车载设备反馈验证结果。Step 409: After successfully verifying the first key loading verification message, the first SHE feeds back the verification result to the first vehicle-mounted device.
步骤4010:第一车载设备根据第一SHE反馈的验证结果,更新第一密钥的状态信息,并相应生成状态数据的验证码。Step 4010: The first vehicle-mounted device updates the state information of the first key according to the verification result fed back by the first SHE, and generates a verification code of the state data accordingly.
步骤4011:第一车载设备向第一安全硬件扩展单元发送状态更新消息。Step 4011: the first vehicle-mounted device sends a status update message to the first security hardware expansion unit.
其中,状态更新消息包括:车内密钥的构建状态;状态更新消息用于第一安全硬件扩展单元对状态更新消息验证成功后,更新自身的车内密钥的构建状态。Wherein, the state update message includes: the construction state of the in-vehicle key; the state update message is used for the first security hardware expansion unit to update the construction state of its own in-vehicle key after the verification of the state update message is successful.
需要说明的是,车内密钥的构建状态可以为密钥体系的构建状态,也可以为第一密钥的构建状态,在此不做限定。It should be noted that the construction state of the in-vehicle key may be the construction state of the key system or the construction state of the first key, which is not limited here.
步骤4012:第一SHE对状态更新消息进行验证,在验证成功后,更新状态数据的安 全验证码。Step 4012: The first SHE verifies the status update message, and updates the security verification code of the status data after the verification is successful.
下面具体介绍每个步骤中涉及的消息。The messages involved in each step are described in detail below.
在步骤401中,第一车载设备接收的第一响应消息中,可以携带第一密钥加载消息的入参和出参,即第一响应消息中携带的出参包括M1~M7。其中,出参M3~M5为第一密钥的第一参数,即第一密钥加载消息对应的入参M1~M3。In step 401, the first response message received by the first vehicle-mounted device may carry the input parameters and output parameters of the first key loading message, that is, the output parameters carried in the first response message include M1-M7. Wherein, the output parameters M3-M5 are the first parameters of the first key, that is, the input parameters M1-M3 corresponding to the first key loading message.
其中,第一密钥加载消息对应的入参满足:Among them, the input parameters corresponding to the first key loading message satisfy:
M1=UID|memory slot|KEY_IDM1=UID|memory slot|KEY_ID
M2=ENC CBC,K1,IV=0(Counter|Flags[|KeyID]|“0…0”m|Key memory slot) M2=ENC CBC, K1, IV=0 (Counter|Flags[|KeyID]|“0…0”m|Key memory slot )
M3=CMAC(K2,M1|M2)M3=CMAC(K2,M1|M2)
其中,UID在Memory Slot为8 bits时,UID可以为128 bits。当第一密钥加载消息用于向第一车载设备的SHE中存储该第一车载设备的专属密钥,比如GLOBAL_FIX_KEY,其他车载设备不获得该密钥时,则UID可以不为0,该UID为第一车载设备的专用标识。当第一密钥加载消息向第一SHE中存储时,且第一密钥还应灌装至第二车载设备时,则UID应该为0(即wildcard UID)。Among them, when the UID is 8 bits in the Memory Slot, the UID can be 128 bits. When the first key loading message is used to store the exclusive key of the first vehicle-mounted device in the SHE of the first vehicle-mounted device, such as GLOBAL_FIX_KEY, when other vehicle-mounted devices do not obtain the key, the UID may not be 0, and the UID It is the special identifier of the first vehicle-mounted device. When the first key loading message is stored in the first SHE, and the first key should also be filled into the second vehicle-mounted device, the UID should be 0 (ie wildcard UID).
Key memory slot为第一密钥。memory slot用于指示第一密钥存储的密钥地址。KEY_ID用于指示该第一密钥加载消息的安全验证密钥,用于派生出K1、K2的密钥的密钥标识。K1、K2是由KEY_ID对应的密钥派生得到的加密密钥和完整性计算密钥,派生方法参考现有SHE规范,在此不再赘述。安全验证密钥的选择可以基于表7确定,例如,该第一密钥加载消息的入参M1~M3(即第一响应消息的出参M3~M5)为第一SHE生成的,则安全验证密钥可以是一车一密的固定密钥、一车一密的长期密钥或更新前的第一密钥等。Counter为第一密钥对应的密钥更新计数值,可以是28 bits。SHE处理时,可以先校验该值是否大于memory slot对应存储区的待更新的第一密钥的Counter值。如果当前处于KMS的密钥体系构建过程中时,即KMS_KH_BuildStatus值为“1-构建中”,还要校验该值与SHE中的KMS_KH_BuildCounter值是否相同。 Key memory slot is the first key. The memory slot is used to indicate the key address of the first key storage. KEY_ID is used to indicate the security verification key of the first key loading message, and is used to derive the key identifier of the key of K1 and K2. K1 and K2 are the encryption key and integrity calculation key derived from the key corresponding to KEY_ID. The derivation method refers to the existing SHE specification and will not be repeated here. The selection of the security verification key can be determined based on Table 7. For example, the input parameters M1-M3 of the first key loading message (that is, the output parameters M3-M5 of the first response message) are generated by the first SHE, then the security verification The key can be a fixed key for one vehicle, one secret, a long-term key for one vehicle, or the first key before updating, etc. Counter is a key update count value corresponding to the first key, which may be 28 bits. During SHE processing, it may first be checked whether this value is greater than the Counter value of the first key to be updated in the storage area corresponding to the memory slot. If the KMS key system is currently being built, that is, the KMS_KH_BuildStatus value is "1-under construction", it is also necessary to check whether this value is the same as the KMS_KH_BuildCounter value in SHE.
可选的,还可以包括KeyID,用于表示memory slot对应密钥的密钥索引(不是Memory Slot)。如果含有该字段,不可为0。“0…0”m:填充0字段,用于块加密对齐。由于AES_CBC_128加密时,块长度为128 bits,如果不含KeyID,则“0…0”m需要填充94 bits的0。如果含有KeyID,则“0…0”m需要填充62 bits的0。Optionally, KeyID can also be included, which is used to indicate the key index of the key corresponding to the memory slot (not the Memory Slot). If this field is included, it cannot be 0. "0...0"m: Fill the field with 0, used for block encryption alignment. Since the block length is 128 bits during AES_CBC_128 encryption, if the KeyID is not included, "0...0"m needs to be filled with 94 bits of 0. If KeyID is included, "0...0"m needs to be filled with 62 bits of 0.
在步骤405中,第二SHE在对第一密钥加载消息携带的入参进行验证成功后,可以相应生成第一密钥加载的响应消息,该第一密钥加载的响应消息可以携带第一密钥加载消息的出参,其中,出参M4和出参M5满足:In step 405, after the second SHE successfully verifies the input parameters carried in the first key loading message, it can correspondingly generate a first key loading response message, and the first key loading response message can carry the first The output parameters of the key loading message, where the output parameters M4 and M5 satisfy:
M4=UID|memory slot|KEY_ID|EncyptedValueM4=UID|memory slot|KEY_ID|EncyptedValue
M5=CMAC(K4,M4)M5=CMAC(K4,M4)
其中,M4中的UID同入参的说明,M4的值也与入参相同。相应的,memory slot和KEY_ID也与入参中的值相同。需要说明的是,该KEY_ID对应的密钥并不用于第一密钥加载的响应消息的出参的加密和/或完整性计算。出参可以是根据更新后的第一密钥进行加密和/或完整性计算的,见下面的说明。Among them, the UID in M4 is the same as the description of the input parameter, and the value of M4 is also the same as the input parameter. Correspondingly, the memory slot and KEY_ID are also the same as the values in the input parameters. It should be noted that the key corresponding to the KEY_ID is not used for encryption and/or integrity calculation of the output parameters of the response message loaded with the first key. The output parameters may be encrypted and/or integrity calculated according to the updated first key, see the description below.
EncyptedValue=ENC CBC,K3,IV=0(Counter|“1” 1[|KeyID]|“0…0”n)。 EncyptedValue = ENC CBC, K3, IV = 0 (Counter|"1" 1 [|KeyID]|"0...0"n).
其中,K3是由第一密钥派生的加密密钥。Counter同入参的Counter值。“1” 1表示数值“1”占用1bit,“0…0”n:表示数值“0”占用填充n个bit。KeyID为可选的,用于表 示第一密钥的密钥索引,如果入参中含有该字段,则此处必须包含。32 bits。AES_CBC_128加密时,块长度为128 bits,例如,在不含KeyID时,则填充99 bits的0。在含有KeyID时,则填充67bits的0。K4是第一密钥派生的完整性计算密钥。派生方法参考现有SHE规范的说明。在第一密钥加载消息验证成功后,第二SHE将第一密钥的构建状态BuildStatus设置为“1-构建成功”。 Wherein, K3 is an encryption key derived from the first key. Counter is the same as the Counter value of the input parameter. "1" 1 indicates that the value "1" occupies 1 bit, "0...0" n: indicates that the value "0" occupies n bits. KeyID is optional and is used to indicate the key index of the first key. If this field is included in the input parameter, it must be included here. 32 bits. For AES_CBC_128 encryption, the block length is 128 bits. For example, if KeyID is not included, 99 bits of 0 are filled. When KeyID is included, 67 bits of 0 are filled. K4 is the integrity calculation key derived from the first key. For the derivation method, refer to the description of the existing SHE specification. After the first key loading message is successfully verified, the second SHE sets the build status BuildStatus of the first key to "1—build successfully".
在步骤406中,第一密钥的灌装验证消息的参数可以如表13所示。In step 406, the parameters of the filling verification message of the first key may be as shown in Table 13.
表13Table 13
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 272272
M2M2 ININ 128128
其中,第一密钥的灌装验证消息可以携带第一密钥的灌装响应消息的出参。即,入参满足:Wherein, the filling verification message of the first key may carry an output parameter of the filling response message of the first key. That is, the input parameters satisfy:
M1=UID|memory slot|KEY_ID|EncyptedValueM1=UID|memory slot|KEY_ID|EncyptedValue
M2=CMAC(K4,M1)M2=CMAC(K4,M1)
第一车载设备通过第一密钥的灌装验证消息,将来自第二车载设备的第一密钥的灌装响应消息的出参的M4、M5传给SHE进行验证,确认第二车载设备的第一密钥的灌装是否成功完成,并将验证结果返回给第一车载设备。The first vehicle-mounted device passes the M4 and M5 of the output parameters of the filling response message of the first key from the second vehicle-mounted device to the SHE for verification through the filling verification message of the first key, and confirms the identity of the second vehicle-mounted device. Whether the filling of the first key is successfully completed, and return the verification result to the first vehicle-mounted device.
其中,第一密钥的灌装响应消息的安全验证密钥可以采用第一车载设备与第一SHE之间的临时密钥。Wherein, the security verification key of the filling response message of the first key may be a temporary key between the first vehicle-mounted device and the first SHE.
在步骤409中,第一车载设备根据第一SHE反馈的验证结果,更新第一密钥的状态信息,并相应生成状态数据的完整性验证码MAC。In step 409, the first vehicle-mounted device updates the state information of the first key according to the verification result fed back by the first SHE, and generates an integrity verification code MAC of the state data accordingly.
在第一密钥的生成过程中,第一车载设备或第二车载设备需要不断将当前密钥体系构建过程中的状态数据,例如,第一密钥的状态数据,或密钥体系的状态数据,安全存储在非易失性存储区中。存储的第一密钥的状态数据可以包括:密钥的构建状态、构建类型、当前构建到第一密钥属于的通信安全域、构建的第一密钥对应的车载设备等。比如存储的状态数据可以包括:During the generation process of the first key, the first vehicle-mounted device or the second vehicle-mounted device needs to continuously update the state data in the process of building the current key system, for example, the state data of the first key or the state data of the key system , safely stored in non-volatile memory. The stored status data of the first key may include: the construction status of the key, the construction type, the communication security domain to which the first key is currently constructed, the in-vehicle device corresponding to the constructed first key, and the like. For example, stored state data may include:
构建状态的标记KMSBuildStatusFlag,用于标记密钥体系的构建状态,未构建、正在构建、已经完成。The flag KMSBuildStatusFlag of the build status is used to mark the build status of the key system, such as unbuilt, under construction, and completed.
构建类型的标记KMSBuildTypeFlag,用于标记当前是初始密钥体系构建、长期密钥更新、还是更换车载设备的密钥体系重构。该标记仅当KMSBuildStatusFlag是正在构建时才有用。The build type flag KMSBuildTypeFlag is used to mark the current initial key system construction, long-term key update, or key system reconstruction for vehicle equipment replacement. This flag is only useful if KMSBuildStatusFlag is building.
构建阶段的标记KMSBuildStageFlag,用于标记当前是正在进行一车一密的固定密钥灌装、一车一密的长期构建或更新、各通信安全域的构建阶段或更新阶段等;The mark KMSBuildStageFlag of the construction stage is used to mark the current one-vehicle-one-key fixed key filling, one-vehicle-one-key long-term construction or update, the construction stage or update stage of each communication security domain, etc.;
当然,还可以附加一些信息,比如当前构建到哪个通信安全域的哪个车载设备等。Of course, some information can also be added, such as which vehicle-mounted device is currently built into which communication security domain, etc.
本申请中,为保证状态数据的安全性,可以对状态数据的完整性保护,加密保护是可选的,下面以在没有加密保护的状态数据,完整性密钥和完整性MAC可以存储在安全存储区的场景。In this application, in order to ensure the security of the state data, the integrity protection of the state data can be protected, and the encryption protection is optional. In the following, the state data without encryption protection, the integrity key and the integrity MAC can be stored in a secure Store scene.
在KMS运行时,可以为上述更新后的状态数据生成的完整性校验码MAC,可以通过临时密钥验证后存储到SHE。When the KMS is running, the integrity check code MAC that can be generated for the above updated state data can be stored in the SHE after being verified by the temporary key.
一种可能的实现方式,可以通过密钥体系构建的启动消息,由SHE生成一个临时密钥 KTemp,并返回给车载设备。在车载设备构建密钥体系的过程中,由KMS和SHE共同持有该临时密钥K Temp。一种可能的实现方式,该临时密钥KTemp,可以采用对称密钥。可以避免运行过程中KMS(普通运行环境,如果是可信运行环境更好,比如隔离运行)密钥可能是SHE不信任,提高状态数据存储的安全性。或者,还可以采用非对称的签名算法,临时生成一对公私钥,临时公钥返回给KMS。考虑到该密钥可能被其他攻击者软件拿到,非对称算法并不会增强安全性,反而降低MAC的计算性能。 In a possible implementation, a temporary key KTemp can be generated by the SHE through the startup message constructed by the key system, and returned to the on-vehicle device. During the process of constructing the key system of the vehicle equipment, the temporary key K Temp is jointly held by the KMS and the SHE. A possible implementation manner, the temporary key KTemp may use a symmetric key. It can avoid KMS (ordinary operating environment, if it is a trusted operating environment, it is better, such as isolated operation) key during the operation process that SHE may not trust, and improve the security of state data storage. Alternatively, an asymmetric signature algorithm can be used to temporarily generate a pair of public and private keys, and the temporary public key is returned to KMS. Considering that the key may be obtained by other attacker software, the asymmetric algorithm will not enhance security, but will reduce the calculation performance of MAC.
通过临时密钥进行完整性保护,可以使得SHE更新第一密钥的相关信息(例如,完整性MAC、状态数据等)时,可以通过临时密钥进行完整性保护,提高防篡改的性能。Integrity protection through the temporary key can enable the SHE to perform integrity protection through the temporary key when updating the relevant information of the first key (for example, integrity MAC, status data, etc.), and improve tamper-resistant performance.
临时密钥KTemp也可以存储在SHE的非易失性存储区中。比如密钥构建过程中,如果设备异常重启,车载设备重启继续密钥体系构建时,需要与SHE再次完成验证,此时SHE可将原分配的KTemp,返回给KMS。当然也可以分配新的临时密钥。即在一次密钥体系构建过程中,KTemp可以保持不变,也可以按需变化。如果变化,需要保证新老临时密钥(KTemp_New、KTemp_Old)的平滑切换——对每个使用老临时密钥KTemp_Old加密和完整性保护的内容,都需要先替换为新临时密钥KTemp_New后,才可删除老临时密钥KTemp_Old。The temporary key KTemp can also be stored in the non-volatile storage area of the SHE. For example, during the key construction process, if the device restarts abnormally, when the vehicle device restarts to continue the key system construction, it needs to complete the verification with SHE again. At this time, SHE can return the originally allocated KTemp to KMS. It is of course also possible to assign a new temporary key. That is, during a key system construction process, KTemp can remain unchanged or can be changed as needed. If it changes, it is necessary to ensure the smooth switching of the old and new temporary keys (KTemp_New, KTemp_Old)—for each content encrypted and integrity-protected using the old temporary key KTemp_Old, it needs to be replaced with the new temporary key KTemp_New before The old temporary key KTemp_Old can be deleted.
密钥体系构建过程中的状态数据的存储,可以是加密存储在普通存储区,例如,车内KMS的服务端或代理端Agent,在密钥体系构建过程中,每次构建状态变化时,利用KTemp派生出加密密钥和完整性密钥,对状态数据加密后,存储到普通存储区。基于加密后的数据生成新的MAC,再利用CMD_KMS_KH_UPDATE_BUILDSTATUS,存储到SHE的KMS_KH_BuildMac中。KMS密钥构建过程中的关键状态数据也可以直接安全存储在SHE内部。例如,在SHE中扩展预留好存储KMS的过程状态数据的存储区即可,比如预留100Bytes。状态数据的具体含义,SHE可以不感知。The storage of the state data during the construction of the key system can be encrypted and stored in a common storage area. For example, the KMS server or agent agent in the car uses the KTemp derives the encryption key and integrity key, encrypts the state data, and stores it in the common storage area. Generate a new MAC based on the encrypted data, and then use CMD_KMS_KH_UPDATE_BUILDSTATUS to store it in KMS_KH_BuildMac of SHE. The key state data in the KMS key construction process can also be directly and securely stored inside the SHE. For example, it is enough to expand and reserve the storage area for storing the process state data of KMS in SHE, for example, reserve 100 Bytes. SHE may not perceive the specific meaning of the state data.
在步骤409中,第一车载设备可以向第一SHE发送状态更新消息。In step 409, the first vehicle-mounted device may send a status update message to the first SHE.
下面举例说明状态更新消息CMD_KMS_KH_UPDATE_BUILDSTATUS,可以涉及到的参数。如表14所示。The following example illustrates the parameters that can be involved in the status update message CMD_KMS_KH_UPDATE_BUILDSTATUS. As shown in Table 14.
表14Table 14
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 168168
M2M2 ININ 128128
以该消息用于将构建状态信息的安全校验码MAC存储到SHE的KMS_KH_BuildMac中为例,该消息的入参满足:Take this message as an example to store the security check code MAC of the build status information in KMS_KH_BuildMac of SHE. The input parameters of this message meet the following requirements:
M2=CMAC(Key,M1)M2=CMAC(Key,M1)
Key是KEY_ID为状态更新消息的安全验证密钥,例如临时密钥。Key is a security verification key whose KEY_ID is a status update message, such as a temporary key.
其中,入参满足:Among them, the input parameters meet:
M1=KEY_ID|KMS_KH_BuildCounter|MACM1=KEY_ID|KMS_KH_BuildCounter|MAC
其中,KEY_ID可以是临时密钥的密钥地址。MAC是利用临时密钥基于当前密钥体系构建状态数据生成的安全校验码。例如,状态数据为KMSBuildStatusData={KMSBuildStatusFlag|KMSBuildTypeFlag|KMSBuildStageFlag|…},则安全校验码满足:Among them, KEY_ID may be the key address of the temporary key. MAC is a security check code generated based on the current key system construction status data using a temporary key. For example, if the status data is KMSBuildStatusData={KMSBuildStatusFlag|KMSBuildTypeFlag|KMSBuildStageFlag|…}, then the security check code satisfies:
MAC=CMAC(Key,KMSBuildStatusData)。KMS_KH_BuildCounter是SHE中的KMS_KH_BuildCounter值,防止该命令的重放攻击。例如,在KMS_KH_BuildCounter值 不等于第一SHE中的值,则忽略该状态更新消息,返回ERC_INVALID_PARAMETER。在MAC与SHE中KMS_KH_BuildMac当前保存的值相同,则表明状态数据无需更新,此时忽略该状态更新消息,并返回ENC_REPEAT_STORE_SAME_DATA。MAC = CMAC(Key, KMSBuildStatusData). KMS_KH_BuildCounter is the KMS_KH_BuildCounter value in SHE to prevent replay attacks of this command. For example, if the KMS_KH_BuildCounter value is not equal to the value in the first SHE, ignore the status update message and return ERC_INVALID_PARAMETER. If the current saved value of KMS_KH_BuildMac in MAC and SHE is the same, it indicates that the state data does not need to be updated. At this time, ignore the state update message and return ENC_REPEAT_STORE_SAME_DATA.
场景4,在密钥体系构建过程中,第一车载设备或第二车载设备都可能出现异常重启的场景,第一车载设备或第二车载设备重启后,第一车载设备或第二车载设备可以重新经过SHE验证,获取临时密钥,该临时密钥可以是重启前生成的临时密钥,也可以是为该车载设备重新生成的临时密钥。在第一车载设备或第二车载设备与相应的SHE获得临时密钥后,可以验证存储的状态数据的完整性,之后继续密钥体系的构建,避免由于第一车载设备或第二车载设备的重启,导致重启密钥体系的构建,提高密钥体系构建的鲁棒性。Scenario 4: During the construction of the key system, the first vehicle-mounted device or the second vehicle-mounted device may restart abnormally. After the first vehicle-mounted device or the second vehicle-mounted device restarts, the first vehicle-mounted device or the second vehicle-mounted device can Re-verified by SHE to obtain a temporary key, which can be a temporary key generated before restarting, or a temporary key regenerated for the on-board device. After the first vehicle-mounted device or the second vehicle-mounted device and the corresponding SHE obtain the temporary key, the integrity of the stored state data can be verified, and then the construction of the key system can be continued to avoid the failure of the first or second vehicle-mounted device. Restarting causes the construction of the key system to be restarted, improving the robustness of the key system construction.
一种可能的实现方式,第一车载设备或第二车载设备异常重启后,也可以通过第一车载设备(例如,服务端或代理端)向第一SHE发送第一查询消息,通知SHE验证重启前存储关键状态数据的MAC,验证成功后,从SHE中安全读取重启前的密钥体系构建进度,即返回密钥体系构建的状态数据。在第一车载设备或第二车载设备获得临时密钥后,可以使用SHE为本次构建生成的临时密钥进行安全性验证。如果验证失败,在第一车载设备为代理端时,可以向服务端发送第一查询请求,以获得密钥体系的构建状态;在第一车载设备为服务端时,则确认密钥体系的构建失败,可以重启密钥体系的构建。第一查询消息的参数可以参见表12所示,在此不再赘述。In a possible implementation, after the first vehicle-mounted device or the second vehicle-mounted device restarts abnormally, the first query message may also be sent to the first SHE through the first vehicle-mounted device (for example, the server or agent) to notify the SHE to verify the restart The MAC that previously stored the key state data, after the verification is successful, securely reads the progress of the key system construction before the restart from the SHE, that is, returns the state data of the key system construction. After the first vehicle-mounted device or the second vehicle-mounted device obtains the temporary key, the temporary key generated by the SHE for this build can be used for security verification. If the verification fails, when the first vehicle-mounted device is the agent, the first query request can be sent to the server to obtain the construction status of the key system; when the first vehicle-mounted device is the server, then confirm the construction of the key system If it fails, you can restart the construction of the key system. The parameters of the first query message can be referred to in Table 12, and will not be repeated here.
如图5所示,为本申请提供的一种重启场景下的密钥生成方法的流程示意图。以第一车载设备重启为例,包括如下步骤:As shown in FIG. 5 , it is a schematic flowchart of a method for generating a key in a restart scenario provided by the present application. Taking the restart of the first vehicle-mounted device as an example, the following steps are included:
步骤501:第一车载设备确定重启后,向第一SHE发送第一查询请求;第一查询请求用于查询第一密钥的第二参数。Step 501: After the first vehicle-mounted device determines to restart, it sends a first query request to the first SHE; the first query request is used to query the second parameter of the first key.
举例来说,第一车载设备可以是KMS的服务端或KMS的代理端。例如,在第一车载设备为服务端时,第一车载设备可以向第一SHE发送第一查询请求。此时,第一SHE为第一车载设备对应的SHE。For example, the first vehicle-mounted device may be a KMS server or a KMS agent. For example, when the first vehicle-mounted device is a server, the first vehicle-mounted device may send a first query request to the first SHE. At this time, the first SHE is the SHE corresponding to the first vehicle-mounted device.
再比如,在第一车载设备为代理端时,第一车载设备可以向第一车载设备对应的SHE发送第一查询请求,通过第一车载设备对应的SHE对第一查询请求进行验证后,返回第一查询响应。或者,第一车载设备可以向服务端发送第一查询请求,通过服务端的SHE对第一查询请求进行验证后,返回第一查询响应。此时,第一SHE为服务端对应的SHE。For another example, when the first vehicle-mounted device is an agent, the first vehicle-mounted device can send a first query request to the SHE corresponding to the first vehicle-mounted device, and after verifying the first query request through the SHE corresponding to the first vehicle-mounted device, return First query response. Alternatively, the first vehicle-mounted device may send the first query request to the server, and return the first query response after verifying the first query request through the SHE of the server. At this time, the first SHE is the SHE corresponding to the server.
步骤502:第一SHE根据第一查询请求,生成第一查询响应消息;第一查询响应消息为第一安全硬件扩展单元对第一查询请求进行验证后返回的;第一查询响应消息包括:第一密钥的第二参数。Step 502: The first SHE generates a first query response message according to the first query request; the first query response message is returned after the first security hardware extension unit verifies the first query request; the first query response message includes: The second parameter of a key.
步骤503:第一SHE向第一车载设备发送第一查询响应消息。Step 503: the first SHE sends a first query response message to the first vehicle-mounted device.
场景4.1,第一车载设备的第一查询消息还可以用于获得临时密钥,即第一安全硬件扩展单元向第一车载设备发送临时密钥;其中,临时密钥用于加密第一请求消息。Scenario 4.1, the first query message of the first vehicle-mounted device can also be used to obtain a temporary key, that is, the first security hardware expansion unit sends the temporary key to the first vehicle-mounted device; where the temporary key is used to encrypt the first request message .
第一SHE在验证该消息时,可以判断当前密钥体系的构建状态KMS_KH_BuildStatus是否为“构建中”。如果不是则拒绝。验证该重启消息和第一查询消息后,第一SHE可以返回密钥体系构建的重启响应消息,该密钥体系构建的重启响应消息携带第一查询响应消息。其中,该第一查询响应消息可以携带临时密钥。When verifying the message, the first SHE can judge whether the current key system construction status KMS_KH_BuildStatus is "under construction". Reject if not. After verifying the restart message and the first query message, the first SHE may return a restart response message constructed by the key system, and the restart response message constructed by the key system carries the first query response message. Wherein, the first query response message may carry a temporary key.
场景4.2,第一车载设备根据第一查询响应,确定当前执行生成第一密钥的操作。In Scenario 4.2, the first vehicle-mounted device determines, according to the first query response, that the operation of generating the first key is currently being performed.
在一些实施例中,第一车载设备根据第一密钥的第二参数和第一消息,生成第一请求消息;第一密钥为重启前第一安全硬件扩展单元待生成的密钥。第一安全硬件扩展单元根据第一请求消息,生成加密的第一密钥。In some embodiments, the first vehicle-mounted device generates the first request message according to the second parameter of the first key and the first message; the first key is the key to be generated by the first security hardware expansion unit before restarting. The first secure hardware expansion unit generates an encrypted first key according to the first request message.
在一种可能的实现方式中,确定第一车载设备重启后,第一车载设备可以向第一SHE通知第一车载设备的重启状态,并通知第一SHE继续重启前的密钥体系的构建,此时可以向第一SHE发送密钥体系构建的重启消息。用于第一车载设备重新获取安全验证密钥及密钥体系构建的状态。例如,针对服务端,重启消息可以使用固定密钥作为安全验证密钥,可以参见密钥体系构建的启动消息,在此不再赘述。针对代理端,重启消息可以使用固定密钥或当期使用的临时密钥作为安全验证密钥,该安全验证密钥可以来自服务端发送给代理端的密钥。针对代理端,重启消息可以使用固定密钥或当期使用的临时密钥作为安全验证密钥,该安全验证密钥可以来自服务端或代理端发送给客户端的密钥。In a possible implementation, after it is determined that the first vehicle-mounted device is restarted, the first vehicle-mounted device may notify the first SHE of the restart status of the first vehicle-mounted device, and notify the first SHE to continue building the key system before restarting, At this time, a restart message of key system construction may be sent to the first SHE. It is used for the first in-vehicle device to reacquire the security verification key and the state of the key system construction. For example, for the server, the restart message can use a fixed key as the security verification key, which can be found in the startup message of the key system construction, and will not be repeated here. For the agent, the restart message can use a fixed key or a temporary key used in the current period as the security verification key, and the security verification key can come from the key sent from the server to the agent. For the agent, the restart message can use a fixed key or a temporary key used in the current period as the security verification key, and the security verification key can come from the key sent to the client by the server or the agent.
需要说明的是,第一查询请求可以是参考上文中的第一查询请求的方式发送的,还可以是通过密钥体系构建的重启消息携带第一查询请求的方式。It should be noted that the first query request may be sent in a manner referring to the first query request above, or may be sent in a manner in which a restart message constructed through a key system carries the first query request.
一种可能的实现方式,第一车载设备可以向第一SHE发送密钥体系构建的重启消息携带第一查询消息。第一SHE可以在第一查询响应中发送该临时密钥。一种可能的实现方式,第一车载设备可以向第一SHE发送密钥体系构建的重启消息携带第一请求消息。In a possible implementation manner, the first on-vehicle device may send a restart message of key system construction to the first SHE, carrying the first query message. The first SHE may send the ephemeral key in the first query response. In a possible implementation manner, the first vehicle-mounted device may send a restart message of key system construction to the first SHE, carrying the first request message.
下面具体介绍密钥体系构建的重启消息可能的实现方式。密钥体系构建的重启消息必须在密钥体系构建的启动消息之后、在密钥体系构建的结束消息之前执行。具体可以通过密钥体系构建的参数进行验证。如表15所示,密钥体系构建的重启消息可能涉及以下参数。The following describes in detail the possible implementation of the restart message of the key system construction. The restart message of key system construction must be executed after the start message of key system construction and before the end message of key system construction. Specifically, it can be verified through the parameters of the key system construction. As shown in Table 15, the restart message for key system construction may involve the following parameters.
表15Table 15
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ mm
M2M2 ININ 128128
M3M3 OUTout nno
M4M4 OUTout 128128
M5M5 OUTout 128128
以第一车载设备为例,第一车载设备可以通过车外设备触发密钥体系构建的重启消息,举例来说,可以由服务器、APP、CDC或中控屏生成密钥体系构建的重启消息所需参数,传递给服务端,服务端将该消息生成密钥体系构建的重启消息,发送给第一SHE,第一SHE对密钥体系构建的重启消息进行验证,在验证后,生成密钥体系构建的重启消息对应的出参,并相应生成密钥体系构建的重启响应消息,该响应消息携带密钥体系构建的重启消息对应的出参。Taking the first vehicle-mounted device as an example, the first vehicle-mounted device can trigger a restart message constructed by the key system through an external device. For example, the restart message generated by the server, APP, CDC or the central control screen can The parameters are required and passed to the server. The server generates the restart message of the key system construction from the message and sends it to the first SHE. The first SHE verifies the restart message of the key system construction. After verification, the key system is generated. The output parameters corresponding to the restart message of the construction, and correspondingly generate the restart response message of the key system construction, and the response message carries the output parameters corresponding to the restart message of the key system construction.
在一些实施例中,该重启消息可以携带其他消息,也可以不携带其他消息,具体方式可以参考In some embodiments, the restart message may or may not carry other messages. For details, please refer to
携带的其他消息可以参考表11,在此不再赘述。密钥体系构建的重启消息携带的参数可以包括M1和M2。For other carried messages, reference may be made to Table 11, which will not be repeated here. The parameters carried in the restart message of key system construction may include M1 and M2.
入参M1满足:The input parameter M1 satisfies:
M1=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_IN_ParametersM1=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_IN_Parameters
入参M2满足:The input parameter M2 satisfies:
M2=CMAC(Key,M1)M2=CMAC(Key,M1)
其中,Key是安全验证密钥,即KEY_ID对应的密钥。在对于车外设备发起的密钥体系构建的启动消息,相应的,车外设备发起的密钥体系构建的重启消息,则KEY_ID是固定密钥对应的KEY_ID,对于内车CDC或中控屏确认后触发的长期密钥更新,可以是长期密钥对应的KEY_ID,比如是一车一密的长期密钥的KEY_ID。Among them, Key is the security verification key, that is, the key corresponding to KEY_ID. For the start message of the key system construction initiated by the device outside the vehicle, and correspondingly, the restart message of the key system construction initiated by the device outside the vehicle, the KEY_ID is the KEY_ID corresponding to the fixed key. For the CDC or central control screen confirmation in the car The long-term key update triggered later may be the KEY_ID corresponding to the long-term key, for example, the KEY_ID of the long-term key for one car one encryption.
CMD_TYPE表示密钥体系构建的重启消息是否携带其他消息。具体参见表11,即密钥体系构建的启动消息携带其他消息的示例。CMD_TYPE_IN_Parameters:是CMD_TYPE对应其他消息的所有入参,此时,CMD_TYPE值不可为0。CMD_TYPE indicates whether the restart message of the key system construction carries other messages. For details, refer to Table 11, which is an example of the startup message of the key system construction carrying other messages. CMD_TYPE_IN_Parameters: CMD_TYPE corresponds to all input parameters of other messages. At this time, the value of CMD_TYPE cannot be 0.
KMS_KH_BuildCounter为密钥体系构建计数的值。第一车载设备对应的第一SHE在执行该密钥体系构建的重启消息时,该密钥体系构建的重启消息中的KMS_KH_BuildCounter值必须等于第一SHE中KMS_KH_BuildCounter的值,且SHE中的KMS_KH_BuildStatus必须为“构建中”,确定第一车载设备对应的第一SHE对密钥体系构建的重启消息验证成功,否则,第一车载设备对应的第一SHE对密钥体系构建的重启消息验证失败。例如,在密钥体系构建的重启消息中的KMS_KH_BuildCounter值不等于第一SHE中的KMS_KH_BuildCounter值,则忽略密钥体系构建的重启消息,并返回ERC_INVALID_PARAMETER。具体可以参见密钥体系构建的启动消息的验证方式,在此不再赘述。KMS_KH_BuildCounter is the value of the key system build count. When the first SHE corresponding to the first vehicle-mounted device executes the restart message of the key system construction, the value of KMS_KH_BuildCounter in the restart message of the key system construction must be equal to the value of KMS_KH_BuildCounter in the first SHE, and the KMS_KH_BuildStatus in the SHE must be "Building", it is determined that the first SHE corresponding to the first vehicle device successfully verifies the restart message of the key system construction; otherwise, the first SHE corresponding to the first vehicle device fails to verify the restart message of the key system construction. For example, if the KMS_KH_BuildCounter value in the key system construction restart message is not equal to the KMS_KH_BuildCounter value in the first SHE, ignore the key system construction restart message and return ERC_INVALID_PARAMETER. For details, please refer to the verification method of the startup message of the key system construction, which will not be repeated here.
在第一车载设备对应的第一SHE对密钥体系构建的重启消息验证成功后,第一车载设备对应的第一SHE可以生成密钥体系构建的重启的响应消息,该响应消息可以携带以下出参M3~M5。After the first SHE corresponding to the first vehicle-mounted device successfully verifies the restart message of the key system construction, the first SHE corresponding to the first vehicle-mounted device can generate a response message for the restart of the key system construction, and the response message can carry the following information: Refer to M3~M5.
其中,出参M3满足:Among them, the output parameter M3 satisfies:
M3=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_OUT_ParametersM3=KEY_ID|KMS_KH_BuildCounter|CMD_TYPE|CMD_TYPE_OUT_Parameters
出参M4满足:M4=CMAC(Key,M3)The output parameter M4 satisfies: M4=CMAC(Key,M3)
出参M5满足:M5=KMS_KH_BuildKTempThe output parameter M5 satisfies: M5=KMS_KH_BuildKTemp
其中,CMD_TYPE_OUT_Parameters:是CMD_TYPE对应的所有出参。Among them, CMD_TYPE_OUT_Parameters: is all the output parameters corresponding to CMD_TYPE.
KMS_KH_BuildKTemp可以是重启前,由密钥体系构建的启动消息生成的一个临时密钥KTemp,也可以是第一SHE针对密钥体系构建的重启消息生成的新的临时密钥。KMS_KH_BuildKTemp may be a temporary key KTemp generated by the start message of key system construction before restart, or a new temporary key generated by the first SHE for the restart message of key system construction.
需要说明的是,相比密钥体系构建的启动消息,在第一车载设备对应的第一SHE对密钥体系构建的重启消息验证成功后,SHE中KMS_KH_BuildCounter的值保持不变。It should be noted that, compared with the start message of key system construction, after the first SHE corresponding to the first vehicle device successfully verifies the restart message of key system construction, the value of KMS_KH_BuildCounter in the SHE remains unchanged.
考虑到在每次执行密钥体系构建的启动消息,启动密钥体系构建时,相应的SHE将本地存储的KMS_KH_BuildCounter增1。在第一密钥构建完成(例如,执行第一请求消息、或第一密钥加载消息成功)后,第一密钥对应的Counter字段设置为KMS_KH_BuildCounter值。从而,在第一车载设备或第二车载设备重启后,可以通过获得密钥体系的状态数据,确定密钥生成的状态,尤其是对于重启前已生成但未完成加载的第一密钥。此时,服务端或代理端可以从相应的SHE中,获得第一密钥的第一参数,生成第一密钥加载消息,并继续向未获得该第一密钥的各客户端或代理端分发,而不必重新启动构建第一密钥的操作。Considering that each time the start message of key system construction is executed, the corresponding SHE will increase the locally stored KMS_KH_BuildCounter by 1 when starting the key system construction. After the construction of the first key is completed (for example, the execution of the first request message, or the success of the first key loading message), the Counter field corresponding to the first key is set to the value of KMS_KH_BuildCounter. Therefore, after the first vehicle-mounted device or the second vehicle-mounted device is restarted, the state of key generation can be determined by obtaining the state data of the key system, especially for the first key that has been generated but not yet loaded before the restart. At this time, the server or agent can obtain the first parameter of the first key from the corresponding SHE, generate the first key loading message, and continue to send the first key to each client or agent that has not obtained the first key. distribution without having to restart the operation that built the first key.
如图6所示,为本申请提供的一种重启场景下的密钥生成方法的流程示意图。以第二车载设备重启为例,包括如下步骤:As shown in FIG. 6 , it is a schematic flowchart of a method for generating a key in a restart scenario provided by the present application. Taking the restart of the second in-vehicle device as an example, the following steps are included:
步骤601:第二车载设备向第一车载设备发送第二消息;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。Step 601: The second vehicle-mounted device sends a second message to the first vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key, or instructing the first vehicle-mounted device to Second, the on-board equipment restarts.
在一些实施例中,第二车载设备可以是KMS的客户端或KMS的代理端。例如,在第一车载设备为服务端,第二车载设备为客户端时,第二车载设备可以向第一车载设备发送第二消息,或者第二车载设备可以向代理端发送第二消息,并由代理端向第一车载设备转发第二消息。In some embodiments, the second in-vehicle device may be a KMS client or a KMS proxy. For example, when the first vehicle-mounted device is a server and the second vehicle-mounted device is a client, the second vehicle-mounted device can send a second message to the first vehicle-mounted device, or the second vehicle-mounted device can send a second message to the agent, and The proxy end forwards the second message to the first vehicle-mounted device.
再比如,在第一车载设备为服务端,第二车载设备为代理端时,第二车载设备可以向第一车载设备发送第二消息。可选的,第二车载设备还可以接收来自第二车载设备所管理的客户端的第二消息。For another example, when the first vehicle-mounted device is the server and the second vehicle-mounted device is the agent, the second vehicle-mounted device may send the second message to the first vehicle-mounted device. Optionally, the second vehicle-mounted device may also receive a second message from a client managed by the second vehicle-mounted device.
步骤602:第一车载设备向第一SHE发送第二消息的验证消息。Step 602: the first vehicle-mounted device sends a verification message of the second message to the first SHE.
其中,第一SHE为第一车载设备对应的SHE。Wherein, the first SHE is the SHE corresponding to the first vehicle-mounted device.
步骤603:第一SHE对第二消息的验证消息进行验证后,向第一车载设备返回第二消息的验证响应消息。Step 603: After verifying the verification message of the second message, the first SHE returns a verification response message of the second message to the first vehicle-mounted device.
通过步骤602和步骤603实现第一车载设备对第二消息的验证。The verification of the second message by the first in-vehicle device is realized through steps 602 and 603 .
步骤604:第一车载设备根据第二消息的验证响应消息,向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。Step 604: The first vehicle-mounted device sends a third message to the second vehicle-mounted device according to the verification response message of the second message; the third message includes at least one of the following items: the second parameter of the first key and the information of the first key.
举例来说,在第一车载设备为服务端,第二车载设备为客户端时,第一车载设备可以向第二车载设备发送第三消息,或者第一车载设备可以向代理端发送第三消息,并由代理端向第二车载设备转发第三消息。For example, when the first vehicle-mounted device is a server and the second vehicle-mounted device is a client, the first vehicle-mounted device can send a third message to the second vehicle-mounted device, or the first vehicle-mounted device can send a third message to the agent , and forward the third message to the second in-vehicle device by the agent.
再比如,在第一车载设备为服务端,第二车载设备为代理端时,第一车载设备可以向第二车载设备发送第三消息。可选的,第二车载设备还可以向第二车载设备所管理的客户端下发第三消息。For another example, when the first vehicle-mounted device is the server and the second vehicle-mounted device is the agent, the first vehicle-mounted device may send the third message to the second vehicle-mounted device. Optionally, the second vehicle-mounted device may also send a third message to the client managed by the second vehicle-mounted device.
再比如,在第一车载设备为代理端时,第一车载设备可以接收服务端转发的第三消息,还可以向第一车载设备所管理的第二车载设备下发第三消息。再比如,在第一车载设备为代理端时,第一车载设备可以生成第三消息,并向可以向第一车载设备所管理的第二车载设备下发第三消息。For another example, when the first vehicle-mounted device is an agent, the first vehicle-mounted device may receive the third message forwarded by the server, and may also send the third message to the second vehicle-mounted device managed by the first vehicle-mounted device. For another example, when the first vehicle-mounted device is an agent, the first vehicle-mounted device may generate a third message, and send the third message to a second vehicle-mounted device that may be managed by the first vehicle-mounted device.
下面以场景5.1~5.2举例说明上述过程。The following uses scenarios 5.1 to 5.2 as examples to illustrate the above process.
场景5.1,第二车载设备向第一车载设备发送的第二消息为第一查询消息。In scenario 5.1, the second message sent by the second vehicle-mounted device to the first vehicle-mounted device is the first query message.
对于第二车载设备的重启,重启后可以是在安全隧道建立成功后,由第一车载设备(例如,代理端、或服务端)根据第一查询消息的入参,生成向第一SHE发送的第一查询消息的验证消息,该第一查询消息的验证消息携带第一查询消息的入参,并通过第一SHE验证后,返回第一查询响应消息的出参(即第二消息的验证响应消息)。For the restart of the second in-vehicle device, after the restart, after the secure tunnel is established successfully, the first in-vehicle device (for example, an agent or server) generates a message sent to the first SHE according to the input parameters of the first query message. The verification message of the first query message, the verification message of the first query message carries the input parameter of the first query message, and after passing the first SHE verification, returns the output parameter of the first query response message (that is, the verification response of the second message information).
需要说明的是,第一查询消息的安全验证密钥可以是第一车载设备和第二车载设备之间使用的密钥,第二消息的验证消息的安全验证密钥可以是第一车载设备与第一SHE之间使用的密钥。It should be noted that the security verification key of the first query message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device, and the security verification key of the verification message of the second message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device. The key used between the first SHEs.
相应的,第一车载设备可以根据第一查询响应消息的出参,生成向第二车载设备发送的第三消息,该第三消息携带第一查询响应消息的出参,并将第三消息发送给重启的第二车载设备,第二车载设备在验证该第三消息后,获得第一查询响应消息的出参。需要说明的是,第三消息的安全验证密钥可以是第一车载设备和第二车载设备之间使用的密钥,第二消息的验证响应消息的安全验证密钥可以是第一车载设备与第一SHE之间使用的密钥。具体第一查询响应消息的入参和出参可以参考上文中的第一查询响应消息。Correspondingly, the first vehicle-mounted device may generate a third message to be sent to the second vehicle-mounted device according to the output parameter of the first query response message, the third message carries the output parameter of the first query response message, and sends the third message to For the restarted second vehicle-mounted device, the second vehicle-mounted device obtains the output parameters of the first query response message after verifying the third message. It should be noted that the security verification key of the third message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device, and the security verification key of the verification response message of the second message may be the key used between the first vehicle-mounted device and the second vehicle-mounted device. The key used between the first SHEs. For specific input parameters and output parameters of the first query response message, refer to the first query response message above.
场景5.2,第二车载设备向第一车载设备发送的第二消息为第一密钥的请求消息。In scenario 5.2, the second message sent by the second vehicle-mounted device to the first vehicle-mounted device is a request message for the first key.
在第二车载设备为代理端时,重启的代理端可以向第一车载设备(服务端)发送第一查询消息,以触发服务端返回第一查询响应消息后,代理端可以向代理端管理的客户端下发第一查询响应消息,以便各客户端与客户端对应的SHE完成验证,获得相应的临时密钥或状态数据等,以继续密钥体系的构建。When the second in-vehicle device is an agent, the restarted agent can send the first query message to the first in-vehicle device (server) to trigger the service end to return the first query response message, and the agent can report to the agent managed by the agent. The client sends the first query response message, so that each client completes the verification with the SHE corresponding to the client, and obtains the corresponding temporary key or status data, etc., to continue the construction of the key system.
相应的,第一车载设备根据第一密钥的请求消息,生成第一密钥加载消息。Correspondingly, the first vehicle-mounted device generates a first key loading message according to the first key request message.
考虑到第一密钥可能是在第二车载设备重启过程中已生成的,或者,是第二车载设备在重启后还未生成的,下面以场景5.2.1~场景5.2.2举例说明。Considering that the first key may have been generated during the restart process of the second vehicle-mounted device, or it has not been generated after the restart of the second vehicle-mounted device, the following uses scenarios 5.2.1 to 5.2.2 as examples for illustration.
场景5.2.1,在一些实施例中,第一车载设备根据第一密钥的第二参数和第一消息,生成第一密钥加载消息;第一密钥为重启前第一安全硬件扩展单元已生成的密钥。从而,第一车载设备可以向第二车载设备发送第一密钥加载消息。一种可能的实现方式,第二车载设备可以在密钥体系构建的重启消息携带第一查询消息。Scenario 5.2.1, in some embodiments, the first vehicle-mounted device generates a first key loading message according to the second parameter of the first key and the first message; the first key is the first secure hardware expansion unit before restarting generated key. Therefore, the first vehicle-mounted device can send the first key loading message to the second vehicle-mounted device. In a possible implementation manner, the second vehicle-mounted device may carry the first query message in the restart message constructed by the key system.
场景5.2.2,在一些实施例中,第一车载设备根据第一密钥的第二参数和第一消息,生成第一请求消息;并向第一SHE发送第一请求消息,在SHE验证第一请求消息后,生成第一响应消息,其中,第一响应消息携带第一密钥的第一参数。从而,第一车载设备接收到第一响应消息后,根据第一密钥的第一参数,生成第一密钥加载消息,并发送给第二车载设备,以使第二车载设备加载第一密钥。其中,第一请求消息可以携带在密钥体系构建的重启消息中发送。Scenario 5.2.2, in some embodiments, the first vehicle-mounted device generates the first request message according to the second parameter of the first key and the first message; and sends the first request message to the first SHE, and the SHE verifies the first request message. After a request message, a first response message is generated, where the first response message carries a first parameter of the first key. Therefore, after the first vehicle-mounted device receives the first response message, it generates a first key loading message according to the first parameter of the first key, and sends it to the second vehicle-mounted device, so that the second vehicle-mounted device loads the first key key. Wherein, the first request message may be carried in the restart message of key system construction and sent.
在密钥体系构建场景下,例如,在密钥体系构建的启动消息执行后,第一车载设备执行第二查询消息查询密钥的状态数据,密钥的状态数据可以包括:密钥的密钥标记、查询密钥是否形成配对等信息。具体可以参见上述状态数据,在此不再赘述。为保证密钥的安全,第二查询消息无法查询密钥内容。In the key system construction scenario, for example, after the start message of the key system construction is executed, the first vehicle-mounted device executes the second query message to query the state data of the key, and the state data of the key may include: the key of the key information such as marking, querying whether the key forms a pair, etc. For details, reference may be made to the above status data, which will not be repeated here. To ensure the security of the key, the second query message cannot query the content of the key.
再比如,服务端可能无法知道第二车载设备是否完成加载或灌装,此时,可以由用户通过密钥管理工具触发密钥验证过程,例如,可以由车外设备触发服务端向服务端的SHE发送第二查询消息,以获得第一密钥的加载状态。For another example, the server may not know whether the second on-vehicle device has been loaded or filled. At this time, the user can trigger the key verification process through the key management tool. For example, the off-vehicle device can trigger the server to send the SHE A second query message is sent to obtain the loading status of the first key.
另一种可能的场景,在第一车载设备或第二车载设备启动时,第一车载设备或第二车载设备检查密钥的构建状态是否完成。比如,如果密钥的构建状态没有完成,上报告警,禁止车辆行驶等。在另一种可能的场景中,还可以是第一车载设备或第二车载设备重启后,通过第一车载设备或第二车载设备发送第二查询消息,以查询第一密钥的加载状态。In another possible scenario, when the first vehicle-mounted device or the second vehicle-mounted device is started, the first vehicle-mounted device or the second vehicle-mounted device checks whether the construction state of the key is completed. For example, if the construction status of the key is not completed, report to the police, prohibit the vehicle from driving, etc. In another possible scenario, after the first vehicle-mounted device or the second vehicle-mounted device restarts, the first vehicle-mounted device or the second vehicle-mounted device sends a second query message to query the loading status of the first key.
下面举例介绍第二查询消息中可以涉及的参数。例如,如表16所示。The parameters that may be involved in the second query message are introduced with examples below. For example, as shown in Table 16.
表16Table 16
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 1616
M2M2 ININ 128128
M3M3 OUTout (13,或24)*8(13, or 24)*8
M4M4 OUTout 128128
以第一车载设备为例,第一车载设备可以生成第二查询消息的入参。其中,入参M1满足:Taking the first vehicle-mounted device as an example, the first vehicle-mounted device may generate an input parameter of the second query message. Among them, the input parameter M1 satisfies:
M1=KEY_ID|memory slot1M1=KEY_ID|memory slot1
入参M2满足:M2=CMAC(Key,M1)The input parameter M2 satisfies: M2=CMAC(Key,M1)
其中,memory slot1用于表示第二查询消息对应查询的密钥。Wherein, memory slot1 is used to represent the key of the query corresponding to the second query message.
一种可能的场景,KEY_ID为第二查询消息的安全验证密钥,Key是KEY_ID对应的密钥。例如,在密钥体系构建的启动消息执行后,在密钥体系构建过程中,第一车载设备执行第二查询消息查询密钥信息时,则KEY_ID是临时密钥的密钥地址。如果KEY_ID为0,表示第二查询消息没有验证信息,忽略后面的M2、M4。In a possible scenario, KEY_ID is the security verification key of the second query message, and Key is a key corresponding to KEY_ID. For example, after the start message of key system construction is executed, during the key system construction process, when the first vehicle device executes the second query message to query key information, then KEY_ID is the key address of the temporary key. If the KEY_ID is 0, it means that the second query message has no verification information, and the following M2 and M4 are ignored.
在第一SHE验证第二查询消息成功后,可以相应生成第二查询响应消息,其中,第二查询响应消息可以包括以下出参。其中,出参M3满足:After the first SHE verifies that the second query message is successful, it may correspondingly generate a second query response message, wherein the second query response message may include the following parameters. Among them, the output parameter M3 satisfies:
M3=KEY_ID|memory slot1|Key1 InfoM3=KEY_ID|memory slot1|Key1 Info
其中,Key1 Info为密钥地址为memory slot1对应的密钥信息,例如,Key1 Info满足:Among them, Key1 Info is the key information corresponding to the key address of memory slot1, for example, Key1 Info satisfies:
Key1 Info=KeyFlags|00|Counter(28 bits)|PairSlot|KeyID,Key1 Info=KeyFlags|00|Counter(28 bits)|PairSlot|KeyID,
其中,KeyFlags可以满足:Among them, KeyFlags can satisfy:
KeyFlags=WRITE-PROTECTION(1bit)|Secure boot failure(1bit)|Debugger activation(1bit)|Wildcard UID(1bit)|Key usage(1bit)|Plain key(1bit)|BuildStatus(1 bit)。KeyFlags=WRITE-PROTECTION(1bit)|Secure boot failure(1bit)|Debugger activation(1bit)|Wildcard UID(1bit)|Key usage(1bit)|Plain key(1bit)|BuildStatus(1 bit).
KeyFlags可以占用7bits,其中,00占用2 bits,KeyID占用32 bits。Counter占用28 bits。PairSlot用于标识查询的密钥Key1是否形成配对、或Slave,即后面是否含有“memory slot2”和“Key2Info”。例如,该PairSlot值为0,则不含;该PairSlot值为1含、且是Pair;值为2含、且是Slave。KeyFlags can occupy 7 bits, among which 00 occupies 2 bits, and KeyID occupies 32 bits. Counter occupies 28 bits. PairSlot is used to identify whether the key Key1 of the query forms a pair, or Slave, that is, whether it contains "memory slot2" and "Key2Info". For example, if the PairSlot value is 0, it does not contain; if the PairSlot value is 1, it is a Pair; if the PairSlot value is 2, it is a Slave.
出参M4满足:M4=CMAC(Key,M3)The output parameter M4 satisfies: M4=CMAC(Key,M3)
从而,第一车载设备解锁到第二查询响应消息后,可以对第二查询响应消息中的出参进行验证后,获得密钥的查询结果。Therefore, after the first in-vehicle device unlocks the second query response message, it can verify the parameters in the second query response message, and then obtain the query result of the key.
在密钥体系待构建的第一密钥全部构建成功后,可以有非KMS设备向第一车载设备发送密钥体系构建完成消息,并由第一SHE验证该消息。用于告知SHE本次KMS的密钥体系构建完成,其中密钥体系构建完成包括密钥体系的所有第一密钥成功生成、密钥体系的密钥加载验证成功等。需要说明的是,该消息可以不包括其他消息,可以含有一个加密和完整性保护的状态信息:KMS密钥体系构建完成,结果成功、或失败。After all the first keys to be constructed in the key system are successfully constructed, a non-KMS device may send a key system construction completion message to the first vehicle-mounted device, and the first SHE verifies the message. It is used to inform SHE that the construction of the key system of this KMS is completed, and the completion of the construction of the key system includes the successful generation of all the first keys of the key system, the success of the key loading verification of the key system, etc. It should be noted that the message may not include other messages, and may contain an encrypted and integrity-protected state information: the construction of the KMS key system is completed, and the result is success or failure.
如图7所示,本申请实施例提供一种密钥生成方法,包括如下步骤:As shown in Figure 7, the embodiment of the present application provides a method for generating a key, including the following steps:
步骤701:第一车载设备获得密钥体系构建完成消息。Step 701: The first vehicle-mounted device obtains a key system construction completion message.
一种可能的场景,在该次密钥体系构建过程中,密钥体系构建的启动消息可以是在车外设备生成并发送给第一车载设备(例如,服务端或代理端)的(比如由车外的服务器、密钥管理工具或APP发起的密钥体系构建启动消息),则密钥体系构建的完成消息也由车外设备生成。In a possible scenario, during this key system construction process, the start message for key system construction may be generated by an off-vehicle device and sent to the first on-vehicle device (for example, a server or agent) (for example, by The key system construction start message initiated by the server, key management tool or APP outside the vehicle), and the completion message of the key system construction is also generated by the device outside the vehicle.
一种可能的场景,在该次密钥体系构建过程中,密钥体系构建的启动消息是在车内设备生成并发送给服务端的(比如由车内CDC或中控屏发起的长期密钥更新),则密钥体系构建的完成消息也可以是在车内设备生成,也可以在车外设备生成,在此不做限定。A possible scenario, during the key system construction process, the start message of the key system construction is generated by the in-vehicle device and sent to the server (for example, the long-term key update initiated by the in-vehicle CDC or the central control panel ), the completion message of the key system construction can also be generated by the in-vehicle device or by the off-vehicle device, which is not limited here.
需要说明的是,密钥体系构建完成消息可以同密钥体系构建启动消息,选用相同的安全验证密钥,具体可以参见表11,在此不再赘述。It should be noted that the key system construction completion message can use the same security verification key as the key system construction start message, and the details can be found in Table 11, which will not be repeated here.
举例来说,第一车载设备可以是KMS的服务端或KMS的代理端。例如,在第一车载设备为服务端时,第一车载设备可以向客户端发送密钥体系构建完成消息,或者第一车载 设备可以向代理端发送密钥体系构建完成消息,并由代理端向客户端转发密钥体系构建完成消息。在第一车载设备为代理端时,第一车载设备可以接收服务端转发密钥体系构建完成消息,还可以向第一车载设备所管理的客户端下发密钥体系构建完成消息。For example, the first vehicle-mounted device may be a KMS server or a KMS agent. For example, when the first vehicle-mounted device is the server, the first vehicle-mounted device may send a key system construction completion message to the client, or the first vehicle-mounted device may send a key system construction completion message to the agent, and the agent sends a key system construction completion message to the client. The client forwards the key system construction completion message. When the first vehicle-mounted device is an agent, the first vehicle-mounted device may receive a key system construction completion message forwarded by the server, and may also send a key system construction completion message to a client managed by the first vehicle-mounted device.
步骤702:第一车载设备根据密钥体系构建完成消息,向第一SHE发送密钥体系构建完成消息的验证消息。Step 702: The first vehicle-mounted device sends a verification message of the key system construction completion message to the first SHE according to the key system construction completion message.
其中,第一SHE为第一车载设备对应的SHE。第一SHE可以是设置与第一车载设备设置在同一ECU中的,也可以是单独设置的,在此不做限定。第一车载设备可以是用于管理该ECU中的密钥的KMS。Wherein, the first SHE is the SHE corresponding to the first vehicle-mounted device. The first SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here. The first in-vehicle device may be a KMS for managing keys in the ECU.
步骤703:第一SHE对密钥体系构建完成消息的验证消息进行验证,向第一车载设备发送验证结果。Step 703: The first SHE verifies the verification message of the key system construction completion message, and sends the verification result to the first vehicle-mounted device.
步骤704:第一车载设备向第二车载设备发送密钥体系构建完成消息。Step 704: the first vehicle-mounted device sends a key system construction completion message to the second vehicle-mounted device.
其中,第二车载设备可以是KMS的客户端或KMS的代理端。例如,在第二车载设备为客户端时,第二车载设备可以接收第一车载设备发送的密钥体系构建完成消息,也可以通过第二车载设备的代理端转发第一车载设备发送的密钥体系构建完成消息。在第二车载设备为代理端时,第二车载设备可以接收第一车载设备发送的密钥体系构建完成消息,还可以向第二车载设备所管理的客户端下发密钥体系构建完成消息。Wherein, the second vehicle-mounted device may be a KMS client or a KMS agent. For example, when the second vehicle-mounted device is the client, the second vehicle-mounted device can receive the key system construction completion message sent by the first vehicle-mounted device, and can also forward the key sent by the first vehicle-mounted device through the agent of the second vehicle-mounted device. System build complete message. When the second vehicle-mounted device is an agent, the second vehicle-mounted device can receive the key system construction completion message sent by the first vehicle-mounted device, and can also send a key system construction completion message to the client managed by the second vehicle-mounted device.
步骤705:第二车载设备根据密钥体系构建完成消息,向第二SHE发送密钥体系构建完成消息的验证消息。Step 705: The second vehicle device sends a verification message of the key system construction completion message to the second SHE according to the key system construction completion message.
其中,第二SHE为第二车载设备对应的SHE。第二SHE可以是设置与第一车载设备设置在同一ECU中的,也可以是单独设置的,在此不做限定。第二车载设备可以是用于管理该ECU中的密钥的KMS。Wherein, the second SHE is the SHE corresponding to the second vehicle-mounted device. The second SHE can be set in the same ECU as the first vehicle-mounted device, or can be set separately, which is not limited here. The second in-vehicle device may be a KMS for managing keys in the ECU.
步骤706:第二SHE对密钥体系构建完成消息的验证消息进行验证,向第二车载设备发送验证结果。Step 706: The second SHE verifies the verification message of the key system construction completion message, and sends the verification result to the second vehicle-mounted device.
步骤707:第二车载设备向第一车载设备发送第二车载设备的验证结果。Step 707: the second vehicle-mounted device sends the verification result of the second vehicle-mounted device to the first vehicle-mounted device.
下面举例说明密钥体系构建完成消息可能的方式,如表17所示,包括密钥体系构建完成消息可能涉及的参数。The following examples illustrate the possible ways of the key system construction completion message, as shown in Table 17, including the possible parameters involved in the key system construction completion message.
表17Table 17
参数ParameterParameterParameter Directiondirection Width(bits)Width(bits)
M1M1 ININ 8080
M2M2 ININ 128128
一种可能的实现方式,密钥体系构建完成消息可以用于告知相应的SHE本次KMS的密钥体系构建完成,以及本次密钥体系构建完成的日期等。密钥体系构建完成消息可以包括以下入参。其中,入参M2满足:M2=CMAC(Key,M1)In a possible implementation manner, the key system construction completion message may be used to inform the corresponding SHE that the key system construction of the KMS is completed, and the date when the key system construction is completed. The key system construction completion message may include the following input parameters. Among them, the input parameter M2 satisfies: M2=CMAC(Key,M1)
其中,Key是KEY_ID对应的密钥。KEY_ID为密钥体系构建完成消息对应的安全验证密钥的密钥地址。对于车外发起的密钥体系构建,则该值必须是固定密钥的KEY_ID(因为该命令消息的构造也必须是在车外完成);对于车内CDC或中控屏发起的长期密钥更新,则可以是长期密钥对应的KEY_ID,比如是一车一密的长期密钥的KEY_ID。Among them, Key is the key corresponding to KEY_ID. KEY_ID is the key address of the security verification key corresponding to the key system construction completion message. For the construction of the key system initiated outside the vehicle, the value must be the KEY_ID of the fixed key (because the construction of the command message must also be completed outside the vehicle); for the long-term key update initiated by the CDC or the central control panel in the vehicle , it can be the KEY_ID corresponding to the long-term key, for example, the KEY_ID of the long-term key for one car one secret.
入参M1可以满足:The input parameter M1 can satisfy:
M1=KEY_ID|BuildStatus|BuildCounter|BuildDateM1=KEY_ID|BuildStatus|BuildCounter|BuildDate
其中,密钥体系构建完成消息中的BuildStatus表示密钥体系的构建状态,例如,0—表示构建成功,其它值—表示构建失败。在SHE对密钥体系构建完成消息验证成功时,可以根据密钥体系构建完成消息中的BuildStatus更新SHE中的KMS_KH_BuildStatus值。Wherein, the BuildStatus in the key system construction completion message indicates the construction status of the key system, for example, 0—indicates that the construction is successful, and other values—indicates that the construction fails. When the SHE successfully verifies the key system construction completion message, it can update the KMS_KH_BuildStatus value in the SHE according to the BuildStatus in the key system construction completion message.
BuildCounter为本次密钥体系构建的构建计数的值。BuildCounter is the value of the build count for this key system construction.
在SHE对密钥体系构建完成消息进行验证时,密钥体系构建完成消息中的BuildCounter的值与SHE中KMS_KH_BuildCounter值一致时,继续其他的验证,否则忽略该密钥体系构建完成消息,并返回ERC_PARAMETER_INVALID。When SHE verifies the key system construction completion message, if the value of BuildCounter in the key system construction completion message is consistent with the KMS_KH_BuildCounter value in SHE, continue other verifications, otherwise ignore the key system construction completion message and return ERC_PARAMETER_INVALID .
在SHE对密钥体系构建完成消息进行验证时,SHE中的KMS_KH_BuildStatus必须是处在“1-构建中”,否则忽略该密钥体系构建完成消息,并返回错误消息ERC_KMS_KH_STATUS_INVALID。When the SHE verifies the key system construction completion message, the KMS_KH_BuildStatus in the SHE must be "1-under construction", otherwise the key system construction completion message is ignored and the error message ERC_KMS_KH_STATUS_INVALID is returned.
在任何一个密钥、任何一项检查失败,SHE都不能更新KMS_KH_BuildStatus的值,并返回ERC_KMS_KH_NOT_FINISHED。If any key or any check fails, SHE cannot update the value of KMS_KH_BuildStatus and returns ERC_KMS_KH_NOT_FINISHED.
在SHE对密钥体系构建完成消息验证成功后,通过SHE检查受KMS_KH_BuildStatus影响的各第一密钥是否都完成构建。例如,包括每个密钥的BuildStatus、Counter的检查。仅当所有第一密钥的检查通过后,密钥体系构建完成消息返回验证结果ERC_NO_ERROR。否则返回验证结果ERC_KMS_KH_NOT_FINISHED。After the SHE successfully verifies the key system construction completion message, the SHE checks whether all the first keys affected by KMS_KH_BuildStatus have been constructed. For example, including BuildStatus, Counter checks for each key. Only when all the first key checks pass, the key system construction completion message returns the verification result ERC_NO_ERROR. Otherwise, return the verification result ERC_KMS_KH_NOT_FINISHED.
在SHE对密钥体系构建完成消息验证成功后,此时SHE设置KMS_KH_BuildStatus为“2-构建成功”,以及刷新KMS_KH_BuildDate。即在每次密钥体系构建完成时,将密钥体系构建完成的日期和时间存储到SHE的KMS_KH_BuildDate。After the SHE has successfully verified the key system construction completion message, at this time, the SHE sets KMS_KH_BuildStatus to "2-build successfully", and refreshes the KMS_KH_BuildDate. That is, when the key system is built each time, the date and time when the key system is built are stored in KMS_KH_BuildDate of the SHE.
在SHE确定BuildStatus表示构建成功(例如,BuildStatus的值为0)时,更新密钥体系构建的完成时间。BuildDate表示密钥体系构建完成消息的完成时间。能够从系统中读取系统时间时,可以忽略该参数,由SHE直接从系统中读取当前时间,作为密钥体系构建完成时间,并更新到KMS_KH_BuildDate。在SHE无法从系统中读取系统时间时,可以先校验该参数,例如,该参数BuildDate是否大于SHE中KMS_KH_BuildDate值。可选的,还可以参考KMS_CFG_KeyLifetime值,比如BuildDate大于或等于KMS_KH_BuildDate与KMS_CFG_KeyLifetime(或该值的二分之一等)的和时,则验证该参数合法,将该参数更新到KMS_KH_BuildDate。When the SHE determines that the BuildStatus indicates that the build is successful (for example, the value of the BuildStatus is 0), it updates the completion time of the key system construction. BuildDate indicates the completion time of the key system construction completion message. When the system time can be read from the system, this parameter can be ignored, and the SHE directly reads the current time from the system as the key system construction completion time, and updates it to KMS_KH_BuildDate. When SHE cannot read the system time from the system, you can check this parameter first, for example, whether the parameter BuildDate is greater than the value of KMS_KH_BuildDate in SHE. Optionally, you can also refer to the KMS_CFG_KeyLifetime value. For example, when BuildDate is greater than or equal to the sum of KMS_KH_BuildDate and KMS_CFG_KeyLifetime (or half of the value, etc.), verify that the parameter is legal and update the parameter to KMS_KH_BuildDate.
如果BuildStatus值表示构建失败,则SHE设置KMS_KH_BuildStatus为“3-构建失败”,可以不刷新KMS_KH_BuildDate值。If the BuildStatus value indicates that the build failed, SHE sets KMS_KH_BuildStatus to "3-Build Failed", and does not need to refresh the KMS_KH_BuildDate value.
通过步骤704~步骤707,保证第二车载设备都执行密钥体系构建完成消息。即服务端需要将密钥体系构建完成消息的参数分发到各代理端和客户端,代理端分发到其代理的各客户端,用于同步各第二车载设备的KMS_KH_BuildCounter值等状态数据。在车内密钥体系构建完成(成功/失败)后,第一车载设备和第二车载设备的要通知SHE将构建状态KMS_KH_BuildStatus设置为“构建成功”、或“构建失败”,并且刷新构建日期。Through steps 704 to 707, it is ensured that the second vehicle-mounted device executes the key system construction completion message. That is, the server needs to distribute the parameters of the key system construction completion message to each agent and client, and the agent distributes it to each client it acts as an agent for synchronizing the status data such as the KMS_KH_BuildCounter value of each second vehicle-mounted device. After the in-vehicle key system construction is completed (success/failure), the first vehicle-mounted device and the second vehicle-mounted device should notify SHE to set the build status KMS_KH_BuildStatus to "build successfully" or "build failed", and update the build date.
图8为本申请实施例适用的一种可能的系统架构示意图,如图8所示的系统架构包括车辆和诊断设备。其中,车辆可以是具有密钥认证功能的任意车辆。诊断设备可以是指诊断仪,也可以是指诊断服务器,还可以是指诊断服务器集群。应理解,本申请实施例对系统架构中车辆的数量和诊断设备的数量均不作限定,例如1台诊断设备可以只与1辆车辆进行信息交互,也可以与多辆车辆进行信息交互。且,本申请实施例所适用的系统架构中 除了包括车辆和诊断设备以外,还可以包括其它设备,如供应商设备、制造商设备、产线设备和销售设备等,对此本申请实施例也不作限定。以及,本申请实施例中的诊断设备可以将所有的功能集成在一个独立的物理设备上,也可以将功能分布在多个独立的物理设备上,对此本申请实施例也不作限定。FIG. 8 is a schematic diagram of a possible system architecture applicable to the embodiment of the present application. The system architecture shown in FIG. 8 includes a vehicle and a diagnostic device. Wherein, the vehicle may be any vehicle having a key authentication function. The diagnosis device may refer to a diagnosis instrument, may also refer to a diagnosis server, and may also refer to a diagnosis server cluster. It should be understood that the embodiment of the present application does not limit the number of vehicles and diagnostic devices in the system architecture. For example, one diagnostic device may perform information interaction with only one vehicle, or may perform information interaction with multiple vehicles. Moreover, in addition to vehicles and diagnostic equipment, the system architecture applicable to the embodiment of the present application may also include other equipment, such as supplier equipment, manufacturer equipment, production line equipment, and sales equipment, etc., and this embodiment of the application also Not limited. Also, the diagnostic device in the embodiment of the present application may integrate all functions on one independent physical device, or distribute the functions on multiple independent physical devices, which is not limited in the embodiment of the present application.
本申请实施例中,车辆诊断可以在有线方式下实现,也可以在无线方式下实现。示例来说,当基于有线方式实现车辆诊断时,诊断设备上通常带有诊断线,车辆上预设有诊断接口,诊断人员可以直接将诊断设备的诊断线一端插入车辆的诊断接口,之后在诊断设备上输入诊断命令,以使诊断命令通过诊断线发送给车辆。其中,诊断接口可以是指统一的诊断服务(unified diagnostic services,UDS)接口,也可以是指车载诊断(on board diagnostics,OBD)接口,还可以是指其它能够实现命令传输功能的接口,不作限定。当基于无线方式实现车辆诊断时,诊断设备和车辆可以具有蓝牙或无线局域网(wireless local area network,WLAN)等近场通讯功能,诊断人员可以先通过诊断设备和车辆的近场通讯功能连接诊断设备和车辆,再在诊断设备上输入诊断命令,以使诊断命令通过无线方式传输车辆。示例性地,诊断设备上还可以设置有液晶显示屏,在得到诊断结果后,诊断设备还可以将诊断结果同步显示在液晶显示屏上,以便于提醒诊断人员及时查看诊断结果,快速查明故障位置及故障原因。In the embodiment of the present application, the vehicle diagnosis may be implemented in a wired manner or in a wireless manner. For example, when vehicle diagnosis is implemented based on wired methods, the diagnostic equipment usually has a diagnostic line, and the vehicle is preset with a diagnostic interface. The diagnostic personnel can directly insert one end of the diagnostic line of the diagnostic equipment into the diagnostic interface of the vehicle. Enter the diagnostic command on the device so that the diagnostic command is sent to the vehicle through the diagnostic line. Wherein, the diagnostic interface may refer to a unified diagnostic service (unified diagnostic services, UDS) interface, may also refer to an on-board diagnostics (OBD) interface, or may refer to other interfaces capable of realizing command transmission functions, without limitation. . When the vehicle diagnosis is realized based on the wireless method, the diagnostic equipment and the vehicle can have near-field communication functions such as Bluetooth or wireless local area network (WLAN), and the diagnostic personnel can first connect the diagnostic equipment through the near-field communication function of the diagnostic equipment and the vehicle. and the vehicle, and then enter the diagnostic command on the diagnostic device so that the diagnostic command is transmitted to the vehicle wirelessly. Exemplarily, the diagnostic equipment can also be provided with a liquid crystal display, and after obtaining the diagnostic results, the diagnostic equipment can also synchronously display the diagnostic results on the liquid crystal display, so as to remind the diagnostic personnel to check the diagnostic results in time and quickly find out the fault location and cause of failure.
如图9所示,本申请提供一种车内密钥获取方法,包括:As shown in Figure 9, the present application provides a method for obtaining an in-vehicle key, including:
步骤901:车外设备向第一车载设备发送第一消息。Step 901: The off-vehicle device sends a first message to the first on-vehicle device.
相应的,第一车载设备接收车外设备发送的第一消息;第一消息用于请求第一车载设备获得第一密钥。Correspondingly, the first on-vehicle device receives the first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain the first key.
一种可能的实现方式,第一密钥可以是触发第一车载设备生成的长期密钥,也可以是车辆预先存储的固定密钥,也可以是云端服务器存储的该车辆的固定密钥,在此不做限定。In a possible implementation, the first key may be a long-term key that triggers the generation of the first vehicle-mounted device, or a fixed key stored in advance by the vehicle, or a fixed key of the vehicle stored on a cloud server. This is not limited.
例如,车外设备可以是诊断设备,诊断设备可以通过与车辆建立安全隧道,向第一车载设备发送第一消息,该第一消息可以包括诊断设备对应的证书、PIN码等。或者,针对设备还可以通过网关发送第一消息,在此不做限定。For example, the off-vehicle device may be a diagnostic device, and the diagnostic device may establish a secure tunnel with the vehicle to send a first message to the first vehicle-mounted device, where the first message may include a certificate corresponding to the diagnostic device, a PIN code, and the like. Alternatively, the device may also send the first message through the gateway, which is not limited here.
步骤902:第一车载设备根据第一消息和第一车载设备的验证信息,生成角色验证请求消息,角色验证请求消息用于服务器对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证;Step 902: The first vehicle-mounted device generates a role verification request message according to the first message and the verification information of the first vehicle-mounted device, and the role verification request message is used for the server to obtain the authority of the first key for the first vehicle-mounted device and the first vehicle-mounted device Verify the verification information;
一种可能的实现方式,第一车载设备可以对PIN码进行加密后获得的加密的PIN码,并根据第一密钥的权限信息生成第一车载设备的验证信息,用于服务器对第一密钥进行验证,从而,第一车载设备可以通过诊断设备对应的证书、加密后的PIN码和加密后的第一密钥的权限信息,生成角色验证请求消息。In a possible implementation manner, the first vehicle-mounted device can encrypt the PIN code obtained after encrypting the PIN code, and generate the verification information of the first vehicle-mounted device according to the authority information of the first key, which is used by the server to verify the first key. Therefore, the first vehicle-mounted device can generate a role verification request message through the certificate corresponding to the diagnostic device, the encrypted PIN code, and the encrypted permission information of the first key.
步骤903:第一车载设备向服务器发送角色验证请求消息。Step 903: the first vehicle-mounted device sends a role verification request message to the server.
一种可能的实现方式,第一车载设备可以通过加密的方式向服务器发送角色验证请求消息,具体加密方式本申请不做限定。In a possible implementation manner, the first vehicle-mounted device may send the role verification request message to the server in an encrypted manner, and the specific encryption manner is not limited in this application.
步骤904:服务器对角色验证请求消息进行验证,生成角色验证的响应消息。Step 904: the server verifies the role verification request message, and generates a role verification response message.
其中,角色验证的响应消息包括:角色验证请求消息的验证结果。Wherein, the response message of the role verification includes: the verification result of the role verification request message.
一种可能的实现方式,服务器可以对加密的PIN码进行验证,对诊断设备对应的证书进行验证,还可以对第一密钥的权限信息进行验证。例如,在第一消息用于请求第一车载设备生成第一密钥时,可以对第一车载设备是否有生成第一密钥的权限和能力进行验证。 在第一消息用于请求服务器向第一车载设备发送第一密钥时,可以对第一车载设备是否有获得第一密钥的权限进行验证。在第一消息用于请求诊断设备获得第一车载设备上的第一密钥用于诊断时,可以对第一车载设备和诊断设备是否有获得第一密钥的权限进行验证。In a possible implementation manner, the server may verify the encrypted PIN code, verify the certificate corresponding to the diagnostic device, and also verify the authority information of the first key. For example, when the first message is used to request the first vehicle-mounted device to generate the first key, it may be verified whether the first vehicle-mounted device has the authority and capability to generate the first key. When the first message is used to request the server to send the first key to the first vehicle-mounted device, it may be verified whether the first vehicle-mounted device has the authority to obtain the first key. When the first message is used to request the diagnostic device to obtain the first key on the first vehicle-mounted device for diagnosis, it may be verified whether the first vehicle-mounted device and the diagnostic device have the authority to obtain the first key.
步骤905:服务器向第一车载设备发送角色验证的响应消息。Step 905: the server sends a response message of role verification to the first vehicle-mounted device.
相应的,第一车载设备接收服务器发送的角色验证的响应消息。Correspondingly, the first vehicle-mounted device receives the response message of the role verification sent by the server.
例如,角色验证的响应消息可以包括同意或拒绝第一车载设备获得第一密钥。可选的,角色验证的响应消息还可以包括其他信息。或者,这些信息还可以是服务器另外发送的,在此不做限定。For example, the response message of the role verification may include agreeing or denying the first vehicle-mounted device to obtain the first key. Optionally, the response message of role verification may also include other information. Alternatively, the information may also be sent by the server, which is not limited here.
一种可能的实现方式,在步骤905之后,第一车载设备可以生成第一车载设备或第二车载设备的第一密钥。具体实现方式可以参见图3中的实现方式。例如,第一车载设备接收服务器发送的第一消息;第一消息用于指示第一车载设备生成第一密钥;第一车载设备根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a possible implementation manner, after step 905, the first vehicle-mounted device may generate a first key of the first vehicle-mounted device or the second vehicle-mounted device. For a specific implementation manner, reference may be made to the implementation manner in FIG. 3 . For example, the first vehicle-mounted device receives a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the first vehicle-mounted device generates a first request message according to the first message; the first request message uses The first security hardware expansion unit corresponding to the first vehicle-mounted device generates a first response message; the first response message includes: first key information; the first key information is generated after encrypting the first key.
需要说明的是,第一车载设备确定生成第一车载设备或第二车载设备的第一密钥的方式可以是服务器发送的第一消息确定的,也可以是第一车载设备根据角色验证的响应消息确定的,此时,角色验证的响应消息可以包括第一消息中的内容。It should be noted that the way the first vehicle-mounted device determines to generate the first key of the first vehicle-mounted device or the second vehicle-mounted device may be determined by the first message sent by the server, or it may be the response of the first vehicle-mounted device according to the role verification If the message is determined, at this time, the response message of the role verification may include the content in the first message.
一种可能的实现方式,在步骤905之后,服务器可以向第一车载设备发送加密的第一密钥。相应的,第一车载设备接收服务器发送的第一密钥。其中,服务器发送加密的第一密钥的方式可以参考上述实施例的场景2中,车外设备向第一车载设备发起发送第一密钥加载消息的方式,使得第一车载设备根据发送第一密钥加载消息,灌装第一密钥。In a possible implementation manner, after step 905, the server may send the encrypted first key to the first vehicle-mounted device. Correspondingly, the first vehicle-mounted device receives the first key sent by the server. Wherein, the method for the server to send the encrypted first key can refer to the method in scenario 2 of the above-mentioned embodiment, where the off-vehicle device initiates sending the first key loading message to the first vehicle-mounted device, so that the first vehicle-mounted device transmits the first Key Loading message, filling the first key.
在另一些实施例中,服务器可以通过单独发送的消息向第一车载设备发送加密的第一密钥,也可以是角色验证的响应消息携带的,本申请不做限定。In some other embodiments, the server may send the encrypted first key to the first in-vehicle device through a message sent separately, or it may be carried in the response message of the role verification, which is not limited in this application.
一种可能的实现方式,在步骤905之后,第一车载设备在角色验证请求消息的验证结果为验证成功时,向车外设备发送第一密钥。In a possible implementation manner, after step 905, when the verification result of the role verification request message is that the verification is successful, the first on-vehicle device sends the first key to the off-vehicle device.
另一种可能的实现方式,服务器可以通过单独发送的消息向第一车载设备指示同意第一车载设备发送第一密钥,或者,也可以是角色验证的响应消息指示的,从而,第一车载设备可以确定向车外设备发送第一密钥。In another possible implementation manner, the server may indicate to the first vehicle-mounted device that the first vehicle-mounted device agrees to send the first key through a message sent separately, or it may also be indicated by a response message of role verification, so that the first vehicle-mounted device The device may determine to send the first key to the off-vehicle device.
第一车载设备向车外设备发送第一密钥的方式可以有多种。举例来说,第一车载设备向车外设备发送第一密钥的方式也可以是参考第一密钥加载消息的方式发送的,从而,车外设备可以根据接收到的第一密钥价值消息进行验证后,获得第一密钥。当然,还可以通过其他安全传输方式,向车外设备发送第一密钥。There may be multiple ways for the first in-vehicle device to send the first key to the out-of-vehicle device. For example, the way the first on-vehicle device sends the first key to the off-vehicle device may also be sent by referring to the first key loading message, so that the off-vehicle device can After verification, the first key is obtained. Of course, the first key may also be sent to the off-vehicle device through other secure transmission methods.
图10为本申请实施例提供的一种密钥生成装置的结构示意图,如图10所示,该装置可以为第一车载设备或第一安全扩展单元,也可以为芯片或电路,比如可设置于第一车载设备中的芯片或电路,再比如可设置于第一安全扩展单元中的芯片或电路,再比如可设置于第一安全扩展单元中内的芯片或电路。Figure 10 is a schematic structural diagram of a key generation device provided by the embodiment of the present application. The chip or circuit in the first vehicle-mounted device is another example of a chip or circuit that can be set in the first security expansion unit, and another example is a chip or circuit that can be set in the first security expansion unit.
进一步的,该密钥生成装置1001还可以进一步包括总线系统,其中,处理器1002、存储器1004、收发器1003可以通过总线系统相连。Furthermore, the key generation device 1001 may further include a bus system, wherein the processor 1002, the memory 1004, and the transceiver 1003 may be connected through the bus system.
应理解,上述处理器1002可以是一个芯片。例如,该处理器1002可以是现场可编程 门阵列(field programmable gate array,FPGA),可以是专用集成芯片(application specific integrated circuit,ASIC),还可以是系统芯片(system on chip,SoC),还可以是中央处理器(central processor unit,CPU),还可以是网络处理器(network processor,NP),还可以是数字信号处理电路(digital signal processor,DSP),还可以是微控制器(micro controller unit,MCU),还可以是可编程控制器(programmable logic device,PLD)或其他集成芯片。It should be understood that the above processor 1002 may be a chip. For example, the processor 1002 may be a field programmable gate array (field programmable gate array, FPGA), may be an application specific integrated circuit (ASIC), may also be a system chip (system on chip, SoC), or It can be a central processing unit (central processor unit, CPU), or a network processor (network processor, NP), or a digital signal processing circuit (digital signal processor, DSP), or a microcontroller (micro controller) unit, MCU), it can also be a programmable controller (programmable logic device, PLD) or other integrated chips.
在实现过程中,上述方法的各步骤可以通过处理器1002中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器1002中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1004,处理器1002读取存储器1004中的信息,结合其硬件完成上述方法的步骤。In the implementation process, each step of the above-mentioned method may be completed by an integrated logic circuit of hardware in the processor 1002 or instructions in the form of software. The steps of the methods disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor 1002 . The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory 1004, and the processor 1002 reads the information in the memory 1004, and completes the steps of the above method in combination with its hardware.
应注意,本申请实施例中的处理器1002可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法实施例的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。It should be noted that the processor 1002 in the embodiment of the present application may be an integrated circuit chip, which has a signal processing capability. In the implementation process, each step of the above-mentioned method embodiments may be completed by an integrated logic circuit of hardware in a processor or instructions in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components . Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
可以理解,本申请实施例中的存储器1004可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the memory 1004 in this embodiment of the present application may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory. Volatile memory can be random access memory (RAM), which acts as external cache memory. By way of illustration and not limitation, many forms of RAM are available such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (synchlink DRAM, SLDRAM ) and direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but not be limited to, these and any other suitable types of memory.
该密钥生成装置1001对应上述方法中的第一车载设备的情况下,该密钥生成装置可以包括处理器1002、收发器1003和存储器1004。该存储器1004用于存储指令,该处理器1002用于执行该存储器1004存储的指令,以实现如上图1至图8中所示的任一项或任多项对应的方法中第一车载设备的相关方案。When the key generation device 1001 corresponds to the first vehicle-mounted device in the above method, the key generation device may include a processor 1002 , a transceiver 1003 and a memory 1004 . The memory 1004 is used to store instructions, and the processor 1002 is used to execute the instructions stored in the memory 1004, so as to implement any one or any number of corresponding methods shown in FIGS. 1 to 8 above. related programs.
当密钥生成装置1001为上述第一车载设备,密钥生成装置1001可以用于执行上述实施例中任一实施例中第一车载设备所执行的密钥生成方法。密钥生成装置1001为上述第 一车载设备时,收发器1003获得第一消息;第一消息用于指示第一车载设备构建第一密钥;处理器1002根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。When the key generating device 1001 is the above-mentioned first vehicle-mounted device, the key generating device 1001 may be used to execute the key generating method performed by the first vehicle-mounted device in any one of the above-mentioned embodiments. When the key generation device 1001 is the above-mentioned first vehicle-mounted device, the transceiver 1003 obtains a first message; the first message is used to instruct the first vehicle-mounted device to construct a first key; the processor 1002 generates a first request message according to the first message ; The first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is encrypted by the first key Generated.
当密钥生成装置1001为上述第一安全硬件扩展单元,密钥生成装置1001可以用于执行上述实施例中任一实施例中第一安全硬件扩展单元所执行的密钥生成方法。收发器1003用于接收第一安全硬件扩展单元对应的第一车载设备发送的第一请求消息;第一请求消息为第一车载设备请求第一安全硬件扩展单元构建第一密钥生成的;处理器1002对第一请求消息进行验证成功后,生成第一密钥信息;第一密钥信息为对第一密钥加密后生成的。When the key generation device 1001 is the above-mentioned first secure hardware extension unit, the key generation device 1001 may be used to execute the key generation method performed by the first secure hardware extension unit in any of the above embodiments. The transceiver 1003 is used to receive the first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key; process After the device 1002 successfully verifies the first request message, it generates first key information; the first key information is generated after encrypting the first key.
基于以上实施例以及相同构思,图11为本申请实施例提供的密钥生成装置的示意图,如图11所示,该密钥生成装置1100可以为第一车载设备或第一安全硬件扩展单元,也可以为芯片或电路,比如可设置于第一车载设备或第一安全硬件扩展单元中的芯片或电路。Based on the above embodiments and the same idea, FIG. 11 is a schematic diagram of a key generation device provided in an embodiment of the present application. As shown in FIG. 11 , the key generation device 1100 may be a first vehicle-mounted device or a first security hardware expansion unit, It can also be a chip or a circuit, such as a chip or a circuit that can be set in the first vehicle-mounted device or the first security hardware expansion unit.
该密钥生成装置可以对应上述方法中的第一车载设备或第一安全硬件扩展单元。该密钥生成装置可以实现如上图1至图8中所示的任一项或任多项对应的方法中第一车载设备或第一安全硬件扩展单元所执行的步骤。该密钥生成装置可以包括获取单元1101和处理单元1102。可选的,还可以包括接收单元1103和发送单元1104。The key generation device may correspond to the first vehicle-mounted device or the first secure hardware expansion unit in the above method. The key generation device may implement the steps performed by the first vehicle-mounted device or the first secure hardware expansion unit in any one or any multiple of the corresponding methods shown in FIG. 1 to FIG. 8 above. The key generation device may include an acquisition unit 1101 and a processing unit 1102 . Optionally, a receiving unit 1103 and a sending unit 1104 may also be included.
当密钥生成装置1100为上述第一车载设备,且实现如上述图3中第一车载设备所执行的步骤时,获取单元1101用于获得第一消息;第一消息用于指示第一车载设备构建第一密钥;处理单元1102根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。When the key generation device 1100 is the above-mentioned first vehicle-mounted device and implements the steps performed by the first vehicle-mounted device in FIG. 3 above, the obtaining unit 1101 is used to obtain the first message; the first message is used to indicate Construct the first key; the processing unit 1102 generates a first request message according to the first message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: First key information; the first key information is generated after encrypting the first key.
一种可能的实现方式,接收单元1103,用于接收来自第一安全硬件扩展单元发送的第一响应消息。In a possible implementation manner, the receiving unit 1103 is configured to receive the first response message sent from the first security hardware extension unit.
一种可能的实现方式,接收单元1103,用于接收来自第一安全硬件扩展单元发送的第一密钥的第一参数;A possible implementation manner, the receiving unit 1103 is configured to receive the first parameter of the first key sent from the first secure hardware extension unit;
处理单元1102,用于根据第一密钥的第一参数,生成第一密钥加载消息;A processing unit 1102, configured to generate a first key loading message according to a first parameter of the first key;
发送单元1104,用于向第二车载设备发送第一密钥加载消息;第一密钥加载消息用于第二车载设备对第一密钥加载消息进行验证成功后,灌装第一密钥。The sending unit 1104 is configured to send a first key loading message to the second vehicle-mounted device; the first key loading message is used for filling the first key after the second vehicle-mounted device successfully verifies the first key loading message.
一种可能的实现方式,获取单元1101获得单元获得第一消息之后,发送单元1104,还用于向第一安全硬件扩展单元发送状态更新消息;状态更新消息包括:车内密钥的构建状态;状态更新消息用于第一安全硬件扩展单元对状态更新消息验证成功后,更新自身的车内密钥的构建状态。In a possible implementation manner, after the obtaining unit 1101 obtains the first message, the sending unit 1104 is further configured to send a status update message to the first security hardware extension unit; the status update message includes: the construction status of the in-vehicle key; The status update message is used for the first security hardware expansion unit to update the construction status of its own in-vehicle key after the verification of the status update message is successful.
一种可能的实现方式,车内密钥的构建状态用于第一安全硬件扩展单元对第一请求消息进行验证。In a possible implementation manner, the construction state of the in-vehicle key is used by the first security hardware expansion unit to verify the first request message.
一种可能的实现方式,处理单元1102确定第一车载设备重启后,通过发送单元1104向第一安全硬件扩展单元发送第一查询请求;第一查询请求用于查询第一密钥的第二参数;通过接收单元1103接收第一安全硬件扩展单元发送的第一查询响应消息;第一查询响应消息为第一安全硬件扩展单元对第一查询请求进行验证后返回的;第一查询响应消息包括:第一密钥的第二参数;根据第一密钥的第二参数和第一消息,生成第一请求消息;第一密钥为第一车载设备重启前第一安全硬件扩展单元待生成的密钥。In a possible implementation, the processing unit 1102 sends a first query request to the first security hardware expansion unit through the sending unit 1104 after determining that the first vehicle-mounted device is restarted; the first query request is used to query the second parameter of the first key ; Receive the first query response message sent by the first security hardware expansion unit through the receiving unit 1103; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first query response message includes: The second parameter of the first key; according to the second parameter of the first key and the first message, generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before the restart of the first vehicle-mounted device key.
一种可能的实现方式,接收单元1103,用于接收来自第一安全硬件扩展单元发送的临时密钥;临时密钥用于加密第一请求消息。In a possible implementation manner, the receiving unit 1103 is configured to receive the temporary key sent from the first security hardware extension unit; the temporary key is used to encrypt the first request message.
一种可能的实现方式,接收单元1103,用于接收第二车载设备发送的第二消息;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。In a possible implementation, the receiving unit 1103 is configured to receive a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate The first key may instruct the second on-vehicle device to restart.
一种可能的实现方式,处理单元1102对第二消息进行验证后,通过发送单元1104向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。In a possible implementation manner, after the processing unit 1102 verifies the second message, the sending unit 1104 sends a third message to the second in-vehicle device; the third message includes at least one of the following: the second parameter of the first key, First key information.
一种可能的实现方式,根据以下任一项获得第一消息:A possible implementation, the first message is obtained according to any of the following:
通过接收单元1103接收车内设备或车外设备发送的第一消息;Receive the first message sent by the in-vehicle device or the out-of-vehicle device through the receiving unit 1103;
通过接收单元1103接收配置文件的初始化或更新信息后,获得第一消息;After receiving the initialization or update information of the configuration file through the receiving unit 1103, the first message is obtained;
通过接收单元1103接收车辆的固定密钥的初始化或更新信息后,获得第一消息;After receiving the initialization or update information of the fixed key of the vehicle through the receiving unit 1103, the first message is obtained;
通过接收单元1103接收车辆的车载设备之间的共享密钥的初始化或更新信息后,获得第一消息。After the receiving unit 1103 receives the initialization or update information of the shared key between the on-vehicle devices of the vehicle, the first message is obtained.
在另一些实施例中,密钥生成装置可以为车辆中的安全硬件扩展单元,该装置包括:In some other embodiments, the key generating device may be a security hardware expansion unit in the vehicle, and the device includes:
接收单元1103,用于接收第一安全硬件扩展单元对应的第一车载设备发送的第一请求消息;第一请求消息为第一车载设备请求第一安全硬件扩展单元构建第一密钥生成的;The receiving unit 1103 is configured to receive a first request message sent by the first vehicle-mounted device corresponding to the first security hardware expansion unit; the first request message is generated by the first vehicle-mounted device requesting the first security hardware expansion unit to construct a first key;
处理单元1102,用于对第一请求消息进行验证成功后,生成第一密钥信息;第一密钥信息为对第一密钥加密后生成的。The processing unit 1102 is configured to generate first key information after successfully verifying the first request message; the first key information is generated after encrypting the first key.
一种可能的实现方式,发送单元1104,用于向第一车载设备发送第一响应消息;第一响应消息包括:第一密钥信息。In a possible implementation manner, the sending unit 1104 is configured to send a first response message to the first vehicle-mounted device; the first response message includes: first key information.
一种可能的实现方式,处理单元1102对第一请求消息进行验证成功后,生成第一密钥的第一参数;通过发送单元1104向第一车载设备发送第一密钥的第一参数;第一密钥的第一参数用于第二车载设备灌装第一密钥。A possible implementation manner, after the processing unit 1102 successfully verifies the first request message, generates the first parameter of the first key; sends the first parameter of the first key to the first vehicle-mounted device through the sending unit 1104; The first parameter of a key is used to fill the first key in the second on-vehicle device.
一种可能的实现方式,接收单元1103,还用于接收第一车载设备发送的状态更新消息;状态更新消息包括:车内密钥的构建状态;处理单元1102,还用于对状态更新消息验证成功后,更新自身的车内密钥的构建状态。In a possible implementation, the receiving unit 1103 is also configured to receive a status update message sent by the first vehicle-mounted device; the status update message includes: the construction status of the in-vehicle key; the processing unit 1102 is also configured to verify the status update message After success, update the build status of your own in-vehicle key.
一种可能的实现方式,接收单元1104,还用于在第一车载设备重启后,接收第一车载设备发送的第一查询请求;第一查询请求用于查询第一密钥的第二参数;In a possible implementation manner, the receiving unit 1104 is further configured to receive a first query request sent by the first vehicle-mounted device after the first vehicle-mounted device restarts; the first query request is used to query the second parameter of the first key;
处理单元1102,用于对第一查询请求进行验证后,通过发送单元1104向第一车载设备发送第一查询响应消息;第一查询响应消息包括:第一密钥的第二参数;第一密钥的第二参数用于第一车载设备生成第一请求消息;第一密钥为重启前第一安全硬件扩展单元待生成的密钥。The processing unit 1102 is configured to send a first query response message to the first vehicle-mounted device through the sending unit 1104 after verifying the first query request; the first query response message includes: the second parameter of the first key; the first key The second parameter of the key is used for the first vehicle device to generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
一种可能的实现方式,处理单元1102,用于对第一请求消息进行验证成功后,生成临时密钥;通过发送单元1104向第一车载设备发送临时密钥;临时密钥用于加密第一请求消息。In a possible implementation, the processing unit 1102 is configured to generate a temporary key after the first request message is verified successfully; send the temporary key to the first vehicle-mounted device through the sending unit 1104; the temporary key is used to encrypt the first request message.
一种可能的实现方式,接收单元1103,用于接收来自第一车载设备的第二消息的验证消息;第二消息为第一车载设备接收第二车载设备发送的;第二消息用于以下至少一项:查询第一密钥的第二参数、请求第一车载设备生成第一密钥或者指示第二车载设备重启。In a possible implementation manner, the receiving unit 1103 is configured to receive a verification message of a second message from the first vehicle-mounted device; the second message is received by the first vehicle-mounted device and sent by the second vehicle-mounted device; the second message is used for at least the following One item: querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key, or instructing the second vehicle-mounted device to restart.
一种可能的实现方式,处理单元1102,用于对第二消息进行验证后,通过发送单元向 第一车载设备发送第二消息的验证响应消息;第二消息的响应消息用于第一车载设备向第二车载设备发送第三消息;第三消息包括以下至少一项:第一密钥的第二参数、第一密钥信息。In a possible implementation manner, the processing unit 1102 is configured to, after verifying the second message, send a verification response message of the second message to the first vehicle-mounted device through the sending unit; the response message of the second message is used by the first vehicle-mounted device Sending a third message to the second vehicle-mounted device; the third message includes at least one of the following items: the second parameter of the first key, and information about the first key.
发送单元1104和接收单元1103在发送信息时可以为发送单元或发射器,接收单元1103在接收信息时可以为接收单元或接收器,发送单元1104和接收单元1103可以为收发器,此收发器、发射器或接收器可以为射频电路,当密钥生成装置1100包含存储单元时,该存储单元用于存储计算机指令,处理单元1103与存储单元通信连接,处理单元1103执行存储单元存储的计算机指令,使密钥生成装置1100可以用于执行上述实施例中第一车载设备或第一安全硬件扩展单元所执行的方法。其中,处理单元1103可以是一个通用中央处理器(CPU),微处理器,特定应用集成电路(Application Specific Intergrated Circuit,ASIC)。The sending unit 1104 and the receiving unit 1103 can be a sending unit or a transmitter when sending information, the receiving unit 1103 can be a receiving unit or a receiver when receiving information, and the sending unit 1104 and the receiving unit 1103 can be transceivers, this transceiver, The transmitter or receiver may be a radio frequency circuit. When the key generating device 1100 includes a storage unit, the storage unit is used to store computer instructions, the processing unit 1103 is connected to the storage unit in communication, and the processing unit 1103 executes the computer instructions stored in the storage unit. The key generation apparatus 1100 can be used to execute the method executed by the first vehicle-mounted device or the first secure hardware expansion unit in the above embodiment. Wherein, the processing unit 1103 may be a general central processing unit (CPU), a microprocessor, or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC).
当密钥生成装置1100为芯片时,发送单元1104和接收单元1103可以是输入和/或输出接口、管脚或电路等。处理单元1103可执行存储单元存储的计算机执行指令,以使该密钥生成装置1100内的芯片执行实施例中任一实施例所执行的方法。可选地,存储单元为芯片内的存储单元,如寄存器、缓存等,存储单元还可以是密钥生成装置1100内的位于该芯片外部的存储单元,如只读存储器(Read Only Memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(Random Access Memory,RAM)等。When the key generation device 1100 is a chip, the sending unit 1104 and the receiving unit 1103 may be input and/or output interfaces, pins or circuits, and the like. The processing unit 1103 may execute the computer-executable instructions stored in the storage unit, so that the chip in the key generation device 1100 executes the method performed in any one of the embodiments. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit may also be a storage unit located outside the chip in the key generation device 1100, such as a read-only memory (Read Only Memory, ROM) Or other types of static storage devices that can store static information and instructions, random access memory (Random Access Memory, RAM), etc.
该密钥生成装置1100所涉及的与本申请实施例提供的技术方案相关的概念,解释和详细说明及其他步骤请参见前述方法或其他实施例中关于这些内容的描述,此处不做赘述。For the concepts, explanations, detailed descriptions and other steps involved in the key generation device 1100 related to the technical solutions provided by the embodiments of the present application, please refer to the foregoing methods or descriptions of these contents in other embodiments, and details are not repeated here.
图12为本申请实施例提供的一种密钥获取装置的结构示意图,如图12所示,该装置可以为第一车载设备或服务器,也可以为芯片或电路,比如可设置于第一车载设备中的芯片或电路,再比如可设置于服务器中的芯片或电路,再比如可设置于服务器中内的芯片或电路。Fig. 12 is a schematic structural diagram of a key acquisition device provided in the embodiment of the present application. As shown in Fig. 12, the device can be a first vehicle-mounted device or server, or a chip or a circuit, for example, it can be set in the first vehicle-mounted device A chip or a circuit in a device, another example is a chip or a circuit that can be installed in a server, and another example is a chip or a circuit that can be installed in a server.
进一步的,该密钥获取装置1201还可以进一步包括总线系统,其中,处理器1202、存储器1204、收发器1203可以通过总线系统相连。Furthermore, the key acquisition device 1201 may further include a bus system, wherein the processor 1202, the memory 1204, and the transceiver 1203 may be connected through the bus system.
应理解,上述处理器1202可以是一个芯片。例如,该处理器1202可以是现场可编程门阵列(field programmable gate array,FPGA),可以是专用集成芯片(application specific integrated circuit,ASIC),还可以是系统芯片(system on chip,SoC),还可以是中央处理器(central processor unit,CPU),还可以是网络处理器(network processor,NP),还可以是数字信号处理电路(digital signal processor,DSP),还可以是微控制器(micro controller unit,MCU),还可以是可编程控制器(programmable logic device,PLD)或其他集成芯片。It should be understood that the above processor 1202 may be a chip. For example, the processor 1202 may be a field programmable gate array (field programmable gate array, FPGA), may be an application specific integrated circuit (ASIC), may also be a system chip (system on chip, SoC), or It can be a central processing unit (central processor unit, CPU), or a network processor (network processor, NP), or a digital signal processing circuit (digital signal processor, DSP), or a microcontroller (micro controller) unit, MCU), it can also be a programmable controller (programmable logic device, PLD) or other integrated chips.
在实现过程中,上述方法的各步骤可以通过处理器1202中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器1202中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1204,处理器1202读取存储器1204中的信息,结合其硬件完成上述方法的步骤。In the implementation process, each step of the above method may be implemented by an integrated logic circuit of hardware in the processor 1202 or instructions in the form of software. The steps of the methods disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor 1202 . The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory 1204, and the processor 1202 reads the information in the memory 1204, and completes the steps of the above method in combination with its hardware.
应注意,本申请实施例中的处理器1202可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法实施例的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者 晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。It should be noted that the processor 1202 in the embodiment of the present application may be an integrated circuit chip, which has a signal processing capability. In the implementation process, each step of the above-mentioned method embodiments may be completed by an integrated logic circuit of hardware in a processor or instructions in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components . Various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
可以理解,本申请实施例中的存储器1204可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the memory 1204 in this embodiment of the present application may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the non-volatile memory can be read-only memory (read-only memory, ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically programmable Erases programmable read-only memory (electrically EPROM, EEPROM) or flash memory. Volatile memory can be random access memory (RAM), which acts as external cache memory. By way of illustration and not limitation, many forms of RAM are available such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (synchlink DRAM, SLDRAM ) and direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but not be limited to, these and any other suitable types of memory.
该密钥获取装置1201对应上述方法中的第一车载设备的情况下,该密钥获取装置可以包括处理器1202、收发器1203和存储器1204。该存储器1204用于存储指令,该处理器1202用于执行该存储器1204存储的指令,以实现如上图9中所示的方法中第一车载设备的相关方案。In the case where the key obtaining device 1201 corresponds to the first vehicle-mounted device in the above method, the key obtaining device may include a processor 1202 , a transceiver 1203 and a memory 1204 . The memory 1204 is used to store instructions, and the processor 1202 is used to execute the instructions stored in the memory 1204, so as to implement the related solution of the first vehicle-mounted device in the method shown in FIG. 9 above.
当密钥获取装置1201为上述第一车载设备,密钥获取装置1201可以用于执行上述实施例中第一车载设备所执行的方法。When the key obtaining device 1201 is the above-mentioned first vehicle-mounted device, the key obtaining device 1201 may be used to execute the method performed by the first vehicle-mounted device in the above-mentioned embodiment.
密钥获取装置1201为上述第一车载设备,且执行图9的实施例时:The key acquisition device 1201 is the above-mentioned first vehicle-mounted device, and when the embodiment in FIG. 9 is executed:
收发器1203用于接收车外设备发送的第一消息;向服务器发送身份验证请求消息。第一消息用于请求第一车载设备获得第一密钥;接收服务器发送的身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The transceiver 1203 is configured to receive the first message sent by the off-vehicle device; and send an identity verification request message to the server. The first message is used to request the first on-vehicle device to obtain the first key; the identity verification response message sent by the server is received; the identity verification response message includes: the verification result of the identity verification request message.
处理器1202用于根据第一消息和第一车载设备的验证信息,生成身份验证请求消息,身份验证请求消息用于服务器对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证。The processor 1202 is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to verify the authority of the first vehicle-mounted device to obtain the first key and the first vehicle-mounted device The information is verified.
一种可能的实现方式,收发器1203还用于接收服务器发送的第一消息;第一消息用于指示第一车载设备生成第一密钥;处理器1202还用于根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a possible implementation manner, the transceiver 1203 is further configured to receive a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the processor 1202 is further configured to generate a second key according to the first message. A request message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; Generated after key encryption.
一种可能的实现方式,收发器1203还用于接收服务器发送的第一密钥。In a possible implementation manner, the transceiver 1203 is also configured to receive the first key sent by the server.
一种可能的实现方式,处理器1202还用于在身份验证请求消息的验证结果为验证成功时,通过收发器1203向车外设备发送第一密钥。In a possible implementation manner, the processor 1202 is further configured to send the first key to the off-vehicle device through the transceiver 1203 when the verification result of the identity verification request message is that the verification is successful.
该密钥获取装置1201对应上述方法中的服务器的情况下,该密钥获取装置可以包括 处理器1202、收发器1203和存储器1204。该存储器1204用于存储指令,该处理器1202用于执行该存储器1204存储的指令,以实现如上图9中所示的方法中服务器的相关方案。In the case where the key obtaining device 1201 corresponds to the server in the above method, the key obtaining device may include a processor 1202, a transceiver 1203, and a memory 1204. The memory 1204 is used to store instructions, and the processor 1202 is used to execute the instructions stored in the memory 1204, so as to realize the related solution of the server in the method shown in FIG. 9 above.
当密钥获取装置1201为上述服务器,密钥获取装置1201可以用于执行上述实施例中第一车载设备所执行的方法。When the key obtaining device 1201 is the above server, the key obtaining device 1201 may be used to execute the method performed by the first vehicle-mounted device in the above embodiment.
密钥获取装置1201为上述服务器,且执行图9的实施例时:When the key acquisition device 1201 is the above-mentioned server, and the embodiment in FIG. 9 is executed:
收发器1203用于接收第一车载设备发送的身份验证请求消息;身份验证请求消息为第一车载设备根据车外设备发送的第一消息和第一车载设备的验证信息生成的;The transceiver 1203 is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
处理器1202用于根据身份验证请求消息,对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证,生成身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The processor 1202 is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: identity verification Validation result of the request message.
收发器1203用于向第一车载设备发送身份验证的响应消息。The transceiver 1203 is configured to send a response message of identity verification to the first vehicle-mounted device.
一种可能的实现方式,收发器1203还用于向第一车载设备发送第一消息;第一消息用于指示第一车载设备生成第一密钥。In a possible implementation manner, the transceiver 1203 is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
一种可能的实现方式,收发器1203还用于向第一车载设备发送第一密钥。In a possible implementation manner, the transceiver 1203 is also configured to send the first key to the first vehicle-mounted device.
一种可能的实现方式,身份验证请求消息用于指示第一车载设备向车外设备发送第一密钥。In a possible implementation manner, the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
图13为本申请实施例提供的密钥获取装置的示意图,如图13所示,该密钥获取装置1300可以为第一车载设备或服务器,也可以为芯片或电路,比如可设置于第一车载设备或服务器中的芯片或电路。其中,第一车载设备可以为车辆中的任一ECU。Fig. 13 is a schematic diagram of a key obtaining device provided in the embodiment of the present application. As shown in Fig. 13, the key obtaining device 1300 can be a first vehicle-mounted device or a server, or can be a chip or a circuit, for example, it can be set in the first Chips or circuits in in-vehicle devices or servers. Wherein, the first vehicle-mounted device may be any ECU in the vehicle.
该密钥获取装置可以对应上述方法中的第一车载设备。该密钥获取装置可以实现如上图9中所示的任一项或任多项对应的方法中第一车载设备所执行的步骤。该密钥获取装置可以包括获取单元1301、处理单元1302、发送单元1303和接收单元1304。The key acquisition device may correspond to the first vehicle-mounted device in the above method. The key acquisition device may implement the steps performed by the first vehicle-mounted device in any one or multiple corresponding methods shown in FIG. 9 above. The device for obtaining a key may include an obtaining unit 1301 , a processing unit 1302 , a sending unit 1303 and a receiving unit 1304 .
当密钥获取装置1300为上述第一车载设备,且实现如上述图9中第一车载设备所执行的步骤时,When the key acquisition device 1300 is the above-mentioned first vehicle-mounted device, and implements the steps performed by the above-mentioned first vehicle-mounted device in FIG. 9 ,
接收单元1304,用于接收车外设备发送的第一消息;第一消息用于请求第一车载设备获得第一密钥;接收服务器发送的身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The receiving unit 1304 is configured to receive a first message sent by the off-vehicle device; the first message is used to request the first on-vehicle device to obtain a first key; receive an identity verification response message sent by the server; the identity verification response message includes: Validation result of the validation request message.
处理单元1302,用于根据第一消息和第一车载设备的验证信息,生成身份验证请求消息,身份验证请求消息用于服务器对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证。The processing unit 1302 is configured to generate an identity verification request message according to the first message and the verification information of the first vehicle-mounted device, and the identity verification request message is used for the server to obtain the authority of the first key for the first vehicle-mounted device and the authentication information of the first vehicle-mounted device. Verify the information for verification.
发送单元1303,用于向服务器发送身份验证请求消息。The sending unit 1303 is configured to send an identity verification request message to the server.
一种可能的实现方式,接收单元1304,还用于接收服务器发送的第一消息;第一消息用于指示第一车载设备生成第一密钥;处理单元1302,还用于根据第一消息,生成第一请求消息;第一请求消息用于第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;第一响应消息包括:第一密钥信息;第一密钥信息为对第一密钥加密后生成的。In a possible implementation manner, the receiving unit 1304 is further configured to receive a first message sent by the server; the first message is used to instruct the first vehicle-mounted device to generate a first key; the processing unit 1302 is further configured to, according to the first message, Generate a first request message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: first key information; the first key information is for the first Generated after encryption with a key.
一种可能的实现方式,接收单元1304,还用于接收服务器发送的第一密钥。In a possible implementation manner, the receiving unit 1304 is further configured to receive the first key sent by the server.
一种可能的实现方式,处理单元1302还用于在身份验证请求消息的验证结果为验证成功时,通过发送单元1303向车外设备发送第一密钥。In a possible implementation manner, the processing unit 1302 is further configured to send the first key to the off-vehicle device through the sending unit 1303 when the verification result of the identity verification request message is that the verification is successful.
当密钥获取装置1300为上述服务器,且实现如上述图9中第一车载设备所执行的步骤时,When the key acquisition device 1300 is the above-mentioned server and implements the steps performed by the first vehicle-mounted device in FIG. 9 above,
接收单元1304,用于接收第一车载设备发送的身份验证请求消息;身份验证请求消息为第一车载设备根据车外设备发送的第一消息和第一车载设备的验证信息生成的;The receiving unit 1304 is configured to receive an identity verification request message sent by the first vehicle-mounted device; the identity verification request message is generated by the first vehicle-mounted device according to the first message sent by the off-vehicle device and the verification information of the first vehicle-mounted device;
处理单元1302,用于根据身份验证请求消息,对第一车载设备获得第一密钥的权限和第一车载设备的验证信息进行验证,生成身份验证的响应消息;身份验证的响应消息包括:身份验证请求消息的验证结果。The processing unit 1302 is configured to verify the authority of the first vehicle-mounted device to obtain the first key and the verification information of the first vehicle-mounted device according to the identity verification request message, and generate an identity verification response message; the identity verification response message includes: Validation result of the validation request message.
发送单元1303,用于向第一车载设备发送身份验证的响应消息。The sending unit 1303 is configured to send a response message of identity verification to the first vehicle-mounted device.
一种可能的实现方式,发送单元1303,还用于向第一车载设备发送第一消息;第一消息用于指示第一车载设备生成第一密钥。In a possible implementation manner, the sending unit 1303 is further configured to send a first message to the first vehicle-mounted device; the first message is used to instruct the first vehicle-mounted device to generate a first key.
一种可能的实现方式,发送单元1303,还用于向第一车载设备发送第一密钥。In a possible implementation manner, the sending unit 1303 is further configured to send the first key to the first vehicle-mounted device.
一种可能的实现方式,身份验证请求消息用于指示第一车载设备向车外设备发送第一密钥。In a possible implementation manner, the identity verification request message is used to instruct the first in-vehicle device to send the first key to the out-of-vehicle device.
发送单元1303在发送信息时可以为收发单元或发射器,接收单元1304在接收信息时可以为收发单元或接收器,发送单元1303和接收单元1304可以为收发器,此收发器、发射器或接收器可以为射频电路,当密钥获取装置1300包含存储单元时,该存储单元用于存储计算机指令,获取单元或处理单元可以分别与存储单元通信连接,获取单元或处理单元执行存储单元存储的计算机指令,使密钥获取装置可以用于执行上述实施例中任一实施例中第一车载设备或服务器所执行的方法。其中,获取单元或处理单元可以是一个通用中央处理器(CPU),微处理器,特定应用集成电路(Application Specific Intergrated Circuit,ASIC)。The sending unit 1303 can be a transceiver unit or a transmitter when sending information, the receiving unit 1304 can be a transceiver unit or a receiver when receiving information, the sending unit 1303 and the receiving unit 1304 can be transceivers, and the transceiver, transmitter or receiver The device can be a radio frequency circuit. When the key acquisition device 1300 includes a storage unit, the storage unit is used to store computer instructions. The acquisition unit or the processing unit can be respectively connected to the storage unit in communication, and the acquisition unit or the processing unit executes the computer stored in the storage unit. An instruction, so that the key acquisition device can be used to execute the method executed by the first vehicle-mounted device or the server in any of the above embodiments. Wherein, the acquiring unit or processing unit may be a general central processing unit (CPU), a microprocessor, or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC).
当密钥获取装置1300为芯片时,发送单元1303和接收单元1304可以是输入和/或输出接口、管脚或电路等。获取单元或处理单元可执行存储单元存储的计算机执行指令,以使该密钥获取装置1300内的芯片执行实施例中第一车载设备或服务器所执行的方法。可选地,存储单元为芯片内的存储单元,如寄存器、缓存等,存储单元还可以是密钥获取装置1300内的位于该芯片外部的存储单元,如只读存储器(Read Only Memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(Random Access Memory,RAM)等。When the key obtaining device 1300 is a chip, the sending unit 1303 and the receiving unit 1304 may be input and/or output interfaces, pins or circuits, and the like. The acquisition unit or the processing unit may execute the computer-executed instructions stored in the storage unit, so that the chip in the key acquisition device 1300 executes the method performed by the first vehicle-mounted device or the server in the embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc., and the storage unit may also be a storage unit located outside the chip in the key acquisition device 1300, such as a read-only memory (Read Only Memory, ROM) Or other types of static storage devices that can store static information and instructions, random access memory (Random Access Memory, RAM), etc.
该密钥获取装置1300所涉及的与本申请实施例提供的技术方案相关的概念,解释和详细说明及其他步骤请参见前述方法或其他实施例中关于这些内容的描述,此处不做赘述。For the concepts, explanations, detailed descriptions and other steps involved in the key acquisition device 1300 related to the technical solutions provided by the embodiments of the present application, please refer to the foregoing methods or descriptions of these contents in other embodiments, and details are not repeated here.
根据本申请实施例提供的方法,本申请还提供一种计算机程序产品,该计算机程序产品包括:计算机程序代码,当该计算机程序代码在计算机上运行时,使得该计算机执行图1至图9所示实施例中任意一个实施例的方法。According to the method provided in the embodiment of the present application, the present application also provides a computer program product, the computer program product including: computer program code, when the computer program code is run on the computer, the computer is made to execute the computer program described in Fig. 1 to Fig. 9 . The method of any one of the embodiments is illustrated.
根据本申请实施例提供的方法,本申请还提供一种计算机可读存储介质,该计算机可读介质存储有程序代码,当该程序代码在计算机上运行时,使得该计算机执行图1至图9所示实施例中任意一个实施例的方法。According to the method provided in the embodiment of the present application, the present application also provides a computer-readable storage medium, the computer-readable medium stores program code, and when the program code is run on the computer, the computer is made to execute the steps shown in Figures 1 to 9. The method of any of the illustrated embodiments.
根据本申请实施例提供的方法,本申请还提供一种密钥生成系统,其包括前述的第一车载设备、第一安全硬件扩展单元或服务器中的至少两项。According to the method provided in the embodiment of the present application, the present application further provides a key generation system, which includes at least two of the foregoing first vehicle-mounted device, the first secure hardware expansion unit, or the server.
本申请实施例还提供一种车辆,车辆包括至少一个本申请上述实施例提到的待诊断单元,或者车辆包括至少一个本申请上述实施例提到的第一车载设备和第一安全硬件扩展单元。The embodiment of the present application also provides a vehicle, the vehicle includes at least one unit to be diagnosed mentioned in the above-mentioned embodiments of the present application, or the vehicle includes at least one of the first vehicle-mounted equipment and the first safety hardware expansion unit mentioned in the above-mentioned embodiments of the present application .
本申请实施例还提供一种车辆,车辆包括至少一个本申请上述实施例提到的待诊断单 元,或者车辆包括至少一个本申请上述实施例提到的第一车载设备和服务器。The embodiment of the present application also provides a vehicle, the vehicle includes at least one unit to be diagnosed mentioned in the above-mentioned embodiments of the present application, or the vehicle includes at least one first vehicle-mounted device and the server mentioned in the above-mentioned embodiments of the present application.
在本说明书中使用的术语“部件”、“模块”、“系统”等用于表示计算机相关的实体、硬件、固件、硬件和软件的组合、软件、或执行中的软件。例如,部件可以是但不限于,在处理器上运行的进程、处理器、对象、可执行文件、执行线程、程序和/或计算机。通过图示,在计算设备上运行的应用和计算设备都可以是部件。一个或多个部件可驻留在进程和/或执行线程中,部件可位于一个计算机上和/或分布在两个或更多个计算机之间。此外,这些部件可从在上面存储有各种数据结构的各种计算机可读介质执行。部件可例如根据具有一个或多个数据分组(例如来自与本地系统、分布式系统和/或网络间的另一部件交互的二个部件的数据,例如通过信号与其它系统交互的互联网)的信号通过本地和/或远程进程来通信。The terms "component", "module", "system" and the like are used in this specification to refer to a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a computing device and the computing device can be components. One or more components can reside within a process and/or thread of execution and a component can be localized on one computer and/or distributed between two or more computers. In addition, these components can execute from various computer readable media having various data structures stored thereon. A component may, for example, be based on a signal having one or more packets of data (e.g., data from two components interacting with another component between a local system, a distributed system, and/or a network, such as the Internet via a signal interacting with other systems). Communicate through local and/or remote processes.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各种说明性逻辑块(illustrative logical block)和步骤(step),能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can appreciate that various illustrative logical blocks (illustrative logical blocks) and steps (steps) described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, or a combination of computer software and electronic hardware. accomplish. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disc and other media that can store program codes. .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例 的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。The above is only a specific implementation of the application, but the scope of protection of the application is not limited thereto. Anyone familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the application. Should be covered within the protection scope of this application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims. Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的保护范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Apparently, those skilled in the art can make various changes and modifications to this application without departing from the protection scope of this application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.

Claims (22)

  1. 一种密钥生成方法,其特征在于,应用于车辆,包括:A method for generating a key, characterized in that it is applied to a vehicle, comprising:
    第一车载设备获得第一消息;所述第一消息用于指示所述第一车载设备构建第一密钥;The first vehicle-mounted device obtains a first message; the first message is used to instruct the first vehicle-mounted device to construct a first key;
    根据所述第一消息,生成第一请求消息;所述第一请求消息用于所述第一车载设备对应的第一安全硬件扩展单元生成第一响应消息;所述第一响应消息包括:第一密钥信息;所述第一密钥信息为对所述第一密钥加密后生成的。Generate a first request message according to the first message; the first request message is used for the first safety hardware expansion unit corresponding to the first vehicle-mounted device to generate a first response message; the first response message includes: Key information; the first key information is generated after encrypting the first key.
  2. 如权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1, further comprising:
    接收来自所述第一安全硬件扩展单元发送的所述第一响应消息。Receive the first response message sent from the first security hardware extension unit.
  3. 如权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, further comprising:
    接收来自所述第一安全硬件扩展单元发送的所述第一密钥的第一参数;receiving a first parameter of the first key sent from the first secure hardware extension unit;
    所述第一车载设备根据所述第一密钥的第一参数,生成第一密钥加载消息;The first vehicle-mounted device generates a first key loading message according to the first parameter of the first key;
    所述第一车载设备向第二车载设备发送所述第一密钥加载消息;所述第一密钥加载消息用于所述第二车载设备对所述第一密钥加载消息进行验证成功后,灌装所述第一密钥。The first vehicle-mounted device sends the first key loading message to the second vehicle-mounted device; the first key loading message is used after the second vehicle-mounted device successfully verifies the first key loading message , filling the first key.
  4. 如权利要求1-3任一项所述的方法,其特征在于,所述第一车载设备获得第一消息之后,还包括:The method according to any one of claims 1-3, wherein after the first vehicle-mounted device obtains the first message, further comprising:
    所述第一车载设备向所述第一安全硬件扩展单元发送状态更新消息;所述状态更新消息包括:车内密钥的构建状态;所述状态更新消息用于所述第一安全硬件扩展单元对所述状态更新消息验证成功后,根据所述状态更新消息更新自身的车内密钥的构建状态。The first in-vehicle device sends a status update message to the first secure hardware expansion unit; the status update message includes: the construction status of the key in the vehicle; the status update message is used for the first secure hardware expansion unit After successfully verifying the state update message, update the construction state of its own in-vehicle key according to the state update message.
  5. 如权利要求1-4任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    确定所述第一车载设备重启后,向所述第一安全硬件扩展单元发送第一查询请求;所述第一查询请求用于查询所述第一密钥的第二参数;After determining that the first vehicle-mounted device is restarted, send a first query request to the first security hardware expansion unit; the first query request is used to query the second parameter of the first key;
    接收所述第一安全硬件扩展单元发送的第一查询响应消息;所述第一查询响应消息为所述第一安全硬件扩展单元对所述第一查询请求进行验证后返回的;所述第一查询响应消息包括:所述第一密钥的第二参数;receiving a first query response message sent by the first security hardware expansion unit; the first query response message is returned after the first security hardware expansion unit verifies the first query request; the first The query response message includes: a second parameter of the first key;
    根据所述第一消息,生成第一请求消息,包括:According to the first message, generate a first request message, including:
    根据所述第一密钥的第二参数和所述第一消息,生成所述第一请求消息;所述第一密钥为重启前所述第一安全硬件扩展单元待生成的密钥。The first request message is generated according to the second parameter of the first key and the first message; the first key is a key to be generated by the first security hardware expansion unit before restarting.
  6. 如权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-5, wherein the method further comprises:
    接收来自所述第一安全硬件扩展单元发送的临时密钥;所述临时密钥用于加密所述第一请求消息。receiving a temporary key sent from the first secure hardware extension unit; the temporary key is used to encrypt the first request message.
  7. 如权利要求1-6任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-6, further comprising:
    接收第二车载设备发送的第二消息;所述第二消息用于以下至少一项:receiving a second message sent by the second vehicle-mounted device; the second message is used for at least one of the following:
    查询所述第一密钥的第二参数、请求所述第一车载设备生成所述第一密钥或者指示所述第二车载设备重启。Querying the second parameter of the first key, requesting the first vehicle-mounted device to generate the first key, or instructing the second vehicle-mounted device to restart.
  8. 如权利要求7所述的方法,其特征在于,所述方法还包括:The method of claim 7, further comprising:
    对所述第二消息进行验证后,向所述第二车载设备发送第三消息;所述第三消息包括以下至少一项:所述第一密钥的第二参数、所述第一密钥信息。After verifying the second message, send a third message to the second vehicle-mounted device; the third message includes at least one of the following: the second parameter of the first key, the first key information.
  9. 一种密钥生成方法,其特征在于,应用于车辆,包括:A method for generating a key, characterized in that it is applied to a vehicle, comprising:
    第一安全硬件扩展单元接收所述第一安全硬件扩展单元对应的第一车载设备发送的第一请求消息;所述第一请求消息为所述第一车载设备用于请求所述第一安全硬件扩展单元构建第一密钥;The first safety hardware expansion unit receives the first request message sent by the first vehicle-mounted device corresponding to the first safety hardware expansion unit; the first request message is used by the first vehicle-mounted device to request the first safety hardware The expansion unit constructs the first key;
    对所述第一请求消息进行验证成功后,生成第一密钥信息;所述第一密钥信息为对所述第一密钥加密后生成的。After the first request message is verified successfully, first key information is generated; the first key information is generated after encrypting the first key.
  10. 如权利要求9所述的方法,其特征在于,所述方法还包括:The method of claim 9, further comprising:
    向所述第一车载设备发送所述第一响应消息;所述第一响应消息包括:第一密钥信息。Sending the first response message to the first vehicle-mounted device; the first response message includes: first key information.
  11. 如权利要求9或10所述的方法,其特征在于,所述方法还包括:The method according to claim 9 or 10, further comprising:
    对所述第一请求消息进行验证成功后,生成第一密钥的第一参数;After successfully verifying the first request message, generating a first parameter of the first key;
    向所述第一车载设备发送所述第一密钥的第一参数;所述第一密钥的第一参数用于第二车载设备灌装所述第一密钥。Sending the first parameter of the first key to the first vehicle-mounted device; the first parameter of the first key is used for the second vehicle-mounted device to fill the first key.
  12. 如权利要求9-11任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 9-11, wherein the method further comprises:
    接收所述第一车载设备发送的状态更新消息;所述状态更新消息包括:车内密钥的构建状态;receiving a status update message sent by the first vehicle-mounted device; the status update message includes: the construction status of the in-vehicle key;
    对所述状态更新消息验证成功后,根据所述状态更新消息更新自身的车内密钥的构建状态。After successfully verifying the state update message, update the construction state of its own in-vehicle key according to the state update message.
  13. 如权利要求9-12任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 9-12, wherein the method further comprises:
    在所述第一车载设备重启后,接收所述第一车载设备发送的第一查询请求;所述第一查询请求用于查询所述第一密钥的第二参数;After the first vehicle-mounted device restarts, receiving a first query request sent by the first vehicle-mounted device; the first query request is used to query the second parameter of the first key;
    对所述第一查询请求进行验证后,向所述第一车载设备发送第一查询响应消息;所述第一查询响应消息包括:所述第一密钥的第二参数;所述第一密钥的第二参数用于所述第一车载设备生成所述第一请求消息;所述第一密钥为重启前所述第一安全硬件扩展单元待生成的密钥。After verifying the first query request, send a first query response message to the first vehicle-mounted device; the first query response message includes: the second parameter of the first key; the first key The second parameter of the key is used by the first vehicle-mounted device to generate the first request message; the first key is the key to be generated by the first security hardware expansion unit before restarting.
  14. 如权利要求9-13任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 9-13, further comprising:
    对所述第一请求消息进行验证成功后,生成临时密钥;After successfully verifying the first request message, generating a temporary key;
    向所述第一车载设备发送所述临时密钥;所述临时密钥用于加密所述第一请求消息。sending the temporary key to the first in-vehicle device; the temporary key is used to encrypt the first request message.
  15. 如权利要求9-14任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 9-14, further comprising:
    接收来自所述第一车载设备的第二消息的验证消息;所述第二消息为所述第一车载设备接收第二车载设备发送的;所述第二消息用于以下至少一项:查询所述第一密钥的第二参数、请求所述第一车载设备生成所述第一密钥或者指示所述第二车载设备重启。Receive a verification message of a second message from the first vehicle-mounted device; the second message is sent by the first vehicle-mounted device and received by the second vehicle-mounted device; the second message is used for at least one of the following: query the the second parameter of the first key, request the first vehicle-mounted device to generate the first key, or instruct the second vehicle-mounted device to restart.
  16. 如权利要求15所述的方法,其特征在于,所述方法还包括:The method of claim 15, further comprising:
    对所述第二消息进行验证后,向所述第一车载设备发送第二消息的验证响应消息;所述第二消息的响应消息用于所述第一车载设备向所述第二车载设备发送第三消息;所述第三消息包括以下至少一项:所述第一密钥的第二参数、所述第一密钥信息。After verifying the second message, send a verification response message of the second message to the first vehicle-mounted device; the response message of the second message is used for the first vehicle-mounted device to send the second message to the second vehicle-mounted device A third message; the third message includes at least one of the following: a second parameter of the first key, and information about the first key.
  17. 一种密钥生成装置,其特征在于,包括:处理器和通信接口,所述通信接口用于接收来自除所述密钥生成装置以外的其它通信装置的信号并传输至处理器或将来自处理器的信号发送给除所述密钥生成装置以外的其它通信装置;所述处理器通过逻辑电路或执行代码指令用于实现如上述权利要求1至8中任一项所述的方法。A key generation device, characterized in that it includes: a processor and a communication interface, the communication interface is used to receive signals from other communication devices except the key generation device and transmit them to the processor or transfer signals from the processing The signal of the processor is sent to other communication devices except the key generation device; the processor is used to implement the method as described in any one of claims 1 to 8 through a logic circuit or executing code instructions.
  18. 一种密钥生成装置,其特征在于,包括:处理器和通信接口,所述通信接口用于接 收来自除所述密钥生成装置以外的其它通信装置的信号并传输至处理器或将来自处理器的信号发送给除所述密钥生成装置以外的其它通信装置;所述处理器通过逻辑电路或执行代码指令用于实现如上述权利要求9至16中任一项所述的方法。A key generation device, characterized in that it includes: a processor and a communication interface, the communication interface is used to receive signals from other communication devices except the key generation device and transmit them to the processor or transfer signals from the processing The signal of the processor is sent to other communication devices except the key generation device; the processor is used to implement the method as described in any one of claims 9 to 16 through a logic circuit or executing code instructions.
  19. 一种车辆,其特征在于,所述车辆包括第一车载设备和第一安全硬件扩展单元,所述第一车载设备用于实现如权利要求1至8中任一项所述的方法,所述第一安全硬件扩展单元用于实现如权利要求9至16中任一项所述的方法。A vehicle, characterized in that the vehicle comprises a first vehicle-mounted device and a first security hardware expansion unit, the first vehicle-mounted device is used to implement the method according to any one of claims 1 to 8, the The first security hardware expansion unit is used to implement the method according to any one of claims 9-16.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,当所述计算机程序被运行时,实现如上述权利要求1至8中任一项所述的方法、或实现如上述权利要求9至16中任一项所述的方法。A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and when the computer program is executed, the method, Or implement the method as described in any one of claims 9 to 16 above.
  21. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序或指令,当所述计算机程序或指令被密钥生成装置执行时,实现如上述权利要求1至8中任一项所述的方法、或实现如上述权利要求9至16中任一项所述的方法。A computer program product, characterized in that the computer program product includes a computer program or an instruction, and when the computer program or instruction is executed by the key generation device, the implementation of any one of the above claims 1 to 8 method, or implement a method as described in any one of claims 9 to 16 above.
  22. 一种芯片系统,其特征在于,包括:A system on a chip, characterized in that it comprises:
    处理器,用于调用存储器中存储的计算机程序或计算机指令,以使得该处理器执行所述存储器中的程序代码,以实现如上述权利要求1至8中任一项所述的方法、或实现如上述权利要求9至16中任一项所述的方法。A processor, used to call the computer program or computer instruction stored in the memory, so that the processor executes the program code in the memory, so as to realize the method as described in any one of the above claims 1 to 8, or realize A method as claimed in any one of claims 9 to 16 above.
PCT/CN2021/095348 2021-05-21 2021-05-21 Key generation method and apparatus WO2022241799A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202180098495.4A CN117378169A (en) 2021-05-21 2021-05-21 Key generation method and device
PCT/CN2021/095348 WO2022241799A1 (en) 2021-05-21 2021-05-21 Key generation method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/095348 WO2022241799A1 (en) 2021-05-21 2021-05-21 Key generation method and apparatus

Publications (1)

Publication Number Publication Date
WO2022241799A1 true WO2022241799A1 (en) 2022-11-24

Family

ID=84140149

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/095348 WO2022241799A1 (en) 2021-05-21 2021-05-21 Key generation method and apparatus

Country Status (2)

Country Link
CN (1) CN117378169A (en)
WO (1) WO2022241799A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018100789A1 (en) * 2016-11-30 2018-06-07 Kddi株式会社 Distribution system, key generation device, in-vehicle computer, data security device, distribution method and computer program
CN109428716A (en) * 2017-08-30 2019-03-05 福特全球技术公司 The encryption key distribution of car group
US20200169392A1 (en) * 2018-11-26 2020-05-28 Electronics And Telecommunications Research Institute System for key control for in-vehicle network
CN111294771A (en) * 2018-12-10 2020-06-16 大陆汽车电子(连云港)有限公司 In-vehicle device, system for implementing in-vehicle communication and related method

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6173411B2 (en) * 2014-12-12 2017-08-02 Kddi株式会社 Management device, vehicle, management system, management method, and computer program
JP6260066B2 (en) * 2016-01-18 2018-01-17 Kddi株式会社 In-vehicle computer system and vehicle
CN113676320A (en) * 2018-08-01 2021-11-19 百度在线网络技术(北京)有限公司 Method, device and equipment for determining vehicle ECU key and storage medium
CN112069502B (en) * 2020-07-22 2024-02-09 延锋伟世通电子科技(上海)有限公司 Safe starting method and device for vehicle-mounted MCU

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018100789A1 (en) * 2016-11-30 2018-06-07 Kddi株式会社 Distribution system, key generation device, in-vehicle computer, data security device, distribution method and computer program
CN109428716A (en) * 2017-08-30 2019-03-05 福特全球技术公司 The encryption key distribution of car group
US20200169392A1 (en) * 2018-11-26 2020-05-28 Electronics And Telecommunications Research Institute System for key control for in-vehicle network
CN111294771A (en) * 2018-12-10 2020-06-16 大陆汽车电子(连云港)有限公司 In-vehicle device, system for implementing in-vehicle communication and related method

Also Published As

Publication number Publication date
CN117378169A (en) 2024-01-09

Similar Documents

Publication Publication Date Title
JP7159328B2 (en) Secure communication between in-vehicle electronic control units
US11985238B2 (en) Vehicle-mounted device upgrade method and related device
CN112585905B (en) Equipment upgrading method and related equipment
US10855460B2 (en) In-vehicle computer system, vehicle, key generation device, management method, key generation method, and computer program
EP3319266B1 (en) Software distribution processing device, vehicle, software distribution processing method, and computer program
US10419220B2 (en) Management device, key generating device, vehicle, maintenance tool, management system, management method, and computer program
KR102450811B1 (en) System for key control for in-vehicle network
JP6178390B2 (en) Management device, management system, vehicle, management method, and computer program
EP3926500A1 (en) Device upgrade method and related device
CN113439425B (en) Message transmission method and device
JPWO2018070242A1 (en) In-vehicle gateway, key management device
CN113016201B (en) Key provisioning method and related product
CN110708388A (en) Vehicle body safety anchor node device, method and network system for providing safety service
CN112740212B (en) Key writing method and device
WO2022160124A1 (en) Service authorisation management method and apparatus
JP2016163265A (en) Key management system, key management method, and computer program
CN114095919A (en) Certificate authorization processing method based on Internet of vehicles and related equipment
CN114785532B (en) Security chip communication method and device based on bidirectional signature authentication
WO2022241799A1 (en) Key generation method and apparatus
WO2023000313A1 (en) Key verification method and related apparatus
WO2022120581A1 (en) Vehicle diagnosis system, method and apparatus
JP2017060031A (en) On-vehicle control system, vehicle, management device, on-vehicle computer, data sharing method, and computer program
CN114647836A (en) Authentication method and device
CN114980012A (en) Internet of vehicles equipment authentication method, device and storage medium
WO2024036805A1 (en) Communication method, apparatus and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21940252

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 202180098495.4

Country of ref document: CN

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21940252

Country of ref document: EP

Kind code of ref document: A1