HSM hardware security system based on task scheduling, task scheduling method and storage medium

By adopting preemptive task scheduling and data slicing processing in the automotive HSM hardware security system, the response delay and resource waste caused by the task cancellation mechanism are solved, and the real-timeness of information security services and system performance are improved.

CN118656837BActive Publication Date: 2024-12-13ZHEJIANG YUXIN SEMICON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411132540.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-12-13
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

In the existing automotive HSM hardware security system, the task cancellation mechanism leads to response delays and waste of computing resources, affecting the real-time and performance of information security services.

Method used

Using preemptive task scheduling method, tasks are divided and executed according to the priority of information security requests. High-priority tasks preempt low-priority tasks, and optimize resource lock acquisition through data slicing processing when necessary to ensure high-priority tasks. Respond in a timely manner.

Benefits of technology

It effectively solves the problems of response delay and waste of computing resources, improves the real-time performance of system performance and information security services, and manages resource competition through priority scheduling and data slicing processing, and improves the scalability and security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656837B_ABST
    Figure CN118656837B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of information security technology of automotive electronic control units, and in particular to an HSM hardware security system based on task scheduling, a task scheduling method and a storage medium, the method comprising the following steps: obtaining an information security request; prioritizing the obtained information security request according to a set priority level, thereby forming an information security task; sending the information security task to a corresponding atomic service for execution; during execution, based on a preemptive task scheduling mechanism, allowing a task with a high priority level to preempt a task with a low priority level being executed, giving priority to executing the task with a high priority level, and resuming execution of the task with a low priority level after completion. The present invention is based on a preemptive task scheduling mechanism, allowing a task with a high priority level to preempt a task with a low priority level, and resuming execution of the task with a low priority level after the high priority task is completed, thereby solving the problem of HSM computing resource waste and original task response delay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology of automobile electronic control units, and in particular to an HSM hardware security system based on task scheduling, a task scheduling method and a storage medium. Background Art

[0002] In automotive information security, HSM (Hardware Security Module) is a professional hardware device integrated in the electronic control unit (ECU), which is designed to provide security encryption and decryption and key management services for the vehicle, and plays an important role in the electronic architecture of the vehicle. HSM generally runs inside the ECU and provides atomic services (Service Primitive) to the outside. The upper-layer software of the ECU builds more complex information security applications based on the atomic services provided by HSM, including remote security diagnosis and firmware updates, secure boot, secure vehicle communications and other application scenarios.

[0003] At present, multi-core MCUs are widely used in automotive electronics. When using HSM's information security atomic services at the ECU application layer, atomic service operations and response time become key considerations. If relevant priority design is not performed, slow, low-priority tasks may have a negative impact on the execution of high-speed, high-priority tasks. For example, when the HSM is performing a time-consuming large-block data hash operation service, if an urgent small-data encryption request suddenly arrives, the system may not be able to respond in time, thus affecting the real-time performance of the service.

[0004] In the CSM (Crypto Service Manager) encryption service management module of the Autosar (Automotive Open System Architecture), a task cancellation interface is introduced. Specifically, when a high-real-time emergency task arrives, the system can cancel the executing task to quickly respond to the emergency task. However, the task cancellation mechanism may cause a delay in the response of the original task, and waste HSM computing resources, causing a certain performance loss. Summary of the invention

[0005] The purpose of the present invention is to overcome the defects of the prior art and provide an HSM hardware security system based on task scheduling, a task scheduling method and a storage medium to solve the problems existing in the existing task cancellation mechanism, such as causing response delay of the original task and waste of HSM computing resources, resulting in certain performance loss, etc.

[0006] The technical solution to achieve the above purpose is:

[0007] The present invention provides a task scheduling method for HSM, comprising the following steps:

[0008] Get information security requests;

[0009] Prioritize the acquired information security requests according to the set priority level, and then form information security tasks of corresponding priority;

[0010] Send the information security tasks of corresponding priority to the corresponding atomic services for execution;

[0011] When executing information security tasks, based on the preemptive task scheduling mechanism, tasks with higher priority levels preempt the tasks with lower priority levels being executed, and the tasks with higher priority levels are executed first. After the tasks are completed, the tasks with lower priority levels are resumed.

