Method for implementing algorithm library operation of password card and related device

By designing an algorithm library with compatible software and hardware algorithm interfaces, the applicability of cryptographic cards in different scenarios has been solved, achieving flexible task sharing and efficient and secure computing performance, suitable for various business needs.

CN119886376BActive Publication Date: 2026-05-12ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
Filing Date
2024-12-19
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Due to factors such as size and price, existing password cards are not suitable for all business scenarios, and users cannot choose the appropriate usage method according to their actual needs.

Method used

Design an algorithm library that includes both software and hardware algorithm interfaces, which are compatible with each other and can collaborate between the server and cryptographic card to perform preset computation tasks. It supports a variety of algorithms, such as a mixture of post-quantum algorithms, national cryptographic algorithms, and international classical algorithms, and achieves flexible task distribution through a layered interface structure.

Benefits of technology

Users can choose the appropriate interface method according to their needs, reduce deployment costs, improve flexibility and security, adapt to different performance and security requirements, and provide efficient computing performance and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886376B_ABST
    Figure CN119886376B_ABST
Patent Text Reader

Abstract

The application discloses a kind of supporting password card algorithm library operation implementation method and related device, algorithm library has software algorithm interface and hardware algorithm interface, algorithm library calls software algorithm interface and / or hardware algorithm interface to complete preset operation task, wherein: software algorithm interface is connected with server signal, to realize preset operation task in server by preset algorithm;Hardware algorithm interface is connected with password card signal, to realize preset operation task in password card by preset algorithm;Software algorithm interface and hardware algorithm interface are compatible with each other.Compared with prior art, by setting software algorithm interface and hardware algorithm interface in algorithm library simultaneously in the application, user can select suitable use mode according to actual demand, and software algorithm interface and hardware algorithm interface are compatible with each other, software algorithm interface and hardware algorithm interface can cooperate to share load, deployment cost is low, and it is more flexible and convenient to deploy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cryptographic algorithm library technology, and in particular to a method and related apparatus for implementing algorithm library operations that support cryptographic cards. Background Technology

[0002] Due to factors such as size and price, password cards cannot be used in all business scenarios. Therefore, it is necessary to develop an algorithm library that allows users to choose the appropriate usage method according to their actual needs. Summary of the Invention

[0003] The purpose of this invention is to provide a method and related apparatus for implementing algorithm library operations that support cryptographic cards, so as to solve the technical problems in the prior art and allow users to choose the appropriate usage method according to their actual needs.

[0004] In a first aspect, the present invention provides a method for implementing algorithm library operations supporting cryptographic cards. The method is used to implement a preset computation task. The algorithm library has a software algorithm interface and a hardware algorithm interface. The algorithm library calls the software algorithm interface and / or the hardware algorithm interface to complete the preset computation task, wherein:

[0005] The software algorithm interface is connected to the server signal so that the preset calculation task can be implemented in the server through a preset algorithm;

[0006] The hardware algorithm interface is connected to the password card signal to implement the preset operation task within the password card through a preset algorithm;

[0007] in:

[0008] The software algorithm interface is compatible with the hardware algorithm interface.

[0009] As described above, in the algorithm library implementation method supporting cryptographic cards, the software algorithm interface and the hardware algorithm interface form the first-level interface of the algorithm library. The algorithm library also has second-level and third-level interfaces. The first-level interface, the second-level interface, the third-level interface, and the cryptographic card are sequentially connected by signals, wherein:

[0010] The software algorithm interface is used to receive raw data and use the server to implement the preset calculation task using the raw data. The hardware algorithm interface is used to receive raw data and call the secondary interface, pass the raw data to the secondary interface, and encapsulate the output data passed from the secondary interface into a format consistent with the software algorithm interface.

[0011] The secondary interface is used to construct an instruction data packet using the original data and call the tertiary interface to pass the instruction data packet to the tertiary interface, and to integrate the calculation results of the cryptographic card passed from the tertiary interface into output data and then pass it to the hardware algorithm interface.

[0012] The third-level interface is used to transmit the instruction data packet to the cryptographic card, and to receive the calculation result from the cryptographic card and then transmit it to the second-level interface.

[0013] The algorithm library implementation method for supporting cryptographic cards, as described above, preferably includes the following steps:

[0014] The hardware algorithm interface receives the raw data and calls the secondary interface to pass the raw data to the secondary interface;

