Communication method and device, computer equipment and readable storage medium
By implementing two-way authentication between the gateway and the target controller in vehicle communication and allocating a symmetric key, the risk of data being monitored or illegally captured in traditional communication methods is solved, and the security of communication is improved.
Patent Information
- Application Number
- CN202510358244.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-06-10
AI Technical Summary
Traditional communication methods have the risk of data being monitored or illegally captured in vehicle communication, resulting in insufficient communication security.
Encrypt communications between the authenticated controllers accessing the gateway are ensured by implementing two-way authentication between the gateway and the target controller and assigning a symmetric key after the second authentication is passed.
Effectively isolate potential security threats, reduce the risk of communication data being monitored or illegally captured, and improve the security of communication and the difficulty of authentication of legitimate devices.
Smart Images

Figure CN120128407A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a communication method, apparatus, computer device, and readable storage medium. Background Art
[0002] With the continuous development of communication technologies, communication between various devices has become increasingly frequent and complex, and communication security issues have become increasingly prominent. Especially for vehicle communication, communication data often involves key information such as vehicle control and sensor readings. Once this key information is leaked or tampered with, it may affect the normal operation of the vehicle.
[0003] In traditional methods, encryption of communication data is usually used to enhance data security during data transmission. Although encryption technology has improved data security to a certain extent, there is still a risk that communication data may be eavesdropped or illegally captured, thus facing the threat of being intercepted and attempted to be cracked, posing potential security problems to normal communication. Summary of the Invention
[0004] Based on this, it is necessary to provide a communication method, apparatus, computer device, and readable storage medium that can improve communication security for the above technical problems.
[0005] In a first aspect, this application provides a communication method applied to a gateway, including:
[0006] Obtaining an authentication request sent when a target controller accesses the gateway;
[0007] In response to the authentication request, performing a first authentication on the target controller;
[0008] When the first authentication is passed, sending a gateway certificate to the target controller so that the target controller performs a second authentication on the gateway according to the gateway certificate;
[0009] When the second authentication is passed, allocating a symmetric key to the target controller; wherein, the symmetric key is used for communication encryption between authenticated controllers accessing the gateway.
[0010] In one of the embodiments, performing a first authentication on the target controller includes at least one of the following: performing validity authentication on the authentication request of the target controller; performing legality authentication on the device identifier of the target controller; performing signature authentication on the device certificate of the target controller.
[0011] In one embodiment, a first authentication is performed on a target controller, and the following authentications are sequentially executed: perform validity authentication on the authentication request of the target controller; perform legality authentication on the device identifier of the target controller; perform signature authentication on the device certificate of the target controller; wherein, in the case that a single authentication fails continuously for a first preset number of times, return to the validity authentication step of the target controller.
[0012] In one embodiment, performing validity authentication on the authentication request of the target controller includes: obtaining the request flag bit of the authentication request; performing validity authentication on the target controller according to the consistency between the request flag bit and the preset flag value.
[0013] In one embodiment, performing legality authentication on the device identifier of the target controller includes: obtaining the device identifier sent by the target controller; in the case that the data length of the device identifier reaches a first preset length, performing legality authentication on the target controller according to the device identifier.
[0014] In one embodiment, performing signature authentication on the device certificate of the target controller includes: obtaining the device certificate sent by the target controller; in the case that the data length of the device certificate reaches a first preset length, performing signature authentication on the device certificate according to the first root certificate of the gateway.
[0015] In one embodiment, in the case that the second authentication is passed, allocating a symmetric key to the target controller includes: in the case that the second authentication is passed, setting the target controller to the working state; allocating a symmetric key to the target controller in the working state at a preset period.
[0016] In a second aspect, the present application also provides another communication method, which is applied to a target controller and includes:
[0017] In the case that the target controller accesses the gateway, sending an authentication request to the gateway so that the gateway performs a first authentication on the target controller in response to the authentication request;
[0018] Obtaining the gateway certificate sent by the gateway in the case that the first authentication is passed;
[0019] Performing a second authentication on the gateway according to the gateway certificate;
[0020] In the case that the second authentication is passed, obtaining the symmetric key allocated by the gateway; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0021] In one embodiment, the second authentication of the gateway based on the gateway certificate includes: when the data length of the gateway certificate reaches a third preset length, performing signature authentication on the gateway certificate according to the second root certificate of the target controller.
[0022] In a third aspect, the present application further provides a communication device, including:
[0023] A first acquisition module, configured to acquire an authentication request sent when a target controller accesses the gateway;
[0024] A first authentication module, configured to perform first authentication on the target controller in response to the authentication request;
[0025] A first sending module, configured to send a gateway certificate to the target controller when the first authentication is passed, so that the target controller performs second authentication on the gateway according to the gateway certificate;
[0026] An allocation module, configured to allocate a symmetric key to the target controller when the second authentication is passed; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0027] In a fourth aspect, the present application further provides another communication device, including:
[0028] A second sending module, configured to send an authentication request to the gateway when the target controller accesses the gateway, so that the gateway performs first authentication on the target controller in response to the authentication request;
[0029] A second acquisition module, configured to acquire the gateway certificate sent by the gateway when the first authentication is passed;
[0030] A second authentication module, configured to perform second authentication on the gateway according to the gateway certificate;
[0031] A third acquisition module, configured to acquire the symmetric key allocated by the gateway when the second authentication is passed; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0032] In a fifth aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the methods in the first aspect or the second aspect in various possible implementation manners are implemented.
[0033] In a sixth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the methods in the first aspect or the second aspect in various possible implementation manners are implemented.
[0034] In a seventh aspect, the present application further provides a computer program product, including a computer program, which when executed by a processor, implements the methods in the first aspect or the second aspect in various possible implementation manners.
[0035] For the above communication method, device, computer device, and readable storage medium, by performing a first authentication on the target controller accessing the gateway, it is possible to identify the access of illegal devices, isolate potential security threats outside the gateway, and reduce the risk of communication data being monitored or illegally captured. On this basis, the target controller performs a second authentication on the gateway according to the gateway certificate, thereby realizing two-way authentication between the target controller and the gateway, increasing the difficulty of disguising illegal device authentication, and reducing the security risk. By allocating a symmetric key to the target controller when the second authentication is passed, communication encryption between the authenticated controllers accessing the gateway is realized, improving the security of communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0037] Figure 1 It is an application environment diagram of the communication method in an embodiment;
[0038] Figure 2 It is a schematic flowchart of the communication method in an embodiment;
[0039] Figure 3 It is a schematic flowchart of the authentication steps of the first authentication in an embodiment;
[0040] Figure 4 It is a schematic flowchart of the allocation steps of the symmetric key in an embodiment;
[0041] Figure 5 It is a schematic flowchart of the communication method in another embodiment;
[0042] Figure 6 It is a schematic flowchart of the communication method in yet another embodiment;
[0043] Figure 7 It is a structural block diagram of the communication device in an embodiment;
[0044] Figure 8 It is a structural block diagram of the communication device in another embodiment;
[0045] Figure 9Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0046] To make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0047] The communication method provided by the embodiments of the present application can be applied to, for example Figure 1 the application environment shown. Among them, the gateway 101 communicates with each controller 103 through the network 102. In particular, the gateway 101 can be a CAN gateway, and the network 102 can be a CAN network. The CAN network refers to the Controller Area Network, which is a serial communication bus applied in the automotive industry. The CAN gateway, also known as the automotive gateway, is the core of the entire CAN network, controlling the forwarding and processing of various signals on the vehicle's CAN bus. The controller 103 can be understood as an electronic control unit. In particular, the controller 103 can specifically include at least one of an engine controller, a transmission controller, a body controller, etc. The present application does not make any limitation on the specific type of the controller 103.
[0048] In the above application scenario, the communication data between the controllers 103 may involve key information. In the traditional method, the controller 103 encrypts the communication data, thereby enhancing the confidentiality protection during the data transmission process. However, there is still a risk that the communication data is monitored or captured by illegal devices, posing a potential threat to normal communication.
[0049] Based on this, the present application provides a communication method. The gateway 101 obtains an authentication request sent by a target controller accessing the gateway; in response to the authentication request, performs a first authentication on the target controller; in the case where the first authentication is passed, sends a gateway certificate to the target controller so that the target controller performs a second authentication on the gateway according to the gateway certificate; in the case where the second authentication is passed, allocates a symmetric key to the target controller; wherein, the symmetric key is used for encrypting communication between the authenticated controllers accessing the gateway. Through the above method, potential security threats are isolated outside the gateway, reducing the risk of communication data being monitored or illegally captured, achieving two-way authentication between the target controller and the gateway, increasing the difficulty of disguising illegal device authentication, and improving the security of communication.
[0050] In an exemplary embodiment, as Figure 2 shown, a communication method is provided. Taking the gateway 101 applied in Figure 1 as an example, the method includes the following steps:
[0051] S210. Obtain the authentication request sent when the target controller accesses the gateway.
[0052] Among them, the target controller can be understood as the controller that currently accesses the gateway and sends the authentication request; the authentication request can be understood as the information or data packet sent by the target controller as the requester, asking the gateway to authenticate it.
[0053] In an optional embodiment, the authentication request includes the target identifier of the target controller. The target identifier can be understood as the identifier of the target controller, which is used to distinguish different controllers or different controller types. Optionally, the target identifier includes at least one of the device identifier, the preset identifier, and the gateway identifier.
[0054] Among them, the device identifier is the device ID of the target controller, and each device identifier uniquely corresponds to a target controller.
[0055] Among them, the preset identifier can be generated by a random number. Compared with the device identifier, the preset identifier can customize the set data length. For example, in the case where the number of target controllers to be authenticated is small, the data length of the preset identifier can be reduced, thereby reducing the data volume during transmission and improving the authentication efficiency; in the case where the number of target controllers to be authenticated is large, the data length of the preset identifier can be increased to avoid different controllers randomly generating the same preset identifier.
[0056] Among them, the gateway identifier is the gateway ID. Each gateway identifier uniquely corresponds to a controller category. In particular, when the gateway is a CAN gateway, the gateway identifier can be the CAN ID.
[0057] S220. In response to the authentication request, perform a first authentication on the target controller.
[0058] Among them, the first authentication can be understood as the gateway performing an identity security authentication on the target controller.
[0059] In an optional embodiment, performing a first authentication on the target controller includes at least one of the following: performing a validity authentication on the authentication request of the target controller; performing a legality authentication on the device identifier of the target controller; performing a signature authentication on the device certificate of the target controller.
[0060] Among them, the validity authentication is used to ensure that the authentication request is a valid and expected request to confirm the integrity and compliance of the authentication request, thereby preventing unauthorized access or operations. The legality authentication is used to confirm the legality of the target controller according to the device identifier. The signature authentication is used to verify the signature value according to the device certificate and confirm the credibility of the target controller.
[0061] Optionally, the target controller stores the same root certificate as the gateway, and the key of the root certificate is used to encrypt and decrypt the authentication information. For the convenience of distinction, the root certificate of the gateway is taken as the first root certificate, and the root certificate of the target controller is taken as the second root certificate. Among them, the authentication information may include at least one of authentication requirement information and authentication result information, etc. The authentication requirement information may include at least one of an authentication request, a device identifier, a device certificate, etc.; the authentication result information may include at least one of authentication passed information and authentication failed information under different authentication methods, etc.
[0062] Optionally, during the authentication process of single-item authentications such as the above-mentioned validity authentication, legality authentication, and signature authentication, the data integrity of the authentication information can be verified first. In the case of passing the data integrity verification, the corresponding single-item authentication is performed on the authentication information; in the case of failing the data integrity verification, an error message is sent to the target controller so that the target controller sends the corresponding authentication information again. Among them, the data integrity verification is to determine whether the data length of the authentication information reaches a preset length. If the data length of the authentication information reaches the preset length, the authentication information passes the data integrity verification. It should be noted that the preset lengths corresponding to different authentication information may be the same or different. For example, the preset length corresponding to the device identifier is the first preset length, and the preset length corresponding to the device certificate is the second preset length. Among them, the first preset length and the second preset length can be set by technicians according to needs, and the present application does not make any limitation on the specific values of the first preset length and the second preset length. Further, in the case where the authentication information needs to be sent in multiple frames, the gateway can obtain the authentication information data frames, and when the number of frames of the authentication information data frames is greater than the preset number of frames corresponding to the authentication information, the authentication information data frames are integrated to obtain the authentication information. Through the above method, the incomplete authentication information can be filtered, avoiding authenticating incorrect authentication information, which is beneficial to improving the authentication efficiency.
[0063] Optionally, in the first authentication process, a parallel authentication method can be adopted. The parallel authentication method can be understood as the authentication processes of the above-mentioned single-item authentications such as validity authentication, legality authentication, and signature authentication, which can be carried out simultaneously or not simultaneously, and the authentication processes of different single-item authentications do not affect each other. It is not difficult to understand that adopting the parallel authentication method is beneficial to improving the authentication efficiency. Exemplarily, the device identifier and the device certificate can be obtained simultaneously, and the legality authentication and the signature authentication are performed on the target controller simultaneously.
[0064] Optionally, in the first authentication process, a serial authentication method can be adopted. The serial authentication method can be understood as the authentication process of the above single-item authentications such as validity authentication, legality authentication, and signature authentication, which need to be carried out in sequence, and in the case that the target controller passes the previous single-item authentication, the next single-item authentication is carried out. It is not difficult to understand that by adopting the serial authentication method, once a single-item authentication fails, the entire authentication process stops immediately, reducing unnecessary authentication processes. Among them, the authentication order of the single-item authentication can be set by technicians according to needs, and this application does not make any limitation on this. In particular, the authentication order can be "validity authentication - legality authentication - signature authentication" in sequence.
[0065] Exemplarily, in the case that the authentication request of the target controller passes the validity authentication, a first feedback message is sent to the target controller, so that the target controller sends the device identifier to the gateway; in the case that the device identifier of the target controller passes the legality authentication, a second feedback message is sent to the target controller, so that the target controller sends the device certificate to the gateway; in the case that the device certificate of the target controller passes the signature authentication, the authentication process of the first authentication is completed.
[0066] Exemplarily, on the basis of the serial authentication method, the above method of encrypting and decrypting the authentication information can be combined to further improve the security of the authentication. Specifically, it can include: encrypting the first feedback message and the second feedback message based on the first root certificate key of the gateway, and / or decrypting the authentication request, the device identifier, and the device certificate based on the first root certificate key of the gateway. It is not difficult to understand that in the case that the target controller is an illegal device, since it cannot decrypt the first feedback message and the second feedback message, it cannot normally send the corresponding authentication information to the gateway. Similarly, in the case that the target controller is an illegal device, it cannot encrypt the authentication request, the device identifier, and the device certificate based on the same second root certificate as the gateway, and the gateway cannot decrypt based on the first root certificate and obtain the authentication information provided by the target controller, resulting in the failure of the authentication.
[0067] S230. In the case that the first authentication is passed, send the gateway certificate to the target controller, so that the target controller performs a second authentication on the gateway according to the gateway certificate.
[0068] Among them, the second authentication can be understood as the target controller performing an identity security authentication on the gateway.
[0069] In an optional embodiment, sending the gateway certificate to the target controller includes: encrypting the gateway certificate based on the first root certificate key and sending it to the target controller, so that the target controller decrypts the gateway certificate based on the second root certificate key and performs a second authentication on the gateway according to the decrypted gateway certificate.
[0070] In an optional embodiment, sending the gateway certificate to the target controller includes: sending a gateway certificate data frame to the target controller, so that the target controller obtains the gateway certificate data frame. When the number of frames of the gateway certificate data frame is not less than the preset number of frames of the gateway certificate, the data frames of the gateway certificate are integrated to obtain the gateway certificate. When the number of frames of the gateway certificate data frame is less than the preset number of frames of the gateway certificate, a gateway certificate error message is sent to the gateway, so that the gateway sends the gateway certificate again. Among them, the gateway certificate data frame can be an encrypted data frame or an unencrypted data frame, and the preset number of frames of the gateway certificate can be set by those skilled in the art according to needs, and the present application does not make any limitation thereto.
[0071] In an optional embodiment, the target controller performs a second authentication on the gateway according to the gateway certificate, including: when the data length of the gateway certificate reaches a third preset length, performing signature authentication on the gateway certificate according to the second root certificate of the target controller. Among them, the third preset length can be set by those skilled in the art according to needs, and the present application does not make any limitation on the specific value of the third preset length.
[0072] S240. When the second authentication is passed, a symmetric key is allocated to the target controller; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0073] In an optional embodiment, during the processes of the first authentication, the second authentication, and the symmetric key allocation, the transmitted data between the target controller and the gateway includes the target identifier of the target controller, so as to facilitate the target controller and the gateway to locate the source or the sending target of the communication data.
[0074] In the embodiments of the present application, by performing the first authentication on the target controller accessing the gateway, illegal device access can be identified, potential security threats can be isolated outside the gateway, and the risk of communication data being eavesdropped or illegally captured can be reduced. On this basis, the target controller performs a second authentication on the gateway according to the gateway certificate, thereby realizing two-way authentication between the target controller and the gateway, increasing the disguise difficulty of illegal device authentication, and reducing the security risk. By allocating a symmetric key to the target controller when the second authentication is passed, communication encryption between the authenticated controllers accessing the gateway is realized, and the communication security is improved.
[0075] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment, in which the authentication steps of the first authentication are refined.
[0076] See Figure 3 The authentication steps of the first authentication shown include sequentially performing the following authentications:
[0077] S310. Perform validity authentication on the authentication request for the target controller.
[0078] In an optional embodiment, when the target controller accesses the gateway, the authentication request can be encrypted using the second certificate key and sent to the gateway at a set period. The authentication request includes a request flag bit. The second certificate key can include an RSA (Rivest-Shamir-Adleman) public key and an RSA private key. RSA is an asymmetric encryption algorithm. The set period can be set by a technician according to needs, and this application does not limit the specific value of the set period. Exemplarily, the set period can be set to 200 ms, and the second certificate can be stored in the HSM (Hardware Security Module) chip of the target controller.
[0079] In an optional embodiment, performing validity authentication on the authentication request for the target controller includes: obtaining the request flag bit of the authentication request; performing validity authentication on the target controller according to the consistency between the request flag bit and a preset flag value. The preset flag value can be set by a technician according to needs, for example, set to 0x01.
[0080] Optionally, obtaining the request flag bit of the authentication request includes: decrypting the authentication request based on the key pair of the first certificate to obtain the request flag bit of the authentication request.
[0081] Optionally, performing validity authentication on the target controller according to the consistency between the request flag bit and the preset flag value includes: when the request flag bit is consistent with the preset flag value, record that the target controller has completed validity authentication; send a first feedback message to the target controller so that the target controller sends a device identifier to the gateway. The first feedback message can include at least one of a device identifier request or a validity authentication passed message, etc. The first feedback message can be encrypted by the gateway based on the key pair of the first certificate and then sent to the target controller. The device identifier can include a device flag bit, and the device identifier can be encrypted by the target controller based on the second certificate key and then sent to the gateway.
[0082] S320. Perform legality authentication on the device identifier of the target controller.
[0083] In an optional embodiment, performing legality authentication on the device identifier of the target controller includes: obtaining the device identifier sent by the target controller; when the data length of the device identifier reaches a first preset length, perform legality authentication on the target controller according to the device identifier.
[0084] Optionally, obtaining the device identifier sent by the target controller includes: obtaining the encrypted device identifier sent by the target controller; decrypting the encrypted device identifier based on the first root certificate key to obtain the first decrypted data; determining the number of data frames of the first decrypted data when the device flag bit of the first decrypted data is consistent with the device flag value; sending a first error message to the target controller to cause the target controller to send the encrypted device identifier again when the number of data frames of the first decrypted data is less than the first preset number of frames; integrating the data frames of the first decrypted data to obtain the device identifier when the number of data frames of the first decrypted data is not less than the first preset number of frames. Among them, the device flag value and the first preset number of frames can be set by technicians according to needs. In particular, the device certificate flag value can be set to 0x02.
[0085] Optionally, performing a legality authentication on the device identifier of the target controller further includes: sending a first error message to the target controller to cause the target controller to send the device identifier again when the data length of the device identifier does not reach the first preset length.
[0086] Optionally, performing a legality authentication on the target controller according to the device identifier includes: sending a first error message to the target controller to cause the target controller to send the device identifier again when the target controller corresponding to the device identifier is an illegal device; recording that the target controller has completed the legality authentication and sending a second feedback message to the target controller to cause the target controller to send the device certificate to the gateway when the target controller corresponding to the device identifier is a legal device. Among them, the second feedback message may include at least one of a device certificate request or a legality authentication passed message, etc., and the second feedback message may be encrypted by the gateway based on the key of the first root certificate and then sent to the target controller. Among them, the device certificate may include a device certificate flag bit, and the device certificate may be encrypted by the target controller based on the key of the second root certificate and then sent to the gateway.
[0087] Further, determining that the target controller corresponding to the device identifier is a legal device may include: querying whether the device identifier is stored in the legal device database; if the device identifier is stored in the legal device database and the status of the target controller corresponding to the device identifier is an effective status, then the target controller corresponding to the device identifier is a legal device. The legal device database may be stored in the terminal or the server.
[0088] S330. Perform a signature authentication on the device certificate of the target controller.
[0089] In an optional embodiment, performing a signature authentication on the device certificate of the target controller includes: obtaining the device certificate sent by the target controller; performing a signature authentication on the device certificate according to the first root certificate of the gateway when the data length of the device certificate reaches the second preset length.
[0090] Optionally, obtaining the device certificate sent by the target controller includes: obtaining the encrypted device certificate sent by the target controller; decrypting the encrypted device certificate based on the first root certificate key to obtain the second decrypted data; determining the number of data frames of the second decrypted data when the device certificate flag bit of the second decrypted data is consistent with the device certificate flag value; sending a second error message to the target controller to cause the target controller to send the encrypted device certificate again when the number of data frames of the second decrypted data is less than the second preset number of frames; integrating the data frames of the second decrypted data to obtain the device certificate when the number of data frames of the second decrypted data is not less than the second preset number of frames. Wherein, the device certificate flag value and the second preset number of frames can be set by technicians according to needs. In particular, the device certificate flag value can be set to 0x03.
[0091] Optionally, performing signature authentication on the device certificate of the target controller further includes: sending a second error message to the target controller to cause the target controller to send the device certificate again when the data length of the device certificate does not reach the second preset length.
[0092] Optionally, performing signature authentication on the device certificate according to the first root certificate of the gateway includes: verifying the signature value of the device certificate according to the first root certificate of the gateway; recording that the target controller completes the legality authentication when the signature value of the device certificate is verified; sending a second error message to the target controller to cause the target controller to send the device certificate again when the signature value of the device certificate is not verified.
[0093] Optionally, after verifying the signature value of the device certificate, it further includes: sending the gateway certificate to the target controller. Wherein, the gateway certificate is encrypted by the gateway based on the first root certificate key and sent to the target controller, and the gateway certificate includes a gateway certificate flag bit.
[0094] In an optional embodiment, when the single-item authentication fails to pass the authentication for the first preset number of consecutive times, return to the step of validating the target controller. Wherein, the first preset number can be set by technicians according to needs or experience, or determined through a large number of experiments, and the present application does not make any limitation thereto. In particular, the first preset number can be 3 times.
[0095] In the embodiments of the present application, a serial authentication method is adopted for the first authentication. Once a single authentication fails, the entire authentication process stops immediately, reducing unnecessary authentication processes. At the same time, the first preset number of times can be customized, so as to be applicable to different application scenarios. In addition, by encrypting the first feedback information and the second feedback information, in the case that the target controller is an illegal device, since it cannot decrypt the first feedback information and the second feedback information, it cannot send the corresponding authentication information to the gateway normally, increasing the disguise difficulty of illegal device authentication and reducing the security risk.
[0096] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment. In this optional embodiment, the distribution steps of the symmetric key are refined.
[0097] See Figure 4 The shown distribution steps of the symmetric key include:
[0098] S410. When the second authentication passes, set the target controller to the working state.
[0099] Among them, setting the target controller to the working state can be understood as enabling the data communication function of the target controller, that is, realizing the communication between the authenticated controllers accessing the gateway.
[0100] In an optional embodiment, setting the target controller to the working state may include: switching the communication module of the target controller to the working state.
[0101] In an optional embodiment, when the second authentication fails to pass for the second preset number of consecutive times, return to the validity authentication step of the target controller. Among them, the second preset number of times can be set by technicians according to needs or experience, or determined through a large number of experiments. The present application does not make any limitations on this. In particular, the second preset number of times can be 3 times.
[0102] S420. Allocate a symmetric key to the target controller in the working state according to a preset period.
[0103] Among them, the preset period can be set by technicians according to needs or experience, or determined through a large number of experiments. The present application does not make any limitations on this. In particular, the preset period can be 5 minutes.
[0104] In an optional embodiment, allocating a symmetric key to the target controller in the working state according to a preset period includes: generating and updating a symmetric key according to a preset period, and allocating the updated symmetric key to the target controller.
[0105] Optionally, generating an updated symmetric key according to a preset period includes: generating a true random number according to the preset period, and generating the updated symmetric key based on the true random number. Herein, the true random number can be understood as a number obtained from a random event.
[0106] Optionally, distributing the updated symmetric key to the target controller includes: signing the updated key with the first root certificate to obtain a key signature value; encrypting the updated symmetric key and the key signature value with the key of the first root certificate to obtain encrypted distribution data; sending the encrypted distribution data to the target controller, so that the target controller decrypts the encrypted distribution data to obtain the updated symmetric key and the key signature value, and when the key signature value passes the key authentication, replacing the original symmetric key with the updated symmetric key. Herein, the encrypted distribution data includes a key flag bit.
[0107] Optionally, the target controller decrypting the encrypted distribution data to obtain the updated symmetric key and the key signature value includes: the target controller obtaining the encrypted distribution data sent by the gateway; decrypting the encrypted distribution data based on the second root certificate to obtain fourth decrypted data; when the key flag bit of the fourth decrypted data is consistent with the key flag value, determining the number of data frames of the fourth decrypted data; when the number of data frames of the fourth decrypted data is less than the fourth preset number of frames, sending a fourth error message to the gateway to enable the gateway to send the encrypted distribution data again; when the number of data frames of the fourth decrypted data is not less than the fourth preset number of frames, integrating the data frames of the fourth decrypted data to obtain the updated symmetric key and the key signature value. Herein, the key flag value and the fourth preset number of frames can be set by those skilled in the art according to needs. In particular, the device certificate flag value can be set to 0x05.
[0108] Optionally, the target controller performing key authentication on the key signature value includes: when the total data length of the updated symmetric key and the key signature value reaches the fourth preset length, the target controller verifying the key signature value with the gateway certificate; when the key signature value passes the verification, the key signature value passes the key authentication; when the total data length does not reach the fourth preset length or the key signature value does not pass the verification, sending a fourth error message to the gateway to enable the gateway to send the encrypted distribution data again.
[0109] In the embodiment of the present application, when the second authentication is passed, the target controller is set to the working state, so that potential security threats can be isolated outside the gateway. By distributing symmetric keys to the target controllers in the working state according to a preset period, communication encryption between the authenticated controllers accessing the gateway is achieved, and the security of communication is further improved by updating the keys regularly.
[0110] In one embodiment, as Figure 5As shown, another communication method is also provided, which is applied to a target controller and includes the following steps:
[0111] S510. When the target controller accesses the gateway, send an authentication request to the gateway so that the gateway performs a first authentication on the target controller in response to the authentication request.
[0112] S520. Obtain the gateway certificate sent by the gateway when the first authentication is passed.
[0113] S530. Perform a second authentication on the gateway according to the gateway certificate.
[0114] S540. When the second authentication is passed, obtain the symmetric key allocated by the gateway; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0115] In an optional embodiment, the gateway certificate is encrypted by the gateway based on the key of the first root certificate and then sent to the target controller. The gateway certificate includes a gateway certificate flag bit.
[0116] In an optional embodiment, obtaining the gateway certificate sent by the gateway when the first authentication is passed includes: obtaining the encrypted gateway certificate sent by the gateway; decrypting the encrypted gateway certificate based on the second root certificate key to obtain the third decryption data; when the gateway certificate flag bit of the third decryption data is consistent with the gateway certificate flag value, determining the number of data frames of the third decryption data; when the number of data frames of the third decryption data is less than the third preset number of frames, sending a third error message to the gateway so that the gateway sends the encrypted gateway certificate again; when the number of data frames of the third decryption data is not less than the third preset number of frames, integrating the data frames of the third decryption data to obtain the gateway certificate. The gateway certificate flag value and the third preset number of frames can be set by those skilled in the art according to needs. In particular, the gateway certificate flag value can be set to 0x04.
[0117] In an optional embodiment, performing a second authentication on the gateway according to the gateway certificate includes: when the data length of the gateway certificate reaches the third preset length, performing a signature authentication on the gateway certificate according to the second root certificate of the target controller.
[0118] Optionally, performing a second authentication on the gateway according to the gateway certificate further includes: when the data length of the gateway certificate does not reach the third preset length, sending a third error message to the gateway so that the gateway sends the gateway certificate again.
[0119] Optionally, signing and authenticating the gateway certificate according to the second root certificate of the target controller includes: verifying the signature value of the gateway certificate according to the second root certificate; and sending a third feedback message to the gateway when the signature value of the gateway certificate is verified successfully. Correspondingly, the gateway records that the target controller passes the second authentication in response to the third feedback message.
[0120] In an optional embodiment, after obtaining the symmetric key allocated by the gateway, the method further includes: sending a data sending request to the communication module of the target controller, so that the communication module reads the symmetric key of the target controller and encrypts the communication data based on the symmetric key to obtain encrypted communication data; and sending the encrypted communication data to the network. The data sending request includes communication data, a first gateway identifier, and a first service identifier corresponding to the communication data. The first gateway identifier may specifically be a CAN ID; the first service identifier is used to distinguish the service types of different communication data, and may specifically be a service ID.
[0121] In an optional embodiment, after obtaining the symmetric key allocated by the gateway, the method further includes: sending a data receiving request to the communication module of the target controller, so that the communication module determines the encrypted communication data corresponding to a second gateway identifier and a second service identifier, decrypts the encrypted communication data based on the symmetric key to obtain decrypted communication data; and receiving the decrypted communication data sent by the communication module. The data receiving request includes the second gateway identifier and the second service identifier. The second gateway identifier may specifically be a CAN ID; the second service identifier is used to distinguish the service types of different communication data, and may specifically be a service ID.
[0122] Further, after sending the data receiving request to the communication module of the target controller, the communication module adds the data receiving request to a request queue. After obtaining the symmetric key allocated by the gateway, the method further includes: sending a cancel data receiving request to the communication module of the controller, so that the communication module deletes the data receiving request including a third gateway identifier and a third service identifier in the request queue. The cancel data receiving request includes the third gateway identifier and the third service identifier.
[0123] In the embodiments provided by the present application, by performing a first authentication on the target controller accessing the gateway, illegal device access can be identified, potential security threats can be isolated outside the gateway, the risk of communication data being eavesdropped or illegally captured can be reduced, and the security of legitimate devices can be improved. On this basis, the target controller performs a second authentication on the gateway according to the gateway certificate, thereby realizing two-way authentication between the target controller and the gateway, increasing the difficulty of disguising illegal device authentication, and reducing the security risk of legitimate devices. By allocating a symmetric key to the target controller when the second authentication is passed, communication encryption between the authenticated controllers accessing the gateway is realized, and the security of communication is improved.
[0124] In one embodiment, as Figure 6 shown, another communication method is further provided, including the following steps:
[0125] S601. When the target controller accesses the gateway, send an authentication request to the gateway.
[0126] S602. The gateway obtains the request flag bit of the authentication request; according to the consistency between the request flag bit and the preset flag value, perform validity authentication on the target controller.
[0127] S603. When the validity authentication passes, the gateway records that the target controller passes the validity authentication.
[0128] S604. The gateway sends the first feedback information to the target controller.
[0129] S605. In response to the first feedback information, the target controller sends the device identifier to the gateway.
[0130] S606. The gateway obtains the device identifier sent by the target controller; when the data length of the device identifier reaches the first preset length, perform legality authentication on the target controller according to the device identifier.
[0131] S607. When the legality authentication passes, the gateway records that the target controller passes the legality authentication.
[0132] S608. The gateway sends the second feedback information to the target controller.
[0133] S609. In response to the second feedback information, the target controller sends the device certificate to the gateway.
[0134] S610. The gateway obtains the device certificate sent by the target controller; when the data length of the device certificate reaches the first preset length, perform signature authentication on the device certificate according to the first root certificate of the gateway.
[0135] S611. When the signature authentication of the device certificate passes, record that the target controller passes the signature authentication.
[0136] S612. The gateway sends the gateway certificate to the target controller.
[0137] S613. When the data length of the gateway certificate reaches the third preset length, the target controller performs signature authentication on the gateway certificate according to the second root certificate of the target controller.
[0138] S614. When the signature authentication of the gateway certificate passes, the target controller sends the third feedback information to the gateway.
[0139] S615. The gateway records the signature authentication of the gateway through the gateway certificate in response to the third feedback information.
[0140] S616. The gateway sets the target controller to the working state; the gateway generates a true random number according to a preset period, and generates an updated symmetric key according to the true random number.
[0141] S617. The gateway signs the updated key with the first root certificate to obtain a key signature value; uses the key corresponding to the first root certificate to encrypt the updated symmetric key and the key signature value to obtain encrypted distribution data.
[0142] S618. Send the encrypted distribution data to the target controller.
[0143] S619. The target controller obtains the encrypted distribution data, decrypts the encrypted distribution data to obtain the updated symmetric key and the key signature value, and replaces the original symmetric key with the updated symmetric key when the key signature value passes the key authentication.
[0144] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.
[0145] Based on the same inventive concept, the embodiments of the present application also provide a communication device for implementing the above-mentioned communication method. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the communication device provided below can refer to the limitations on the communication method in the above text, and will not be repeated here.
[0146] In an exemplary embodiment, as Figure 7 shown, a communication device is provided, including: a first acquisition module 710, a first authentication module 720, a first sending module 730, and a distribution module 740, where:
[0147] The first acquisition module 710 is configured to acquire an authentication request sent when the target controller accesses the gateway.
[0148] The first authentication module 720 is configured to perform a first authentication on the target controller in response to an authentication request.
[0149] The first sending module 730 is configured to send a gateway certificate to the target controller when the first authentication is passed, so that the target controller performs a second authentication on the gateway according to the gateway certificate.
[0150] The allocation module 740 is configured to allocate a symmetric key to the target controller when the second authentication is passed; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0151] In one embodiment, the first authentication module 720 includes at least one of the following authentication sub-units: a first authentication sub-unit configured to perform validity authentication on the authentication request of the target controller; a second authentication sub-unit configured to perform legality authentication on the device identifier of the target controller; a third authentication sub-unit configured to perform signature authentication on the device certificate of the target controller.
[0152] In one embodiment, the first authentication module 720 includes: a first authentication unit configured to perform validity authentication on the authentication request of the target controller; a second authentication unit configured to perform legality authentication on the device identifier of the target controller; a third authentication unit configured to perform signature authentication on the device certificate of the target controller. Wherein, in the case where the single authentication fails to pass the authentication for the first preset number of consecutive times, the validity authentication step for the target controller is returned.
[0153] In one embodiment, the first authentication unit includes: a first acquisition sub-unit configured to acquire a request flag bit of the authentication request; a first authentication sub-unit configured to perform validity authentication on the target controller according to the consistency between the request flag bit and a preset flag value.
[0154] In one embodiment, the second authentication unit includes: a second acquisition sub-unit configured to acquire the device identifier sent by the target controller; a second authentication sub-unit configured to perform legality authentication on the target controller according to the device identifier when the data length of the device identifier reaches a first preset length.
[0155] In one embodiment, the third authentication unit includes: a third acquisition sub-unit configured to acquire the device certificate sent by the target controller; a third authentication sub-unit configured to perform signature authentication on the device certificate according to the first root certificate of the gateway when the data length of the device certificate reaches a first preset length.
[0156] In one embodiment, the allocation module 740 includes: a processing unit configured to set the target controller to a working state when the second authentication is passed; an allocation unit configured to allocate a symmetric key to the target controller in the working state at a preset period.
[0157] In an exemplary embodiment, as Figure 8 shown, another communication device is provided, including: a second sending module 810, a second obtaining module 820, a second authentication module 830, and a third obtaining module 840, where:
[0158] The second sending module 810 is configured to send an authentication request to the gateway when the target controller accesses the gateway, so that the gateway performs a first authentication on the target controller in response to the authentication request;
[0159] The second obtaining module 820 is configured to obtain the gateway certificate sent by the gateway when the first authentication is passed;
[0160] The second authentication module 830 is configured to perform a second authentication on the gateway according to the gateway certificate;
[0161] The third obtaining module 840 is configured to obtain the symmetric key allocated by the gateway when the second authentication is passed; wherein, the symmetric key is used for communication encryption between the authenticated controllers accessing the gateway.
[0162] Each module in the above communication device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor in the computer device in the form of hardware or be independent of it, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0163] In an exemplary embodiment, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 9As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a communication method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, a trackball, or a touchpad set on the computer device housing, or an external keyboard, touchpad, or mouse, etc.
[0164] Those skilled in the art can understand that Figure 9 the structure shown in the figure is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0165] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0166] In an alternative embodiment, the present application further provides a vehicle in which the computer device shown in Figure 9 the figure is provided.
[0167] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0168] In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0169] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.
[0170] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope recorded in the present application.
[0171] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A communication method, characterized in that: Applied to a gateway, the method comprises: Get the authentication request sent by the target controller when it is connected to the gateway; In response to the authentication request, performing a first authentication on the target controller; If the first authentication passes, sending a gateway certificate to the target controller, so that the target controller performs a second authentication on the gateway according to the gateway certificate; In the case where the second authentication is passed, a symmetric key is allocated to the target controller; wherein the symmetric key is used to encrypt communications between authenticated controllers accessing the gateway.
2. The method according to claim 1, characterized in that The first authentication of the target controller includes at least one of the following: Performing validity authentication on the authentication request of the target controller; Performing legitimacy authentication on the device identification of the target controller; Perform signature authentication on the device certificate of the target controller.
3. The method according to claim 2, characterized in that The first authentication of the target controller is performed by performing the following authentications in sequence: Performing validity authentication on the authentication request of the target controller; Performing legitimacy authentication on the device identification of the target controller; Performing signature authentication on the device certificate of the target controller; Wherein, when the single authentication fails for a first preset number of consecutive times, the process returns to the step of validating the target controller.
4. The method according to claim 2, characterized in that: The authentication request for the target controller is authenticated for validity, including: Obtaining a request flag of the authentication request; The validity of the target controller is authenticated according to the consistency between the request flag and the preset flag value.
5. The method according to claim 2, characterized in that: The legitimacy authentication of the device identification of the target controller includes: Obtaining a device identification sent by the target controller; When the data length of the device identification reaches a first preset length, the target controller is authenticated for legitimacy based on the device identification.
6. The method according to claim 2, characterized in that The performing signature authentication on the device certificate of the target controller includes: Obtaining a device certificate sent by the target controller; When the data length of the device certificate reaches a first preset length, the device certificate is signed and authenticated according to the first root certificate of the gateway.
7. A communication method, characterized in that: Applied to a target controller, the method comprises: When the target controller is connected to a gateway, sending an authentication request to the gateway, so that the gateway performs a first authentication on the target controller in response to the authentication request; Obtaining a gateway certificate sent by the gateway when the first authentication passes; Performing a second authentication on the gateway according to the gateway certificate; In case the second authentication is passed, the symmetric key allocated by the gateway is obtained; wherein the symmetric key is used to encrypt communications between authenticated controllers accessing the gateway.
8. A communication device, characterized in that: The device comprises: A first acquisition module, used to acquire an authentication request sent when the target controller accesses the gateway; A first authentication module, configured to perform a first authentication on the target controller in response to the authentication request; A first sending module, configured to send a gateway certificate to the target controller if the first authentication is passed, so that the target controller performs a second authentication on the gateway according to the gateway certificate; A distribution module is used to distribute a symmetric key to the target controller when the second authentication is passed; wherein the symmetric key is used to encrypt communications between authenticated controllers accessing the gateway.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Vehicle electronic control unit anti-counterfeiting method, terminal equipment and storage medium
CN121585374A