Method and device for managing encryption card resources used by multiple users based on operating system

By creating SDF instances and key indexes in the operating system, using the encryption card driver and SDF software stack to manage encryption card resources, the multi-user encryption card resource management problem in the absence of PCIe hardware is solved, and an efficient and secure encryption card is achieved Resource allocation and control.

CN118094524BActive Publication Date: 2024-11-19北京长擎量子技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410287322.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-13
Publication Date
2024-11-19
Estimated Expiration
2044-03-13

AI Technical Summary

Technical Problem

The existing encryption card virtualization technology requires PCIe hardware support, which limits the ability to manage multi-user encryption card resources without PCIe hardware.

Method used

Through the operating system's external encryption card driver and SDF software stack, the cryptographic algorithm interface conversion layer, logical implementation layer and packaging interface are used to create SDF instances and key indexes, manage encryption card resources for each system user, and realize calls to the encryption card and key management avoids the dependence of PCIe hardware.

Benefits of technology

Multiple users can manage encrypted card resources without PCIe hardware support, improve resource utilization efficiency and security, and enhance the encryption card resource control capabilities at the operating system level.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118094524B_ABST
    Figure CN118094524B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for managing encryption card resources used by multiple users based on an operating system, and relates to the technical field of resource management. The operating system arranges a cryptographic algorithm interface conversion layer, an SDF logic implementation layer, and an SDF encapsulation interface in an SDF software stack. In the SDF logic implementation layer, the system user is used as a unit to limit the use of encryption card resources by the system user by creating an SDF instance, and a corresponding key type and key index are created for the designated system user. The generated key of the corresponding key type is stored in the corresponding SDF instance according to the corresponding key index. When a target system user uses the SDF encapsulation interface to access the encryption card resources, the key is obtained from the corresponding SDF instance, and the encryption card is called so that the encryption card provides the target system user with the corresponding cryptographic operation. This solution does not require PCIe hardware support, and the management of encryption card resources used by multiple users can be achieved only by the operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of resource management, and in particular to a method and device for managing encryption card resources used by multiple users based on an operating system. Background Art

[0002] With the rapid development of the Internet, big data, artificial intelligence, and the Internet of Things, people are increasingly relying on cryptographic modules. As basic cryptographic devices, cryptographic modules provide identity authentication, algorithm acceleration, sensitive security parameter management, and protection services for various security applications in the financial, Internet, and industrial control industries.

[0003] Currently, software cryptographic modules and hardware cryptographic cards are used to provide cryptographic services at the same time. When allocating cryptographic card resources, cryptographic card virtualization technology is usually used to implement resource allocation. Existing cryptographic card virtualization technologies all require PCIe hardware support, and cryptographic devices need to support PCIe virtualization functions. Summary of the invention

[0004] The embodiment of the present invention provides a method and device for managing the use of encryption card resources by multiple users based on an operating system. Without the need for PCIe hardware support, the operating system implements the management of the use of encryption card resources by users.

[0005] In a first aspect, an embodiment of the present invention provides a method for managing encryption card resources used by multiple users based on an operating system, wherein the operating system is connected to an external encryption card, and the operating system includes an encryption card driver, an encryption card call interface, and an SDF software stack connected in sequence, and the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer, and an SDF encapsulation interface; the method is executed by the SDF logic implementation layer, and the method includes:

[0006] Create a corresponding SDF instance for each specified system user in the operating system, so that the specified system user with the SDF instance can use the encryption card resources;

[0007] Create a corresponding key type and key index for each specified system user, generate a key of the corresponding key type, and store the generated key in the corresponding SDF instance according to the corresponding key index;

[0008] When receiving a request from a target system user to access encryption card resources using an SDF encapsulation interface, determine whether there is an SDF instance of the target system user; if so, obtain a key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to implement a call to the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide corresponding cryptographic operations for the target system user; if not, deny the target system user access to encryption card resources.

[0009] In a second aspect, an embodiment of the present invention further provides a device for managing the use of encryption card resources by multiple users based on an operating system, wherein the operating system is connected to an external encryption card, and the operating system includes an encryption card driver, an encryption card calling interface, and an SDF software stack connected in sequence, and the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer, and an SDF encapsulation interface; the device is located in the SDF logic implementation layer, and the device includes:

[0010] The SDF instance creation unit is used to create a corresponding SDF instance for each designated system user in the operating system, so that the designated system user with the SDF instance created can use the encryption card resources;

[0011] A key generation unit, used to create a corresponding key type and key index for each designated system user, generate a key of the corresponding key type, and store the generated key in a corresponding SDF instance according to the corresponding key index;