[0012] A further improvement of the task scheduling method of the HSM of the present invention is that when a task with a high priority level preempts a task with a low priority level being executed, if the information security task with a high priority level fails in trying to obtain a resource lock, the task currently occupying the resource lock is subjected to data slicing processing to form a plurality of grouped data;

[0013] After the current group data processing is completed, the resource lock is released, allowing the information security task with a high priority level to successfully obtain the resource lock and resume operation. After completion, the preempted task with a low priority level is resumed.

[0014] A further improvement of the task scheduling method of the HSM of the present invention is that the set priority levels include background level, low level, medium level, high level and emergency level;

[0015] Setting the first slice data length for the background level information security task;

[0016] Setting a second slice data length for a low-level information security task, wherein the set second slice data length is greater than the first slice data length;

[0017] A third slice data length is set for a medium-level information security task, and the set third slice data length is greater than the second slice data length;

[0018] If the priority level of the currently executing task is high or urgent, data slicing processing will not be performed on the currently executing task, and the resource lock will be released after the processing is completed.

[0019] A further improvement of the task scheduling method of the HSM of the present invention is that a service ID is set for the atomic service module, and the set service ID is formed by splicing a service type value, an algorithm type value, and an algorithm mode value;

[0020] When an information security task of corresponding priority is sent to the corresponding atomic service for execution, the service ID value is calculated according to the service type, algorithm type and algorithm mode of the information security task, the atomic service module is determined according to the calculated service ID value, and the information security task is sent to the determined atomic service module for execution.

[0021] A further improvement of the HSM task scheduling method of the present invention is that when obtaining the information security request, the session ID is also obtained;

[0022] When sending the information security task of the corresponding priority to the corresponding atomic service for execution, the workspace corresponding to the acquired session ID is sent as a parameter to the corresponding atomic service as a service operation space;

[0023] After the execution is completed, the execution result and session ID are fed back at the same time.

[0024] The present invention also provides a storage medium, characterized in that a program of the HSM task scheduling method is stored on the storage medium, and the program of the HSM task scheduling method implements the steps of the HSM task scheduling method when executed by a processor.

[0025] The present invention further provides an HSM hardware security system based on task scheduling, comprising:

[0026] Request and response unit, used to obtain information security requests;

[0027] A processing unit connected to the request and response unit, the processing unit is used to prioritize the acquired information security requests according to the set priority level, thereby forming information security tasks of corresponding priority;

[0028] An atomic service unit connected to the processing unit, used to receive corresponding information security tasks for execution;

[0029] The interrupt service unit connected to the processing unit and the atomic service unit is used to allow the task with a higher priority level to preempt the task with a lower priority level being executed based on the preemptive task scheduling mechanism when the atomic service unit executes the information security task, give priority to the task with the higher priority level, and resume the execution of the task with the lower priority level after completion.

[0030] A further improvement of the HSM hardware security system based on task scheduling of the present invention is that the interrupt service unit is also used to perform data slicing processing on the task currently occupying the resource lock to form multiple grouped data when an information security task with a high priority level attempts to obtain a resource lock and fails, and release the resource lock after the current grouped data processing is completed, so that the information security task with a high priority level can successfully obtain the resource lock and resume operation, and after completion, the preempted task with a low priority level can resume operation.

[0031] A further improvement of the HSM hardware security system based on task scheduling of the present invention is that the atomic service unit includes multiple atomic service modules, each atomic service module is configured with a service ID, and the service ID is formed by splicing a service type value, an algorithm type value, and an algorithm mode value;

[0032] The processing unit is also used to calculate a service ID value according to the service type, algorithm type and algorithm mode of the information security task, determine the atomic service module according to the calculated service ID value, and send the information security task to the determined atomic service module for execution.

[0033] A further improvement of the HSM hardware security system based on task scheduling of the present invention is that the request and response unit is also used to obtain a session ID;

[0034] The processing unit is also used to send the workspace corresponding to the acquired session ID as a parameter to the corresponding atomic service as a service operation space;

[0035] The request and response unit is also used to feed back the execution result and the session ID at the same time after the atomic service unit is executed.

[0036] The beneficial effects of the HSM hardware security system based on task scheduling, the task scheduling method and the storage medium of the present invention are:

[0037] The present invention configures priority levels for information security tasks and, based on a preemptive task scheduling mechanism, allows tasks with high priority levels to preempt tasks with low priority levels. After the high priority tasks are completed, the low priority tasks are resumed, thereby solving the problems of HSM computing resource waste and original task response delay.

