Password service method and apparatus, and electronic device and storage medium
By judging the cryptographic service request in the electronic device, selecting the supported hardware security carrier or software implementation, providing cryptographic services that meet the needs, solving the problem that the hardware security carrier does not support cryptographic algorithms, and achieving application security assurance and improved maintenance efficiency. .
Patent Information
- Application Number
- PCT/CN2024/079147
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-03
- Filing Date
- 2024-02-28
- Publication Date
- 2024-09-12
AI Technical Summary
The hardware security carrier in electronic devices does not support certain cryptographic algorithms, resulting in the inability to provide corresponding cryptographic services. Moreover, replacing the hardware security carrier is complicated and cannot effectively provide cryptographic services for applications.
By judging the cryptographic algorithm and security level specified by the cryptographic service request sent by the application in the electronic device, the supported hardware security carrier or the cryptographic function implemented by the software is selected to provide cryptographic services that meet the needs.
It realizes the provision of any cryptographic service according to the application's cryptographic algorithm and security level requirements, guarantees the security of the application, and simplifies the maintenance and replacement process of the hardware security carrier.
Smart Images

Figure CN2024079147_12092024_PF_FP_ABST
Abstract
Description
Cryptographic service method, device, electronic device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 3, 2023, with application number 202310225313.6 and application name “Cryptographic Service Method, Device, Electronic Device and Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of cryptographic technology, and in particular to a cryptographic service method, device, electronic device, and storage medium. Background Art
[0003] Electronic devices, such as IoT devices, computers, mobile terminals, etc., are an important part of the new generation of information technology. With the continuous development of the Internet and the IoT, security issues have received widespread attention. The hardware security carriers included in electronic devices are diverse in form. Some electronic devices support hardware security carriers in the form of security chips, some electronic devices support hardware security carriers in the form of trusted execution environments, and some electronic devices support both security chips and trusted execution environments. Some electronic devices do not support hardware security carriers and use cryptographic functions implemented in software. In a related technology, an electronic device needs to maintain multiple cryptographic service installation packages corresponding to the multiple hardware security carriers it has. The hardware security carrier in the electronic device may not be able to provide the corresponding cryptographic service because it does not support a certain cryptographic algorithm, and replacing the hardware security carrier is relatively complicated, and it cannot effectively provide cryptographic services for applications on the electronic device.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a cryptographic service method, device, electronic device and storage medium to solve the problems existing in the related art.
[0006] In a first aspect, an embodiment of the present application provides a cryptographic service method, which is applied to an electronic device, wherein the electronic device includes a first hardware security carrier, and the cryptographic service method includes: receiving, by the first hardware security carrier, a cryptographic service request sent by an application in the electronic device, wherein the cryptographic service request specifies a cryptographic algorithm; and determining whether the first hardware security carrier supports the cryptographic algorithm, wherein if the first hardware security carrier supports the cryptographic algorithm, the first hardware security carrier provides cryptographic services for the application; and if the first hardware security carrier does not support the cryptographic algorithm, determining whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein if the security level corresponding to the cryptographic service request is the predetermined security level, the electronic device sends a predetermined signal to a second hardware security carrier, so that the second hardware security carrier can provide cryptographic services for the application; and if the security level corresponding to the cryptographic service request is lower than the predetermined security level, providing cryptographic services for the application through a cryptographic function implemented by software in the electronic device.
[0007] In a second aspect, an embodiment of the present application provides a cryptographic service method, which is applied to an electronic device, wherein the electronic device includes multiple first hardware security carriers, and the cryptographic service method includes: generating a cryptographic service request by an application in the electronic device, wherein the cryptographic service request includes predetermined requirements; and determining whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein if the security level of the cryptographic service request is lower than the predetermined security level, providing the cryptographic service to the application through a cryptographic function implemented by software in the electronic device; and if the security level of the cryptographic service request is the predetermined security level, selecting a first hardware security carrier that meets the predetermined requirements from the multiple first hardware security carriers, and providing cryptographic services to the application through the cryptographic function implemented by the first hardware security carrier that meets the predetermined requirements.
[0008] In a third aspect, an embodiment of the present application provides a cryptographic service device, which is deployed in an electronic device, wherein the electronic device includes a first hardware security carrier, and the cryptographic service device includes: a request receiving unit, configured to receive a cryptographic service request sent by an application in the electronic device by the first hardware security carrier, wherein the cryptographic service request specifies a cryptographic algorithm; and a processing unit, configured to determine whether the first hardware security carrier supports the cryptographic algorithm, wherein if the first hardware security carrier supports the cryptographic algorithm, the first hardware security carrier provides cryptographic services for the application; and if the first hardware security carrier does not support the cryptographic algorithm, determining whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein if the security level corresponding to the cryptographic service request is the predetermined security level, the electronic device sends a predetermined signal to the second hardware security carrier, so that the second hardware security carrier can provide cryptographic services for the application; and if the security level corresponding to the cryptographic service request is lower than the predetermined security level, providing cryptographic services for the application through a cryptographic function implemented by software in the electronic device.
[0009] In a fourth aspect, an embodiment of the present application provides a cryptographic service device, which is deployed in an electronic device, wherein the electronic device includes multiple first hardware security carriers, and the cryptographic service device includes: a request generation unit, configured to generate a cryptographic service request by an application in the electronic device, wherein the cryptographic service request includes predetermined requirements; and a processing unit, configured to determine whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein if the security level of the cryptographic service request is lower than the predetermined security level, the cryptographic service is provided to the application through a cryptographic function implemented by software in the electronic device; and if the security level of the cryptographic service request is the predetermined security level, the first hardware security carrier that meets the predetermined requirements among the multiple first hardware security carriers is selected, and the cryptographic service is provided to the application through the cryptographic function implemented by the first hardware security carrier that meets the predetermined requirements.
[0010] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the above methods when executing the computer program.
[0011] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any of the methods described above.
[0012] Compared with the prior art, this application has the following advantages:
[0013] According to an embodiment of the present application, based on the cryptographic algorithm specified in the cryptographic service request sent by an application in an electronic device and the security level corresponding to the cryptographic service request, a cryptographic function that meets the algorithm and security level requirements can be used to provide cryptographic services for the application. This can satisfy any cryptographic service requested by the application and ensure the security of the application.
[0014] According to the embodiments of the present application, when an application in an electronic device has no requirements for a cryptographic algorithm, a cryptographic function that meets the predetermined requirements and the security level requirements in the cryptographic service request can be used to provide cryptographic services for the application, thereby meeting any cryptographic service requested by the application and ensuring the security of the application.
[0015] The above description is only an overview of the technical solution of this application. In order to more clearly understand the technical means of this application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of this application more obvious and easy to understand, the specific implementation methods of this application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments according to the present application and should not be regarded as limiting the scope of the present application.
[0017] FIG1 is a flow chart illustrating a cryptographic service method according to an embodiment of the present application;
[0018] FIG2 is a flow chart illustrating a cryptographic service method according to another embodiment of the present application;
[0019] FIG3 is a block diagram showing a cryptographic service device according to an embodiment of the present application;
[0020] FIG4 is a block diagram showing a cryptographic service device according to another embodiment of the present invention; and
[0021] FIG5 is a block diagram illustrating an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] Hereinafter, only certain exemplary embodiments are briefly described. As will be appreciated by those skilled in the art, the described embodiments may be modified in various ways without departing from the spirit or scope of the present application. Therefore, the drawings and description are to be regarded as illustrative in nature and not restrictive.
[0023] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and all of them fall within the scope of protection of the embodiments of the present application.
[0024] An embodiment of the present application provides a cryptographic service method 100, which is applied to an electronic device, wherein the electronic device includes a first hardware security carrier, and the electronic device can be an electronic device such as an Internet of Things device, a computer, a mobile terminal, or a server. The cryptographic service method 100 of the present application will be described below with reference to FIG1 . FIG1 is a flowchart showing the cryptographic service method of an embodiment of the present application. As shown in FIG1 , the cryptographic service method 100 may include the following steps S101 to S106. Steps S101 to S106 will be described in detail below in conjunction with specific embodiments.
[0025] First, proceed to step S101. In step S101, the first hardware security element receives a cryptographic service request sent by an application in the electronic device, wherein the cryptographic service request specifies a cryptographic algorithm.
[0026] In the cryptographic service method 100, the first hardware security carrier may be a hardware security carrier such as Software Guard Extensions (SGX), Trusted Execution Environment (TEE), or Trusted Platform Module (TPM). In some embodiments, the application in the electronic device may be an artificial intelligence algorithm reasoning application in an artificial intelligence IoT all-in-one machine. In other embodiments, the application in the electronic device may be a video transmission application in a camera. The above is merely an example of the first hardware security carrier and the application in the electronic device. Those skilled in the art may apply the principles of this application to electronic devices that require cryptographic services according to actual conditions.
[0027] In some embodiments, a cryptographic service request sent by an application in an electronic device may include a specified cryptographic algorithm. Cryptographic algorithms can be categorized into three categories: symmetric cryptographic algorithms, asymmetric cryptographic algorithms, and hash algorithms. Symmetric cryptographic algorithms primarily include the AES algorithm and the SM4 algorithm, and their primary purpose is to encrypt and decrypt data. Asymmetric cryptographic algorithms primarily include the RSA algorithm, the ECC algorithm, and the SM2 algorithm, and their primary purpose is to digitally sign and verify data. Hash algorithms primarily include the SHA256 algorithm and the SM3 algorithm, and their primary purpose is to perform hash operations on data. For example, a cryptographic service request sent by an application in an electronic device may request symmetric encryption of a segment of video data, with the specified cryptographic algorithm being the AES algorithm. Another example may be a cryptographic service request sent by an application in an electronic device, with the specified cryptographic algorithm being the SM2 algorithm. The first hardware security element can obtain the cryptographic algorithm specified in the cryptographic service request by parsing the cryptographic service request sent by the application.
[0028] In some embodiments, when the first hardware security carrier receives a cryptographic service request sent by an application in an electronic device, the first hardware security carrier can authenticate the identity of the application. For example, the application in the electronic device, as a process, can send a cryptographic service request to the first hardware security carrier through IPC (Inter-Process Communication). After receiving the cryptographic service request, the first hardware security carrier can obtain the identity of the process (i.e., the application in the electronic device) and verify the identity of the process to determine whether the application is a real and legal application in the electronic device. Only after the verification is passed can the cryptographic service be provided to the application, thereby avoiding providing cryptographic services to counterfeit applications.
[0029] Next, the process proceeds to step S102. In step S102, it is determined whether the first hardware security element supports the cryptographic algorithm.
[0030] In some embodiments, the first hardware security element provides an interface for determining whether a certain algorithm is supported. For example, if the first hardware security element supports the AES algorithm, and the cryptographic algorithm specified in the cryptographic service request received by the first hardware security element is the SM4 algorithm, then the first hardware security element does not support the algorithm. For another example, if the first hardware security element supports the ECC algorithm, and the cryptographic algorithm specified in the cryptographic service request received by the first hardware security element is the ECC algorithm, then the first hardware security element supports the algorithm.
[0031] If the first hardware security element supports the cryptographic algorithm, the process proceeds to step S103. In step S103, the first hardware security element provides cryptographic services for the application.
[0032] The first hardware security carrier provides various cryptographic functions based on the cryptographic algorithms it supports. For example, if the first hardware security carrier supports the AES algorithm and the SM2 algorithm, the first hardware security carrier can provide a symmetric encryption function and a symmetric decryption function based on the AES algorithm, as well as a digital signature function and a signature verification function based on the SM2 algorithm. In one embodiment, the cryptographic service request sent by the application in the electronic device received by the first hardware security carrier is to perform symmetric encryption based on the AES algorithm for a piece of data. The first hardware security carrier supports the AES algorithm, so the first hardware security carrier uses the symmetric encryption function based on the AES algorithm to provide the cryptographic service request for the application. In another embodiment, the cryptographic service request sent by the application in the electronic device received by the first hardware security carrier is to perform digital signature based on the SM2 algorithm for a piece of data. The first hardware security carrier supports the SM2 algorithm, so the first hardware security carrier uses the digital signature function based on the SM2 algorithm to provide the cryptographic service request for the application.
[0033] If the first hardware security element does not support the cryptographic algorithm, the process proceeds to step S104. In step S104, it is determined whether the security level corresponding to the cryptographic service request is a predetermined security level.
[0034] In some embodiments, the cryptographic service request sent by the application in the electronic device may include a security level field. After the first hardware security carrier parses the cryptographic service request, the security level corresponding to the cryptographic service request can be obtained to determine whether the security level is a predetermined security level.
[0035] If the security level corresponding to the cryptographic service request is the predetermined security level, the process proceeds to step S105. In step S105, the electronic device sends a predetermined signal to the second hardware security element, so that the second hardware security element can provide cryptographic services for the application.
[0036] In some embodiments, the application in the electronic device can divide the security level of the cryptographic service request into two levels (i.e., high security level and low security level), and set the predetermined security level to the high security level. The security of the high security level is higher than that of the low security level, and the requirements of the high security level cryptographic service request for the robustness of the cryptographic function and the security of the key storage are higher than those of the low security level cryptographic service request. Since the first hardware security carrier does not support the cryptographic algorithm specified in the cryptographic service request sent by the application in the electronic device, and the security level corresponding to the cryptographic service request is the predetermined security level (i.e., high security level), the security of the cryptographic function implemented by software is low and cannot meet the requirements of the high security level. Therefore, the cryptographic function implemented by software cannot be used to provide cryptographic services for the application. A cryptographic function implemented by the second hardware security carrier is required to provide cryptographic services for the cryptographic service request, and the second hardware security carrier supports the cryptographic algorithm specified by the cryptographic service request. Because the security level corresponding to the cryptographic service request is a high security level, a high security level cryptographic service is required. The second hardware security carrier stores the key involved in the cryptographic operation in its own hardware, and the key cannot be stolen. The second hardware security carrier generates a random number involved in the cryptographic operation based on its own random temperature or random noise source. The random number cannot be predicted. Therefore, the second hardware security carrier can provide a high-security cryptographic function, thereby providing a high-security level of cryptographic services for applications in electronic devices.
[0037] In some embodiments, a second hardware security carrier can be connected to the electronic device to provide cryptographic services for the cryptographic service request. The difference between the first hardware security carrier and the second hardware security carrier is that the first hardware security carrier is a hardware security carrier installed on the electronic device before the electronic device leaves the factory, and the second hardware security carrier is a hardware security carrier installed on the electronic device after the electronic device is sold in order to meet the cryptographic application requirements. The second hardware security carrier can also be a hardware security carrier such as SGX, TEE, TPM. The electronic device can forward the cryptographic service request sent by the application in the electronic device to the second hardware security carrier, so that the second hardware security carrier provides cryptographic services for the application.
[0038] If the security level corresponding to the cryptographic service request is lower than the predetermined security level, the process proceeds to step S106. In step S106, cryptographic services are provided to the application through the cryptographic function implemented by software in the electronic device.
[0039] In some embodiments, an application in an electronic device can divide the security level of a cryptographic service request into two levels (i.e., a high security level and a low security level), with the predetermined security level set to a high security level. If the security level corresponding to the cryptographic service request is lower than the predetermined security level, i.e., the security level corresponding to the cryptographic service request is a low security level, cryptographic services are provided to the application through a cryptographic function implemented in software in the electronic device. Software-implemented cryptographic functions can support any cryptographic algorithm, but the security level of software-implemented cryptographic functions is lower than that of cryptographic functions implemented by hardware security elements. This is because software stores the key involved in the cryptographic operation in the electronic device's memory, which carries the risk of theft. Furthermore, software generates the random number involved in the cryptographic operation using a pseudo-random number algorithm, which carries the risk of being predicted, reducing the security level of the cryptographic function. Therefore, software-implemented cryptographic functions can only be used when the security level corresponding to the cryptographic service request is a low security level. In one embodiment, the cryptographic service request sent by the application in the electronic device and received by the first hardware security element is for symmetric encryption of a piece of data based on the SM4 algorithm, and the security level is lower than the predetermined security level. If the first hardware security element does not support the SM4 algorithm, a symmetric encryption function based on the SM4 algorithm implemented in software on the electronic device may be used to provide symmetric encryption services for the application. In another embodiment, the cryptographic service request sent by the application on the electronic device and received by the first hardware security element is for a digital signature based on the RSA algorithm for a piece of data, and the security level is lower than a predetermined security level. If the first hardware security element does not support the RSA algorithm, a digital signature function based on the RSA algorithm may be implemented in software on the electronic device to provide digital signature services for the application.
[0040] Before step S101, the cryptographic service method 100 also includes: obtaining a cryptographic service installation package, the cryptographic service installation package including: a first version sub-package, corresponding to the first hardware security carrier and the second hardware security carrier; and a second version sub-package, used to implement the software, wherein the cryptographic function library is installed into the electronic device through the first version sub-package and the second version sub-package.
[0041] In some embodiments, the electronic device can obtain the cryptographic service installation package from the security vendor. For example, the owner of the electronic device can obtain the cryptographic service installation package from a link provided by the security vendor and copy it to the electronic device. The security vendor can also push the cryptographic service installation package to the electronic device using OTA (Over The Air) technology. The above description of the method for the electronic device to obtain the cryptographic service installation package is only exemplary, and those skilled in the art can choose the method for obtaining the cryptographic service installation package according to actual circumstances.
[0042] In some embodiments, the electronic device may include multiple first hardware security carriers and second hardware security carriers, for example, including a first hardware security carrier 1, a first hardware security carrier 2, a second hardware security carrier 1, and a second hardware security carrier 2. The cryptographic service installation package may include multiple first version sub-packages, each of which has its corresponding supported hardware security carrier. For example, the cryptographic service installation package includes first version sub-packages 1 to first version sub-packages 10, first version sub-package 1 corresponds to the first hardware security carrier 1, first version sub-package 3 corresponds to the first hardware security carrier 2, first version sub-package 6 corresponds to the second hardware security carrier 1, and first version sub-package 9 corresponds to the second hardware security carrier 2. By installing the first version sub-package 1 to the first hardware security carrier 1, the cryptographic function library based on the first hardware security carrier 1 can be installed into the electronic device. Similarly, the first version sub-package in the cryptographic service installation package can be installed into the corresponding first hardware security carrier and second hardware security carrier in the same or similar manner, thereby installing the cryptographic function library based on the first hardware security carrier and the second hardware security carrier into the electronic device. The cryptographic service installation package may also include a second version sub-package, which is used to implement software that can also provide cryptographic services to applications. By installing the second version sub-package in an electronic device, the cryptographic function library implemented by the software can be installed in the electronic device.
[0043] In some embodiments, the cryptographic function library is installed into the electronic device through the first version sub-package and the second version sub-package, including: identifying the first hardware security carrier in the electronic device; installing the corresponding first version sub-package in the identified first hardware security carrier so as to install the cryptographic function library implemented by the first hardware security carrier into the electronic device; installing the second version sub-package so as to install the cryptographic function library implemented by the software into the electronic device.
[0044] Specifically, the electronic device can identify which first hardware security elements are installed in the electronic device and search the cryptographic service installation package for the first version sub-package corresponding to the first hardware security element. The corresponding first version sub-package is then installed in the identified first hardware security element, thereby installing the cryptographic function library implemented by the first hardware security element into the electronic device. After installing the first version sub-package, the second version sub-package also needs to be installed to install the software-implemented cryptographic function library into the electronic device, thereby flexibly meeting cryptographic service requests with low security requirements.
[0045] In some embodiments, in the above-mentioned step S105, the electronic device sends the predetermined signal to the second hardware security carrier so that the second hardware security carrier can provide the cryptographic service for the application, including: identifying the second hardware security carrier; installing the corresponding first version sub-package in the identified second hardware security carrier so as to install the cryptographic function library implemented by the second hardware security carrier into the electronic device; and providing the cryptographic service to the application through the cryptographic function implemented by the second hardware security carrier.
[0046] Specifically, the electronic device can identify which second hardware security elements are connected to the electronic device and search the cryptographic service installation package for the first version sub-package corresponding to the second hardware security element. The corresponding first version sub-package is then installed in the identified second hardware security element, thereby installing the cryptographic function library implemented by the second hardware security element into the electronic device. After the cryptographic function library is installed, cryptographic services can be provided to the application based on the cryptographic functions implemented by the second hardware security element.
[0047] In some embodiments, the second hardware security carrier supports the cryptographic algorithm, and the second hardware security carrier is in the list of hardware security carriers supported by the cryptographic service installation package. The second hardware security carrier needs to support the cryptographic algorithm specified in the cryptographic service request sent by the application in the electronic device. Based on this, the second hardware security carrier can provide cryptographic services for the application when the first hardware security carrier does not support the cryptographic algorithm. The second hardware security carrier also needs to be in the list of hardware security carriers supported by the cryptographic service installation package. Based on this, the second hardware security carrier can install the corresponding first version sub-package into the second hardware security carrier after the external electronic device is connected, thereby installing the cryptographic function library implemented by the second hardware security carrier into the electronic device.
[0048] In some embodiments, the hardware security carrier list includes the manufacturer information of the hardware security carrier and the model information of the hardware security carrier. The security manufacturer needs to adapt to the common hardware security carriers on the market in advance. After the adaptation is completed, the first version sub-package adapted to the hardware security carrier can be added to the cryptographic service installation package, and a list of hardware security carriers supported by the cryptographic service installation package can be made. The hardware security carrier list can include the manufacturer information of the hardware security carrier, such as the hardware security carrier manufacturer number, manufacturer information, etc., as well as the model information of the hardware security carrier. Based on this, the owner of the electronic device can select the hardware security carrier recorded in the hardware security carrier list as the second hardware security carrier according to the hardware security carrier list supported by the cryptographic service installation package, and connect it to the electronic device.
[0049] Based on the technical solution of the embodiment of the present application, an electronic device with multiple hardware security carriers can maintain only one cryptographic service installation package. When installing the cryptographic service, the corresponding first version sub-package is installed on the identified hardware security carrier to implement the cryptographic function based on the hardware security carrier. The second version sub-package can also be installed at the same time to implement the software-based cryptographic function. The process of maintaining the installation package and installing the cryptographic service is efficient and can effectively provide cryptographic services for applications in electronic devices.
[0050] Based on the technical solution of the embodiment of the present application, based on the cryptographic algorithm specified in the cryptographic service request sent by the application in the electronic device and the security level corresponding to the cryptographic service request, a cryptographic function that meets the algorithm and security level requirements can be used to provide cryptographic services for the application. Any cryptographic service requested by the application can be met to ensure the security of the application.
[0051] Based on the technical solution of the embodiment of the present application, different security carriers can be used to provide cryptographic services for the application according to the security level and cryptographic algorithm selected by the application in the electronic device. In high-concurrency scenarios, cryptographic computing resources can be reasonably scheduled, and this solution is scalable.
[0052] Another embodiment of the present application provides a cryptographic service method 200, which is applied to an electronic device, wherein the electronic device includes multiple first hardware security carriers, and the electronic device can be an electronic device such as an Internet of Things device, a computer, a mobile terminal, and a server. The cryptographic service method 200 of the present application will be described below with reference to Figure 2. Figure 2 is a flowchart showing the cryptographic service method of another embodiment of the present application. As shown in Figure 2, the cryptographic service method 200 may include the following steps S201 to S204. Steps S201 to S204 will be described in detail below in conjunction with specific embodiments.
[0053] First, proceed to step S201. In step S201, an application in the electronic device generates a cryptographic service request, wherein the cryptographic service request includes a predetermined requirement.
[0054] In the cryptographic service method 100, the first hardware security element may be a hardware security element such as SGX, TEE, or TPM. In some embodiments, the cryptographic service request generated by an application in the electronic device may not specify a cryptographic algorithm, but may include predetermined requirements. For example, the predetermined requirements may include symmetric encryption of a piece of data, digital signature of a piece of data, hashing of a piece of data, etc., without specifying a specific cryptographic algorithm.
[0055] Next, the process proceeds to step S202. In step S202, it is determined whether the security level corresponding to the cryptographic service request is a predetermined security level.
[0056] In some embodiments, the cryptographic service request generated by the application in the electronic device may include a security level field, and the electronic device may obtain the security level corresponding to the cryptographic service request to determine whether the security level is a predetermined security level.
[0057] If the security level of the cryptographic service request is lower than the predetermined security level, the process proceeds to step S203. In step S203, the cryptographic service is provided to the application through the cryptographic function implemented by software in the electronic device.
[0058] In some embodiments, an application in an electronic device may divide the security level of a cryptographic service request into two levels (i.e., a high security level and a low security level), and set the predetermined security level to a high security level. If the security level corresponding to the cryptographic service request is lower than the predetermined security level, that is, the security level corresponding to the cryptographic service request is a low security level, then cryptographic services are provided to the application through the cryptographic function implemented by the software in the electronic device. For example, if the cryptographic service request generated by the application in the electronic device is to symmetrically encrypt a piece of data, and the security level corresponding to the cryptographic service request is lower than the predetermined security level, and no cryptographic algorithm is specified, then a symmetric encryption function based on the SM4 algorithm or a symmetric encryption function based on the AES algorithm may be implemented by the software in the electronic device to provide symmetric encryption services to the application. Because the cryptographic service request does not specify a cryptographic algorithm, any symmetric cryptographic algorithm may be used as long as the predetermined requirements of the cryptographic service request are met.
[0059] If the security level corresponding to the cryptographic service request is the predetermined security level, the process proceeds to step S204. In step S204, a first hardware security element that meets the predetermined requirements is selected from the plurality of first hardware security elements, and cryptographic services are provided to the application using a cryptographic function implemented by the first hardware security element that meets the predetermined requirements.
[0060] In some embodiments, an application in an electronic device may divide the security level of a cryptographic service request into two levels (i.e., a high security level and a low security level), and set the predetermined security level to a high security level. There may be multiple first hardware security carriers in an electronic device, and the cryptographic algorithms they support may be different. For example, the first hardware security carrier in the electronic device includes a first hardware security carrier 1 and a first hardware security carrier 2. The first hardware security carrier 1 supports the ECC algorithm, and the first hardware security carrier 2 supports the SM4 algorithm. For example, the cryptographic service request generated by the application in the electronic device is to digitally sign a piece of data. The security level corresponding to the cryptographic service request is a predetermined security level, and no cryptographic algorithm is specified. Then, the first hardware security carrier that meets the predetermined requirements can be selected from the multiple first hardware security carriers, that is, the first hardware security carrier 1 is selected. The first hardware security carrier supports the ECC algorithm and can meet the digital signature requirements in the cryptographic service request. Then, the digital signature function implemented by the first hardware security carrier 1 provides cryptographic services for the application.
[0061] Based on the technical solution of the embodiments of the present application, when an application in an electronic device has no requirements for a cryptographic algorithm, a cryptographic function that meets the predetermined requirements and security level requirements in a cryptographic service request can be used to provide cryptographic services for the application, thereby meeting any cryptographic service requested by the application and ensuring the security of the application.
[0062] Corresponding to the application scenario and method of the method provided in the embodiment of the present application, an embodiment of the present application also provides a cryptographic service device 300, which is deployed in an electronic device, wherein the electronic device includes a first hardware security carrier, and the electronic device can be an electronic device such as an Internet of Things device, a computer, a mobile terminal, and a server. The cryptographic service device 300 of the present application will be described below with reference to Figure 3. Figure 3 is a structural block diagram of the cryptographic service device of an embodiment of the present application. As shown in Figure 3, the cryptographic service device 300 may include: a request receiving unit 301 and a processing unit 302.
[0063] The request receiving unit 301 is configured to receive, by the first hardware security element, a cryptographic service request sent by an application in the electronic device, wherein the cryptographic service request specifies a cryptographic algorithm.
[0064] The request receiving unit 301 may be a component in the electronic device, and the electronic device receives the cryptographic service request sent by an application in the electronic device through the component.
[0065] The processing unit 302 is configured to determine whether the first hardware security carrier supports the cryptographic algorithm, wherein, if the first hardware security carrier supports the cryptographic algorithm, the first hardware security carrier provides cryptographic services for the application; and if the first hardware security carrier does not support the cryptographic algorithm, determine whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein, if the security level corresponding to the cryptographic service request is the predetermined security level, the electronic device sends a predetermined signal to the second hardware security carrier so that the second hardware security carrier can provide cryptographic services for the application; and if the security level corresponding to the cryptographic service request is lower than the predetermined security level, provide cryptographic services for the application through the cryptographic function implemented by software in the electronic device.
[0066] The processing unit 302 may be a component in the electronic device, and the electronic device processes the cryptographic service request sent by the application in the electronic device through the component.
[0067] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.
[0068] Corresponding to the application scenario and method of the method provided in another embodiment of the present application, another embodiment of the present application further provides a cryptographic service device 400, which is deployed on an electronic device, wherein the electronic device includes multiple first hardware security carriers, and the electronic device can be an electronic device such as an Internet of Things device, a computer, a mobile terminal, and a server. The cryptographic service device 400 of the present application will be described below with reference to Figure 4. Figure 4 is a structural block diagram of the cryptographic service device of another embodiment of the present application. As shown in Figure 4, the cryptographic service device 400 may include: a request generation unit 401 and a processing unit 402.
[0069] The request generating unit 401 is configured to generate a cryptographic service request by an application in the electronic device, wherein the cryptographic service request includes a predetermined requirement.
[0070] The request generating unit 401 may be a component in the electronic device, through which the electronic device generates a cryptographic service request.
[0071] The processing unit 402 is configured to determine whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein, if the security level of the cryptographic service request is lower than the predetermined security level, the cryptographic service is provided to the application through the cryptographic function implemented by the software in the electronic device; and if the security level of the cryptographic service request is the predetermined security level, the first hardware security carrier that meets the predetermined requirements among the multiple first hardware security carriers is selected, and the cryptographic service is provided to the application through the cryptographic function implemented by the first hardware security carrier that meets the predetermined requirements.
[0072] The processing unit 402 may be a component in the electronic device, through which the electronic device processes a cryptographic service request generated by an application in the electronic device.
[0073] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.
[0074] According to an embodiment of the present application, based on the cryptographic algorithm specified in the cryptographic service request sent by an application in an electronic device and the security level corresponding to the cryptographic service request, a cryptographic function that meets the algorithm and security level requirements can be used to provide cryptographic services for the application. This can satisfy any cryptographic service requested by the application and ensure the security of the application.
[0075] According to the embodiments of the present application, when an application in an electronic device has no requirements for a cryptographic algorithm, a cryptographic function that meets the predetermined requirements and the security level requirements in the cryptographic service request can be used to provide cryptographic services for the application, thereby meeting any cryptographic service requested by the application and ensuring the security of the application.
[0076] According to an embodiment of the present application, the cryptographic service installation package includes installation sub-packages of all hardware security carriers on the electronic device. Through the cryptographic service installation package, all cryptographic function libraries can be installed on the electronic device, making it more convenient for the electronic device to maintain the cryptographic service installation package.
[0077] According to the embodiments of the present application, different security carriers can be used to provide cryptographic services for the application based on the security level and cryptographic algorithm selected by the application in the electronic device. In high-concurrency scenarios, cryptographic computing resources can be reasonably scheduled, making this solution scalable.
[0078] Figure 5 is a block diagram of an electronic device used to implement embodiments of the present application. As shown in Figure 5 , the electronic device includes a memory 501 and a processor 502. Memory 501 stores a computer program executable on processor 502. Processor 502 executes the computer program to implement the methods described in the above embodiments. Memory 501 and processor 502 may be present in one or more locations.
[0079] The electronic device also includes:
[0080] The communication interface 503 is used to communicate with external devices and perform data exchange transmission.
[0081] If the memory 501, processor 502, and communication interface 503 are implemented independently, the memory 501, processor 502, and communication interface 503 can be interconnected via a bus and communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. This bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, FIG5 shows only one thick line, but this does not mean that there is only one bus or only one type of bus.
[0082] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.
[0083] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.
[0084] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided in the embodiment of the present application.
[0085] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory. The input interface, the output interface, the processor and the memory are connected through an internal connection path. The processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.
[0086] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor that supports the Advanced RISC Machines (ARM) architecture.
[0087] Furthermore, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct RAM bus random access memory (DR RAM).
[0088] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.
[0089] In the description of this specification, the reference terms "one embodiment," "some embodiments," "example," "specific example," or "some examples" mean that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials, or characteristics described may be combined in any appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification, as well as features of different embodiments or examples, unless they are mutually inconsistent.
[0090] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Thus, a feature specified as "first" or "second" may explicitly or implicitly include at least one of such features. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.
[0091] Any process or method described in the flowchart or otherwise described herein can be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process. The scope of the preferred embodiments of the present application includes other implementations in which the functions may be performed in a different order than shown or discussed, including performing the functions substantially simultaneously or in reverse order depending on the functions involved.
[0092] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with such instruction execution systems, apparatuses or devices.
[0093] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.
[0094] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the aforementioned integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk, or an optical disk, etc.
[0095] The above is merely an exemplary embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various modifications or substitutions within the technical scope described in this application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A cryptographic service method, applied to an electronic device, wherein the electronic device includes a first hardware security carrier, and the cryptographic service method includes: Receiving, by the first hardware security carrier, a cryptographic service request sent by an application in the electronic device, wherein the cryptographic service request specifies a cryptographic algorithm; and Determine whether the first hardware security element supports the cryptographic algorithm, wherein: If the first hardware security carrier supports the cryptographic algorithm, the first hardware security carrier provides cryptographic services for the application; and If the first hardware security carrier does not support the cryptographic algorithm, determining whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein: If the security level corresponding to the cryptographic service request is the predetermined security level, the electronic device sends a predetermined signal to the second hardware security element so that the second hardware security element can provide cryptographic services for the application; and If the security level corresponding to the cryptographic service request is lower than the predetermined security level, cryptographic services are provided to the application through a cryptographic function implemented by software in the electronic device.
2. The cryptographic service method according to claim 1, wherein: Before receiving the cryptographic service request sent by the application in the electronic device, the method further includes: Obtain a password service installation package, which includes: A first version sub-package, corresponding to the first hardware security carrier and the second hardware security carrier; and The second version sub-package is used to implement the software, wherein: The cryptographic function library is installed into the electronic device through the first version sub-package and the second version sub-package.
3. The cryptographic service method according to claim 2, wherein the cryptographic function library is installed into the electronic device through the first version sub-package and the second version sub-package, comprising: Identifying a first hardware security carrier in the electronic device; Installing the corresponding first version sub-package in the identified first hardware security element so as to install the cryptographic function library implemented by the first hardware security element into the electronic device; The second version sub-package is installed so as to install the cryptographic function library implemented by the software into the electronic device.
4. The cryptographic service method according to claim 2, wherein the electronic device sends the predetermined signal to the second hardware security element so that the second hardware security element can provide the cryptographic service for the application, comprising: identifying the second hardware security carrier; Installing the corresponding first version sub-package in the identified second hardware security element so as to install the cryptographic function library implemented by the second hardware security element into the electronic device; The cryptographic function implemented by the second hardware security carrier provides the cryptographic service for the application.
5. The cryptographic service method according to claim 4, wherein the second hardware security carrier supports the cryptographic algorithm, and the second hardware security carrier is in the list of hardware security carriers supported by the cryptographic service installation package. 6 . The cryptographic service method according to claim 5 , wherein the hardware security carrier list includes manufacturer information of the hardware security carrier and model information of the hardware security carrier.
7. A cryptographic service method, applied to an electronic device, wherein the electronic device comprises a plurality of first hardware security carriers, and the cryptographic service method comprises: generating, by an application in the electronic device, a cryptographic service request, wherein the cryptographic service request includes a predetermined requirement; and Determine whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein: If the security level of the cryptographic service request is lower than the predetermined security level, providing the cryptographic service to the application through a cryptographic function implemented by software in the electronic device; and If the security level of the cryptographic service request is the predetermined security level, a first hardware security carrier that meets the predetermined requirements is selected from the multiple first hardware security carriers, and cryptographic services are provided for the application through the cryptographic function implemented by the first hardware security carrier that meets the predetermined requirements.
8. A cryptographic service device, deployed in an electronic device, the electronic device comprising a first hardware security carrier, the cryptographic service device comprising: a request receiving unit configured to receive, by the first hardware security carrier, a cryptographic service request sent by an application in the electronic device, wherein the cryptographic service request specifies a cryptographic algorithm; and A processing unit configured to determine whether the first hardware security element supports the cryptographic algorithm, wherein: If the first hardware security carrier supports the cryptographic algorithm, the first hardware security carrier provides cryptographic services for the application; and If the first hardware security carrier does not support the cryptographic algorithm, determining whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein: If the security level corresponding to the cryptographic service request is the predetermined security level, the electronic device sends a predetermined signal to the second hardware security element so that the second hardware security element can provide cryptographic services for the application; and If the security level corresponding to the cryptographic service request is lower than the predetermined security level, cryptographic services are provided to the application through a cryptographic function implemented by software in the electronic device.
9. A cryptographic service device, deployed in an electronic device, the electronic device comprising a plurality of first hardware security carriers, the cryptographic service device comprising: a request generating unit configured to generate a cryptographic service request by an application in the electronic device, wherein the cryptographic service request includes a predetermined requirement; and A processing unit configured to determine whether the security level corresponding to the cryptographic service request is a predetermined security level, wherein: If the security level of the cryptographic service request is lower than the predetermined security level, providing the cryptographic service to the application through a cryptographic function implemented by software in the electronic device; and If the security level of the cryptographic service request is the predetermined security level, selecting a first hardware security carrier that meets the predetermined requirements from among the plurality of first hardware security carriers, and The cryptographic functions implemented by the hardware security carrier provide cryptographic services for the application.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
11. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Negotiation method for cryptographic algorithm of data transport services in distribution network
CN107302428A
Cipher device and data encryption and decryption method thereof
CN109672519A
Cryptographic device for user to autonomously control data security level protection
CN110879880A
Password calling method and device, electronic equipment and storage medium
CN115549940A
Password service method and device, electronic equipment and storage medium
CN116226883A