[0015] The secondary interface uses the original data to construct an instruction data packet and calls the tertiary interface to pass the instruction data packet to the tertiary interface;

[0016] The third-level interface transmits the instruction data packet to the cryptographic card. After receiving the instruction data packet, the cryptographic card completes the preset calculation task and sends the calculation result to the third-level interface. The third-level interface then sends the calculation result to the second-level interface.

[0017] The secondary interface integrates the calculation results into output data and then transmits it to the hardware algorithm interface. The hardware algorithm interface adjusts the data format to be compatible with the software interface before outputting it to the user.

[0018] In the above-described method for implementing algorithm library operations for cryptographic cards, preferably, the hardware algorithm interface includes an internal hardware interface and an external hardware interface. The internal hardware interface performs operations using a key stored internally in the cryptographic card, and the external hardware interface performs operations using an external key.

[0019] In the above-described algorithm library operation implementation method for supporting cryptographic cards, preferably, when a key needs to be generated or used, the internal hardware interface transmits the index number corresponding to the key to the cryptographic card, and the cryptographic card reads or stores the key from the corresponding index location.

[0020] In the above-described method for implementing an algorithm library for supporting cryptographic cards, preferably, the preset algorithm employs any one of the following:

[0021] Post-quantum algorithms;

[0022] Chinese national cryptographic algorithm;

[0023] International classic algorithm;

[0024] A first hybrid algorithm based on the post-quantum algorithm and the national cryptographic algorithm;

[0025] A second hybrid algorithm based on the post-quantum algorithm and the international classical algorithm;

[0026] A third hybrid algorithm based on the aforementioned national cryptographic algorithm and the aforementioned international classical algorithm;

[0027] A fourth hybrid algorithm based on the post-quantum algorithm, the national cryptographic algorithm, and the international classical algorithm.

[0028] The above-described method for implementing an algorithm library for cryptographic cards preferably includes, wherein the national cryptographic algorithm comprises one or more of SM1, SM2, SM3, SM4, SM7, SM9 and ZUC, the post-quantum algorithm comprises one or more of Kyber and Dilithum, and the international classical algorithm comprises one or more of AES, RSA and ECDSA.

[0029] The algorithm library operation implementation method for supporting cryptographic cards as described above preferably includes at least one of random number generation, key generation, key encapsulation / decapsulation, encryption / decryption, signature / verification, and hash value calculation.

[0030] In a second aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the aforementioned method.

[0031] Thirdly, the present invention provides a computer-readable storage medium storing the aforementioned method.

[0032] Compared with existing technologies, this invention sets up both software algorithm interfaces and hardware algorithm interfaces in the algorithm library. Users can choose the appropriate usage method according to their actual needs. The software algorithm interface and the hardware algorithm interface are compatible with each other. The software algorithm interface and the hardware algorithm interface can cooperate to share the load, resulting in low deployment cost and more flexible and convenient deployment. Attached Figure Description

[0033] Figure 1 This is a flowchart of one of the computational implementation methods of the algorithm library provided in the embodiments of the present invention. Detailed Implementation

[0034] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0035] In a first aspect, embodiments of the present invention provide a method for implementing algorithm library operations supporting cryptographic cards. The method is used to implement a preset computation task. The algorithm library includes a software algorithm interface and a hardware algorithm interface. The algorithm library calls the software algorithm interface and / or the hardware algorithm interface to complete the preset computation task, wherein:

[0036] The software algorithm interface is used to connect to the server signal to perform preset computation tasks within the server using preset algorithms. The software algorithm interface can perform cryptographic operations on the server's general-purpose processor (such as CPU) through software programs without the need for additional hardware support and can run on any hardware platform that supports the software.

[0037] The hardware algorithm interface is used to connect with the cryptographic card signal to perform preset calculation tasks within the cryptographic card using preset algorithms. It utilizes the dedicated hardware of the cryptographic card to improve the security and performance of the calculations. Since the cryptographic calculations are performed on dedicated hardware, optimizations can be made for specific algorithms. Especially when dealing with complex cryptographic calculations, it can reduce calculation time and provide faster processing speed.

[0038] in:

[0039] The software algorithm interface and the hardware algorithm interface are compatible with each other, enabling them to collaborate and share the same algorithms and computational tasks. This allows the algorithm library to flexibly select the most suitable interface under different environments and requirements without having to change the preset algorithms or computational tasks. Keys and data can be migrated between the software algorithm interface and the hardware algorithm interface without affecting the security and performance of the algorithm library.