[0038] The preemptive task scheduling mechanism of the present invention can effectively solve the problem of priority inversion by setting a data slicing processing method. For the occupation of resource locks by low-priority tasks, data slicing processing is performed on the tasks to form multiple grouped data. After executing one grouped data, the resource lock is released, so that high-priority tasks can obtain the resource lock in time for execution response, which can effectively manage the competition for global resources and improve system performance.

[0039] The present invention can flexibly dispatch atomic services through the calculation of service IDs, adapt to different service request types and modes, unify service request parameters, simplify parameter processing, improve system scalability, and meet new service requirements that may arise in the future.

[0040] The present invention configures a corresponding workspace for information security tasks. The workspace, as a service operation space for atomic services, can effectively isolate different service data and ensure the execution security and independence of the requested services. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is an architecture diagram of the HSM hardware security system based on task scheduling of the present invention.

[0042] Figure 2 This is a service execution process diagram using data slicing in the HSM hardware security system based on task scheduling and the task scheduling method of the present invention.

[0043] Figure 3 It is a schematic diagram of atomic service dispatch in the HSM hardware security system based on task scheduling and the task scheduling method of the present invention.

[0044] Figure 4 The present invention is a schematic diagram of the principle of allocating workspace to the atomic service module in the HSM hardware security system and task scheduling method based on task scheduling.

[0045] Figure 5 The present invention is a flowchart of session workspace management in the HSM hardware security system based on task scheduling and the task scheduling method.

[0046] Figure 6 The flowchart of the task scheduling method of HSM of the present invention.

[0047] Figure 7 Execute the process graph for services that do not use data slices. DETAILED DESCRIPTION

[0048] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0049] See also Figure 1The present invention provides an HSM hardware security system based on task scheduling, a task scheduling method and a storage medium, which sets priorities for information security service requests, encapsulates different requests into tasks of different priorities, and dispatches the execution process to the corresponding atomic service module through task scheduling, thereby realizing concurrent requests and execution processes of multiple atomic services, and realizing efficient and flexible information security services by adopting corresponding priority design, data slicing method, session space management, etc. The HSM hardware security system based on task scheduling, the task scheduling method and the storage medium of the present invention are described below in conjunction with the accompanying drawings.

[0050] See also Figure 1 , shows the architecture diagram of the HSM hardware security system based on task scheduling of the present invention. Figure 1 , the HSM hardware security system based on task scheduling of the present invention is described.

[0051] like Figure 1 As shown, the HSM hardware security system based on task scheduling of the present invention includes a request and response unit, a processing unit, an atomic service unit and an interrupt service unit, wherein the processing unit is connected to the request and response unit, the atomic service unit is connected to the processing unit, and the interrupt service unit is connected to the processing unit and the atomic service unit. The request and response unit is used to obtain information security requests, and the request and response unit is connected to the external application communication of the HSM, and can receive information security requests sent by the external application; the processing unit is used to obtain the information security requests obtained by the request and response unit, and prioritize the obtained information security requests according to the set priority level, thereby forming information security tasks of corresponding priorities; the atomic service unit is used to receive and execute information security tasks sent by the processing unit; the interrupt service unit is used to allow tasks with high priority levels to preempt tasks with low priority levels being executed based on the preemptive task scheduling mechanism when the atomic service unit executes information security tasks, and give priority to executing tasks with high priority levels, and resume executing tasks with low priority levels after completion.

[0052] The present invention sets a service priority mechanism, and information security requests of different priorities are executed in order of priority levels, with high-priority services being executed first, so that high-priority services can preempt the executing low-priority services. At this time, the low-priority services are interrupted first, and the execution of the low-priority services is resumed after completion, thereby avoiding the waste of HSM computing resources.

[0053] like Figure 1As shown, the HSM hardware security system of the present invention includes three parts, namely, the request and response layer (Request Response Layer), the server layer (Server Layer) and the primitive layer (Primitive Layer). The request and response unit in the security system of the present invention is arranged in the request and response layer, which is responsible for obtaining information security requests from the outside of the HSM, and sending the obtained request parameters to the server layer for scheduling and execution. At the same time, it is also responsible for receiving the response data sent from the server layer and sending the response data to the external application layer. As a special information security module, HSM generally exists in the form of a special peripheral in the automotive electronic control unit (ECU). The HOST end of the ECU is responsible for running the application layer software and using the information security services provided by the HSM. The ways of transmitting requests between the HOST end and the HSM end include interrupts, special function registers, shared memory, etc. If the HSM obtains the request parameters from the shared memory, the HSM will also send the response result to the shared memory.