[0012] The access processing unit is used to determine whether there is an SDF instance of the target system user when receiving a request from the target system user to access the encryption card resources using the SDF encapsulation interface; if so, obtain a key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to call the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide the target system user with corresponding cryptographic operations; if not, deny the target system user access to the encryption card resources.

[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in any embodiment of this specification is implemented.

[0014] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, enables the computer to execute the method described in any embodiment of this specification.

[0015] The embodiment of the present invention provides a method and device for managing the use of encryption card resources by multiple users based on an operating system. After the external encryption card is connected, the operating system installs the encryption card driver and obtains the encryption card calling interface, and deploys the cryptographic algorithm interface conversion layer, the SDF logic implementation layer and the SDF encapsulation interface in the SDF software stack. In the SDF logic implementation layer, the use of encryption card resources by system users is restricted by creating SDF instances in units of system users. After creating an SDF instance for a specified system user, a corresponding key type and key index are created for the specified system user, and the generated key of the corresponding key type is stored in the corresponding SDF instance according to the corresponding key index. When a target system user uses the SDF encapsulation interface to access the encryption card resources, the key is obtained from the corresponding SDF instance, and the encryption card is called so that the encryption card provides the target system user with the corresponding cryptographic operation. It can be seen that this solution does not require PCIe hardware support, and the management of the use of encryption card resources by multiple users can be achieved only by the operating system. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 This is a flow chart of a method for managing encryption card resources used by multiple users based on an operating system, provided by an embodiment of the present invention;

[0018] Figure 2 It is a schematic diagram of the structure of an encryption card software stack provided by an embodiment of the present invention;

[0019] Figure 3 is a hardware architecture diagram of an electronic device provided by an embodiment of the present invention;

[0020] Figure 4 The present invention provides a device structure diagram for managing encryption card resources used by multiple users based on an operating system, according to an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0022] Please refer to Figure 1 The embodiment of the present invention provides a method for managing encryption card resources used by multiple users based on an operating system, wherein the operating system is connected to an external encryption card, and the operating system includes an encryption card driver, an encryption card calling interface, and an SDF software stack connected in sequence, and the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer, and an SDF encapsulation interface; the method is executed by the SDF logic implementation layer, and the method includes:

[0023] Step 100, creating a corresponding SDF instance for each designated system user in the operating system, so that the designated system user with the SDF instance created can use the encryption card resources;

[0024] Step 102, creating a corresponding key type and key index for each designated system user, generating a key of the corresponding key type, and storing the generated key in the corresponding SDF instance according to the corresponding key index;

[0025] Step 104, when receiving a request from a target system user to access encryption card resources using an SDF encapsulation interface, determine whether an SDF instance of the target system user exists; if so, obtain a key of a corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to implement a call to the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide corresponding cryptographic operations for the target system user; if not, deny the target system user access to encryption card resources.

[0026] In the embodiment of the present invention, after the external encryption card is connected, the operating system installs the encryption card driver and obtains the encryption card calling interface, and deploys the cryptographic algorithm interface conversion layer, the SDF logic implementation layer and the SDF encapsulation interface in the SDF software stack. In the SDF logic implementation layer, the use of encryption card resources by system users is restricted by creating SDF instances in units of system users. After creating an SDF instance for a specified system user, a corresponding key type and key index are created for the specified system user, and the generated key of the corresponding key type is stored in the corresponding SDF instance according to the corresponding key index. When the target system user uses the SDF encapsulation interface to access the encryption card resources, the key is obtained from the corresponding SDF instance, and the encryption card is called so that the encryption card provides the target system user with the corresponding cryptographic operation. It can be seen that this solution does not require PCIe hardware support, and the management of encryption card resources used by multiple users can be achieved only by the operating system.

[0027] In the description Figure 1 Before describing the execution methods of each step, the structural relationship between the operating system and the encryption card is described.

[0028] Please refer to Figure 2 , which is a schematic diagram of the encryption card software stack structure. The operating system is connected to an external encryption card, which is an encryption card that supports national encryption. The operating system includes an encryption card driver, an encryption card calling interface and an SDF software stack that are connected in sequence.

[0029] Among them, the encryption card driver and the encryption card calling interface are provided by the encryption card manufacturer. By calling the encryption card calling interface to utilize the encryption card driver, the resource call of the encryption card can be realized.

[0030] In order to manage the use of encryption card resources by multiple users, a cryptographic algorithm interface conversion layer, an SDF logic implementation layer and an SDF encapsulation interface are arranged in the SDF software stack.

[0031] The following is a general description of each module in the SDF software stack.

[0032] First, the cryptographic algorithm interface conversion layer is used to convert the encryption card call interface into multiple cryptographic algorithm interfaces that implement different functions. When the cryptographic algorithm of the corresponding function is needed, the corresponding cryptographic algorithm interface is directly called, and the encryption card provides the corresponding cryptographic operation.