[0040] By ensuring compatibility between software and hardware algorithm interfaces, they can collaborate to share the load, resulting in lower deployment costs and greater flexibility. Users can freely switch between software and hardware algorithm interfaces to adapt to different performance and security requirements. In scenarios requiring high performance, computationally intensive tasks can be offloaded to the external hardware interface, while other tasks remain in the software interface. For steps requiring higher security, such as signing, the external hardware interface can be used to leverage the hardware's security features. When hardware acceleration is not required, the lower-cost software interface can be used, with the hardware interface utilized only when needed.

[0041] In the embodiments provided by this invention, the algorithm library adopts a layered design, having a first-level interface, a second-level interface, and a third-level interface. The first-level interface, the second-level interface, the third-level interface, and the cryptographic card are sequentially connected by signals, wherein:

[0042] The primary interfaces include software algorithm interfaces and hardware algorithm interfaces. Together, they provide users with an entry point to interact with the algorithm library. The software algorithm interface directly receives the raw data to be processed from the user or other system components, and uses the server's general-purpose processor and preset algorithms to perform preset computation tasks using the raw data. The hardware algorithm interface receives the raw data and calls the secondary interfaces, passing the raw data to the secondary interfaces. It can also encapsulate the output data passed from the secondary interfaces into a format consistent with the software algorithm interface, ensuring that the format is consistent with the output of the software algorithm interface. This allows users to have a consistent experience when using both interfaces.

[0043] The secondary interface, acting as an abstraction layer, hides the specific implementation details of the hardware. Within the algorithm library, it serves as a bridge between the primary and tertiary interfaces, coordinating data transfer and task execution. The secondary interface constructs instruction data packets from the raw data. These packets contain all the information required for the cryptographic card to perform calculations. Once the instruction data packets are constructed, the secondary interface calls the tertiary interface, which directly interacts with the cryptographic card and is responsible for sending the data packets. After the cryptographic card completes its calculations, the secondary interface receives the results from the tertiary interface, integrates these results into output data, and then sends it back to the primary interface, completing the entire calculation task.

[0044] The Level 3 interface is designed as a universal interface, supporting cryptographic cards of different models and brands. In the algorithm library, the Level 3 interface acts as a bridge for direct interaction with the cryptographic card. It is responsible for transmitting instruction data packets from the Level 2 interface to the cryptographic card and, after the cryptographic card completes the calculation, returning the result to the Level 2 interface. Specifically, the Level 3 interface receives instruction data packets from the Level 2 interface, which contain the specific computational tasks that the cryptographic card needs to perform. The Level 3 interface communicates with the cryptographic card via hardware communication protocols (such as SPI, I2C, USB, etc.), sending instruction data packets to the cryptographic card. After the cryptographic card completes the computational tasks in the instruction data packets, the Level 3 interface is responsible for receiving the computation results and passing them back to the Level 2 interface.

[0045] In the embodiments provided by this invention, a layered design of the algorithm library helps to provide a user-friendly abstraction layer while maintaining the flexibility and security of the underlying hardware and software implementation, thus improving the maintainability and scalability of the algorithm library. The first-level interface provides users with two compatible entry points for interacting with the algorithm library: a software algorithm interface and a hardware algorithm interface. The second-level interface ensures the efficient operation of the algorithm library and provides necessary error handling and data integration functions, enabling the first-level interface to interact smoothly with the cryptographic card. The third-level interface ensures efficient and secure communication between the algorithm library and the cryptographic card, and also provides necessary support for the second-level interface.

[0046] In one feasible implementation, the hardware algorithm interface includes both internal and external hardware interfaces. Both the internal and external hardware interfaces need to be compatible with the software algorithm interface. This is achieved by encapsulating the interfaces to provide a consistent calling method, thus maintaining interface consistency. Specifically:

[0047] The internal hardware interface uses keys stored inside the cryptographic card for computation. These keys are typically stored in the hardware security module (HSM) of the cryptographic card. Since the keys never leave the cryptographic card, the risk of the keys being intercepted during transmission is reduced. The keys are not easily accessed or leaked by outsiders. By reading and storing the keys directly on the cryptographic card, a high level of security is provided. It is suitable for scenarios that require high security and can reduce data transmission latency and improve overall performance.