[0054] The processing unit and the interrupt service unit in the security system of the present invention are arranged in the server layer, which is responsible for receiving specific information security request parameters, packaging them into OS tasks of different priorities for scheduling and execution, and returning the response results at the same time. The server layer will dispatch atomic services according to the parameter information of the request, including searching and retrieving the corresponding atomic services, and dispatching the specific execution process of the task to a specific atomic service module. At the same time, the server layer will also check the session environment and status, prepare the session workspace required to execute the corresponding service, and preferably start task scheduling and execution.

[0055] The atomic service unit in the security system of the present invention is arranged in the atomic service layer, which provides basic information security services, including random number generation, hash operation, symmetric encryption, message authentication code, digital signature verification and other functions. Each atomic service module is independent of each other, performs a specific function, and provides a relatively unified interface for the upper layer to call. According to different service types, algorithm types and algorithm modes, there may be many atomic service modules inside the HSM. These atomic services are included in one layer, and relatively independent service interfaces are provided to the outside. This can not only realize the modularity and reusability of the system, but also enhance the flexibility of the system, and can be more easily maintained, expanded and updated.

[0056] In a specific implementation of the present invention, the present invention sets five priorities for information security requests, namely background level, low level, medium level, high level and urgent level. The service characteristics of different priorities are as follows:

[0057] Background level priority: Background level services and system idle tasks use the same priority and always keep running in the background without stopping. They are suitable for tasks that require long execution and do not require high real-time performance, such as information security RTMD (Runtime Manipulation Detection) real-time intrusion detection, hash operation services for large files, etc., which cannot send requests through hardware interrupts;

[0058] Low priority: Low priority services are suitable for service requests with low real-time requirements and large computational workload, such as digital signatures, RSA asymmetric encryption, and large-block data hash operations. Requests cannot be sent through hardware interrupts.

[0059] Medium priority: Medium priority is suitable for service requests with medium data volume and moderate real-time requirements, such as AES symmetric encryption services, and requests can be sent through hardware interrupts;

[0060] High priority: High priority is applicable to service requests that have high real-time requirements and need to be processed as soon as possible, such as MAC verification tasks in vehicle safety communication SecOC, which can send requests through hardware interrupts;

[0061] Emergency level priority: Emergency priority is suitable for requests that need to be processed immediately and cannot be delayed, such as RTMD detecting external intrusion, penalty measures when security startup fails, etc. Emergency priority runs directly in the interrupt context and sends a response in the interrupt after processing. There is no need to arrange task scheduling execution, eliminating the overhead of context switching, and ensuring the certainty of response time.

[0062] Thus, when the interrupt service unit of the present invention finds that there are tasks with medium, high and emergency priorities to be executed, it interrupts the currently executed background and low priority tasks, and gives priority to the high-level tasks. If there are two or more high-level tasks, the installation priority levels are executed in order from high to low, and the priorities are emergency priority, high priority and medium priority from high to low. The background and low priority tasks are executed in the order of the time when the tasks are dispatched.

[0063] In a specific embodiment of the present invention, the interrupt service unit is also used to perform data slicing processing on the task currently occupying the resource lock to form multiple grouped data when an information security task with a high priority level attempts to obtain a resource lock and fails, and release the resource lock after the current grouped data processing is completed, so that the information security task with a high priority level can successfully obtain the resource lock and resume operation, and after completion, the preempted low priority task can resume operation.