[0033] In an embodiment of the present invention, the cryptographic algorithm interface includes at least multiple of the following: a persistent key generation and revocation interface, a user key generation import and export interface, a national secret cryptographic operation interface, a key negotiation interface, a random number acquisition interface, a national secret SM3 hash calculation interface, and an HMAC calculation interface.

[0034] The following is a description of each of the above cryptographic algorithm interfaces.

[0035] 1. Persistent key generation and revocation interface: A persistent key refers to a key that can be persistently stored in an encryption card. Even if the machine is restarted or powered off, the key can still be stored in the encryption card. In the embodiment of the present invention, the persistent key is used to encrypt and protect the SDF instance parameters of the system user and the key of the SDF instance. The persistent key generation interface is used to generate a persistent key, and the persistent key revocation interface is used to clear the persistent key in the encryption card.

[0036] 2. User key generation import and export interface: When the user key is used for cryptographic operations, it needs to be decrypted from the outside and imported into the encryption card, and then the key data is used for cryptographic operations. The user key generation import interface is used to import the user key into the encryption card, and the user key generation export interface is used to export the generated user key to the specified location of the operating system, and then encrypted and stored by the encryption card.

[0037] 3. National secret cryptographic operation interface: The national secret cryptographic operation interface includes national secret SM4 symmetric cryptographic operation and national secret SM2 asymmetric cryptographic operation.

[0038] 4. Key negotiation interface: The key negotiation interface is the process interface for the caller and the responder to negotiate the session key, which consists of two interfaces of the caller and one interface of the responder. Some encryption cards will provide such interfaces. If the encryption card does not support such interfaces, the encryption algorithm can be called according to the SM2 key interaction protocol standard specification for assembly and implementation.

[0039] 5. Random number acquisition interface: used to obtain a random value of a specified number of bytes from the encryption card.

[0040] 6. National SM3 hash calculation interface: used to call the encryption card to implement the national SM3 hash calculation function.

[0041] 7. HMAC calculation interface: used to call the encryption card to implement HMAC (Hash-based Message Authentication Code) calculation.

[0042] Second, the SDF logic implementation layer is responsible for managing the use of encryption card resources by multiple users. For example, the logical function of the SDF encapsulation interface, the mapping of SDF instances and system users, and the security audit function. The implementation method of this part will be discussed later. Figure 1 The description process is explained below.

[0043] Third, the SDF encapsulation interface provides the use of the standard SDF encapsulation interface for the system user in the operating system through local inter-process communication. In the embodiment of the present invention, the SDF encapsulation interface includes at least any one of the following types of interfaces: session key interface, symmetric encryption operation interface, asymmetric encryption operation interface and hash operation interface.

[0044] Each type of SDF encapsulation interface mentioned above is described below.

[0045] Session key interface: Session keys are temporary keys that run on an SDF instance and are not permanently stored on the SDF instance. These session key interfaces include keys generated by key negotiation and session keys imported from outside.

[0046] Symmetric encryption operation interface: includes the symmetric encryption interface and decryption interface provided by the SDF instance.

[0047] Asymmetric encryption operation interface: including the asymmetric encryption interface and asymmetric decryption interface provided by the SDF instance, as well as the asymmetric signature and verification interface.

[0048] Hash operation interface: includes hash-related interfaces and HMAC interfaces provided by the SDF instance.

[0049] Since there are many types of encryption cards, the encryption card calling interfaces provided by encryption card manufacturers are different. In order to ensure the operating system's support for multiple encryption cards, in an embodiment of the present invention, the above-mentioned SDF encapsulation interface is provided to system users on the operating system, and the encryption card calling interface provided by the manufacturer is shielded for system users. When system users need to use encryption card resources, they can use the above-mentioned SDF encapsulation interface to access encryption card resources, which can facilitate the management of system users' use of encryption card resources.

[0050] Described below Figure 1 How the various steps are performed.

[0051] First, step 100 "creates a corresponding SDF instance for each designated system user in the operating system, so that the designated system user with the created SDF instance can use the encryption card resources" and step 102 "creates a corresponding key type and key index for each designated system user, generates a key of the corresponding key type, and stores the generated key in the corresponding SDF instance according to the corresponding key index" are explained at the same time.

[0052] There are multiple system users in the operating system, and the encryption card resources are limited, so the encryption card resources cannot guarantee the use of multiple system users at the same time. In order to allow system users in the operating system to use the encryption card reasonably, it is necessary to add the function of allocating encryption card resources to system users at the operating system level.

[0053] In the embodiment of the present invention, encryption card resources are allocated based on system users in the operating system, and a corresponding SDF instance is created for each designated system user in the operating system, so that the designated system users with created SDF instances can use the encryption card resources, and the system users without created SDF instances cannot use the encryption card resources.