[0048] When a key needs to be generated or used, the internal hardware interface only needs to pass the index number corresponding to the key to the cryptographic card, and the cryptographic card will then read or store the key from the corresponding index location. By using the index number to reference the key, the internal hardware interface simplifies the key management and retrieval process. This method allows the system to access the key through a unique identifier without directly processing the key itself.

[0049] Hardware external interfaces use external keys for computation. These keys may come from software, user input, or other external systems, thus providing greater flexibility and allowing them to be replaced as needed. This makes them suitable for scenarios that require flexibility and configurability.

[0050] In one feasible implementation, the preset algorithm employs any of the following:

[0051] Post-quantum algorithms provide quantum-safe data protection to ensure data security in the era of quantum computing, including one or more algorithms in Kyber and Dilithum.

[0052] The term "national cryptographic algorithm" refers to cryptographic algorithms approved by the State Cryptography Administration, including one or more of the following algorithms: SM1, SM2, SM3, SM4, SM7, SM9, and ZUC.

[0053] International classic algorithms refer to cryptographic algorithms that are widely used internationally, including one or more of AES, RSA, and ECDSA.

[0054] A first hybrid algorithm based on post-quantum and Chinese cryptographic algorithms combines both to provide a more flexible security solution. This hybrid approach can introduce post-quantum algorithms to address future security challenges while maintaining compatibility with traditional algorithms.

[0055] A second hybrid algorithm, based on post-quantum and classical international algorithms, combines both approaches to provide a more flexible security solution. This hybrid method can introduce post-quantum algorithms to address future security challenges while maintaining compatibility with traditional algorithms.

[0056] The third hybrid algorithm, based on Chinese national cryptographic algorithms and international classic algorithms, combines Chinese national cryptographic algorithms and international classic algorithms to provide stronger security and flexibility.

[0057] A fourth hybrid algorithm, based on post-quantum algorithms, Chinese national cryptographic algorithms, and international classical algorithms, combines these three approaches to provide a more flexible security solution. This hybrid method can introduce post-quantum algorithms to address future security challenges while maintaining compatibility with traditional algorithms.

[0058] By designing a variety of preset algorithms, the algorithm library provided by the embodiments of the present invention allows users to select suitable algorithms according to their actual needs. Whether it is a traditional national cryptographic algorithm or an emerging post-quantum algorithm, it can be supported in the same algorithm library, providing users with a comprehensive, flexible and forward-looking security solution to protect data from current and future potential threats.

[0059] In the embodiments provided by the present invention, the preset computation tasks include at least one of random number generation, key generation, key encapsulation / decapsulation, encryption / decryption, signature / verification, and hash value calculation. Since the software algorithm interface and the hardware algorithm interface are compatible with each other, each preset computation task can be implemented independently by the software algorithm interface and the hardware algorithm interface. Users can flexibly switch between software and hardware solutions according to performance, security or cost requirements.

[0060] For example: In the process of generating a key pair via the software algorithm interface -> signing via the software algorithm interface -> verifying the signature via the software algorithm interface, replacing any one or more steps with an external hardware interface will still allow the function to complete correctly. For example:

[0061] The steps are as follows: Hardware algorithm interface generates key pair -> Software algorithm interface signs -> Software algorithm interface verifies signature. Alternatively, software algorithm interface generates key pair -> hardware algorithm interface signs -> software algorithm interface verifies signature. All of these operations are feasible; users can choose the interface they need based on their actual requirements.

[0062] Reference Figure 1As shown, this invention provides an implementation method for an algorithm library, used to perform preset computation tasks within a cryptographic card using a preset algorithm. The algorithm library includes a first-level interface, a second-level interface, and a third-level interface. The implementation method includes the following steps:

[0063] Step S101: The hardware algorithm interface receives the raw data and calls the secondary interface to pass the raw data to the secondary interface. Specifically, the hardware algorithm interface is the entry point for the user to interact with the algorithm library. It receives raw data from the user or other systems. After receiving the raw data, the hardware algorithm interface calls the secondary interface and passes the raw data to it.

[0064] The hardware algorithm interface is used to receive raw data and call the secondary interface, pass the raw data to the secondary interface, and encapsulate the output data passed from the secondary interface into a format consistent with the software algorithm interface, ensuring that its format is consistent with the output of the software algorithm interface. This way, users can get a consistent experience when using the two interfaces.