[0064] The present invention utilizes data slicing to divide the data (or tasks) to be processed in the atomic service, and then processes them in stages. Data slicing can effectively alleviate the priority inversion problem that may occur during the execution of different services. Priority inversion is usually caused by competition for the global resource lock of the HSM. By encapsulating different information security service requests into tasks of different priorities, concurrent execution of multiple services can be achieved. However, due to the limited resources of the HSM special function peripherals, such as the AES hardware accelerator, if two tasks use the AES hardware accelerator at the same time, priority inversion problems will be caused due to competition, which manifests as a high priority waiting for a low priority. Only after the low priority task releases the resources can the high priority task obtain the resource lock and execute normally. This priority inversion may cause high priority service requests to not be responded to in a timely manner, thereby affecting the overall performance of the HSM. Specifically, Figure 7 As shown, at system time t0, the low-priority service S0 starts to execute. At t1, the S0 service successfully obtains the HSM hardware accelerator resource lock during execution. At t2, the HSM hardware interrupt occurs, and the service request of the high-priority service S1 is obtained in the interrupt ISR (also known as the interrupt service unit). At t3, the system responds to the S1 service limitedly, so the S1 service preempts the S0 service to start execution. At t4, the S1 service tries to obtain the hardware acceleration resource lock during execution, but fails. Since the resource lock is already held by the S0 service, the S1 service can only give up the execution right. The S0 service completes execution and releases the resource lock at t5. Only then can the S1 service successfully obtain the resource lock and execute. The high-priority service S1 needs to wait for the low-priority service S0 to complete execution before it can successfully obtain the resource lock, resulting in a delay in the service completion time, thereby reducing the timeliness of the system response.

[0065] The interrupt service unit of the present invention processes data in fixed-length groups during the execution of information security services, especially when global hardware accelerators are required to participate in operations. After processing each group, the resource lock is released and an attempt is made to reacquire the resource lock to process the next group. The release and reacquisition of the resource lock is the timing for scheduling and executing high-priority tasks. This method effectively manages global resource competition and improves system performance. Specifically, Figure 2 As shown, at time t4, the S1 service fails to obtain the hardware accelerator resource lock and gives up the execution right. The interrupt service unit starts to process the data slice of the S0 service at time t4. After the S0 service occupies the resource lock and processes the fixed group data, it temporarily releases the resource lock. In this way, at time t5, S1 can successfully obtain the resource lock, seize S0 and resume operation. At time t7, the S1 service is completed, S0 re-acquires the resource lock and resumes operation. At time t8, the S0 service is completed. Figure 2 and Figure 7By comparison, it can be seen that when a low-priority task occupies a resource lock and a high-priority task cannot preempt it, the low-priority task is sliced ​​into data to obtain multiple groups. After one group is executed, the resource lock is released. In this way, the high-priority task can preempt the resource lock and start execution, so that the high-priority task does not need to wait for the low-priority task to complete execution before obtaining the resource lock for execution. This saves the waiting time of the high-priority task and solves the priority inversion problem.

[0066] Furthermore, during slicing processing, the interrupt service unit performs slicing according to the preset data slicing length of the corresponding level. Specifically, the background-level information security task sets the first slicing data length; the low-level information security task sets the second slicing data length, and the set second slicing data length is greater than the first slicing data length; the medium-level information security task sets the third slicing data length, and the set third slicing data length is greater than the second slicing data length; the high-level information security task and the emergency-level information security task do not perform data slicing and the processing is completed in one time.

[0067] The data slice processing methods with different priorities are shown in Table 1:

[0068] Service Priority Data Slicing Method Background Level 64-byte slices are processed in batches Low Level Slice 128 bytes and process in batches Intermediate 256-byte slices are processed in batches High Level No data slicing, one-time processing Emergency Level No data slicing is performed, and the processing is completed at one time in the interrupt environment

[0069] Table 1 - Table of data slicing methods with different priorities.

[0070] In a specific embodiment of the present invention, the atomic service unit includes a plurality of atomic service modules, each of which is configured with a service ID, and the service ID is formed by splicing a service type value, an algorithm type value, and an algorithm mode value;

[0071] The processing unit is also used to calculate a service ID value according to the service type, algorithm type and algorithm mode of the information security task, determine the atomic service module according to the calculated service ID value, and send the information security task to the determined atomic service module for execution.

[0072] When an information security service request occurs, the HSM encapsulates tasks of different priorities according to specific request parameters for scheduling and execution. The actual execution process of the service needs to be dispatched to a specific atomic service module. Since the HSM contains many atomic service modules, the present invention calculates the service ID through the request parameters with a unified format, retrieves the atomic service module according to the service ID, and dispatches it to the specific task to start execution.