[0054] Specifically, a corresponding SDF instance can be created for each designated system user in the operating system in the following manner, including: for each designated system user in the operating system, executing: obtaining the user name of the designated system user; determining whether the user name of the designated system user exists, and if so, creating a corresponding SDF instance directory according to the user name of the designated system user under the designated path, and creating an empty key file under the created SDF instance directory.

[0055] The designated system users may be some system users or all system users.

[0056] It should be noted that the designated paths of different designated system users may be the same or different, and each designated system user has its own SDF instance directory.

[0057] The empty key file created in the SDF instance directory is used to store the key of the specified system user. Therefore, after creating the SDF instance, you also need to generate the corresponding key for the specified system user.

[0058] In step 102, a corresponding key type and key index need to be created for each designated system user. The key type includes a symmetric key and an asymmetric key. The key index is used to indicate the storage location of the key.

[0059] In the embodiment of the present invention, the key type created for the specified system user can be one or two. For each key type created, a key of the corresponding key type needs to be generated. The key generation method is to directly call the cryptographic algorithm interface provided by the cryptographic algorithm interface conversion layer to achieve.

[0060] In one embodiment, a cryptographic algorithm interface of a corresponding function is called to generate a key of a corresponding key type in an encryption card. The cryptographic algorithm interface is a user key generation import and export interface. Specifically, when the key type is an asymmetric key, the user key generation import and export interface is called to generate an asymmetric key pair in the encryption card; when the key type is a symmetric key, the user key generation import and export interface is called to generate a symmetric key in the encryption card.

[0061] Accordingly, after the key is generated, it is necessary to store the generated key in the corresponding SDF instance according to the corresponding key index. Specifically, for each designated system user in the operating system, the following operations are performed: determining the key file in the corresponding SDF instance directory according to the user name of the designated system user, calculating the storage location according to the corresponding key index of the designated system user, and storing the generated key in the corresponding storage location of the key file.

[0062] In another embodiment, in order to ensure the storage security of the generated key, after the encryption card is used to generate the key of the corresponding key type in the above embodiment, the generated key can also be encrypted by the encryption card.

[0063] It can be understood that when the obtained key is a key encrypted by an encryption card, the key stored in the corresponding SDF instance is a key encrypted by the encryption card.

[0064] In one embodiment of the present invention, after creating an SDF instance for a system user, if it is necessary to prohibit the system user from accessing encryption card resources, this can be achieved by deleting the SDF instance of the system user. Specifically, the SDF instance directory of the system user under the specified path is deleted according to the user name of the system user.

[0065] Then, for step 104, when receiving a request from the target system user to access the encryption card resources using the SDF encapsulation interface, determine whether there is an SDF instance of the target system user; if so, obtain a key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to implement the call to the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide the target system user with corresponding cryptographic operations; if not, deny the target system user access to the encryption card resources.

[0066] Because the encryption card calling interface provided by the encryption card manufacturer is shielded when facing system users, system users can only use the SDF encapsulation interface to access encryption card resources. For example, when system users need to perform symmetric encryption operations, they use the symmetric encryption operation interface to access encryption card resources, so that the encryption card provides them with symmetric encryption operations; for example, when system users need to perform asymmetric encryption operations, they use the asymmetric encryption operation interface to access encryption card resources, so that the encryption card provides them with asymmetric encryption operations. By providing the SDF encapsulation interface to system users and shielding the encryption card calling interface, it is not only easy to manage the access of system users to encryption card resources, but also to achieve fine-grained encryption card resource management and control.

[0067] When receiving a request from the target system user to access the encryption card resources using the SDF encapsulation interface, it is first necessary to determine whether there is an SDF instance of the target system user based on the user name of the target system user. Only if there is an SDF instance of the target system user is the target system user eligible to access the encryption card resources. If there is no SDF instance, the target system user is denied access to the encryption card resources. Different SDF encapsulation interfaces need to use keys of corresponding key types to implement corresponding operations. Therefore, it is necessary to obtain the key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to implement the call to the encryption card through the encryption card call interface and the encryption card driver, so that the encryption card uses the obtained key to provide the target system user with the corresponding cryptographic operation.

[0068] It should be noted that if the key type of the key stored in the SDF instance is different from the key type required by the target system user to use the fixed SDF encapsulation interface, the target system user is denied access to the encryption card resources.

[0069] In one embodiment of the present invention, in order to implement the restricted management of system users' access to encryption card resources, it can also include: generating and storing a blacklist of SDF encapsulation interfaces, wherein the blacklist includes the types of SDF encapsulation interfaces that are prohibited from being accessed by designated system users. For example, designated system user A is prohibited from accessing the session key interface and the symmetric encryption operation interface, and designated system user B is prohibited from accessing the asymmetric encryption operation interface.

