Authentication method, apparatus and computer program product
By using a two-factor verification authentication method in the vehicle diagnostic system, verifying the holder identity of the target digital certificate and diagnostic equipment, the problem of low authentication safety of diagnostic equipment in the prior art is solved, and higher vehicle information security is achieved.
Patent Information
- Application Number
- CN202411626257.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-25
AI Technical Summary
In the existing vehicle diagnostic system, after the diagnostic equipment is connected to the OBD interface of the vehicle, it is authenticated through password verification. It has low security and is easily disguised as a legal equipment by illegal equipment for data reading and writing.
The two-factor authentication method is adopted to verify the legitimacy of the target digital certificate first. If it is passed, it will be secondary authentication through the public key and the random number of preset bytes in the target digital certificate to ensure that the diagnostic device is the holder of the target digital certificate.
Through the dual-factor verification, the information security of the vehicle is significantly improved, and illegal equipment is prevented from reading and writing data on the vehicle by disguising as legal equipment, enhancing the safety of the vehicle.
Smart Images

Figure CN119519982A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle safety technology, and in particular to an authentication method, device and computer program product. Background Art
[0002] With the continuous development of automobile technology, on-board diagnostics (OBD) systems have gradually been applied to various types of vehicles to monitor vehicles and record faults. When a vehicle fails, technicians connect the diagnostic equipment to the vehicle's OBD interface to obtain the vehicle's operating data and fault information. In this case, how to ensure the legality of the diagnostic equipment is an issue that needs to be focused on.
[0003] In the related art, after the diagnostic device is connected to the OBD interface of the vehicle, the vehicle can authenticate whether the diagnostic device is legitimate by password verification. However, this authentication method has low security. Summary of the invention
[0004] The present application provides an authentication method, device and computer program product, which can improve vehicle safety. The technical solution is as follows:
[0005] In a first aspect, an authentication method is provided, which is applied to a vehicle, and the method comprises:
[0006] receiving a first authentication message sent by a diagnostic device, wherein the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of a holder;
[0007] Verifying the target digital certificate;
[0008] When the target digital certificate is verified, sending a first response message to the diagnostic device, wherein the first response message includes first information;
[0009] Receiving a second authentication message sent by the diagnostic device, where the second authentication message includes second information, where the second information is obtained by encrypting the first information by the diagnostic device using its own private key;
[0010] Verifying the second information according to the public key in the target digital certificate and the first information;
[0011] If the second information is verified successfully, it is determined that the diagnostic device is authenticated.
[0012] In the present application, a double verification method is adopted, that is, first verifying the legitimacy of the target digital certificate, and then verifying whether the diagnostic device is the holder of the target digital certificate based on the confirmed legitimacy of the target digital certificate. In this way, the legitimacy of the diagnostic device can be confirmed more accurately, and illegal devices can be effectively prevented from reading and writing data on the vehicle by disguising themselves as legal devices, thereby greatly improving the information security of the vehicle.
[0013] Optionally, the first authentication message includes a routine identification field, an OCSP Stapling length field, an OCSP Stapling field, a certificate length field and a certificate field, and the certificate field contains the target digital certificate.
[0014] Optionally, the verifying the target digital certificate includes:
[0015] The target digital certificate is verified according to the data included in the OCSP Stapling field.
[0016] Optionally, the first information is a random number of preset bytes, and / or the first response message also includes a verification result flag, and the verification result flag is used to indicate whether the target digital certificate passes the verification.
[0017] Optionally, the verifying the second information according to the public key in the target digital certificate and the first information includes:
[0018] Decrypt the second information using the public key in the target digital certificate to obtain third information;
[0019] If the first information is identical to the third information, determining that the second information is verified;
[0020] When the first information is different from the third information, it is determined that the second information verification has failed.
[0021] In a second aspect, an authentication method is provided, which is applied to a diagnostic device, and the method comprises:
[0022] Sending a first authentication message to the vehicle, the first authentication message including a target digital certificate, the target digital certificate including a public key of a holder;
[0023] receiving a first response message sent by the vehicle, the first response message including first information, the first response message being sent when the target digital certificate is verified;
[0024] encrypting the first information using a private key of the diagnostic device to obtain second information;
[0025] A second authentication message is sent to the vehicle, wherein the second authentication message includes the second information, and the second authentication message is used to instruct the vehicle to authenticate the diagnostic device according to the public key in the target digital certificate, the first information, and the second information.
[0026] Optionally, before sending the first authentication message to the vehicle, the method further includes:
[0027] generating a public-private key pair, the public-private key pair comprising a private key and a public key of the diagnostic device;
[0028] The target digital certificate is obtained according to the public key of the diagnostic device.
[0029] Optionally, before sending the first authentication message to the vehicle, the method further includes:
[0030] Sending an inquiry message to the vehicle, wherein the inquiry message is used to determine whether the vehicle supports an authentication function;
[0031] If a second response message sent by the vehicle is received, the step of sending the first authentication message to the vehicle is performed, and the second response message is used to indicate that the vehicle supports the authentication function.
[0032] In a third aspect, an authentication method is provided, the method comprising:
[0033] The diagnostic device sends a first authentication message to the vehicle, the first authentication message including a target digital certificate, the target digital certificate including a public key of a holder;
[0034] The vehicle receives the first authentication message sent by the diagnostic device;
[0035] The vehicle verifies the target digital certificate;
[0036] In the case where the target digital certificate is verified, the vehicle sends a first response message to the diagnostic device, wherein the first response message includes first information;
[0037] The diagnostic device receives the first response message sent by the vehicle;
[0038] The diagnostic device encrypts the first information using a private key of the diagnostic device to obtain second information;
[0039] The diagnostic device sends a second authentication message to the vehicle, the second authentication message including the second information;
[0040] The vehicle receives the second authentication message sent by the diagnostic device;
[0041] The vehicle verifies the second information based on the public key in the target digital certificate and the first information;
[0042] The vehicle determines that the diagnostic device is authenticated if the second information is verified.
[0043] In a fourth aspect, an authentication device is provided, which is applied to a vehicle and includes:
[0044] A first receiving module, configured to receive a first authentication message sent by a diagnostic device, wherein the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of a holder;
[0045] A first verification module, used for verifying the target digital certificate;
[0046] A sending module, configured to send a first response message to the diagnostic device if the target digital certificate is verified successfully, wherein the first response message includes first information;
[0047] A second receiving module is used to receive a second authentication message sent by the diagnostic device, where the second authentication message includes second information, where the second information is obtained by encrypting the first information by the diagnostic device using its own private key;
[0048] A second verification module, configured to verify the second information according to the public key in the target digital certificate and the first information;
[0049] A determination module is used to determine whether the diagnostic device is authenticated if the second information is authenticated.
[0050] In a fifth aspect, an authentication device is provided, which is applied to a diagnostic device, and the authentication device includes:
[0051] A first sending module, used for sending a first authentication message to the vehicle, wherein the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of a holder;
[0052] A receiving module, configured to receive a first response message sent by the vehicle, wherein the first response message includes first information and is sent when the target digital certificate is verified;
[0053] an encryption module, used to encrypt the first information using a private key of the diagnostic device to obtain second information;
[0054] The second sending module is used to send a second authentication message to the vehicle, wherein the second authentication message includes the second information, and the second authentication message is used to instruct the vehicle to authenticate the diagnostic device according to the public key in the target digital certificate, the first information and the second information.
[0055] In a sixth aspect, an authentication system is provided, the authentication system comprising a diagnostic device and a vehicle, the diagnostic device being used to implement the authentication method described in the second aspect, and the vehicle being used to implement the authentication method described in the first aspect.
[0056] In a seventh aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the authentication method described in the first aspect or the second aspect.
[0057] In an eighth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the authentication method described in the first aspect or the second aspect is implemented.
[0058] In a ninth aspect, a computer program product is provided. When the computer program product is run on a computer device, the computer device executes the authentication method described in the first aspect or the second aspect.
[0059] It can be understood that the beneficial effects of the second, third, fourth, fifth, sixth, seventh, eighth and ninth aspects mentioned above can be found in the relevant description of the first aspect mentioned above and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0061] Figure 1 is a flow chart of an authentication method provided in an embodiment of the present application;
[0062] Figure 2 It is a structural diagram of an authentication device provided in an embodiment of the present application;
[0063] Figure 3 is a schematic diagram of the structure of another authentication device provided in an embodiment of the present application;
[0064] Figure 4 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0066] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.
[0067] The phrases such as "one embodiment" or "some embodiments" described in the present application mean that the specific features, structures or characteristics described in the embodiment are included in one or more embodiments of the present application. Therefore, the phrases such as "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments" that appear in the differences in the present application do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. In addition, the terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0068] The application scenarios of the embodiments of the present application are described below.
[0069] OBD has been gradually applied to various types of vehicles for monitoring and fault recording because of its advantages such as real-time monitoring of vehicle performance and timely detection of potential vehicle faults. Currently, there are problems of illegal devices connecting to the OBD interface of vehicles to obtain data in the vehicle, and even performing dangerous upgrades and data writing, which greatly affects the safety of the vehicle. In this case, how to ensure the legitimacy of the diagnostic equipment connected to the vehicle is an issue that needs to be focused on.
[0070] In the related art, after the diagnostic device is connected to the OBD interface of the vehicle, the vehicle can authenticate whether the diagnostic device is legitimate through password verification. However, this authentication method is relatively simple, and illegal devices can easily steal the password, resulting in low vehicle security.
[0071] To this end, an embodiment of the present application provides an authentication method. After the diagnostic device is connected to the OBD interface of the vehicle, the vehicle can perform digital certificate authentication and encrypted information authentication on the diagnostic device, thereby improving vehicle safety.
[0072] The authentication method provided in the embodiment of the present application is explained in detail below.
[0073] It should be noted that, before executing the authentication method, the diagnostic device and the vehicle may be connected, such as the diagnostic device and the vehicle may be connected by wire or wirelessly. For example, the diagnostic device may be connected by wire to the OBD interface of the vehicle.
[0074] After the diagnostic device is connected to the vehicle, the vehicle can perform dual authentication on the diagnostic device according to the authentication method. If the dual authentication is passed, the vehicle can allow the diagnostic device to perform related operations, such as obtaining data such as the vehicle's operating condition data and fault information.
[0075] For example, the vehicle may be various types of vehicles, such as a car, a bus, a truck, etc., which is not limited in the embodiments of the present application.
[0076] For example, the diagnostic device may be a device capable of implementing a vehicle diagnostic function.
[0077] Figure 1 is a flow chart of an authentication method provided by an embodiment of the present application. Figure 1 , the method comprises the following steps:
[0078] Step 101: The diagnostic device sends a first authentication message to the vehicle, the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of the holder.
[0079] The vehicle is the vehicle to which the diagnostic device is connected.
[0080] The first authentication message is used to request authentication of whether the target digital certificate in the first authentication message is legitimate. For example, the first authentication message may be sent to the vehicle after the diagnostic device is connected to the OBD interface of the vehicle.
[0081] The target digital certificate is the digital certificate currently being used by the diagnostic device.
[0082] By way of example, the target digital certificate may include one or more of issuer information, validity period, status, public key, digital signature, and the like.
[0083] The issuer information is information of an institution (such as a certificate authority (CA) server) that issues the target digital certificate. For example, the issuer information may include a subject name (distinguished name, DN) and a serial number of the issuer.
[0084] The validity period is the validity period of the target digital certificate.
[0085] This status indicates whether the target digital certificate is valid.
[0086] The public key is the public key of the holder of the target digital certificate. In the embodiment of the present application, the holder of the target digital certificate is the diagnostic device.
[0087] The digital signature is generated by the CA server.
[0088] In some embodiments, the diagnostic device may communicate with the vehicle via a preset protocol.
[0089] The preset protocol can be set in advance. For example, the preset protocol can be a standard protocol for automobile diagnosis.
[0090] In this case, the first authentication message may include a routine identification field, an online certificate status protocol (OCSP) stapling length field, an OCSP stapling field, a certificate length field, and a certificate field.
[0091] The routine identification field includes a routine identification, and the routine identification is used to identify the message type of the first authentication message. For example, the routine identification 31 01XX X1 can be the message type of the authentication message. For example, the length of the routine identification field can be 2 bytes.
[0092] The OCSP Stapling length field includes the length information of the OCSP Stapling field. For example, the length of the OCSP Stapling length field may be 2 bytes.
[0093] The OCSP Stapling field contains attribute data of the target digital certificate.
[0094] The certificate length field includes the length information of the certificate field. For example, the length of the certificate length field may be 2 bytes.
[0095] The Certificate field contains the target digital certificate.
[0096] In some embodiments, before the diagnostic device sends the first authentication message to the vehicle, it can first check whether the target digital certificate exists locally; if the target digital certificate exists locally and the target digital certificate has not expired, the first authentication message is sent to the vehicle; if the target digital certificate does not exist locally, or the target digital certificate exists locally but the target digital certificate has expired, the target digital certificate can be obtained first and then the first authentication message is sent to the vehicle.
[0097] Of course, the method is not limited to the above. The diagnostic device can also obtain the target digital certificate every time it needs to send the first authentication message to the vehicle. The embodiment of the present application does not limit this.
[0098] For example, the operation of the diagnostic device acquiring the target digital certificate may be: generating a public-private key pair, and acquiring the target digital certificate according to a public key in the public-private key pair.
[0099] The public-private key pair is a key pair used for encryption, and the public-private key pair includes a public key and a private key of the diagnostic device.
[0100] For example, the diagnostic device can generate a public-private key pair through an asymmetric encryption algorithm. For example, the asymmetric encryption algorithm can be an RSA (rivest, shamir, adleman) encryption algorithm, a digital signature algorithm (digital signature algorithm, DSA), an elliptic curve cryptography (elliptic curve cryptography, ECC) algorithm, etc., which is not limited in the embodiments of the present application.
[0101] For example, the operation of the diagnostic device obtaining the target digital certificate according to the public key in the public-private key pair can be: the diagnostic device uses the public key to create an application document for a digital certificate, and the application document for the digital certificate includes the identity information of the diagnostic device and the public key. Then, the diagnostic device sends the application document to a CA server in a public key infrastructure (PKI) system. The PKI server receives and verifies the application document, generates a digital certificate according to the application document after the application document is verified, and then sends the digital certificate to the diagnostic device. In this way, the diagnostic device obtains a digital certificate (i.e., a target digital certificate) that can prove its own legitimacy.
[0102] Of course, the diagnostic device may also obtain the target digital certificate in other ways according to the public key in the public-private key pair, and this embodiment of the present application does not limit this.
[0103] In some cases, after acquiring the target digital certificate, the diagnostic device may save the target digital certificate locally.
[0104] In some embodiments, before the diagnostic device sends the first authentication message to the vehicle, it may send an inquiry message to the vehicle; after the vehicle receives the inquiry message, it may send a second response message to the diagnostic device; if the diagnostic device receives the second response message sent by the vehicle, it may send the first authentication message to the vehicle.
[0105] The inquiry message is used to determine whether the vehicle supports the authentication function.
[0106] The second response message is used to indicate that the vehicle supports the authentication function.
[0107] If the diagnostic device receives the second response message sent by the vehicle, it means that the vehicle supports the authentication function, so the first authentication message can be sent to the vehicle to request the vehicle to authenticate the diagnostic device. If the diagnostic device receives a response message sent by the vehicle indicating that it does not support the authentication function, or if the diagnostic device does not receive a response message sent by the diagnostic device within a preset time after sending the inquiry message, it means that the vehicle does not support the authentication function, so the first authentication message may not be sent to the vehicle, but related operations may be directly performed, such as directly reading and writing data in the vehicle.
[0108] For example, the inquiry message may be a data identifier (DID) 1 message.
[0109] Step 102: After receiving the first authentication message sent by the diagnostic device, the vehicle verifies the target digital certificate.
[0110] In some embodiments, the operation of step 102 may be: the vehicle verifies the target digital certificate according to the data included in the OCSP Stapling field in the first authentication message.
[0111] For example, the data included in the OCSP Stapling field may include one or more of a digital certificate serial number, a digital certificate status, an issuance time, an expiration time, a response signature, and the like.
[0112] The digital certificate serial number is used to uniquely identify the digital certificate.
[0113] The digital certificate status is used to indicate whether the digital certificate is valid. For example, the digital certificate status can be "valid", "revoked" or the like.
[0114] The issuance time is the generation time of the data contained in the OCSP Stapling field.
[0115] The expiration time is the expiration time of the data included in the OCSP Stapling field.
[0116] The response signature is the signature generated by the CA server.
[0117] In some embodiments, a root certificate is stored in the vehicle, and the root certificate is a root certificate issued by a CA server. The root certificate includes a public key of the CA server. For example, the vehicle can obtain the root certificate in advance from the CA official website or other reliable sources.
[0118] In this case, the operation of the vehicle verifying the target digital certificate according to the data contained in the OCSP Stapling field in the first authentication message may be: the vehicle verifies the response signature in the OCSP Stapling field according to the public key of the CA server. If the response signature verification fails, it is determined that the target digital certificate verification fails; if the response signature verification passes, it is checked whether the digital certificate serial number in the OCSP Stapling field is the same as the serial number in the target digital certificate. If the digital certificate serial number in the OCSP Stapling field is different from the serial number in the target digital certificate, it is determined that the target digital certificate verification fails; if the digital certificate serial number in the OCSP Stapling field is the same as the serial number in the target digital certificate, the digital certificate status in the OCSP Stapling field is checked. If the digital certificate status in the OCSP Stapling field is not a valid status (such as "revoked"), it is determined that the target digital certificate verification has failed; if the digital certificate status in the OCSP Stapling field is a valid status (such as "valid"), the issuance time and expiration time in the OCSP Stapling field are checked to determine whether the data contained in the OCSP Stapling field is within the validity period. If the data contained in the OCSP Stapling field is not within the validity period, it is determined that the target digital certificate verification has failed; if the data contained in the OCSP Stapling field is within the validity period, the digital signature in the target digital certificate is verified according to the public key of the CA server. If the digital signature in the target digital certificate fails to be verified, it is determined that the target digital certificate verification has failed; if the digital signature in the target digital certificate passes the verification, it is determined whether the target digital certificate is within the validity period according to the validity period in the target digital certificate. If the target digital certificate is not within the validity period, it is determined that the target digital certificate verification has failed; if the target digital certificate is within the validity period, it is determined whether the target digital certificate is valid according to the status in the target digital certificate. If the target digital certificate is invalid, it is determined that the target digital certificate verification has failed; if the target digital certificate is valid, it is determined that the target digital certificate verification has passed.
[0119] Of course, the method is not limited to the above. The vehicle can also verify the target digital certificate in other ways based on the data contained in the OCSP Stapling field in the first authentication message. The embodiment of the present application does not limit this.
[0120] It should be noted that the vehicle can determine the legitimacy of the target digital certificate by verifying the target digital certificate. In this way, it can prevent illegal devices from using forged digital certificates to commit identity fraud, thereby improving vehicle safety.
[0121] In some embodiments, when the target digital certificate is verified, the vehicle can also obtain and store the public key in the target digital certificate.
[0122] Step 103: When the target digital certificate is verified successfully, the vehicle sends a first response message to the diagnostic device, where the first response message includes first information.
[0123] The first information may be a value pre-generated by the vehicle. For example, the first information may be a random number of preset bytes. For example, the first information may be generated by the vehicle through a random number generation algorithm.
[0124] Since it is possible that an illegal device steals the target digital certificate, the vehicle can generate first information when the target digital certificate is verified, so as to perform secondary authentication on the diagnostic device to verify whether the diagnostic device is the real holder of the target digital certificate. In this way, the vehicle safety can be further improved.
[0125] Optionally, the first response message may further include a verification result flag, where the verification result flag is used to indicate whether the target digital certificate passes the verification.
[0126] For example, the format of the first response message may be: verification result flag + Challenge (ie, first information). For example, the first response message may be an affirmative response message with a routine identifier of 71 01XX X2 00, in which the verification result flag is used to indicate that the target digital certificate has been verified.
[0127] Optionally, when the target digital certificate verification fails, the vehicle may send a third response message to the diagnostic device. The third response message is used to indicate that the target digital certificate verification fails. For example, the third response message may be a negative response message with a routine identifier of 71 01XX X2 01.
[0128] Step 104: After receiving the first response message sent by the vehicle, the diagnostic device uses the private key of the diagnostic device to encrypt the first information to obtain the second information.
[0129] For example, the diagnostic device may use the private key of the diagnostic device to encrypt the Challenge in the first response message to obtain a Signature (ie, the second information) of N bytes.
[0130] Step 105: The diagnostic device sends a second authentication message to the vehicle, where the second authentication message includes second information.
[0131] The second authentication message is used to request authentication of whether the second information in the second authentication message is encrypted by the holder of the target digital certificate.
[0132] For example, the second authentication message may be an authentication message with a routine identifier of 31 01XX X2. For example, the format of the second authentication message may be: 31 01XX X2 (2 bytes) + Signature.
[0133] Step 106: After receiving the second authentication message sent by the diagnostic device, the vehicle verifies the second information according to the public key in the target digital certificate and the first information, and determines that the diagnostic device is authenticated if the second information is authenticated.
[0134] In an embodiment of the present application, the second information is verified based on the public key in the target digital certificate and the first information, and it can be determined whether the second information is encrypted by the holder of the target digital certificate. If the second information verification passes, that is, if the second information is encrypted by the holder of the target digital certificate, it can be determined that the diagnostic device currently communicating with the vehicle is the holder of the target digital certificate, that is, the diagnostic device is a legal device, and it can be determined that the diagnostic device has passed the authentication. If the second information verification fails, that is, if the second information is not encrypted by the holder of the target digital certificate, it can be determined that the diagnostic device currently communicating with the vehicle is not the holder of the target digital certificate, that is, the diagnostic device is an illegal device, and it can be determined that the diagnostic device has not passed the authentication.
[0135] In this way, through the double verification method, that is, first verifying the legitimacy of the target digital certificate, and then further verifying whether the diagnostic device currently communicating with the vehicle is the holder of the target digital certificate when the target digital certificate is determined to be legitimate, and determining that the diagnostic device is authenticated when the diagnostic device is the holder of the target digital certificate, it can effectively prevent illegal devices from reading and writing data on the vehicle by disguising themselves as legal devices, thereby greatly improving the information security of the vehicle and reducing after-sales costs.
[0136] In some embodiments, the operation of the vehicle verifying the second information based on the public key in the target digital certificate and the first information can be: the vehicle uses the public key in the target digital certificate to decrypt the second information to obtain the third information; when the first information and the third information are the same, it is determined that the second information verification has passed; when the first information and the third information are different, it is determined that the second information verification has failed.
[0137] If the first information is the same as the third information, it means that the second information is encrypted by the private key of the holder of the target digital certificate, so it can be determined that the second information verification is successful; if the first information is different from the third information, it means that the second information is not encrypted by the private key of the holder of the target digital certificate, so it can be determined that the second information verification is failed.
[0138] Optionally, when the second information is verified, the vehicle may send a fourth response message to the diagnostic device. The fourth response message is used to indicate that the diagnostic device has passed the authentication. After receiving the fourth response message sent by the vehicle, the diagnostic device may perform relevant operations on the vehicle, such as performing data reading and writing operations.
[0139] Optionally, the fourth response message may include a verification result flag. For example, the fourth response message may be a positive response message with a routine identifier of 71 01XX X2 00, and the verification result flag in the positive response message is used to indicate that the diagnostic device has passed the authentication.
[0140] Optionally, when the second information verification fails, the vehicle may send a fifth response message to the diagnostic device. The fifth response message is used to indicate that the diagnostic device has not passed the authentication. When the diagnostic device has not passed the authentication, the vehicle may exit the authentication process and prohibit the diagnostic device from communicating with the vehicle.
[0141] For example, the fifth response message may be a negative response message whose routine identifier is 71 01XX X2 01.
[0142] In some embodiments, the authentication process of the vehicle to the diagnostic device in the embodiment of the present application can be performed by the vehicle gateway in the vehicle, that is, the above steps 102, 103 and 106 can all be performed by the vehicle gateway. Of course, the authentication process of the vehicle to the diagnostic device can be performed by other modules in the vehicle, and the embodiment of the present application does not limit this.
[0143] In an embodiment of the present application, the diagnostic device sends a first authentication message to the vehicle, the first authentication message includes a target digital certificate, and the target digital certificate includes the public key of the holder. After receiving the first authentication message, the vehicle verifies the target digital certificate, and sends a first response message to the diagnostic device when the target digital certificate is verified. The first response message includes the first information. After receiving the first response message, the diagnostic device encrypts the first information using its own private key to obtain the second information, and then sends a second authentication message to the vehicle, the second authentication message includes the second information. After receiving the second authentication message, the vehicle verifies the second information according to the public key in the target digital certificate and the first information, and determines that the diagnostic device is authenticated when the second information is verified. In this way, through the double verification method, that is, first verifying the legitimacy of the target digital certificate, and then verifying whether the diagnostic device is the holder of the target digital certificate based on the confirmed legitimacy of the target digital certificate, the legitimacy of the diagnostic device can be confirmed more accurately, and the illegal device can be effectively prevented from reading and writing data to the vehicle by disguising as a legal device, thereby greatly improving the information security of the vehicle.
[0144] Figure 2 Schematic diagram of the structure of an authentication device provided in an embodiment of the present application. The device can be implemented by software, hardware or a combination of both to form part or all of a computer device, and the computer device can be the following Figure 4 Computer equipment shown. Figure 2 The device includes: a first receiving module 201, a first verification module 202, a sending module 203, a second receiving module 204, a second verification module 205, and a determination module 206.
[0145] The first receiving module 201 is used to receive a first authentication message sent by the diagnostic device, the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of the holder;
[0146] A first verification module 202, used to verify the target digital certificate;
[0147] The sending module 203 is used to send a first response message to the diagnostic device when the target digital certificate is verified, and the first response message includes first information;
[0148] The second receiving module 204 is used to receive a second authentication message sent by the diagnostic device, where the second authentication message includes second information, where the second information is obtained by encrypting the first information by the diagnostic device using its own private key;
[0149] A second verification module 205, configured to verify the second information according to the public key in the target digital certificate and the first information;
[0150] The determination module 206 is used to determine that the diagnostic device has passed the authentication if the second information has passed the authentication.
[0151] Optionally, the first authentication message includes a routine identification field, an OCSP Stapling length field, an OCSP Stapling field, a certificate length field and a certificate field, and the certificate field includes a target digital certificate.
[0152] Optionally, the first verification module 202 is used to:
[0153] The target digital certificate is verified based on the data contained in the OCSP Stapling field.
[0154] Optionally, the first information is a random number of preset bytes, and / or the first response message further includes a verification result flag, where the verification result flag is used to indicate whether the target digital certificate passes the verification.
[0155] Optionally, the second verification module 205 is used to:
[0156] Decrypt the second information using the public key in the target digital certificate to obtain third information;
[0157] If the first information is identical to the third information, determining that the second information is verified;
[0158] In the case where the first information is different from the third information, it is determined that the second information verification has failed.
[0159] In an embodiment of the present application, a vehicle receives a first authentication message sent by a diagnostic device, the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of the holder. The vehicle verifies the target digital certificate, and when the target digital certificate is verified, a first response message is sent to the diagnostic device, the first response message including the first information. Afterwards, the vehicle receives a second authentication message sent by the diagnostic device, the second authentication message includes the second information, and the second information is obtained by the diagnostic device encrypting the first information using its own private key. The vehicle verifies the diagnostic device according to the first information and the second information, and determines that the diagnostic device is authenticated when the second information is verified. In this way, through a double verification method, that is, first verifying the legitimacy of the target digital certificate, and then verifying whether the diagnostic device is the holder of the target digital certificate based on the confirmed legitimacy of the target digital certificate, the legitimacy of the diagnostic device can be confirmed more accurately, and illegal devices can be effectively prevented from reading and writing data to the vehicle by disguising as legal devices, thereby greatly improving the information security of the vehicle.
[0160] Figure 3Schematic diagram of the structure of an authentication device provided in an embodiment of the present application. The device can be implemented by software, hardware or a combination of both to form part or all of a computer device, and the computer device can be the following Figure 4 Computer equipment shown. Figure 3 The device includes: a first sending module 301, a receiving module 302, an encryption module 303, and a second sending module 304.
[0161] A first sending module 301 is used to send a first authentication message to the vehicle, the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of the holder;
[0162] The receiving module 302 is used to receive a first response message sent by the vehicle, the first response message includes first information, and the first response message is sent when the target digital certificate is verified;
[0163] An encryption module 303 is used to encrypt the first information using the private key of the diagnostic device to obtain the second information;
[0164] The second sending module 304 is used to send a second authentication message to the vehicle, the second authentication message includes second information, and the second authentication message is used to instruct the vehicle to authenticate the diagnostic device according to the public key in the target digital certificate, the first information and the second information.
[0165] Optionally, the device further comprises:
[0166] A first generating module, used to generate a public-private key pair, the public-private key pair including a private key and a public key of the diagnostic device;
[0167] The second generating module is used to obtain a target digital certificate according to the public key of the diagnostic device.
[0168] Optionally, the device further comprises:
[0169] A third sending module, used for sending an inquiry message to the vehicle, where the inquiry message is used to determine whether the vehicle supports the authentication function;
[0170] The trigger module is used to trigger the first sending module 301 to send a first authentication message to the vehicle if a second response message sent by the vehicle is received, and the second response message is used to indicate that the vehicle supports the authentication function.
[0171] In an embodiment of the present application, the diagnostic device sends a first authentication message to the vehicle, the first authentication message includes a target digital certificate, and the target digital certificate includes the public key of the holder. Afterwards, the diagnostic device receives a first response message sent by the vehicle, the first response message includes the first information, and the first response message is sent when the target digital certificate is verified. The diagnostic device encrypts the first information using its own private key to obtain the second information, and sends a second authentication message including the second information to the vehicle, so that the vehicle authenticates the diagnostic device according to the public key, the first information and the second information in the target digital certificate. In this way, through a double verification method, that is, first verifying the legitimacy of the target digital certificate, and then verifying whether the diagnostic device is the holder of the target digital certificate based on the confirmed legitimacy of the target digital certificate, the legitimacy of the diagnostic device can be confirmed more accurately, and illegal devices can be effectively prevented from reading and writing data to the vehicle by disguising as legal devices, thereby greatly improving the information security of the vehicle.
[0172] It should be noted that: the authentication device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example during authentication. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0173] The functional units and modules in the above embodiments may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit, and the above integrated units may be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present application.
[0174] The authentication device and authentication method embodiments provided in the above embodiments belong to the same concept. The specific working process of the units and modules in the above embodiments and the technical effects brought about can be found in the method embodiment part and will not be repeated here.
[0175] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 4 As shown, the computer device 4 includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer program 42, the steps performed by the diagnostic device or the vehicle in the authentication method in the above embodiment are implemented.
[0176] Those skilled in the art will understand that Figure 4It is only an example of the computer device 4 and does not constitute a limitation on the computer device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, etc.
[0177] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0178] In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the computer device 4. The memory 41 is used to store an operating system, an application program, a boot loader, data, and other programs. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0179] An embodiment of the present application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, and when the processor executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.
[0180] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0181] An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps in the above-mentioned method embodiments.
[0182] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.
[0183] It should be understood that all or part of the steps to implement the above embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.
[0184] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0185] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0186] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0187] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0188] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant regulations and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0189] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An authentication method, characterized in that: Applied to a vehicle, the method comprises: receiving a first authentication message sent by a diagnostic device, wherein the first authentication message includes a target digital certificate, and the target digital certificate includes a public key of a holder; Verifying the target digital certificate; When the target digital certificate is verified, sending a first response message to the diagnostic device, wherein the first response message includes first information; Receiving a second authentication message sent by the diagnostic device, where the second authentication message includes second information, where the second information is obtained by encrypting the first information by the diagnostic device using its own private key; Verifying the second information according to the public key in the target digital certificate and the first information; If the second information is verified successfully, it is determined that the diagnostic device is authenticated.
2. The method according to claim 1, characterized in that The first authentication message includes a routine identification field, an Online Certificate Status Protocol Stapling (OCSP) Stapling length field, an OCSP Stapling field, a certificate length field, and a certificate field, and the certificate field includes the target digital certificate.
3. The method according to claim 2, characterized in that The verifying the target digital certificate comprises: The target digital certificate is verified according to the data included in the OCSP Stapling field.
4. The method according to claim 1, characterized in that The first information is a random number of preset bytes, and / or the first response message also includes a verification result flag, and the verification result flag is used to indicate whether the target digital certificate passes the verification.
5. The method according to any one of claims 1 to 4, characterized in that: The verifying the second information according to the public key in the target digital certificate and the first information includes: Decrypt the second information using the public key in the target digital certificate to obtain third information; If the first information is identical to the third information, determining that the second information is verified; When the first information is different from the third information, it is determined that the second information has failed verification.
6. An authentication method, characterized in that: Applied to diagnostic equipment, the method comprises: Sending a first authentication message to the vehicle, the first authentication message including a target digital certificate, the target digital certificate including a public key of a holder; receiving a first response message sent by the vehicle, the first response message including first information, the first response message being sent when the target digital certificate is verified; encrypting the first information using a private key of the diagnostic device to obtain second information; A second authentication message is sent to the vehicle, wherein the second authentication message includes the second information, and the second authentication message is used to instruct the vehicle to authenticate the diagnostic device according to the public key in the target digital certificate, the first information, and the second information.
7. The method according to claim 6, characterized in that Before sending the first authentication message to the vehicle, the method further includes: generating a public-private key pair, the public-private key pair comprising a private key and a public key of the diagnostic device; The target digital certificate is obtained according to the public key of the diagnostic device.
8. The method according to claim 6 or 7, characterized in that Before sending the first authentication message to the vehicle, the method further includes: Sending an inquiry message to the vehicle, wherein the inquiry message is used to determine whether the vehicle supports an authentication function; If a second response message sent by the vehicle is received, the step of sending the first authentication message to the vehicle is performed, and the second response message is used to indicate that the vehicle supports the authentication function.
9. A computer device, characterized in that: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 1 to 8 when executed by the processor.
10. A computer program product, characterized in that When the computer program product is executed on a computer device, the computer device is caused to execute the method according to any one of claims 1 to 8.