[0073] Information security service request parameters follow the general parameter format, including service type, algorithm type, algorithm mode, input and output data addresses, etc. The service type, algorithm type, and algorithm mode can uniquely represent the specific atomic service requested for execution. Therefore, the service ID is determined based on this mapping relationship: service ID = service type value_algorithm type value_algorithm mode value. Specifically, Figure 3 As shown, the atomic service layer is retrieved according to the service ID, and the corresponding atomic service module is found to complete the service execution process.

[0074] The following two examples illustrate atomic service dispatch.

[0075] For example, if the ID value of a hash service request is calculated, the service type is 0x00, the algorithm type is x03, and the algorithm mode is x00, then the service ID value is 0x000300. Similarly, if the ID value of a symmetric encryption service request is calculated, the service type is 0x03, the algorithm type is 0x14, and the algorithm mode is 0x01, then the service ID value is 0x031401.

[0076] By introducing the calculation of service ID, the present invention enables the system to flexibly dispatch atomic services and adapt to different service request types and modes. It can also unify service request parameters, simplify the parameter processing process, improve system scalability, and meet new service requirements that may arise in the future.

[0077] In a specific embodiment of the present invention, the request and response unit is also used to obtain a session ID; the processing unit is also used to send the workspace corresponding to the obtained session ID as a parameter to the corresponding atomic service as a service operation space; the request and response unit is also used to simultaneously feedback the execution result and the session ID after the atomic service unit is executed.

[0078] Furthermore, in the system of the present invention, a total number of sessions is preset, and each session includes at least one workspace, such as Figure 5 As shown, before making an information security service request, the application layer first applies to open a session, that is, the application layer first sends a session application, and the request and response unit receives the session application and sends it to the processing unit, which checks whether there is an available session workspace. If so, it allocates a workspace for the session and generates a random number as a session ID, binds the session ID and the workspace, and sends the session ID to the application layer through the request and response unit. In this way, when the application layer makes a service request, it sends the session ID together, realizes the specified session ID, and provides a workspace for the running service.

[0079] The processing unit of HSM obtains the service request parameters, dispatches the atomic service, and initializes the workspace according to the specific atomic service module. Then, the workspace is sent as a parameter to the atomic service module as the service operation space, and finally the service is scheduled for execution. After the service is executed, the processing unit of HSM returns the session ID and response result to the application layer through the request and response unit at the same time. When there is no other information security service demand, the application layer applies to close the session and specifies the session ID. The processing unit of HSM closes the session, cleans up the workspace, and destroys the session ID.

[0080] like Figure 4 As shown, a schematic diagram of allocating workspace is shown. The session ID and session workspace of the present invention are bound to each other, so that the application layer distinguishes and uses different sessions through the session ID, and the HSM can quickly locate the workspace according to the session ID to perform operations such as querying the session status. During the operation of the algorithm, the atomic service module requires a computing space to save temporary data, etc., while the atomic service module itself does not save the workspace, and the required computing space is uniformly provided by the corresponding session. This session workspace mechanism effectively isolates different service data and ensures the execution security and independence of the requested service.

[0081] According to different information security service requests, the session space is allocated to different atomic service modules and becomes their dedicated operation space. Therefore, a specific session can only execute one service request at the same time, and it needs to wait for the last request to be completed before initiating the next service request. By allowing applications to apply for multiple sessions, HSM has the ability to process multiple service requests at the same time, realizing efficient and concurrent service processes.

[0082] In the present invention, five different priorities are set for information security services, and service requests are encapsulated into tasks for scheduling and execution. By setting different data slicing methods and execution processes, the needs of various information security service applications are met. Response service execution methods are also set for different priorities.

[0083] In order to better implement the service concurrency mechanism, the service ID mapping mechanism is introduced to dispatch the corresponding atomic service module for the task according to the service ID, and the session ID and session workspace mechanism are introduced to allocate an independent workspace for each atomic service module to provide a secure and dedicated service running environment. The concurrent information security service request and response process is realized through the session mechanism.

[0084] The present invention also provides a task scheduling method for an HSM, which is described below.

[0085] like Figure 6 As shown, the task scheduling method includes the following steps:

[0086] Execute step S11 to obtain an information security request; then execute step S12;

[0087] Execute step S12 to prioritize the acquired information security requests according to the set priority level, thereby forming information security tasks of corresponding priorities; then execute step S13;

[0088] Execute step S13, send the information security task of the corresponding priority to the corresponding atomic service for execution; then execute step S14;