[0065] Step S102: The secondary interface constructs an instruction data packet using the original data and calls the tertiary interface to pass the instruction data packet to the tertiary interface. Specifically, after receiving the original data, the secondary interface constructs the instruction data packet according to the requirements of the preset algorithm. These data packets contain all the information required for the cryptographic card to perform operations. After constructing the instruction data packet, the secondary interface calls the tertiary interface and passes the instruction data packet to it.

[0066] The secondary interface, as an abstraction layer, hides the specific implementation details of the hardware. In the algorithm library, it acts as a bridge between the primary and tertiary interfaces, responsible for coordinating data transmission and task execution. The secondary interface uses raw data to construct instruction data packets, which contain all the information required for the cryptographic card to perform operations. Once the instruction data packets are constructed, the secondary interface calls the tertiary interface to pass the instruction data packets to the tertiary interface.

[0067] Step S103: The third-level interface transmits the instruction data packet to the cryptographic card. After receiving the instruction data packet, the cryptographic card completes the preset calculation task and sends the calculation result to the third-level interface. The third-level interface then sends the calculation result to the second-level interface.

[0068] The Level 3 interface is designed as a universal interface, supporting cryptographic cards of different models and brands. In the algorithm library, the Level 3 interface acts as a bridge for direct interaction with the cryptographic card. It is responsible for transmitting instruction data packets from the Level 2 interface to the cryptographic card and, after the cryptographic card completes the calculation, returning the result to the Level 2 interface. Specifically, the Level 3 interface receives instruction data packets from the Level 2 interface, which contain the specific computational tasks that the cryptographic card needs to perform. The Level 3 interface communicates with the cryptographic card via hardware communication protocols (such as SPI, I2C, USB, etc.), sending instruction data packets to the cryptographic card. After the cryptographic card completes the computational tasks in the instruction data packets, the Level 3 interface is responsible for receiving the computation results and passing them back to the Level 2 interface.

[0069] Step S104: The secondary interface integrates the calculation results into output data and then transmits it to the hardware algorithm interface. The hardware algorithm interface adjusts the data format to be compatible with the software interface, and then outputs it to the user.

[0070] After the cryptographic card completes its calculations, the secondary interface receives the calculation results from the tertiary interface, integrates the results from the tertiary interface into output data, and then transmits it to the hardware algorithm interface to complete the entire calculation task.

[0071] Secondly, embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to implement the steps in any of the above method embodiments.

[0072] Specifically, the aforementioned electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the aforementioned processor, and the input / output device is connected to the aforementioned processor.

[0073] Specifically, in this embodiment, the processor described above can be configured to implement the following steps via a computer program:

[0074] Step S101: The hardware algorithm interface receives the raw data and calls the secondary interface to transfer the raw data to the secondary interface.

[0075] Step S102: The secondary interface uses the original data to construct an instruction data packet and calls the tertiary interface to pass the instruction data packet to the tertiary interface.

[0076] Step S103: The third-level interface transmits the instruction data packet to the cryptographic card. After receiving the instruction data packet, the cryptographic card completes the preset calculation task and sends the calculation result to the third-level interface. The third-level interface then sends the calculation result to the second-level interface.

[0077] Step S104: The secondary interface integrates the calculation results into output data and then transmits it to the hardware algorithm interface. The hardware algorithm interface adjusts the data format to be compatible with the software interface, and then outputs it to the user.

[0078] Thirdly, embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to implement the steps in any of the above method embodiments when running.

[0079] Specifically, in this embodiment, the storage medium can be configured to store a computer program for implementing the following steps:

[0080] Step S101: The hardware algorithm interface receives the raw data and calls the secondary interface to transfer the raw data to the secondary interface.

[0081] Step S102: The secondary interface uses the original data to construct an instruction data packet and calls the tertiary interface to pass the instruction data packet to the tertiary interface.

[0082] Step S103: The third-level interface transmits the instruction data packet to the cryptographic card. After receiving the instruction data packet, the cryptographic card completes the preset calculation task and sends the calculation result to the third-level interface. The third-level interface then sends the calculation result to the second-level interface.

[0083] Step S104: The secondary interface integrates the calculation results into output data and then transmits it to the hardware algorithm interface. The hardware algorithm interface adjusts the data format to be compatible with the software interface, and then outputs it to the user.