[0070] In the embodiment of the present invention, the blacklist may correspond to at least two forms, one is that the blacklist includes all designated system users whose access is prohibited, and the other is that each designated system user whose access is prohibited corresponds to a blacklist.

[0071] Regardless of the form of the blacklist, it must be stored in a fixed location so that it can be quickly retrieved from the fixed location for subsequent use.

[0072] Before storing the blacklist, the blacklist may also be encrypted using an encryption card to store the encrypted blacklist in a fixed location.

[0073] In one embodiment of the present invention, when the operating system uses a blacklist to implement restricted management of system users' access to encryption card resources, before obtaining a key of a corresponding key type from a corresponding SDF instance based on the key index of the target system user, it may also include: obtaining the blacklist, and determining according to the blacklist whether the type of SDF encapsulation interface used by the target system user when accessing the encryption card resources is a type that is prohibited from access; if so, prohibiting the target system user from accessing the encryption card resources; if not, executing the step of obtaining a key of a corresponding key type from the corresponding SDF instance based on the key index of the target system user.

[0074] Among them, when the target system user uses the SDF encapsulation interface to access the encryption card resources, if the blacklist is stored after being encrypted by the encryption card, the encryption card is used to decrypt the blacklist into the specified memory space of the SDF instance to determine whether the SDF encapsulation interface used by the target system user is prohibited.

[0075] In one embodiment of the present invention, since the encryption card resources are limited, in order to ensure that the designated system users can use the encryption card resources at the same time, it may also include: setting a maximum rate for cryptographic operations on the corresponding SDF instance for each designated system user.

[0076] Similarly, the maximum rate set is the same as the blacklist, and also needs to be stored in a fixed location, and before storage, the encryption card encrypts the file storing the maximum rate to store the encrypted file.

[0077] Correspondingly, after providing the corresponding cryptographic operation for the system user, it may also include: calculating the cryptographic operation rate in the SDF instance corresponding to the system user, determining whether the cryptographic operation rate exceeds the set maximum rate, if so, returning an error message, if not, continuing to provide the corresponding cryptographic operation for the system user.

[0078] In an embodiment of the present invention, the cryptographic operation rate in the SDF instance corresponding to the system user can be calculated in the following manner, including: determining whether the difference between the current time and the start time is greater than or equal to a set duration, and if so, calculating the quotient of the data length of the current cryptographic operation in the SDF instance corresponding to the system user and the difference, and determining the quotient as the cryptographic operation rate in the SDF instance corresponding to the system user; the start time is the time when the system user is received to access the encryption card resources using the SDF encapsulation interface.

[0079] It should be noted that the maximum rate can be set for the SDF instance of the system user, or for the specific cryptographic operation in the corresponding SDF instance. If it is set for the SDF instance of the system user, all the cryptographic operations in progress in the SDF instance will participate in the accumulation of data length and running time, and then the quotient of the accumulated data length and the accumulated running time will be used to determine the cryptographic operation rate; if it is set for a specific cryptographic operation, the rate will only be calculated for the specific cryptographic operation.

[0080] When setting up a specific cryptographic operation, a set of (start, size) can be defined in one implementation. alg Variable unit, where start indicates the start time of the cryptographic operation, size indicates the accumulated data length of the cryptographic operation, and alg indicates the specific cryptographic algorithm, such as symmetric algorithm, asymmetric algorithm and hash algorithm; at the same time, the time for the SDF encapsulation interface to run is defined as time current , the length of the data currently being cryptographically calculated is size current , the result of the cryptographic operation rate is V alg .

[0081] When receiving the target system user using the SDF encapsulation interface to access the encryption card resources, get the current time current , the current time current Determine the start time. alg The variable is empty. In the subsequent key calculation process, assuming that the set time is 1s, the following judgment is made:

[0082] Current (time current -start alg) value is less than 1s, the data length of the current cryptographic operation is current The value is added to size alg superior;

[0083] Current (time current -start alg ) value is greater than or equal to 1s, then the cryptographic operation rate V alg =(size alg +size current ) / (time current -start alg ).

[0084] In the embodiment of the present invention, by setting the maximum rate of cryptographic operations for the SDF instance of the system user, it is ensured that the encryption card will not be used all the time by a certain system user.

[0085] In the embodiment of the present invention, the SDF logic implementation layer can be implemented by the highest authority Root user of the operating system. In order to ensure the security of the operating system, preferably, the SDF logic implementation layer is implemented by the three-rights separation security mechanism in the secure operating system. Among them, the three-rights users of the three-rights separation security mechanism are the system administrator, the security administrator, and the audit administrator.