[0089] Execute step S14. When executing information security tasks, based on the preemptive task scheduling mechanism, let the task with a high priority level preempt the task with a low priority level being executed, and give priority to the task with a high priority level. After completion, resume the execution of the task with a low priority level.

[0090] In a specific implementation of the present invention, when a task with a higher priority level preempts a task with a lower priority level being executed, if the information security task with a higher priority level fails in trying to obtain a resource lock, the task currently occupying the resource lock is subjected to data slicing processing to form a plurality of grouped data;

[0091] After the current group data processing is completed, the resource lock is released, allowing the information security task with a high priority level to successfully obtain the resource lock and resume operation. After completion, the preempted task with a low priority level is resumed.

[0092] like Figure 2 As shown, at system time t0, the low-priority service S0 starts to execute; at t1, during the execution of the S0 service, the HSM hardware accelerator resource lock is successfully obtained; at t2, the HSM hardware interrupt occurs, and the service request of the high-priority service S1 is obtained in the interrupt ISR; at t3, the system responds to the S1 service first, so the S1 service preempts the S0 service to start execution; at t4, during the execution of the S1 service, an attempt is made to obtain the hardware accelerator resource lock, but the acquisition fails because the resource lock is already held by the S0 service, so the S1 service can only give up the execution right; from t4 to t5, the S0 service performs data slicing processing, and after processing the fixed group data, the resource lock is temporarily released; at t5, S1 successfully obtains the resource lock, preempts S0 again and resumes operation; at t7, the S1 service is completed, S0 re-acquires the resource lock and resumes operation; at t8, the S0 service is completed.

[0093] In a specific embodiment of the present invention, the set priority levels include background level, low level, medium level, high level and emergency level;

[0094] Setting the first slice data length for the background level information security task;

[0095] Setting a second slice data length for a low-level information security task, wherein the set second slice data length is greater than the first slice data length;

[0096] A third slice data length is set for a medium-level information security task, and the set third slice data length is greater than the second slice data length;

[0097] If the priority level of the currently executing task is high or urgent, data slicing processing will not be performed on the currently executing task, and the resource lock will be released after the processing is completed.

[0098] Preferably, the first slice data length can be set to 64 bytes, for example, the second slice data length can be set to 128 bytes, for example, and the third slice data length can be set to 256 bytes.

[0099] In a specific implementation of the present invention, a service ID is set for the atomic service module, and the set service ID is formed by splicing a service type value, an algorithm type value, and an algorithm mode value;

[0100] When an information security task of corresponding priority is sent to the corresponding atomic service for execution, the service ID value is calculated according to the service type, algorithm type and algorithm mode of the information security task, the atomic service module is determined according to the calculated service ID value, and the information security task is sent to the determined atomic service module for execution.

[0101] In a specific implementation of the present invention, when obtaining the information security request, the session ID is also obtained;

[0102] When sending the information security task of the corresponding priority to the corresponding atomic service for execution, the workspace corresponding to the acquired session ID is sent as a parameter to the corresponding atomic service as a service operation space;

[0103] After the execution is completed, the execution result and session ID are fed back at the same time.

[0104] Preferably, the total number of sessions is preset through static configuration, and each session contains at least one workspace. Before making an information security service request, the application layer needs to apply to open a session. The HSM checks whether there is an available session workspace. If so, a workspace is allocated to the session, and a random number is generated as the session ID, the session ID is bound to the workspace, and then the session ID is returned to the application layer. When making a service request, the application layer needs to specify a session ID to represent the workspace running the service. The HSM obtains the service request parameters, performs atomic service dispatch, and initializes the workspace according to a specific atomic service module, and then sends the workspace as a parameter to the atomic service module as a service operation space, and finally schedules the service execution. After the service execution is completed, the HSM returns the session ID and the response result to the application layer at the same time. When there is no other information security service demand, the application layer applies to close the session and specifies the session ID. The HSM closes the session, cleans up the workspace, and destroys the session ID.

[0105] The present invention further provides a storage medium on which a program of the HSM task scheduling method is stored. When the program of the HSM task scheduling method is executed by a processor, steps of the HSM task scheduling method are implemented.

[0106] The present invention is described in detail above in conjunction with the embodiments of the accompanying drawings. A person skilled in the art can make various variations of the present invention according to the above description. Therefore, certain details in the embodiments should not constitute a limitation of the present invention, and the scope of protection of the present invention shall be defined by the scope of the attached claims.

