Secret key storage method and device and electronic equipment
By using virtual key slot technology and encryption methods, the key storage location is dynamically determined, solving the problem that the key storage location in intelligent connected vehicles is easily detected and tampered with, and achieving high key security and continuous management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the key storage location of intelligent connected vehicles is easily detected and tampered with, resulting in insufficient key security and an inability to effectively prevent unauthorized intrusion and malicious tampering.
By employing virtual key slot technology, the location of random key slots is dynamically determined by acquiring virtual key slots and key injection counters, and keys are stored using encryption methods. A mapping relationship between key slots and external systems is established to ensure the unpredictability and security of key storage.
It improves key security, prevents unauthorized access and tampering, enhances information security of intelligent connected vehicles, and ensures the continuity and reliability of key management.
Smart Images

Figure CN121770733A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent vehicle information security, and more specifically, to a key storage method, apparatus, and electronic device. Background Technology
[0002] With the development of the information age and the rapid advancement of intelligent technology, especially the rise of intelligent connected vehicles, in-vehicle information systems are rapidly advancing towards high integration and interconnectivity. In intelligent connected vehicles, security hardware and security chips play a crucial role. Through encryption technology, authentication, and other means, they construct a robust defense against network attacks and data tampering, ensuring the stable operation of the in-vehicle system and the security of data transmission. Compared to the control units of traditional vehicles, the security hardware and security chips of intelligent vehicles demonstrate higher efficiency and stronger protection capabilities in handling security threats in complex network environments, becoming a core component of the intelligent vehicle information security system. However, as the level of vehicle intelligence increases, its information security threats are also becoming increasingly complex. Attacks targeting security hardware, in particular, can lead to attackers attempting to maliciously tamper with or replace the keys within the security hardware once they successfully infiltrate the main control chip. This directly impacts the vehicle's startup, communication, and overall security performance.
[0003] The significant shortcomings of related technologies in key injection lie in the fact that key injection is typically completed during the development phase or vehicle production process. Once the vehicle is delivered to the user, the storage location and access permissions for the keys become fixed. While this approach simplifies key management, its limitations become increasingly apparent in the face of growing information security challenges. For example, if the identifier of the key storage slot is obtained without authorization, an attacker can easily tamper with the key, causing security hardware to malfunction and thus jeopardizing the normal operation of the vehicle and passenger safety.
[0004] Although the relevant key storage methods can protect the information security of intelligent connected vehicles to a certain extent, they still suffer from insufficient key security when faced with unauthorized intrusion and malicious tampering, due to the ease with which the key storage location can be detected and altered.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This invention provides a key storage method, apparatus, and electronic device to at least solve the technical problem of insufficient key security caused by the ease with which the key storage location can be detected and tampered with.
[0007] According to one aspect of the present invention, a key storage method is provided, comprising: obtaining a virtual key slot, wherein the virtual key slot stores at least a key injection counter and a plurality of target location identifiers, the plurality of target location identifiers corresponding one-to-one with a plurality of target key slots, the target location identifiers being used to identify the storage location of the corresponding target key slot in a hardware security module of a vehicle, the virtual key slot being used to establish a mapping relationship between the virtual key slot and the plurality of target key slots in the hardware security module, and the target key slot representing a slot for storing a corresponding historical key; obtaining a successful injection count from the key injection counter, wherein the successful injection count represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module; based on the successful injection count, obtaining a target key injection request result for the target key, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module; and in response to the target key injection request result, determining a random key slot from the hardware security module and storing the target key in the random key slot.
[0008] Optionally, before obtaining the virtual key slot, the method further includes: performing a security test on the hardware security module to obtain a security test result, wherein the security test result indicates whether the hardware security module is in a secure state before injecting the target key, and the security test includes at least one of the following: detecting the security state of the network environment in which the hardware security module is located, detecting the key management state of the hardware security module, and detecting the access management state of the hardware security module; if the security test result is secure, obtaining the virtual key slot.
[0009] By employing the above methods, we can ensure the security of the network environment, key management, and access management status of the hardware security module, increase the security of the key injection process, prevent key operations when there are security vulnerabilities in the hardware security module, and thus protect the security of the keys.
[0010] Optionally, based on the number of successful injections, the target key injection request result is obtained, including: obtaining the expected number of injections of the target key; detecting whether the expected number of injections is greater than the number of successful injections by a predetermined value; and obtaining the target key injection request result if the expected number of injections is greater than the number of successful injections by a predetermined value.
[0011] By using the above methods, the difference between the actual number of successful key injections and the expected number of injections can be monitored. Using the difference as an indicator, the key injection strategy can be dynamically adjusted to ensure that the key is always in a controllable and updated state, thereby maintaining information security.
[0012] Optionally, in response to the result of the target key injection request, a random key slot is determined from the hardware security module, and the target key is stored in the random key slot, including: in response to the result of the target key injection request, using a random identifier generator to obtain the location identifier corresponding to the random key slot, wherein the random identifier generator is located in the hardware security module and is used to randomly generate the key slot location; and determining the random key slot from the hardware security module based on the location identifier of the random key slot.
[0013] By using the above methods, it can be ensured that each key injection points to a different key slot, making the actual storage location of the key unpredictable to external systems. This greatly improves the level of key protection and prevents potential malicious attacks or key tampering targeting fixed storage locations.
[0014] Optionally, after determining the random key slot from the hardware security module based on the location identifier of the random key slot, the method further includes: encrypting the target key using a preset encryption method to obtain the encrypted target key; and storing the encrypted target key into the random key slot based on the location identifier of the random key slot.
[0015] By using the above methods, the security of key storage can be improved. Even if the location of the random key slot is leaked, the key stored there will be encrypted, increasing the difficulty of cracking and effectively preventing unauthorized access and use.
[0016] Optionally, after determining the random key slot from the hardware security module and storing the target key in the random key slot in response to the result of the target key injection request, the method further includes: updating the virtual key slot to obtain the updated virtual key slot by: storing the location identifier of the random key slot in the virtual key slot; updating multiple target location identifiers to obtain the updated multiple target location identifiers; updating the number of successful injections to obtain the updated number of successful injections; and obtaining the updated virtual key slot based on the updated multiple target location identifiers and the updated number of successful injections.
[0017] By using the above methods, we can not only ensure that the virtual key slot maintains the latest key location information and injection history, providing accurate guidance for subsequent key access and management, but also maintain the security and orderliness of key management in real time, prevent inconsistencies between key status and virtual key slot recorded information, and ensure that each key use is based on the latest and most secure storage location.
[0018] According to another aspect of the present invention, a key injection device is also provided, comprising: a virtual key slot acquisition module, configured to acquire a virtual key slot, wherein the virtual key slot stores at least a key injection counter and a plurality of target location identifiers, the plurality of target location identifiers corresponding one-to-one with a plurality of target key slots, the target location identifiers being used to identify the storage location of the corresponding target key slot in the hardware security module of the vehicle, the virtual key slot being used to establish a mapping relationship between the virtual key slot and the plurality of target key slots in the hardware security module, and the target key slot representing the slot storing the corresponding historical key; a successful injection count acquisition module, configured to acquire the successful injection count from the key injection counter, wherein the successful injection count represents the total number of times the historical key was successfully injected into the corresponding target key slot in the hardware security module; a target key injection request result acquisition module, configured to acquire the target key injection request result of the target key based on the successful injection count, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module; and a random key slot determination module, configured to determine a random key slot from the hardware security module in response to the target key injection request result, and store the target key in the random key slot.
[0019] According to another aspect of the present invention, a non-volatile storage medium is also provided, the non-volatile storage medium storing a plurality of instructions adapted to be loaded by a processor and executed by any one of the key storage methods described herein.
[0020] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any one of the key storage methods described above.
[0021] According to another aspect of the present invention, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of any one of the key storage methods.
[0022] In this embodiment of the invention, a virtual key slot is obtained, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, and the multiple target location identifiers correspond one-to-one with multiple target key slots. The target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module. The virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module. The target key slot represents the slot where the corresponding historical key is stored. The number of successful injections is obtained from the key injection counter, wherein the number of successful injections represents the total number of times the historical key has been successfully injected into the corresponding target key slot in the hardware security module. Based on the number of successful injections, the target key injection request result of the target key is obtained, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module. In response to the target key injection request result, a random key slot is determined from the hardware security module, and the target key is stored in the random key slot. This achieves the purpose of determining the random key slot of the target key by obtaining the virtual key slot and the target key injection request result of the target key, thereby achieving the technical effect of improving the randomness and security of the key, and thus solving the technical problem of insufficient key security caused by the easy detection and tampering of the key storage location. Attached Figure Description
[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0024] Figure 1 This is a flowchart of a key storage method according to an embodiment of the present invention;
[0025] Figure 2 This is a flowchart of an optional key storage method according to an embodiment of the present invention;
[0026] Figure 3 This is a schematic diagram of a key injection device according to an embodiment of the present invention. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] A virtual key slot is a concept used in secure hardware to enhance the security of key management and protection. Its core idea is to create a layer of logical abstraction that makes the physical storage location of the actual keys invisible to external systems (such as the control unit or other systems requesting access to the keys), thereby preventing the keys from being directly located and maliciously tampered with.
[0030] A key is a parameter used to encrypt and decrypt data. It is the core of an algorithm, used to convert plaintext (raw data) into ciphertext (encrypted data) and vice versa. A key can be numbers, letters, symbols, or a combination thereof, and its length and complexity determine the security strength of the encryption algorithm. Secure key management is fundamental to ensuring the overall security of a system; the storage and use of keys require special care to prevent data tampering or system attacks.
[0031] The main core refers to the core part of the vehicle's central processing unit or control unit. It is responsible for most of the vehicle's computing tasks and logic control, including but not limited to key functions such as driver assistance, powertrain control, entertainment system, and network communication.
[0032] According to an embodiment of the present invention, a method embodiment for key injection is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0033] Figure 1 This is a flowchart of a key storage method according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0034] Step S102: Obtain a virtual key slot, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, and the multiple target location identifiers correspond one-to-one with multiple target key slots. The target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module. The virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module. The target key slot represents the slot where the corresponding historical key is stored.
[0035] Optionally, acquiring a virtual key slot is a method to enhance key security storage and management. Its core lies in using a virtual key slot to indirectly manage and locate the real key slot within the hardware security module. Specifically, the virtual key slot's fixed non-volatile storage area stores at least the following critical information: a key injection counter records the number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module, used to verify the continuity and correctness of key injection and prevent unauthorized or repeated key injection operations; multiple target location identifiers each correspond to the storage location of a target key slot within a hardware security module. By randomly assigning these identifiers, the location of the key slot can be ensured to be unpredictable to the main core or any external entity, thereby enhancing key storage security. Even if an external party attempts to tamper with the key, the location of the real key slot is unknown, making tampering extremely difficult.
[0036] In an optional embodiment, before obtaining the virtual key slot, the method further includes: performing a security test on the hardware security module to obtain a security test result, wherein the security test result indicates whether the hardware security module is in a secure state before injecting the target key, and the security test includes at least one of the following: detecting the security state of the network environment in which the hardware security module is located, detecting the key management state of the hardware security module, and detecting the access management state of the hardware security module; if the security test result is secure, obtaining the virtual key slot.
[0037] Optionally, security checks are performed to ensure that the hardware security module is in a secure, uncompromised, and attack-free state before key injection. Checking the network environment's security status assesses the potential threats within the network environment, such as whether it's under distributed denial-of-service (DDoS) attacks, whether there's suspicious packet monitoring, and whether the network connection is secure and stable. The purpose of network environment checks is to prevent key injection in insecure network environments, avoiding key interception during transmission or attacks from unauthorized clients. Checking the key management status verifies the integrity of the hardware security module's internal key management system, such as confirming no unauthorized key copying, proper key lifecycle management, and complete key usage records. Key management status checks ensure the integrity of key storage space, preventing key leakage due to internal management vulnerabilities. Checking the access management status audits the hardware security module's access permissions and control mechanisms, ensuring only secure entities can access keys under appropriate times and conditions. Access management status checks include, but are not limited to, verifying access logs, confirming no unauthorized access attempts, and checking access control lists. Access management status checks prevent insecure users or attackers from obtaining keys through existing security vulnerabilities. Ultimately, only when the security test results indicate that the hardware security module is in a secure state will the subsequent steps, namely obtaining the virtual key slot for key injection, be triggered. This pre-emptive security testing mechanism ensures that the key injection operation occurs under the highest security standards, thereby greatly reducing the risk during the injection process and protecting the key from malicious tampering or theft. Security testing adds an important layer of protection to the information security system of intelligent connected vehicles, maintaining the stability and security of the vehicle's electronic control unit and the entire in-vehicle network.
[0038] Step S104: Obtain the number of successful injections from the key injection counter, where the number of successful injections represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module.
[0039] Optionally, the number of successful injections is an important security parameter. It records the total number of times a key has been successfully injected into the target key slot within the hardware security module since the module was put into use. This number is crucial for monitoring key usage history, identifying any potential anomalies, and maintaining key lifecycle management. Recording the number of successful injections also ensures that each key injection is correctly mapped to the target key slot in the hardware security module. Furthermore, the record allows for tracing all key injection events, helping security administrators understand the frequency, patterns, and history of key injections, thereby better managing the key lifecycle and taking appropriate security measures when necessary.
[0040] Step S106: Based on the number of successful injections, obtain the target key injection request result of the target key, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module.
[0041] Optionally, obtaining the target key injection request result based on the number of successful injections is a key strategy to ensure the security and continuity of key management. It is mainly applied to the key injection or update process of hardware security modules to avoid unauthorized or malicious key injection behavior, thereby protecting the vehicle from security threats.
[0042] In one optional embodiment, obtaining the target key injection request result based on the number of successful injections includes: obtaining the expected number of injections for the target key; detecting whether the expected number of injections is greater than the number of successful injections by a predetermined value; and obtaining the target key injection request result if the expected number of injections is greater than the number of successful injections by a predetermined value.
[0043] Optionally, before the key injection process begins, the expected number of injections for the target key needs to be obtained. This expected number is calculated by the main control system or external management agency based on the key's usage history and update requirements, representing the total number of times the target key should have been successfully injected before the current injection operation. Next, the obtained expected number of injections is compared with the current successful injection count stored in the key injection counter in the virtual key slot. The difference between the two is checked to see if it exceeds a predetermined value, which can be 1. This predetermined value is set to prevent any discontinuous or abnormal key injection attempts, such as attempts to inject a key by skipping the normal injection process, or mismatches due to system time tampering, communication delays, etc. Finally, if the difference between the expected number of injections and the successful injection count is equal to the predetermined value, the continuity verification condition is met, indicating that the target key injection request result can be accepted and processed. Conversely, if the difference is not equal to the predetermined value, the injection request is rejected to avoid potential security risks. The key injection request processing method based on the number of successful injections provides robust security protection for the hardware security modules of intelligent connected vehicles through rigorous count verification. This can greatly enhance the vehicle's defense capabilities against network attacks and the reliability of key management.
[0044] Step S108: In response to the result of the target key injection request, determine the random key slot from the hardware security module and store the target key in the random key slot.
[0045] Optionally, the use of random key slots is an important security measure in key management technology. It makes the key storage location unpredictable to external attackers. Even if an attacker gains some access to the main control system, it is difficult to directly locate a specific key storage slot, thus greatly increasing the difficulty of the attack. Because the location identifier of the storage slot is randomly generated each time a key is injected, and is closely related to the number of previous key injections, it effectively prevents key tampering and attacks by attackers attempting to replay old key injection requests.
[0046] In one optional embodiment, in response to the result of the target key injection request, determining a random key slot from the hardware security module and storing the target key in the random key slot includes: in response to the result of the target key injection request, using a random identifier generator to obtain a location identifier corresponding to the random key slot, wherein the random identifier generator is located in the hardware security module and is used to randomly generate the key slot location; and determining the random key slot from the hardware security module based on the location identifier of the random key slot.
[0047] Optionally, first, the hardware security module receives a key injection request from the main control unit or other authorized entity. Once the key injection request is approved (i.e., the target key injection request result is obtained), the random identifier generator inside the hardware security module is activated. The random identifier generator uses a random algorithm to generate a location identifier that points to a random key slot within the hardware security module that can be used to store the target key. Next, the generated location identifier is equivalent to a random address of the key slot. Based on this location identifier, a random key slot can be allocated within the non-volatile storage area of the hardware security module as the storage space for the target key. Finally, after determining the location of the random key slot, the hardware security module can accurately locate this key slot based on the location identifier and inject the target key into it. After this step, the actual storage location of the key is known only within the hardware security module and is kept confidential from external entities. To ensure correct use of the key in the future, the hardware security module also saves the generated random key slot location identifier. For example, the random key slot location identifier can be stored in a virtual key slot or a dedicated secure storage area to ensure that the correct key slot can be quickly located when needed. Through the above steps, since the location of the key slot is determined by a random identifier, even if an attacker gains partial access to the hardware security module, it is difficult to predict and locate the actual storage location of the target key, which can greatly increase the difficulty of unauthorized access or tampering with the key.
[0048] In an optional embodiment, after determining the random key slot from the hardware security module based on the location identifier of the random key slot, the method further includes: encrypting the target key using a preset encryption method to obtain the encrypted target key; and storing the encrypted target key into the random key slot based on the location identifier of the random key slot.
[0049] Optionally, before storing the target key in the random key slot, the hardware security module encrypts the target key using a preset encryption method. The encryption process includes, but is not limited to, using a preset encryption algorithm or a preset encryption key (the encryption key is a fixed key within the target key used to encrypt all stored keys) to convert the target key into an encrypted key form. After encryption, the encrypted target key is stored in the random key slot located by a location identifier. Through this step, even if an attacker physically accesses the storage area of the hardware security module or reads the data without authorization, the attacker will find it difficult to directly utilize this key data because the key has been encrypted. By encrypting the target key before storage, even if the physical storage of the hardware security module is accessed without authorization, attackers will find it difficult to directly decrypt and utilize the key, thereby enhancing the security protection of the hardware security module's storage area.
[0050] In an optional embodiment, after determining a random key slot from the hardware security module and storing the target key in the random key slot in response to the result of the target key injection request, the method further includes:
[0051] The updated virtual key slot is obtained by updating it as follows: the location identifier of the random key slot is stored in the virtual key slot; multiple target location identifiers are updated to obtain multiple updated target location identifiers; the number of successful injections is updated to obtain the number of successful injections; and the updated virtual key slot is obtained based on the updated multiple target location identifiers and the updated number of successful injections.
[0052] Optionally, after each successful key injection into a random key slot, the hardware security module stores the location identifier of the corresponding random key slot in the virtual key slot. This is equivalent to recording the actual storage location of the key, but this location information is stored in an encrypted or hidden form, ensuring that even if the virtual key slot is accessed without authorization, attackers cannot directly locate the specific target key slot. Furthermore, each time a key injection is successful, the key injection counter in the virtual key slot is updated to reflect the latest key injection status. This counter is crucial for verifying the continuity of subsequent key injection requests and is an indispensable security feature in the key management process. Simultaneously updating the virtual key slot allows for efficient management of the dynamic changes in the virtual key slot and key injection operations, while ensuring the security of key management and avoiding security risks caused by key location leakage or mismanagement.
[0053] Through the above steps S102 to S108, the goal of determining the random key slot of the target key can be achieved by obtaining the target key injection request result of the virtual key slot and the target key, thereby improving the technical effect of key security and solving the technical problem of insufficient key security caused by the easy detection and tampering of the key storage location.
[0054] Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation method. Figure 2 This is a flowchart of an optional key storage method according to an embodiment of the present invention, such as... Figure 2 As shown, the method includes:
[0055] S1: Obtain the expected number of injections for the target key. The specific implementation process is the same as in the previous embodiment, and will not be repeated here.
[0056] S2: Obtain the number of successful injections recorded by the key injection counter stored in the virtual key slot. The specific implementation process is the same as in the previous embodiment, and will not be repeated here.
[0057] S3: If the expected number of injections is greater than the number of successful injections by a predetermined value, the target key injection request result of the target key is obtained. The specific implementation process is the same as the aforementioned embodiment, and will not be repeated here.
[0058] S4: Based on the result of the target key injection request, a random identifier generator is used to obtain the position identifier corresponding to the random key slot. The specific implementation process is the same as the previous embodiment, and will not be repeated here.
[0059] S5: Based on the location identifier of the random key slot, perform target key injection and determine the random key slot from the hardware security module. The specific implementation process is the same as the previous embodiment, and will not be repeated here.
[0060] According to the steps of this embodiment, when a user needs to inject a key, they first need to obtain the number of times the key was previously injected from the developer or production department. After obtaining the number of times the key was previously injected, the user can inject the key and the number of times the key was previously injected into the main core software through a diagnostic tool or other device. After receiving the key and the number of times the key was previously injected, the main core software passes them to the hardware security module to trigger the key import process in this embodiment. The virtual key slot will randomly generate a location identifier, which is unknown to the user, developer, production department, etc., and cannot be tampered with. Unless all keys in the hardware security module are initialized, deleted, or tampered with, it cannot be guaranteed that the key will not be tampered with. Compared with the key storage methods in related technologies, where the user needs to inject a key and directly obtains the slot location identifier of the slot to be injected from the developer or production department, and then directly injects the key into the slot of that location identifier, the methods in related technologies directly expose the location identifier of the key slot to the end user. The user or unauthorized intruder can arbitrarily tamper with the key, causing vehicle security to fail.
[0061] The key storage method proposed in this embodiment can achieve at least one of the following effects: (1) It can ensure that the hardware security module can securely access the key and prevent the key stored in the hardware security module from being maliciously tampered with; (2) It has high security. By isolating the main core from the key slot in the hardware security module through the virtual key slot, it can ensure high security of key operations; (3) It has low cost and does not require additional hardware costs; (4) It is simple to operate. Normal key injection can be performed without additional operations on the main core.
[0062] This embodiment also provides a key injection device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the terms "module" and "device" can refer to a combination of software and / or hardware that performs a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0063] According to embodiments of the present invention, an apparatus embodiment for implementing the above-described key storage method is also provided. Figure 3 This is a schematic diagram of a key injection device according to an embodiment of the present invention, as shown below. Figure 3 As shown, the above-mentioned key injection device includes: a virtual key slot acquisition module 300, a successful injection count acquisition module 302, a target key injection request result acquisition module 304, and a random key slot determination module 306, wherein:
[0064] The virtual key slot acquisition module 300 is used to acquire virtual key slots. The virtual key slot stores at least a key injection counter and multiple target location identifiers. The multiple target location identifiers correspond one-to-one with multiple target key slots. The target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module. The virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module. The target key slot represents the slot where the corresponding historical key is stored.
[0065] The successful injection count acquisition module 302 is connected to the virtual key slot acquisition module 300 and is used to acquire the successful injection count from the key injection counter. The successful injection count represents the total number of times that a historical key has been successfully injected into the corresponding target key slot in the hardware security module.
[0066] The target key injection request result acquisition module 304 is connected to the successful injection count acquisition module 302, and is used to acquire the target key injection request result of the target key based on the successful injection count, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module;
[0067] The random key slot determination module 306 is connected to the target key injection request result acquisition module 304. In response to the target key injection request result, it determines the random key slot from the hardware security module and stores the target key in the random key slot.
[0068] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0069] It should be noted that the virtual key slot acquisition module 300, successful injection count acquisition module 302, target key injection request result acquisition module 304, and random key slot determination module 306 mentioned above correspond to steps S102 to S108 in the embodiments. The instances and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can run in a computer terminal.
[0070] It should be noted that the optional or preferred implementation methods of this embodiment can be found in the relevant descriptions in the embodiments, and will not be repeated here.
[0071] The aforementioned key injection device may further include a processor and a memory. The aforementioned virtual key slot acquisition module 300, successful injection count acquisition module 302, target key injection request result acquisition module 304, random key slot determination module 306, etc., are all stored in the memory as program modules, and the processor executes the aforementioned program modules stored in the memory to realize the corresponding functions.
[0072] The processor contains a core that retrieves the corresponding program modules from memory. One or more cores may be configured. Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory includes at least one memory chip.
[0073] According to an embodiment of this application, an embodiment of a non-volatile storage medium is also provided. Optionally, in this embodiment, the non-volatile storage medium includes a stored program, wherein, when the program runs, it controls the device where the non-volatile storage medium is located to execute any of the key storage methods described above.
[0074] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals, and the non-volatile storage medium includes stored programs.
[0075] Optionally, during program execution, the device containing the non-volatile storage medium performs the following functions: acquiring a virtual key slot, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, each of which corresponds one-to-one with a target key slot. The target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module. The virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module, and the target key slot represents the slot where the corresponding historical key is stored. Acquiring the number of successful injections from the key injection counter, wherein the number of successful injections represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module. Based on the number of successful injections, acquiring the target key injection request result for the target key, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module. In response to the target key injection request result, determining a random key slot from the hardware security module and storing the target key in the random key slot.
[0076] According to an embodiment of this application, an embodiment of a processor is also provided. Optionally, in this embodiment, the processor is used to run a program, wherein the program executes any of the key storage methods described above.
[0077] According to an embodiment of this application, an embodiment of a computer program product is also provided. Optionally, in this embodiment, the computer program product includes a computer program that, when executed by a processor, implements the key storage method steps described above.
[0078] Optionally, when the aforementioned computer program product is executed on a data processing device, it is suitable to execute an initialization program with the following method steps: obtaining a virtual key slot, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, the multiple target location identifiers corresponding one-to-one with multiple target key slots, the target location identifiers being used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module, the virtual key slot being used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module, and the target key slot representing the slot storing the corresponding historical key; obtaining the number of successful injections from the key injection counter, wherein the number of successful injections represents the total number of times the historical key was successfully injected into the corresponding target key slot in the hardware security module; based on the number of successful injections, obtaining the target key injection request result for the target key, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module; and in response to the target key injection request result, determining a random key slot from the hardware security module and storing the target key in the random key slot.
[0079] This invention provides an electronic device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: obtaining a virtual key slot, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, each of which corresponds one-to-one with a target key slot. The target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module. The virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module, and each target key slot represents a slot storing a corresponding historical key; obtaining the number of successful injections from the key injection counter, wherein the number of successful injections represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module; based on the number of successful injections, obtaining the target key injection request result for the target key, wherein the target key injection request result indicates that the target key is allowed to be injected into the hardware security module; and responding to the target key injection request result, determining a random key slot from the hardware security module and storing the target key in the random key slot.
[0080] The order of the above embodiments of the present invention is merely for description and does not represent the superiority or inferiority of the embodiments.
[0081] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0082] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of modules described above can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between modules, and may be electrical or other forms.
[0083] The modules described above as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0084] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0085] If the aforementioned integrated modules are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a non-volatile storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned non-volatile storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0086] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A key storage method, characterized in that, include: A virtual key slot is obtained, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, the multiple target location identifiers correspond one-to-one with multiple target key slots, the target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module, the virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module, and the target key slot represents the slot for storing the corresponding historical key; The successful injection count is obtained from the key injection counter, wherein the successful injection count represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module; Based on the number of successful injections, the target key injection request result is obtained, wherein the target key injection request result indicates that the target key is allowed to inject into the hardware security module; In response to the result of the target key injection request, a random key slot is determined from the hardware security module, and the target key is stored in the random key slot.
2. The method according to claim 1, characterized in that, The step of obtaining the target key injection request result based on the number of successful injections includes: Obtain the expected number of injections for the target key; Detect whether the expected number of injections is greater than the number of successful injections by a predetermined value; If the expected number of injections is greater than the number of successful injections by a predetermined value, the result of the target key injection request is obtained.
3. The method according to claim 1, characterized in that, The step of responding to the result of the target key injection request by determining a random key slot from the hardware security module and storing the target key in the random key slot includes: In response to the result of the target key injection request, a random identifier generator is used to obtain the location identifier corresponding to the random key slot, wherein the random identifier generator is located in the hardware security module and is used to randomly generate the key slot location; The random key slot is determined from the hardware security module based on the location identifier of the random key slot.
4. The method according to claim 3, characterized in that, After determining the random key slot from the hardware security module based on the location identifier of the random key slot, the method further includes: The target key is encrypted using a preset encryption method to obtain the encrypted target key; Based on the location identifier of the random key slot, the encrypted target key is stored in the random key slot.
5. The method according to claim 1, characterized in that, Prior to obtaining the virtual key slot, the method further includes: The hardware security module is subjected to security testing to obtain a security testing result, wherein the security testing result indicates whether the hardware security module is in a secure state before the target key injection is performed. The security testing includes at least one of the following: detecting the security state of the network environment in which the hardware security module is located, detecting the key management state of the hardware security module, and detecting the access management state of the hardware security module. If the security test result is secure, the virtual key slot is obtained.
6. The method according to any one of claims 1 to 5, characterized in that, After determining a random key slot from the hardware security module and storing the target key in the random key slot in response to the result of the target key injection request, the method further includes: The updated virtual key slot is obtained by updating the virtual key slot in the following manner: The location identifier of the random key slot is stored in the virtual key slot, and the multiple target location identifiers are updated to obtain the updated multiple target location identifiers; Update the successful injection count to obtain the updated successful injection count; The updated virtual key slot is obtained based on the updated multiple target location identifiers and the updated number of successful injections.
7. A key storage device, characterized in that, include: A virtual key slot acquisition module is used to acquire virtual key slots, wherein the virtual key slot stores at least a key injection counter and multiple target location identifiers, the multiple target location identifiers correspond one-to-one with multiple target key slots, the target location identifiers are used to identify the storage location of the corresponding target key slot in the vehicle's hardware security module, the virtual key slot is used to establish a mapping relationship between the virtual key slot and the multiple target key slots in the hardware security module, and the target key slot represents the slot for storing the corresponding historical key; The successful injection count acquisition module is used to acquire the successful injection count from the key injection counter, wherein the successful injection count represents the total number of times a historical key has been successfully injected into the corresponding target key slot in the hardware security module; The target key injection request result acquisition module is used to acquire the target key injection request result of the target key based on the number of successful injections, wherein the target key injection request result indicates that the target key is allowed to inject into the hardware security module; A random key slot determination module is used to determine a random key slot from the hardware security module in response to the result of the target key injection request, and store the target key in the random key slot.
8. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores multiple instructions, which are adapted to be loaded by a processor and executed by the key storage method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs for execution, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the key storage method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the key storage method according to any one of claims 1 to 6.