[0086] In the embodiment of the present invention, the creation and deletion of SDF instances are the responsibility of the security administrator, and the key generation and storage, blacklist setting and maximum rate setting are the responsibility of the system administrator. The audit administrator can view the management of the SDF instances of system users and the audit results of the calls of the SDF encapsulation interface to determine whether there is any violation of the use of encryption card resources.

[0087] like Figure 3 , Figure 4 As shown, the embodiment of the present invention provides a device for managing the use of encryption card resources by multiple users based on an operating system. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From the hardware level, Figure 3 As shown, a hardware architecture diagram of an electronic device in which a device for managing multi-user use of encryption card resources based on an operating system is provided in an embodiment of the present invention is located. Figure 3 In addition to the processor, memory, network interface, and non-volatile memory shown, the electronic device in the embodiment may also include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, Figure 4As shown, as a device in a logical sense, the CPU of the electronic device in which it is located reads the corresponding computer program in the non-volatile memory into the memory and runs it. This embodiment provides a device for managing the use of encryption card resources by multiple users based on an operating system, the operating system is connected to an encryption card, the operating system includes an encryption card driver, an encryption card calling interface and an SDF software stack connected in sequence, the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer and an SDF encapsulation interface; the device is located in the SDF logic implementation layer, and the device includes:

[0088] The SDF instance creation unit 401 is used to create a corresponding SDF instance for each designated system user in the operating system, so that the designated system user with the SDF instance created can use the encryption card resources;

[0089] The key generation unit 402 is used to create a corresponding key type and key index for each designated system user, generate a key of the corresponding key type, and store the generated key in the corresponding SDF instance according to the corresponding key index;

[0090] The access processing unit 403 is used to determine whether there is an SDF instance of the target system user when receiving a request from the target system user to access the encryption card resources using the SDF encapsulation interface; if so, obtain a key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to call the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide the target system user with corresponding cryptographic operations; if not, deny the target system user access to the encryption card resources.

[0091] In one embodiment of the present invention, the SDF instance creation unit is specifically used to: for each designated system user in the operating system, execute: obtaining the user name of the designated system user; determining whether the user name of the designated system user exists, and if so, creating a corresponding SDF instance directory according to the user name of the designated system user under a designated path, and creating an empty key file under the created SDF instance directory;

[0092] When the key generation unit stores the generated key in the corresponding SDF instance according to the corresponding key index, it specifically includes: for each designated system user in the operating system, it executes: determining the key file under the corresponding SDF instance directory according to the user name of the designated system user, calculating the storage location according to the corresponding key index of the designated system user, and storing the generated key in the corresponding storage location of the key file.

[0093] In one embodiment of the present invention, the cryptographic algorithm interface conversion layer is used to convert the encryption card call interface into a plurality of cryptographic algorithm interfaces that implement different functions;

[0094] When the key generation unit generates a key of a corresponding key type, the key generation unit specifically includes: calling a cryptographic algorithm interface of a corresponding function, generating a key of a corresponding key type in an encryption card, and encrypting the generated key using the encryption card;

[0095] The key stored in the corresponding SDF instance is the key encrypted by the encryption card.

[0096] In one embodiment of the present invention, the cryptographic algorithm interface includes at least multiple of the following: persistent key generation and revocation interface, user key generation import and export interface, national secret cryptographic operation interface, key negotiation interface, random number acquisition interface, national secret SM3 hash calculation interface and HMAC calculation interface.

[0097] In one embodiment of the present invention, the SDF encapsulation interface includes at least any one of the following types of interfaces: a session key interface, a symmetric encryption operation interface, an asymmetric encryption operation interface, and a hash operation interface;

[0098] It also includes: a blacklist generating unit, which is used to generate and store a blacklist of SDF encapsulation interfaces, wherein the blacklist includes the types of SDF encapsulation interfaces that are prohibited from being accessed by designated system users;

[0099] The access processing unit is also used to: obtain the blacklist, and determine whether the type of SDF encapsulation interface used by the target system user when accessing the encryption card resources is a prohibited access type based on the blacklist. If so, the target system user is prohibited from accessing the encryption card resources; if not, the key of the corresponding key type is obtained from the corresponding SDF instance based on the key index of the target system user.

[0100] In one embodiment of the present invention, it further comprises: a rate setting unit, configured to set a maximum rate of cryptographic operations on a corresponding SDF instance for each designated system user;

[0101] The access processing unit is also used to calculate the cryptographic operation rate in the SDF instance corresponding to the system user, determine whether the cryptographic operation rate exceeds the set maximum rate, and if so, return an error message; if not, continue to provide the corresponding cryptographic operation for the system user.