Claims

1. A task scheduling method for HSM, characterized in that: The steps include: Get information security requests; Prioritize the acquired information security requests according to the set priority level, and then form information security tasks of corresponding priority; Send the information security tasks of corresponding priority to the corresponding atomic services for execution; When executing information security tasks, based on the preemptive task scheduling mechanism, tasks with higher priority levels preempt tasks with lower priority levels being executed, and tasks with higher priority levels are executed first. After completion, tasks with lower priority levels are resumed. Set a service ID for the atomic service module. The set service ID is formed by concatenating the service type value, algorithm type value, and algorithm mode value. When an information security task of corresponding priority is sent to the corresponding atomic service for execution, the service ID value is calculated according to the service type, algorithm type and algorithm mode of the information security task, the atomic service module is determined according to the calculated service ID value, and the information security task is sent to the determined atomic service module for execution.

2. The HSM task scheduling method according to claim 1, characterized in that: When a task with a higher priority level preempts a task with a lower priority level being executed, if the information security task with a higher priority level fails in its attempt to obtain a resource lock, the task currently occupying the resource lock is subjected to data slicing processing to form multiple grouped data; After the current group data processing is completed, the resource lock is released, allowing the information security task with a high priority level to successfully obtain the resource lock and resume operation. After completion, the preempted task with a low priority level is resumed.

3. The HSM task scheduling method according to claim 2, characterized in that: The priority levels set include background level, low level, medium level, high level and emergency level; Setting a first slice data length for a background level information security task; Setting a second slice data length for a low-level information security task, wherein the set second slice data length is greater than the first slice data length; A third slice data length is set for a medium-level information security task, and the set third slice data length is greater than the second slice data length; If the priority level of the currently executing task is high or urgent, data slicing processing will not be performed on the currently executing task, and the resource lock will be released after the processing is completed.

4. The HSM task scheduling method according to claim 1, characterized in that: When obtaining information security requests, the session ID is also obtained; When sending the information security task of the corresponding priority to the corresponding atomic service for execution, the workspace corresponding to the acquired session ID is sent as a parameter to the corresponding atomic service as a service operation space; After the execution is completed, the execution result and session ID are fed back at the same time.

5. A storage medium, characterized in that: The storage medium stores a program of the HSM task scheduling method, and when the program of the HSM task scheduling method is executed by the processor, the steps of the HSM task scheduling method according to any one of claims 1 to 4 are implemented.

6. A HSM hardware security system based on task scheduling, characterized in that: include: Request and response unit, used to obtain information security requests; A processing unit connected to the request and response unit, the processing unit is used to prioritize the acquired information security requests according to the set priority level, thereby forming information security tasks of corresponding priority; An atomic service unit connected to the processing unit, used to receive corresponding information security tasks for execution; An interrupt service unit connected to the processing unit and the atomic service unit, for allowing a task with a high priority level to preempt a task with a low priority level being executed based on a preemptive task scheduling mechanism when the atomic service unit executes an information security task, and giving priority to executing the task with a high priority level, and resuming execution of the task with a low priority level after completion; The atomic service unit includes a plurality of atomic service modules, each of which is configured with a service ID, and the service ID is formed by splicing a service type value, an algorithm type value, and an algorithm mode value; The processing unit is also used to calculate a service ID value according to the service type, algorithm type and algorithm mode of the information security task, determine the atomic service module according to the calculated service ID value, and send the information security task to the determined atomic service module for execution.

7. The HSM hardware security system based on task scheduling as claimed in claim 6, characterized in that: The interrupt service unit is also used to perform data slicing processing on the task currently occupying the resource lock to form multiple grouped data when a high-priority information security task attempts to obtain the resource lock but fails, and release the resource lock after the current grouped data processing is completed, so that the high-priority information security task can successfully obtain the resource lock and resume operation, and after completion, the preempted low-priority task can resume operation.

8. The HSM hardware security system based on task scheduling as claimed in claim 6, characterized in that: The request and response unit is also used to obtain a session ID; The processing unit is also used to send the workspace corresponding to the acquired session ID as a parameter to the corresponding atomic service as a service operation space; The request and response unit is also used to feed back the execution result and the session ID at the same time after the atomic service unit is executed.