[0084] The above description, based on the embodiments shown in the figures, details the structure, features, and effects of the present invention. The above description is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or equivalent embodiments modified to have equivalent changes, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.

Claims

1. A method for implementing algorithm library operations supporting cryptographic cards, the method being used to implement a preset operation task, characterized in that, The algorithm library has software algorithm interfaces and hardware algorithm interfaces, which form the first-level interface of the algorithm library. The algorithm library also has second-level and third-level interfaces. The first-level interface, the second-level interface, the third-level interface, and the cryptographic card are sequentially connected by signals, wherein: When the software algorithm interface is invoked, the software algorithm interface is connected to the server signal so that the preset calculation task is implemented in the server through a preset algorithm; When the hardware algorithm interface is called, the hardware algorithm interface receives the raw data and calls the secondary interface to pass the raw data to the secondary interface. The secondary interface uses the raw data to construct an instruction data packet and calls the tertiary interface to pass the instruction data packet to the tertiary interface. The tertiary interface passes the instruction data packet to the cryptographic card so that the preset operation task can be implemented in the cryptographic card using a preset algorithm. Wherein: the software algorithm interface is compatible with the hardware algorithm interface, and the hardware algorithm interface encapsulates the operation result of the password card into a format consistent with the software algorithm interface.

2. The method according to claim 1, characterized in that: The method includes the following steps: The software algorithm interface is used to receive raw data and use the server to implement the preset calculation task using the raw data. The hardware algorithm interface is used to receive raw data and call the secondary interface, pass the raw data to the secondary interface, and encapsulate the output data passed from the secondary interface into a format consistent with the software algorithm interface. The secondary interface is used to construct an instruction data packet using the original data and call the tertiary interface to pass the instruction data packet to the tertiary interface, and to integrate the calculation results of the cryptographic card passed from the tertiary interface into output data and then pass it to the hardware algorithm interface. The third-level interface is used to transmit the instruction data packet to the cryptographic card, and to receive the calculation result from the cryptographic card and then transmit it to the second-level interface.

3. The method according to claim 2, characterized in that: The method includes the following steps: The hardware algorithm interface receives the raw data and calls the secondary interface to pass the raw data to the secondary interface; The secondary interface uses the original data to construct an instruction data packet and calls the tertiary interface to pass the instruction data packet to the tertiary interface; The third-level interface transmits the instruction data packet to the cryptographic card. After receiving the instruction data packet, the cryptographic card completes the preset calculation task and sends the calculation result to the third-level interface. The third-level interface then sends the calculation result to the second-level interface. The secondary interface integrates the calculation results into output data and then transmits it to the hardware algorithm interface. The hardware algorithm interface adjusts the data format to be compatible with the software interface before outputting it to the user.

4. The method according to claim 1, characterized in that: The hardware algorithm interface includes an internal hardware interface and an external hardware interface. The internal hardware interface uses the key stored inside the cryptographic card for calculation, while the external hardware interface uses an external key for calculation.

5. The method according to claim 4, characterized in that: When a key needs to be generated or used, the internal hardware interface transmits the index number corresponding to the key to the cryptographic card, which then reads or stores the key at the corresponding index location.

6. The method according to claim 1, characterized in that: The preset algorithm adopts any one of the following: Post-quantum algorithms; Chinese national cryptographic algorithm; International classic algorithm; A first hybrid algorithm based on the post-quantum algorithm and the national cryptographic algorithm; A second hybrid algorithm based on the post-quantum algorithm and the international classical algorithm; A third hybrid algorithm based on the aforementioned national cryptographic algorithm and the aforementioned international classical algorithm; A fourth hybrid algorithm based on the post-quantum algorithm, the national cryptographic algorithm, and the international classical algorithm.

7. The method according to claim 6, characterized in that: The national cryptographic algorithms include one or more of SM1, SM2, SM3, SM4, SM7, SM9 and ZUC; the post-quantum algorithms include one or more of Kyber and Dilithum; and the international classical algorithms include one or more of AES, RSA and ECDSA.

8. The method according to claim 1, characterized in that: The preset computational tasks include at least one of random number generation, key generation, key encapsulation / decapsulation, encryption / decryption, signature / verification, and hash value calculation.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores the method for performing any one of claims 1 to 8.