[0102] In one embodiment of the present invention, when the access processing unit calculates the cryptographic operation rate in the SDF instance corresponding to the system user, it specifically includes: determining whether the difference between the current time and the start time is greater than or equal to the set duration, and if so, calculating the quotient of the data length of the current cryptographic operation in the SDF instance corresponding to the system user and the difference, and determining the quotient as the cryptographic operation rate in the SDF instance corresponding to the system user; the start time is the time when the system user is received to access the encryption card resources using the SDF encapsulation interface.

[0103] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on a device for managing the use of encryption card resources by multiple users based on an operating system. In other embodiments of the present invention, a device for managing the use of encryption card resources by multiple users based on an operating system may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0104] The information interaction, execution process and other contents between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.

[0105] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, a method for managing the use of encryption card resources by multiple users based on an operating system in any embodiment of the present invention is implemented.

[0106] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes a method for managing the use of encryption card resources by multiple users based on an operating system in any embodiment of the present invention.

[0107] Specifically, a system or device equipped with a storage medium can be provided, on which software program code that implements the functions of any of the above-mentioned embodiments is stored, and a computer (or CPU or MPU) of the system or device can be enabled to read and execute the program code stored in the storage medium.

[0108] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0109] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.

[0110] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0111] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion module connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or expansion module is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0112] It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical factors in the process, method, article or device including the elements.

[0113] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.

[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for managing multiple users using encryption card resources based on an operating system, characterized in that: The operating system is connected to an external encryption card, and the operating system includes an encryption card driver, an encryption card calling interface and an SDF software stack connected in sequence, and the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer and an SDF encapsulation interface; the cryptographic algorithm interface conversion layer is used to convert the encryption card calling interface into a plurality of cryptographic algorithm interfaces that implement different functions; The method is performed by the SDF logic implementation layer, and the method includes: Create a corresponding SDF instance for each specified system user in the operating system, so that the specified system user with the SDF instance can use the encryption card resources; Create a corresponding key type and key index for each specified system user, generate a key of the corresponding key type, and store the generated key in the corresponding SDF instance according to the corresponding key index; When receiving a request from a target system user to access encryption card resources using an SDF encapsulation interface, determine whether an SDF instance of the target system user exists; if so, obtain a key of a corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to call the encryption card through the encryption card calling interface and the encryption card driver, so that the encryption card uses the obtained key to provide corresponding cryptographic operations for the target system user; if not, deny the target system user access to encryption card resources; The step of creating a corresponding SDF instance for each specified system user in the operating system includes: For each designated system user in the operating system, the following operations are performed: obtaining the user name of the designated system user; determining whether the user name of the designated system user exists; if so, creating a corresponding SDF instance directory according to the user name of the designated system user in the designated path, and creating an empty key file in the created SDF instance directory; The step of storing the generated key into the corresponding SDF instance according to the corresponding key index includes: For each designated system user in the operating system, the following steps are performed: determining the key file in the corresponding SDF instance directory according to the user name of the designated system user, calculating the storage location according to the corresponding key index of the designated system user, and storing the generated key in the corresponding storage location of the key file.

2. The method according to claim 1, characterized in that The generating of a key of a corresponding key type comprises: Call the cryptographic algorithm interface of the corresponding function, generate a key of the corresponding key type in the encryption card, and encrypt the generated key using the encryption card; The key stored in the corresponding SDF instance is the key encrypted by the encryption card.

3. The method according to claim 2, characterized in that The cryptographic algorithm interface includes at least several of the following: persistent key generation and revocation interface, user key generation import and export interface, national secret cryptographic operation interface, key negotiation interface, random number acquisition interface, national secret SM3 hash calculation interface and HMAC calculation interface.

4. The method according to claim 1, characterized in that: The SDF encapsulation interface includes at least one of the following types of interfaces: a session key interface, a symmetric encryption operation interface, an asymmetric encryption operation interface, and a hash operation interface; The method further includes: generating and storing a blacklist of SDF encapsulation interfaces, wherein the blacklist includes types of SDF encapsulation interfaces that are prohibited for access by designated system users; Before obtaining the key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user, it also includes: obtaining the blacklist, and determining whether the type of SDF encapsulation interface used by the target system user when accessing the encryption card resources is a prohibited access type according to the blacklist, if so, prohibiting the target system user from accessing the encryption card resources, if not, executing the acquisition of the key of the corresponding key type from the corresponding SDF instance based on the key index of the target system user.

5. The method according to claim 1, characterized in that Also includes: Set the maximum rate of cryptographic operations on the corresponding SDF instance for each specified system user; After providing the corresponding cryptographic operations for the system user, it also includes: calculating the cryptographic operation rate in the SDF instance corresponding to the system user, determining whether the cryptographic operation rate exceeds the set maximum rate, if so, returning an error message, if not, continuing to provide the corresponding cryptographic operations for the system user.

6. The method according to claim 5, characterized in that The calculating of the cryptographic operation rate in the SDF instance corresponding to the system user includes: Determine whether the difference between the current time and the start time is greater than or equal to the set duration. If so, calculate the quotient of the data length of the current cryptographic operation in the SDF instance corresponding to the system user and the difference, and determine the quotient as the cryptographic operation rate in the SDF instance corresponding to the system user; the start time is the time when the system user is received to access the encryption card resources using the SDF encapsulation interface.

7. A device for managing multiple users' use of encryption card resources based on an operating system, characterized in that: The operating system is connected to an external encryption card, and the operating system includes an encryption card driver, an encryption card calling interface and an SDF software stack connected in sequence, and the SDF software stack includes a cryptographic algorithm interface conversion layer, an SDF logic implementation layer and an SDF encapsulation interface; the cryptographic algorithm interface conversion layer is used to convert the encryption card calling interface into a plurality of cryptographic algorithm interfaces that implement different functions; The device is located in the SDF logic implementation layer, and the device includes: The SDF instance creation unit is used to create a corresponding SDF instance for each designated system user in the operating system, so that the designated system user with the SDF instance created can use the encryption card resources; A key generation unit, used to create a corresponding key type and key index for each designated system user, generate a key of the corresponding key type, and store the generated key in a corresponding SDF instance according to the corresponding key index; The access processing unit is used to determine whether there is an SDF instance of the target system user when receiving a request from the target system user to access the encryption card resources using the SDF encapsulation interface; if so, obtain a key of a corresponding key type from the corresponding SDF instance based on the key index of the target system user, and use the cryptographic algorithm interface conversion layer to implement the call to the encryption card through the encryption card call interface and the encryption card driver, so that the encryption card uses the obtained key to provide the target system user with the corresponding cryptographic operation; if not, deny the target system user access to the encryption card resources; The SDF instance creation unit is specifically used to: for each designated system user in the operating system, execute: obtaining the user name of the designated system user; determining whether the user name of the designated system user exists, and if so, creating a corresponding SDF instance directory according to the user name of the designated system user under a designated path, and creating an empty key file under the created SDF instance directory; When the key generation unit stores the generated key in the corresponding SDF instance according to the corresponding key index, it specifically includes: for each designated system user in the operating system, it executes: determining the key file under the corresponding SDF instance directory according to the user name of the designated system user, calculating the storage location according to the corresponding key index of the designated system user, and storing the generated key in the corresponding storage location of the key file.

8. The device according to claim 7, characterized in that When the key generation unit generates a key of a corresponding key type, the key generation unit specifically includes: calling a cryptographic algorithm interface of a corresponding function, generating a key of a corresponding key type in an encryption card, and encrypting the generated key using the encryption card; The key stored in the corresponding SDF instance is the key encrypted by the encryption card.

9. The device according to claim 8, characterized in that The cryptographic algorithm interface includes at least several of the following: persistent key generation and revocation interface, user key generation import and export interface, national secret cryptographic operation interface, key negotiation interface, random number acquisition interface, national secret SM3 hash calculation interface and HMAC calculation interface.

10. The device according to claim 7, characterized in that The SDF encapsulation interface includes at least one of the following types of interfaces: a session key interface, a symmetric encryption operation interface, an asymmetric encryption operation interface, and a hash operation interface; It also includes: a blacklist generating unit, which is used to generate and store a blacklist of SDF encapsulation interfaces, wherein the blacklist includes the types of SDF encapsulation interfaces that are prohibited from being accessed by designated system users; The access processing unit is also used to: obtain the blacklist, and determine whether the type of SDF encapsulation interface used by the target system user when accessing the encryption card resources is a prohibited access type based on the blacklist. If so, the target system user is prohibited from accessing the encryption card resources; if not, the key of the corresponding key type is obtained from the corresponding SDF instance based on the key index of the target system user.

11. The device according to claim 7, characterized in that Also includes: A rate setting unit, used to set a maximum rate of cryptographic operations on a corresponding SDF instance for each designated system user; The access processing unit is also used to calculate the cryptographic operation rate in the SDF instance corresponding to the system user, determine whether the cryptographic operation rate exceeds the set maximum rate, and if so, return an error message; if not, continue to provide the corresponding cryptographic operation for the system user.

12. The device according to claim 11, characterized in that When calculating the cryptographic operation rate in the SDF instance corresponding to the system user, the access processing unit specifically includes: determining whether the difference between the current time and the start time is greater than or equal to the set duration; if so, calculating the quotient of the data length of the current cryptographic operation in the SDF instance corresponding to the system user and the difference, and determining the quotient as the cryptographic operation rate in the SDF instance corresponding to the system user; the start time is the time when the system user is received to access the encryption card resources using the SDF encapsulation interface.

13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

14. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 6.