Apparatus and method for performing cryptographic algorithms

By introducing policy binding into HSM devices, client programs are allowed to execute encryption algorithms that are not pre-stored on the HSM, which solves the problem of insufficient security and flexibility when upgrading HSM devices and achieves the effect of efficiently executing new encryption algorithms without interrupting services.

CN116235174BActive Publication Date: 2026-11-27NCIPHER SECURITY LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202180056692.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-08-07
Filing Date
2021-08-05
Publication Date
2026-11-27
Estimated Expiration
2041-08-05

AI Technical Summary

Technical Problem

Existing Hardware Security Module (HSM) devices require service interruption and suffer from insufficient security and flexibility when upgrading or adding new encryption algorithms.

Method used

By introducing policy binding into HSM devices, client programs are allowed to execute encryption algorithms that are not pre-stored on the HSM, ensuring both security and flexibility by leveraging access control lists and policy-constrained algorithms.

Benefits of technology

It enables the efficient execution of new encryption algorithms or new combinations of existing algorithms without interrupting HSM services, thereby improving the system's security and functional flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116235174B_ABST
    Figure CN116235174B_ABST
Patent Text Reader

Abstract

A computer-implemented method comprising: obtaining first data comprising a representation of computer program code implementing an encryption algorithm; obtaining second data; receiving a request to perform a first mechanism, the request comprising information identifying the first mechanism, and information identifying the first data as corresponding to a program and the second data as corresponding to an input; performing the first mechanism, wherein performing the first mechanism comprises: performing a first determination comprising: determining whether a first policy associated with the second data allows the second data to be used with the program represented in the first data, and determining whether a third policy associated with the computer program code allows the computer program code to be used with the second data; and if the first determination is successful, executing the program represented in the first data with the second data as input.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an apparatus and method for performing encryption algorithms. For example, the apparatus may be a hardware security module device. Background Technology

[0002] Various devices can be used to execute encryption algorithms. For example, a Hardware Security Module (HSM) is a device that securely stores and manages encryption keys and executes a set of encryption algorithms. An HSM can include both physical and non-physical attributes that provide security. Non-physical security attributes can include the use of encryption, that is, including software or physical components within the device for performing encryption on the stored data. Physical security attributes can include, for example, tamper switches triggered by physical access, and tamper-proof membranes surrounding the physical boundaries of the device.

[0003] The set of algorithms supported by the HSM can be defined by the trusted party. For example, the computer program code that implements these algorithms can be embedded into the HSM during manufacturing by the trusted party, or it can be provided by the trusted party, in whole or in part, after manufacturing, in the form of downloads, updates, or plugins.

[0004] To add a new encryption algorithm to the set of algorithms supported by the HSM device, the trusted party can define the interface for the new algorithm and translate the algorithm's specification into executable code. The trusted party then performs an upgrade process at the HSM, storing the new code on the HSM. This upgrade process interrupts the HSM's service. Summary of the Invention

[0005] According to one aspect, a computer-implemented method is provided, comprising: obtaining first data, the first data including a representation of computer program code implementing an encryption algorithm; obtaining second data; receiving a request to execute a first mechanism, the request including information identifying the first mechanism and information identifying the first data as corresponding to a program and the second data as corresponding to input; executing the first mechanism, wherein executing the first mechanism includes: performing a first determination, the first determination including determining whether a first policy associated with the second data allows the second data to be used with the program represented in the first data; and if the first determination is successful, executing the program represented in the first data, taking the second data as input.

[0006] Obtaining the first data may include receiving the first data from the first device at the second device, wherein the first mechanism is performed at the second device. The first device may be a client device. The second device may be an HSM device. The request is received at the second device from the same first device or a different third device.

[0007] The above method enhances system security by allowing the algorithm to be provided to and executed within the device under constraints set by a policy associated with the algorithm's input. This policy can, for example, be cryptographically bound to the input or bound by a mechanism used to provide the input. This method enables the new algorithm to be executed more efficiently on the device compared to implementing it directly in updated firmware. This method increases the device's functional flexibility, allowing for the secure execution of new algorithms or new combinations of existing algorithms. The second data can, for example, be an encryption key. The policy attached to the key can constrain the code that operates on the key.

[0008] The execution of the program may also include steps based on the output data of the program's result. The result of the program may be an encryption key. The output data may be an identifier or reference to the encryption key.

[0009] In an embodiment, the first determination further includes determining whether a first policy allows the use of the second data in the first mechanism. The first policy may be a first access control list that includes a list of allowed uses related to the use of the second data. The second data packet may include the second data and the first policy. In this specification, a data packet may be, but is not necessarily, one or more packets of a data communication system.

[0010] In one embodiment, a policy attached to the code can constrain the key it operates on. In another embodiment, the first determination further includes determining whether a third policy associated with the computer program code allows the computer program code to be used with the second data. The first determination may also include determining whether the third policy allows the computer program code to be used with the first mechanism. The third policy may be a third access control list that includes a list of permissions associated with the use of the program. The first data may be a first data packet that includes a representation of the computer program code and the third policy.

[0011] In an embodiment, the method further includes: obtaining third data, the third data including a representation of output strategy information; wherein the request further includes identifying the third data as information corresponding to a second strategy; wherein executing the first mechanism further includes associating the second strategy with the output data of the program.

[0012] In one embodiment, the policy attached to the code may constrain the template to be bound to the output of the code. In another embodiment, the policy attached to the template may constrain the code used to generate the key to be bound to the template. In yet another embodiment, the first determination may further include determining whether the first policy allows the second data to be used with the output policy in the third data. The first determination may also include determining whether a fourth policy associated with the output policy allows the output policy to be used with the second data. The first determination may further include determining whether the fourth policy allows the output policy to be used with the first mechanism. The first determination may further include determining whether the fourth policy allows the output policy to be used with the program represented in the first data. The third data group may include the third data and the fourth policy.

[0013] In an embodiment, the method may further include: obtaining fourth data; wherein the request further includes information identifying the fourth data as corresponding to input data; wherein performing the first determination further includes determining whether a fifth strategy associated with the fourth data allows the fourth data to be used with the program represented in the first data.

[0014] The request can define the roles of the second and fourth data. In embodiments where multiple input keys exist, the input keys can constrain each other. In embodiments, the first determination also includes determining whether a fifth policy allows the fourth data to be used with the second data and / or determining whether a first policy allows the second data to be used with the fourth data. The fourth data group may include the fourth data and the fifth policy.

[0015] In one embodiment, the computer program code includes functions from a predetermined set of functions that are combined to implement an encryption algorithm. The program code implementing the predetermined set of functions is stored on a device on which the first mechanism is executed. The executing program includes retrieving and executing program code that implements the functions specified in the computer program code implementing the encryption algorithm. These functions can take values ​​assigned to registers as input.

[0016] In one embodiment, the method further includes: generating a representation of computer program code implementing the encryption algorithm at a first device; and sending first data to a second device.

[0017] In an embodiment, the method further includes: generating a request to perform a first mechanism at a first device; sending the request to perform the first mechanism to a second device; and performing the first mechanism at the second device.

[0018] In an embodiment, the method further includes sending data from a second device to a first device based on the result of the first mechanism. The step of executing the program may further include outputting data based on the result of the program. The result of the program may be an encryption key. The output data may be a reference to or an identifier of the encryption key. The output data may be sent from the second device to the first device. In an embodiment, executing the first mechanism further includes: if the first determination fails, outputting an error message. The error message may be sent from the second device to the first device.

[0019] According to the second aspect, a carrier medium including computer-readable code is provided, the computer-readable code being configured to cause a computer to perform any of the methods described above.

[0020] According to a third aspect, an apparatus is provided, comprising: an input configured to receive a request to perform a first mechanism, the request including information identifying the first mechanism and information identifying first data as corresponding to a program and second data as corresponding to input; and a processor configured to: obtain the first data and obtain the second data, the first data including a representation of computer program code implementing one or more cryptographic operations; perform the first mechanism, wherein performing the first mechanism includes: performing a first determination, the first determination including determining whether a first policy associated with the second data allows the second data to be used with the program represented in the first data; and if the first determination is successful, performing the program represented in the first data as input, with the second data as input.

[0021] These methods are computer-implemented. Since some methods according to embodiments can be implemented in software, some embodiments include computer code provided on any suitable carrier medium. The carrier medium may include any storage medium, such as a CD-ROM, magnetic device, or programmable storage device, or any transient medium (e.g., any signal, such as an electrical, optical, or microwave signal). The carrier medium may also include non-transient computer-readable storage media. Attached Figure Description

[0022] The apparatus and method according to a non-limiting embodiment will now be described with reference to the accompanying drawings, in which:

[0023] Figure 1 This is a schematic diagram of a hardware security module device according to an embodiment;

[0024] Figure 2 This is a schematic diagram of an example mechanism of a key wrapping algorithm, in which the first input key is encrypted under the second input key;

[0025] Figure 3 A schematic diagram of a computer implementation method for performing an encryption algorithm on a device, according to an embodiment, is shown;

[0026] Figure 4 This illustrates how an input key can be loaded or imported into the internal RAM of an HSM as part of a computer implementation method for performing cryptographic algorithms on a device according to an embodiment;

[0027] Figure 5 An example of receiving a request to perform a first mechanism is shown as part of a computer implementation method for performing an encryption algorithm on a device according to an embodiment;

[0028] Figure 6 An example of how one input key can constrain another input key is shown as part of a computer implementation method for performing cryptographic algorithms on a device according to an embodiment;

[0029] Figure 7 A portion of a computer implementation method for performing an encryption algorithm on a device according to an embodiment is shown;

[0030] Figure 8 This is a schematic diagram of an example process for generating HSM firmware, which serves as part of a computer implementation method for performing encryption algorithms on a device according to an embodiment;

[0031] Figure 9 This is a schematic diagram of an example process for generating a converter application, which serves as part of a computer implementation method for performing an encryption algorithm on a device according to an embodiment;

[0032] Figure 10 This is a schematic diagram of an example process for generating a serialized representation of a program, as part of a computer implementation method for executing an encryption algorithm on a device according to an embodiment;

[0033] Figure 11 This is a schematic diagram of an example process for deserializing a program representation into an internal format suitable for execution, as part of a computer implementation method for executing an encryption algorithm on a device according to an embodiment. Detailed Implementation

[0034] Figure 1This is a schematic diagram of a hardware security module device 21 according to an embodiment. The HSM 11 includes a processor 303, a non-volatile storage device 305, and working memory, i.e., random access memory (RAM) 309. RAM 309 is the operating memory of the CPU 303. The non-volatile storage device 305 may include any form of non-volatile device memory, such as flash memory, optical disk drive, or magnetic hard disk drive. The non-volatile storage device 305 may be physically secure and tamper-proof, for example, by including a physical security element such as a membrane covering the entire device that cannot be removed without damaging the underlying physical hardware (and thus rendering it unusable). The CPU 303 communicates bidirectionally with the non-volatile storage device 305 via a wired connection and also with the RAM 309 via a wired connection.

[0035] Computer program code is stored in non-volatile storage device 305. When executed, the program is represented as a software product or process in working memory 309. Processor 303 includes logic circuitry that responds to and processes instructions in the code in working memory 309. The following description refers to "firmware," which is a program containing a set of computer instructions. Firmware includes machine code stored in non-volatile storage device 305 on the HSM 21. Non-volatile storage device 305 on the HSM 21 also stores any components required to execute the firmware, including runtime system files. A copy of the firmware machine code is stored in working memory 309 when executed. A "firmware process" is an instance of firmware being executed, including machine code in RAM 309. Execution of the firmware by processor 303 enables the methods described herein.

[0036] The processor 303 runs an operating system, such as Linux. The operating system includes system software that manages the hardware and software resources of the HSM device 21 and acts as an intermediary between the firmware and the HSM hardware.

[0037] Firmware includes computer instructions that implement a set of one or more cryptographic algorithms. For example, firmware includes computer instructions that implement one or more of the following cryptographic algorithms: encryption key generation; key derivation; encryption; decryption; and digital signature algorithms (e.g., digital signatures or verification of digital signatures). Firmware may be embedded in the non-volatile storage device 305 of hardware security module 21 during manufacturing by a trusted party, or it may be provided by the trusted party, wholly or partially, after manufacturing. For example, firmware may be introduced by the trusted party as a computer program product, which may be done through download. Alternatively, the trusted party may modify existing firmware through updates or plugins.

[0038] HSM device 21 can be located within a larger system. For example, HSM 21 can be communicatively coupled to a computer or server device in the larger system via interface 307, which includes a communication link to the computer or server device. For example, HSM device 21 can be a PCI Fast Card that is directly inserted into the computer or server device, or HSM device 21 can be communicatively connected to the computer or server device via a USB connection. In use, HSM device 21 receives client requests through interface 307. The term "client" is used throughout the description to refer to the user of HSM device 21.

[0039] HSM 21 can be located in client system 317. In this case, client system 317 has a dedicated local HSM 21 device. HSM 21 is communicatively coupled directly to general-purpose computer 317 in client system via interface 307, for example, HSM device 21 can be communicatively connected to computer 317 via USB connection.

[0040] Alternatively, HSM 21 can be located in a host system separate from client computer 317. The host system could be, for example, a service provider system. In this case, client computer 317 communicates with a computer or server device in the host system. HSM device 21 is coupled to the computer or server device in the host system via interface 307. For example, HSM device 21 can be a PCI Fast Card that is directly inserted into the computer or server device in the host system, or HSM device 21 can be communicatively connected to the computer or server device via a USB connection. Client device 317 is thus communicatively coupled to HSM device 21 via the computer or server device in the host system. Communication between client device 317 and the host or server device can be performed via, for example, an Internet connection. Although only a single client machine 317 is shown in the figure, it should be understood that two or more clients can use HSM device 21 in this configuration.

[0041] The non-volatile data storage device 305 can also store data items, such as one or more encryption keys associated with a client. For example, one or more master keys associated with a client can be stored. One or more master keys define a “secure world” associated with the client, in which the HSM device 11 registers. The term “secure world” refers to one or more security applications (e.g., HSMs), or is part of a security device that shares at least one private key and is configured to protect encryption keys and execute a set of encryption algorithms. The master keys stored on the non-volatile data storage device 15 may include a Module Secure World Key (KMSW) key. This KMSW key is a symmetric key used as the root of keys for other applications.

[0042] Many encryption application keys are associated with the client and are used in conjunction with encryption algorithms implemented in the firmware. Application keys can be securely stored outside the HSM device 21 using a KMSW key. In this case, the application keys can be encrypted using, for example, Triple-DES encryption.

[0043] The HSM can enforce policies regarding the use of encryption keys. This is achieved by cryptographically binding the key to an Access Control List (ACL), which represents the policy as a list of operations that the key can participate in, along with the authorizations required for those operations (if any). When a user requests an operation using the application key, the operation is searched for in the ACL of that application key. The operation proceeds only if it is found and only if any required authorizations are met. The key and ACL are encrypted using a KMSW key. This forms a "key blob". The encrypted key blob can be stored externally to the HSM device 21, such as on a smart card or server storage device (e.g., a hard drive within the host system), and loaded onto the HSM device 21 when needed. Alternatively, the application key can be stored in a non-volatile data storage device 305 on the HSM device 21.

[0044] The application key associated with the client is used to execute one or more encryption algorithms implemented in the firmware. When a client request to execute an algorithm is received, one or more relevant application keys are retrieved using the module key and loaded into the RAM space of the firmware process. The relevant application keys can then be used by the hardware security module to execute one or more encryption algorithms, including various encryption and decryption algorithms, as well as digital signature algorithms.

[0045] HSM device 11 also includes a board support processor 313. The board support processor 313 is configured to communicate with multiple onboard sensors to monitor the operation of the main CPU and other hardware components of the hardware security module 21. The sensors may include, but are not limited to, CPU and / or board temperature sensors, voltage sensors, and / or current sensors. HSM device 11 also includes an encryption coprocessor 311. Various other components, not shown, may be included.

[0046] Although HSM devices have been described above, the present invention is not limited thereto, and the methods described below can be implemented on various devices used to execute cryptographic algorithms. For example, a software emulator running on a general-purpose computing device or server can make the computing device or server behave like an HSM device. In this case, a computer program running in the computer device or server emulates the HSM device, and the methods described below are implemented on the computer device or server in that environment.

[0047] Various encryption algorithms can be executed using the key export operation as follows, with examples provided in [the relevant section]. Figure 2 As shown in the diagram. This operation is parameterized by a mechanism identifier and an input key set. The mechanism identifier identifies the computer program code in the firmware of the HSM device 21 that implements the encryption algorithm. The effect of this operation is to create a derived encryption key in the manner defined by the mechanism identifier.

[0048] Figure 2 An example of this mechanism being used in a key wrapping algorithm is shown, in which a first input key is encrypted under a second input key. Initially, the template and the two input keys are loaded into the RAM space of the firmware process in the HSM device 21. They may be imported or decrypted from the wrapped form, or they may be the result of an earlier key export operation.

[0049] The client, or an application acting on behalf of the client, requests the execution of a wrapper mechanism in the command "Cmd DeriveKey". This command includes an identifier of the mechanism to be executed (in this case, a wrapper mechanism) and a reference to the key to be used (including a template). This command is sent to HSM device 21. The command "Cmd DeriveKey" takes the mechanism identifier and a list of two or more keys as parameters and generates a resulting key. Figure 2 The operation shown includes a packaging mechanism identifier.

[0050] The computer program code in the firmware on HSM device 21 is identified and executed by the received "Cmd_DeriveKey" command. This code implements... Figure 2 Steps S201 and S203 are shown. The computer program code in the firmware on the HSM device 21 that implements the packaging mechanism, identified by a mechanism identifier, includes a packaging algorithm that encrypts the base key. This code implements... Figure 2 The step S202 is shown. The code can be identified by a table on the HSM device 21, which is associated with a numeric constant corresponding to “Cmd_DeriveKey”. The memory address of the corresponding code is then retrieved from RAM 309. For example, as shown in Appendix 1, the “Cmd DeriveKey” command is identified by the numeric constant 75.

[0051] The interpretation of the input keys depends on the mechanism. Each key is assigned a specific role. This can be defined by the order in which they appear in each mechanism—for example, for a wrapping key mechanism, the first "key" in the list is considered the template "key," the second key is the key to be wrapped (the base key), and the third key is the key used for wrapping (the wrapping key). For all "Cmd DeriveKey" commands, the first "key" can be defined as always being the template "key," regardless of the specified mechanism. As explained later, alternative methods for defining various key roles are available.

[0052] Although the term "key" is used to refer to a template, the template "key" is not actually an encryption key, but rather a data packet that includes ACL information for the output key. Templates also have their own ACL, which specifies how the template can be used.

[0053] The operation must be permitted by the ACL of each input key and template involved. In S201, the ACL of each input key and template "key" is checked to determine if the ACL allows the key to be used in the DeriveKey operation using the wrapping mechanism and in the role it has been assigned. Additionally, the ACL of each input key can constrain the type and value of other keys involved in the operation. For example, the input key to be wrapped (the base key) can constrain the input key that wraps it (the wrapping key) to prevent it from being wrapped under an unauthorized key. This is also checked in S201.

[0054] If the ACL check for each input key and template is successful, the wrapping mechanism is executed in S202. Using input key 1 as the base key and input key 2 as the wrapping key, the computer program code implementing the wrapping mechanism (i.e., the encryption algorithm) in the firmware on the HSM device 21 is executed. Finally, in S203, the exported key (the wrapped key) is cryptographically bound to the ACL. This ACL is provided in a dedicated input "key" called the template. Therefore, any or all input keys involved in this operation can constrain the ACL of the exported key by constraining the template "key".

[0055] In the manner described above, various operations can be performed to generate or derive the output key. However, the operations that can be performed are limited to those of the computer program code stored in the firmware on the HSM device 21. Specifically, the packaging algorithm can only be executed if the computer program code implementing the packaging algorithm is already stored in the firmware on the HSM device 21.

[0056] Users may wish to execute algorithms whose computer program code is not stored in the firmware on HSM device 21. Allowing users to provide computer program code implementing the desired algorithm in the form of firmware updates would compromise the security of HSM device 21. To avoid this, a trusted party can define an interface for the new algorithm and translate the specification of the new algorithm into executable code. This new code may need to be tested and signed before delivery to ensure it does not compromise the security of the HSM device. The trusted party then performs the upgrade process on the HSM. However, this process will interrupt the service of the HSM. For example, the process may also involve the client presenting a physical authorization token to reinitialize the HSM before it can return to service.

[0057] Furthermore, even if the code for each individual operation is stored on the HSM device 21, combining multiple operations used to derive the key presents challenges. For example, generating a strategy for subsequent operations might be problematic if the output key of one operation is expected to be used as the input key for a subsequent operation. For instance, if a subsequent operation uses a wrapping mechanism and the wrapping key is the output of the previous operation, an ACL for the base key (the key to be wrapped) would need to be generated after executing the previous operation to constrain the wrapping key. Additionally, the ACL for the wrapping key would need to allow subsequent operations. For security purposes, it is also desirable that the ACL for the wrapping key allow subsequent operations to use the desired mechanism instead of others to avoid intermediate use of the key. Connecting multiple operations in this way to generate an encryption algorithm quickly becomes complex. Furthermore, potential security vulnerabilities arise at each connection point because the output key could potentially be used intermediately.

[0058] Figure 3 A schematic diagram illustrates a computer implementation method for performing an encryption algorithm on a device according to an embodiment. The device may be, for example, related to... Figure 1 The HSM device 21 is described. However, as explained above, the method can alternatively be executed on one or more of a variety of devices, including general-purpose computers. The method provides a mechanism, a first mechanism, by which algorithms not stored on the HSM device 21 can be securely executed on the HSM device 21. This first mechanism is also referred to herein as the "DeriveMech Programmed" mechanism.

[0059] The computer code that implements the "Cmd_DeriveKey" operation and the first mechanism is part of the firmware, for example, it is included in the firmware during device manufacturing or included in a firmware update. However, the computer code that implements the desired algorithm is not included in the firmware on the HSM device 21, but is provided by the client.

[0060] As mentioned above Figure 2The implementation that has already been described Figure 3 The computer program code for steps S301 and S303 shown is stored on the HSM device 21. A first mechanism is also defined. The computer program code is included in the firmware implementing the first mechanism on the HSM device 21. This code specifies... Figure 3 Step S302, as shown, includes executing a client program that takes input data as input. This step is executed only if the initial check in S301 is successful.

[0061] In the first mechanism, the first input "key" is also a representation of the template. The second input "key" is a representation of the client program that implements the desired algorithm. Similarly, although the term "key" is used, the program "key" is not actually the encryption key, but rather a representation of the computer program (client program).

[0062] The computer program code implementing the desired algorithm does not need to be pre-stored on the HSM device 21, but can be provided in the input data packet (input program "key"). The computer program code corresponding to the operation (derived key operation) and mechanism (first mechanism) is defined and stored on the HSM 21. This operation and mechanism can then be used to implement various algorithms provided by the user in the program "key". The remaining input keys are available for operation by the client program. The final result of the client program's execution is the derived key, which assigns an ACL from the template "key", and can then be used in any way permitted by that ACL.

[0063] The client program is transmitted as an input "key". Its "value" or content can be constrained by the ACL of any or all other keys involved in the operation. Security is maintained in this way. Additionally, since the client program itself is bound to the ACL, it can constrain the values ​​of any other participating keys. The representation of the client program code is bound to a policy. For example, the ACL is bound to the representation of the client program via an import command and stored in a manner that associates it with the client program on HSM device 21. The client program code is directly bound to the policy; that is, the client program code is not bound to the signing key, but the signing key is bound to the policy.

[0064] By providing a program "key" and requesting the execution of the first mechanism, a client can implement an encryption algorithm without performing a firmware upgrade. By utilizing an ACL system, the client can restrict which keys the algorithm can be applied to and control the authorization required to execute the algorithm. The relevant ACL is checked before executing the client program code in the program "key." The client program code in the program "key" will only execute if it has been determined that permission is granted. It then completes its execution, generating one or more derived keys.

[0065] If multiple client programs are to be run, the first client program does not need to be terminated to load the next client program. The only limitation on the number of different client algorithms that can be executed at one time is the general resource limit of the HSM (e.g., the amount of RAM contained in the HSM).

[0066] As a first step, the client generates a program on client device 31 7 that implements the desired algorithm. Optionally, the client program can be written in a general-purpose computer language such as Python. In this case, the runtime system files and interpreter required to execute the client program must be stored on HSM device 21 and / or packaged and sent along with the program key. Alternatively, the client program can be written, for example, in C, and compiled to run on HSM device 21. A representation of the compiled machine code is then sent to HSM device 21.

[0067] However, in the examples described herein, the client uses a custom representation to write a textual representation of the desired algorithm. An example of a textual representation of an algorithm using a custom representation is shown below. The various functions shown (Unpack, LoadInt, Branch, Concatenate, Sign, ...) will be described later. These functions (Unpack, LoadInt, Branch, Concatenate, Sign, ...) directly map to definitions included in the HSM firmware. The machine code implementing these functions is also included in the firmware. Although the HSM firmware includes computer program code implementing the various functions, the combination of functions in the desired algorithm is not provided in the firmware. Instead, a representation of the algorithm is provided in the program key.

[0068]

[0069] The client uses a custom representation on client device 317 to write a text representation of the desired program. A converter program executes on client device 317. The text representation serves as input to the converter program, which takes the text representation and converts it into a serialized representation. The converter is an executable program that includes serialization code and various definitions. Therefore, computer program code written in a common computer language that implements the converter program is stored on the client device. In this example, the computer language is Python. In this example, the converter includes: Python language type definitions, and code for serialization, deserialization, and various other functions. See later. Figure 9 and Figure 10 Describe the converter in detail, including how it is generated. The converter's output is a serialized representation of the data from the client program, i.e., a bit string.

[0070] By constraining the client to use a custom representation to write the desired program, and this custom representation includes a fixed number of available functions (corresponding to functions defined and stored on the HSM device 21), the chance of human error jeopardizing security during code writing is reduced. Furthermore, the machine code implementing these functions is included in the firmware of the HSM device 21. However, these functions can be combined by the client in various ways to generate the desired algorithm. The resulting combinations can run in a single operation.

[0071] The serialization of the client program is represented by binding to the serialization ACL via an import command used to import the program "key". The program "key" is then stored in the internal RAM 309 of HSM 21. A key handle referencing this result is created. The program key is then sent from client device 317 to HSM device 21.

[0072] The inputs to the key export operation are template "key" 45, program "key" 47, and one or more input keys (along with the bound ACL). As described above, the program "key" is imported from client device 317 into HSM 21. Template "key" 45 and other input keys are also loaded or imported into the HSM's internal RAM, such as... Figure 4 As shown. Figure 4 Two input keys are shown, but the actual number may be one or more. Typically, a template key and a program key are likely imported into the HSM, while the input keys can be stored encrypted on the HSM or in storage accessible to the HSM. For example, they can be encrypted under a long-term symmetric key stored in the HSM, under a different application key, or under a key reassembled from the smart card set. The client provides a “Cmd LoadBlob” command associated with any desired key stored on or accessible to the HSM device 21. When the load command is executed, the key referenced in the command is retrieved, decrypted, and stored in the HSM's internal RAM. A key handle referencing this result is created. The ACL is stored in association with the corresponding key (e.g., in the same location).

[0073] Use the "Cmd Import" command for any keys (including program "key" 47) to be imported into HSM device 21. This command is provided directly with the key and its corresponding ACL, without any encryption. The command loads the key and ACL, given in plain text form, from client device 317 into HSM device 21. When the import command is executed, the key and ACL provided with the command are stored in HSM internal RAM 309. A key handle referencing this result is created. The ACL is stored in association with the corresponding key (e.g., in the same location). This process is used to load keys without any encryption. For example, it might be suitable for loading client programs that do not require encryption. The import command creates a binding between the program key and its ACL.

[0074] In the example described herein, program "key" 47 is prepared in client device 317 and sent to HSM device 21 along with the bound ACL and "Cmd Import". However, various keys can typically be loaded or imported into the HSM's RAM 309 in various ways. For example, a key may be imported, decrypted from a packaged form, or may be the result of an earlier key export operation. Different keys may be obtained in different ways; for example, program "key" 47 and template "key" 45 are imported, while the input key is loaded from storage devices internal to HSM 21 or accessible to HSM 21. The exact manner in which the key is entered into HSM 21 is not important. Optionally, at least one key will be entered into the HSM in a manner that maintains its confidentiality and is bound to a policy (ACL) controlling its use.

[0075] In this step, a first data packet 42 is obtained, comprising a program "key" 47 and a program ACL 48. The program ACL 48 is also referred to as the third ACL 48. The program "key" includes a representation of the client program defining the encryption algorithm. The third ACL 48 is an example of a third policy associated with the client program. The program ACL 48 is associated with the program "key" 47. In this example, the program "key" 47 and the program ACL 48 are serialized and then bound. For example, the serialized client program 47 and the corresponding serialized access control list are bound via an import command. The program "key" 47 includes a representation of computer program code implementing the algorithm desired by the user (i.e., the client program). The serialized program code comprises a series of bits. At HSM 21, the program "key" 47 and the program ACL 48 are deserialized and stored together in the HSM internal RAM 309. A key handle referencing this result is created.

[0076] In the deserialization step, the serialization program 47 and program ACL 48 are read at the HSM device 21 according to the serialization format. The serialization program 47 is converted into a form executable on the HSM device 21. In this case, the serialization program is converted into a memory representation of the program. The code used to deserialize program 47 is included in the firmware of the HSM device 21. Alternatively, the serialized client program can be converted into machine code. For example, the serialization representation can also be executed directly if the function is encoded in the firmware. In this case, the deserialization step is not performed, and the serialization representation is simply stored.

[0077] A third data packet 41, including template "key" 45 and template ACL 46, is also obtained. Template "key" 45 includes a representation of output access control information related to the use of the output data. Template ACL 46, also referred to as the fourth ACL, is associated with the template "key". The fourth ACL is an example of a fourth policy associated with the output access control information. In this example, template "key" 45 and template ACL 46 are serialized and then bound, for example, they can be provided in an import command or encrypted and bound and loaded. The serialized template includes a series of bits. In HSM 21, template "key" 45 and template ACL 46 are deserialized and stored together in HSM internal RAM 309. A key handle referencing this result is created. Similar to program key 47, in the deserialization step, serialized template 45 and template ACL 46 are read according to the serialization format.

[0078] A second data packet 43, including input key #249 and its ACL 50, is also obtained. The ACL 50 of input key #2 is also referred to as the first ACL. The first ACL is associated with input key #2. In this example, the first ACL is cryptographically bound to input key #2. For example, they could be encrypted with a long-term symmetric key stored in HSM device 21 and stored in storage accessible to HSM device 21. Input key #2 can be referred to as second data. The first access control list 50 includes a list of allowed uses associated with input key 2. The first access control list is an example of a first policy associated with the second data.

[0079] A fourth data packet 44, including input key #351 and its ACL 52, is also obtained. The ACL 52 of input key #3 is also referred to as the fifth ACL. The fifth ACL 52 is associated with input key #3. In this example, the fifth ACL is cryptographically bound to input key #3. For example, they could be encrypted with a long-term symmetric key stored in HSM device 21 and stored in storage accessible to HSM device 21. Input key #3 can be referred to as fourth data. The fifth access control list 52 includes a list of allowed uses associated with input key #3. The fifth access control list 52 is an example of a fifth policy associated with the fourth data.

[0080] The client sends a "Cmd LoadBlob" command associated with input keys #2 and #3 to HSM 21. When the load command is executed at HSM 21, input keys #2 and #3 blobs are retrieved, decrypted, and stored along with the ACL in HSM internal RAM 309. A key handle referencing this result is created.

[0081] In this example, each ACL is bound to a corresponding object. The input key is cryptographically bound to the ACL. The cryptographic techniques used to protect the key material (i.e., blob creation) guarantee both confidentiality and integrity; that is, an attacker cannot discover the blob's contents, and an attacker cannot modify it without detection. Access control lists define the policies under which the key can be used. Access control lists consist of a set of allowed groups. Only one allowed group must match the action to be allowed.

[0082] Each ACL includes a table of allowed groups, each defining a set of operations and the credentials (if any) required to perform those operations. Allowed groups are checked sequentially, using the first allowed group that allows the action. If no group matches the expected operation, the command returns an error message. An allowed group is an entry in the access control list. An allowed group defines a set of operations and the credentials (if any) required to perform those operations. An allowed group consists of a set of general constraints plus a list of actions that directly match the action to be performed. An action defines one or more permitted operations. There are many possible different actions. “Act_DeriveKey” represents any action attempted using the command “Cmd_DeriveKey” described above. For export key operations, for each participating key, the key's ACL should include an Act_DeriveKey entry where the role field matches the role the key will use, the mech field matches the requested mechanism (i.e., the first mechanism), and for each other role, the otherkeys field either does not mention the role or mentions the key hash of the key acting as that role.

[0083] For example, if it is desired to restrict which input keys can be used with the program key, the program key ACL 48 lists the allowed input keys and roles (e.g., "DeriveRole WrapKey", "DeriveRole Key3"). Therefore, in this example, the program ACL 48 could list the Act_DeriveKey entry, where the role field lists "DeriveRoleBaseKey" (which can be identified by the numeric constant 1), the mech field lists "DeriveMech Programmed" (which can be identified by the numeric constant 42), the otherkeys field does not mention "DeriveRole TemplateKey," but lists the role "DeriveRoleWrapKey" (which can be identified by the numeric constant 2) with the identifier of input key #2 (which can be a cryptographic hash of the key value and key type) and the role "DeriveRole" with the identifier of input key #3 (which can be a cryptographic hash of the key value and key type). Key3 (which can be identified by the numeric constant 3). These roles can include "template", "procedure", and various general input roles, but other or alternative specifications for roles can be defined, such as to distinguish different roles for different input keys. Key types also include "template" and "procedure", but encryption key types can take various known encryption key types, such as AES keys.

[0084] If you don't want to restrict which keys can be used with an object in a specific role, then that role won't be listed in the object's ACL. In this case, any key can be used in that role (as long as the ACLs of other objects used in the mechanism allow it). So, for example, if program ACL 48 doesn't list the role "template," it means that program "key" 47 can be used with any template "key."

[0085] In this step, various keys and ACLs are decrypted, deserialized, and stored in RAM as needed. Each key is stored in a manner associated with its ACL.

[0086] The client, or an application acting on behalf of the client, then requests execution of the first mechanism in a command that includes an identifier for the first mechanism and a reference to each key to be used. The command “DeriveKey” is used, with the mechanism identifier and a list of two or more keys as parameters. The mechanism identifier identifies the first mechanism, namely “DeriveMech Programmed”. This command can be sent from client device 317 to HSM device 21. Although this document describes the case where the program keys and commands are sent to HSM device 21 from the same client device 317, it will be understood that the program keys and commands can be sent from separate devices to HSM device 21.

[0087] Each key is then reassigned to a specific role within the command. This can be defined by the order in which they appear in the command—for example, the first key in the list is the template key, the second is the program key, and subsequent keys occupy roles with sequential numbers. However, various different orders or methods can be used to define roles.

[0088] Figure 5 An example of the "Cmd DeriveKey" command 501 is shown. Computer program code in the firmware on HSM device 21 is identified and executed by the "Cmd DeriveKey" command. This code implements... Figure 3 Steps S301 and S303 are shown. The code can be identified using a table on the HSM device 21 that includes a command identifier. The command identifier can be a numeric constant. The “Cmd DeriveKey” command can be identified by the numeric constant 75 in the client request, and the memory address of the code to be executed on the HSM device 21 in response to the “Cmd DeriveKey” command is retrieved.

[0089] The “Cmd DeriveKey” command 501 includes information identifying the first mechanism (“DeriveMech Programmed”). The mechanism identifier can be a numeric constant. For example, the first mechanism “DeriveMech Programmed” corresponds to the numeric constant 42 used for identification. The mechanism identifier allows identification of computer program code in the firmware on the HSM device 21. This code specifies… Figure 3 The step S302 is shown. This code implements functions for executing the program provided in the program key.

[0090] Command 501 also includes information identifying the following: identifying the first data block 42 as containing a representation of the program to be executed; identifying the third data block 41 as containing a representation of a second access control list for output keys; identifying the second data block 43 as containing input data; and identifying the fourth data block 44 as containing input data. Different roles for different inputs can also be defined by order. This identification information may include a list of key identifiers, ordered such that the first identifier in the list identifies the template key, the second identifier identifies the program key, and subsequent identifiers occupy sequentially numbered roles. These keys may be identified by key handles or filenames that allow identification of the corresponding keys stored in RAM on the HSM device 21. The step of requesting execution of the first mechanism is performed by sending command 501 from the client device 317 to the HSM device 21.

[0091] In step S301, as part of the key export operation, a first determination is performed. In this step, all constraints in all ACLs of the objects used in the operation are checked. If all constraints are satisfied, the process proceeds to S302. If no constraints are satisfied, the operation terminates at this stage. In this case, the program represented in program key 47 is not executed.

[0092] For export key operations, for each participating key, search the key's ACL for an Act_DeriveKey entry, where the role field matches the role in which the key will be used, the mech field matches the requested mechanism (i.e., the first mechanism), and for each other role, the otherkeys field either does not mention the role or mentions the key hash of the key acting as that role. For example, template "key" ACL 46 must allow template 45 to be used in the template role. Program "key" ACL 48 must allow program 47 to be used in the program role.

[0093] As previously stated, each object can constrain the keys allowed to be used in one or more roles by listing the keys permitted to be used with the role in the `otherkeys` field. Objects whose ACLs do not list a specific role do not constrain that role, and therefore do not require checking that role. Therefore, for each ACL, the first determination includes: a first step of determining whether each role included in the command is listed in the ACL, and a second step of determining, for each listed role, whether the key identified in the role in command 501 is included in the ACL list. If any key is identified in the role in command 501 that has a constraint in the ACL, and that key does not satisfy the constraint, the first determination fails.

[0094] In this example, the first determination therefore includes determining whether the first access control list 50 of input key #2 allows input key #2 to be used in the first mechanism in a role that has already been assigned (i.e., in this case, as "DeriveRoleWrapKey"). This is confirmed by comparing the action in ACL 50 with command 501, comparing the mechanism identifier in the relevant action with the mechanism identifier in command 501, and comparing the role in the relevant action with the ordinal position of the input key #2 identifier in command 501. Note that although the first input key role is labeled "wrapping key", the first key is not necessarily used as a wrapping key, but can perform any role specified by the cryptographic algorithm.

[0095] In this example, the first access control list includes constraints related to the program key. Therefore, the first access control list includes one or more identifiers of keys in the program role. Thus, the first determination also includes determining whether the first access control list 50 for input key #2 allows input key #2 to be used with the program "key" 47 identified in command 501. The first ACL 50 includes a list of identifiers of all allowed keys in the "DeriveRole BaseKey" role (i.e., the program role). For example, the first ACL 50 includes the key type and cryptographic hash (e.g., SHA-1 or SHA-256) of all allowed keys. In the case of the program key, the "key material" is a serialized program. In S301, the program key 47 identified in command 501 and the key type "program" are combined with a cryptographic hash using the same hash function. This is then compared to the list in the first ACL 50. If there is no match, the first mechanism stops and an error message is returned. The program code in the program key is not executed.

[0096] Any other constraints are also confirmed. Each key may optionally constrain the identifiers of some or all other keys. For example, any input key can constrain the ACL of the exported key by constraining the template key that can use it. Optionally, the first access control list includes constraints associated with the template key, i.e., the first access control list includes one or more identifiers of the key in the template role. Therefore, the first determination also includes determining whether the first access control list 50 of input key #2 allows input key #2 to be used with the template "key" 45 identified in the command. This is confirmed in the same manner as described above, where, in the case of the template "key," the "key material" is a serialized ACL.

[0097] The program "key" can also constrain other keys. For example, a third access control list can include constraints related to input keys, i.e., the third access control list includes one or more identifiers of keys in various input roles. Therefore, the first determination also includes determining whether the third access control list allows the computer program code in program "key" 47 to be used with the first input key #2 as input data and / or with the second input key #3 as input data. In this way, a program can constrain the keys it can operate on. Therefore, authorization can be bidirectional, because the program's ACL can constrain the keys it operates on, just as the key's ACL can constrain the programs that can operate on it. It can be additionally or alternatively determined whether the third access control list allows the computer program code in program "key" 47 to be used with the template key 45 as a template. This check is performed in the same manner as described above by comparing the cryptographic hash of the key identified in command 501 with the cryptographic hash in the third ACL.

[0098] The template "key" can also constrain other keys. For example, the fourth access control list may include constraints related to the input key, i.e., the fourth access control list includes one or more identifiers of the key in the input role. The first determination may also include determining whether the fourth access control list 46 allows the template 45 to be used with the input key #2 as input data, and / or with the second input key #3 as input data. It may additionally or alternatively determine whether the fourth access control list 46 allows the template 45 to be used with the program 47 as program data. Similarly, this check is performed in the same manner as described above by comparing the cryptographic hash of the key identified in command 501 with the cryptographic hash in the fourth ACL.

[0099] exist Figure 6In the example shown, input keys 2 and 3 constrain template key 45. Therefore, the ACLs of both input keys #2 and #3 list the identifier of template key 45 along with the role "template". One or more identifiers of other template keys may also be listed along with the "template" role. Input key #2 constrains program key 47, so the ACL of input key #2 lists the identifier of program key 47 along with the role "program". Similarly, identifiers of other programs may also be listed along with the "program" role in the ACL of input key #2. However, input key #3 does not constrain program keys, so the role "program" is not listed in the ACL of input key #3. During the first determination, it is checked whether template key 45 is identified in the list of keys with the "template" role in the ACLs of input keys #2 and #3. It is also checked whether program key 47 is identified in the list of keys with the "program" role in the ACL of input key #2. No check is performed to determine if program key 47 is identified in the ACL of input key #3, because the ACL of input key #3 does not include the "Program" role ("DeriveRole BaseKey"). As mentioned above, constraints can be represented as a cryptographic hash of the key type and key material (e.g., SHA-1 or SHA-256). In the case of template keys, the "key material" is a serialized ACL, while for program keys it is a serialized program.

[0100] If the first determination is successful, i.e., if all constraints in all ACLs are satisfied, the process proceeds to S302. If no constraints are satisfied, the mechanism terminates at this stage. In this case, procedure 47 is not executed. Therefore, when executing the first mechanism, the policy (ACL) of each key is checked to determine if that key can participate in the operation in its selected role. The ACL of each key can also constrain the values ​​of keys in other roles. If any ACL check fails, the entire operation fails at this stage. In this case, an error message can be sent to notify the client.

[0101] In S302, the encryption algorithm implemented in the client program is executed, taking the input keys as input for their designated roles (defined in this case by the order in which they are listed in command 501). The output of S302 is the derived key. S302 includes: taking input keys #2 and #3 as input, executing program 47 stored in RAM.

[0102] In this example, the contents of the program key are interpreted as a program in a domain-specific language. However, as described above, the client program can alternatively be provided in a general-purpose computer language such as Python. In this case, in S302, the interpreter executes on HSM device 21, which directly executes the Python instructions in the client program. Alternatively, the client program can be provided as compiled code, in which case it executes directly on HSM device 21.

[0103] In this example, the HSM firmware includes program code that implements an interpreter. This interpreter code is identified by the "DeriveMechProgrammed" mechanism identifier and is executed in S302. The interpreter reads the memory representation of the client program and implements it using machine code stored on the HSM device 21 as part of the firmware. For example, if it finds the memory representation of a "signing" operation, it calls the machine code corresponding to the signing function. Each function is identified by the interpreter and implemented in machine code.

[0104] These functions take values ​​assigned to "registers" as input values. These registers are variables referenced by code in the HSM firmware. In S302, input keys (excluding template keys and program keys) are uniformly assigned to registers by the HSM firmware. Function outputs can also be assigned to registers by client program code. For example, registers can be assigned specific values ​​by client program code or default values ​​by firmware code. The maximum number of registers is defined in the firmware. During key export operations, each register corresponds to a separate physical memory address.

[0105] These functions include branching functions and one or more cryptographic functions, such as hashing, signing, encryption, and decryption. In embodiments, these functions include one or more of the following: concatenation, slicing, hashing, signing, encryption, decryption, loading constant values, converting between byte blocks and integers, obtaining length, performing binary operations (e.g., addition or subtraction), branching based on comparison results, and raising errors. The custom representation used by the client to write the algorithm is therefore limited to a restricted set of approved functions. These functions can be combined by the client in various ways to generate the desired algorithm. In this way, some control over the scope and type of functions that can be executed on the device is preserved, while allowing the client to more easily combine these approved functions in various ways within a single operation. Additionally, it can be ensured that each basic function conforms to any relevant security standards. For example, various checks can be built into these basic functions. Typically, the function set can be anything that the implementer can express. The definitions and code implementing these functions are included in the firmware stored on the HSM device 21.

[0106] The language is capable of branching and looping, such as making conditional decisions based on input or generating sequential output of a desired length. By writing programs using custom representations (where commands correspond to a fixed set of functions, the definitions of which and the code implementing the functions are stored on the HSM device 21), clients can implement any cryptographic algorithm that can use the function representations without performing firmware upgrades.

[0107] The supporting files and applications required to execute these functions are stored on HSM device 21. This may include runtime system files, definitions of various functions, and machine code corresponding to each function.

[0108] In the examples described in this article, the language is based on a register machine. It uses multiple uniquely addressed registers for computation, with each register holding a single value. These registers are typed. In this example, possible types are integers (represented here by i), blocks of bytes (represented here by b), and elliptic curve points. Additional types can be added. Using registers allows for more direct handling of errors in the program. The maximum number of registers of each type to be used is initially set in the client program. If these limits are exceeded, the program will immediately stop. Furthermore, mapping each variable to a physical address provides stability and thus improves security. However, a stack-based architecture can be used as an alternative.

[0109] The client program commits to the maximum number of registers of each type it will use. In S302, when the client program starts, the input keys (excluding the template key and program key) are uniformly assigned to registers by the firmware. Any registers not assigned in this way are given default values ​​(e.g., the integer register is 0).

[0110] In this example, if all ACL checks succeed, the values ​​of input keys #2 and #3 are assigned to registers, and the algorithm described in program 47 is executed. If no error is encountered, the output of the client algorithm (i.e., the derived key) takes the result of the algorithm as its value and the value of the template key as its ACL, as described in S303 below. The algorithm includes functions from a set of functions that include one or more of the following: concatenation and slicing of byte block registers; hashing, signing, encrypting, and decrypting byte block registers; loading constant values ​​into registers; conversion between byte blocks and integers; obtaining the length of a byte block register; performing binary operations such as addition or subtraction on integer registers; branching based on the result of comparing integer registers; and raising errors.

[0111] The client program 47 comprises a series of steps, each including a function and its parameters. Each step executes a function on zero or more registers and can proceed to the next step or branch to another location within the client program. If the last step of the program is not a branch, the client program terminates after it has been executed. Depending on the target key type specified by the client program, the exported key is uniformly obtained from the register values.

[0112] Figure 7 Further details of the steps performed within S302 are shown. Figure 7 In the example shown, the client program is an implementation of the National Institute of Standards and Technology (NIST) Feedback Key Derivation Function (KDF) (SP800-108). The values ​​of input key #2 and input key #3 are assigned to registers by the firmware. The value of input key #2 is assigned to register b0, while the value of input key #3 is assigned to register b1. As previously described, program 47 has been deserialized and stored in RAM.

[0113] The text representation of the client program is reproduced below. The first two lines define the number of input keys required (including the program key and template key) and the type of exported key to be computed. The "Unpack" function loads an integer into the integer register i0, which is taken from 4 bytes at offset 0 within the byte block register b1. This is the expected length of the exported key. In this particular client program, the expected length of the exported key is based on the input key #3, but the length of the exported key can be set in various different ways. For example, a fixed limit of 32 bytes can be set. The LoadInt function sets the integer registers i1 and i3 to 1. The LoadBytes function sets the byte block register b1 to empty.

[0114] The code between "loop" and "done" is the implementation of the repetitive part of the algorithm. It will not be described in detail, as it is included only as an example algorithm that can be implemented. However, the conditional "Branch" function at the beginning will exit the loop when enough output has been generated. The "Sign" function is the core cryptographic step of the algorithm. The definitions of the "Branch" and "Sign" functions are included in the firmware on the HSM device 21 and the machine code that implements these functions. The last two lines truncate the output (which may be a bit too long) to the desired length.

[0115]

[0116] If an error occurs during program execution, an error will be returned to the client, whether it is caused by an explicit error or by an attempt to perform an impossible operation.

[0117] Otherwise, when the program completes, in S303, an exported key is generated, and the contents of template "key" 45 are bound to the exported key. A reference to this result is returned to the client, who can then use it like any other key (within the constraints defined by the ACL). Therefore, in S303, a second access control list is generated and associated with the output key. The second access control list is generated based on the information in template 47 stored in RAM and is, for example, cryptographically bound to the output key. The second access control list and the output key are encrypted using, for example, a symmetric key.

[0118] In the above method, the deserialization code running on the HSM device 21 converts the serialized representation (i.e., bit string) of the client program into a data structure in memory representing the client program, i.e., a memory representation corresponding to the client program. The memory representation can be an array filled during the deserialization process. Each element of the array corresponds to a step in the client program identified by a corresponding numeric constant (e.g., a "signature" is identified by the numeric constant 5).

[0119] The deserialization code is part of the firmware stored on the HSM device 21. Function definitions and the machine code implementing those functions are also included in the firmware. During the execution of the client program, the interpreter reads the client program's memory representation (i.e., an array) and implements it using the machine code that implements the functions. For example, if it finds the memory representation of the "signature" operation (corresponding to the numeric constant of the signature operation), it calls the machine code corresponding to the signature function. Alternatively, the array may contain the memory addresses of the machine code implementing that step in the HSM memory; in this case, a lookup to find the machine code is not required each time the step is executed.

[0120] Now refer to Figure 8 This describes the process used to generate HSM firmware, including the code described above. The HSM firmware is generated on a trusted party's server and then introduced into the HSM during manufacturing or as a download or update. Therefore, the following steps are performed on the trusted party's server.

[0121] To generate HSM firmware code, tool 81 generates language-specific representations (including functions) of data types and language-specific code, including code for generating serialized representations of data types and code for deserializing these representations, as well as an interpreter program. Data types include those corresponding to each function (signature, branch, etc.) in a set of functions available to the client as part of a client algorithm. In this example, the language is C. Tool 81 runs on a trusted party's build system, such as a server in the trusted party's data center.

[0122] The syntax is associated with tool 81. This syntax describes data types in a language-independent manner. Tool 81 is used to automate a portion of the HSM firmware development process. This syntax defines the format of commands sent to the HSM and the responses they send back. The format of client programs is also defined by this syntax (i.e., the data types corresponding to the function set); however, client programs are not represented in this syntax. Instead, the textual representation of the program is written by the client using the aforementioned custom representation.

[0123] Objects in this syntax have a type that determines what values ​​they can hold and how they can be used. Some types, known as primitive types, are built into Tool 81. This syntax provides a way to define new types. Built-in types can include:

[0124] Character: Represents an integer within the range of 0 <= n <= 4294967295;

[0125] Bignum: Represents an integer that has no inherent bindings—some restrictions may be imposed in actual implementations;

[0126] Byte block: Represents a sequence of bytes—in principle, any length up to 4,294,967,295 is allowed, but in practice, there may be smaller restrictions.

[0127] In this syntax, some methods for defining new types include:

[0128] Enumeration type: A collection of names that are associated with numerical values. The values ​​of an enumeration type can also have a structure type associated with them.

[0129] Bitmap type: A collection of named flags of up to 32 bits, where each flag can take the value 0 or 1.

[0130] Structure type: A series of fields, each with a name and type.

[0131] Fields in a structure can have any type. Fields can be optional—in which case their presence in the structure depends on the value of a flag in a bitmap within the same structure. Fields can be tables, meaning they can hold zero or more values ​​of their type (typically they hold only one value). Fields can be mutable, meaning their type depends on the value of a field with an enumeration type within the same structure. Specifically, the type is the structure type associated with that value.

[0132] In this syntax, type names, enumeration value names, and (with some exceptions) flag names typically begin with an uppercase letter. Field names in a struct typically begin with a lowercase letter.

[0133] Language bindings include conventions that map these concepts to concepts in the target language (e.g., C, Python). Tool 81 implements this mapping.

[0134] The input 82 of tool 81 is a collection of data types represented by this syntax, including data types corresponding to each function (signature, branch, etc.). An excerpt of the Application Programming Interface (API) definition is shown in Appendix 1. This is an excerpt of the definition document, in which human-readable comments are enclosed in square brackets, constituting the API documentation. This excerpt lists the data type definitions represented by this syntax. These data types, represented by this syntax, serve as input to tool 81, and tool 81 runs on a trusted server.

[0135] The output of tool 81 is the language-specific representation of these data types (i.e., the same types expressed in C syntax), along with code that operates on these data types. Specifically, it outputs serialized C code and deserialized C code that operate on these data types. This is combined with other C code, including C code implementing these functions (signatures, branches, etc.), C code implementing the interpreter, C code implementing the first mechanism and derived key operations, and C code implementing any other desired functions of the HSM device 21.

[0136] Tool 81 generates C code and C language type definitions (C structs). This is combined with other C code 84. The compiler runs in step 85. The compiler generates compiled machine code, i.e., native code compiled to run on HSM device 21. This code is the HSM firmware. This HSM firmware is then incorporated into the HSM during manufacturing or as a download. The firmware then runs on HSM device 21. The code running on the HSM (i.e., the "firmware") is machine code that implements both existing HSM functions and the functions described herein. The firmware may include handwritten code as well as parts generated by tool 81. First, tool 81 generates serialization code and deserialization code.

[0137] Tool 81 can also be used to generate code written in a range of programming languages ​​for use on general-purpose computing platforms (e.g., Java or Python). For example, as described above, the client uses a custom-designed representation to write a text representation of the program code, i.e., a text file. The custom-designed representation is closely related to the syntax because functions in the custom representation (unpacking, LoadInt, signing, branching) directly map to definitions in the syntax. However, it is not written in that syntax. Converter 87 is executed on the client machine 317 to convert the text representation into a serialized form. In addition to being used for generating firmware, tool 81 can also be used to generate converter 87 in the manner described below.

[0138] Converter 87 includes Python code. References will be made now. Figure 9 The process for generating converter 87 is described. The converter code is generated on the trusted party's server and then, for example, downloaded to client machine 317. Therefore, the following steps are also performed on the trusted party's server to generate converter 87.

[0139] As previously mentioned, tool 81 runs on a trusted server, this time to generate Python code. In this case, the output of tool 81 is a language-specific representation of the data type (in this case, Python), namely the Python language type definition and the Python code. This forms converter 87. Converter 87 includes code that converts the textual representation of the client program into Python source code, and code that uses the Python language type definition to convert the Python source code into a serialized representation.

[0140] As described above, the client uses a custom-designed representation to write a text representation of the program code. Transformer 87 executes on the client machine 317 to convert the text representation into a serialized form. Transformer 87 unpacks the text representation, identifies each data type, and constructs the Python source code corresponding to the client program using Python language type definitions. Specifically, the Python definitions corresponding to the DKProgram data structures described in Appendix 1 describe the Python structures corresponding to the client program. Transformer 87 constructs the Python source code representation of the client program, including a series of program steps using these definitions.

[0141] The serialized code then serializes the Python source code using numeric constants corresponding to each data type, that is, converting the Python source code into a bit string. Converter 87 thus runs on client machine 317 and generates a serialized representation of the program in the format expected by HSM21. A uniform serialization is always used, ensuring that a single, real byte string (i.e., serialization) exists for any given client program.

[0142] In this scenario, converter 87 maps from the text representation to the program source code, i.e., Python code, and then from the Python code to the serialized representation. However, it can alternatively be configured to map from the text representation to the memory representation, and then to the serialized representation. Alternatively, it can directly map from the text representation to the serialized representation.

[0143] The bit string representation of the client algorithm is sent from the client machine 317 to the HSM device 21. The client includes a serialized representation in its application and submits it to the HSM device 21 when it wishes to use the algorithm.

[0144] HSM device 21 receives the serialized form of the client program and deserializes it into an internal format suitable for execution, as previously described. Figure 11 The process is illustrated in more detail. As described above, the deserialization code takes a bit string, which serves as a serialized representation of the client program code, as input and converts it into a memory representation. This is a data structure representing the client program in memory, and is a convenient format for execution by the HSM device 21. This memory representation may include an array, where each entry corresponds to a step in the client program, identified by a numeric constant corresponding to that function. This deserialization step is performed when a serialization program is received at the HSM device 21. The program ACL, template, and template ACL are also deserialized using the same deserialization code.

[0145] When the program is executed in S302 above, the interpreter on HSM device 21 executes and operates through the program's memory representation. Numeric constants are used to retrieve the machine code corresponding to the function in the firmware. For example, if it finds an element containing a numeric constant corresponding to the "sign" operation, it calls its own signature function, that is, it executes the machine code corresponding to the signature function in the firmware of HSM device 21.

[0146] As mentioned above, it can also be directly deserialized to machine code addresses. In this case, the memory address of the machine code corresponding to the function in the firmware is stored in this array.

[0147] The deserialization code running on HSM device 21 can alternatively be configured to convert the serialized program into machine code. In this case, the serialized representation of the client program is converted into native code, and the CPU executes it directly. No translator is required. For example, if the serialization representation is functionally encoded into the firmware, it can also be used directly.

[0148] Although tool 81 is described as part of generating firmware and converters in the example above, firmware and converter code can be generated in a variety of other ways.

[0149] An excerpt from the API definition document is shown in Appendix 1, with human-readable comments enclosed in square brackets. The API runs on HSM device 21 and interacts with the firmware. The API processes incoming commands from HSM 21 and outgoing responses from HSM. The API also defines serialization formats, ACL structures, etc. These definitions use the aforementioned non-language-specific syntax and are described in more detail below with examples.

[0150] Within a computer program, regardless of the specific programming language used, these definitions are represented as data structure definitions. Therefore, when generating the HSM firmware as described above, the data structure definitions in the C code corresponding to the definitions in Appendix 1 are included. Figure 8 In the C language type definitions, and in step 85, these data structure definitions are compiled into machine code. For example, the "signature" function is represented as a C structure with fields called brdest, brmsg, etc. The machine code corresponding to the signature function is also included in the firmware. The DKProgram definition (which is a definition of the client program data structure) is also converted into a C structure called M_DKProgram, which has fields called flags, nbbr, nir, etc. Similarly, in converter 87, Python language definitions are used.

[0151] Each data type (i.e., each definition) is accompanied by generated code that converts or deserializes it from a byte sequence in a consistent but language-neutral manner (i.e., the serialization and deserialization codes described above included in the converter 87 on the HSM firmware and client machine). The byte sequence format is used when communicating between the client machine 317 and the HSM device 21. This value is used to give the serialized form of the enumeration type.

[0152] The definitions in Appendix 1, DeriveRole WrapKey=2 and DeriveRole Key3=3, define two values ​​of the DeriveRole enumeration, which are used for input key #2 and input key #3, respectively.

[0153] The definitions `DKProgramOp LoadInt = 8` and `DKProgramOp GetLength = 9` define two values ​​for the `DKProgramOp` enumeration, each with an associated structure. These definitions correspond to functions that can be used in client programs. These structures are converted by tool 81 into language-specific representations (e.g., a `struct` in C or a `class` in Java). Each structure as a whole is serialized by serializing each of its fields sequentially. The `DKProgramStep` definition defines a structure called `DKProgramStep` with two fields. There is a relationship between these two fields. The first field (`op`) has the enumeration type. This controls what type `args` will take. The second field (`args`) has a type that depends on the value of `op`. If `op = 8`, the `Args` structure in `DKProgramOpLoadInt` is used. If `op = 9`, the `Args` structure in `DKProgramOpGetLength` is used. The same principle applies to all other values ​​for the `DKProgramOp` enumeration.

[0154] The DKProgram definition defines a structure called DKProgram, which corresponds to the client program. The flags field is a bitmap. It contains two possible flags: ExposeErrors and ? curve. The curve field is optional and only exists if the ? curve flag is non-zero. The program field is not limited to a single DKProgramStep, but can be any number of objects of that type.

[0155] While the above describes specific examples of how procedures and policies can be presented, various other options for presenting procedures and / or policies are possible. For example, a procedure can be passed directly to an operation instead of being presented as a key. In this case, the constraints on the procedure (in the policy attached to the key) will be constraints of a separate type, rather than constraints on the key in a specific role. For example, these constraints can still be provided in an ACL. For example, the procedure can be preloaded into the device performing the operation in a form different from that of a key and referenced in the operation by name or identifier. Thus, when referenced in command 501, a data packet including the procedure can be preloaded into the HSM device and, in this case, obtained, i.e., retrieved. This data packet can be in the form of a file loaded onto the device. Alternatively, the procedure can be referenced during the operation by name or identifier and retrieved from an external source as needed. Alternatively, the procedure can be physically presented to the device, for example, via an attached keyboard or keypad, or via a removable storage medium. In this case, the procedure can be identified by, for example, a filename. ACLs can be provided, for example, embedded in a file or in a separate association file.

[0156] Furthermore, while the examples above illustrate specific ways of binding policies (ACLs) to procedures and keys, various other approaches can be used. For instance, a device might have a fixed policy for each key type, or some means for physically presenting policies (e.g., if it operates in a secure physical environment). Various methods can be used to ensure the security of the relationship between each object and its policy, in the sense that the relationship is immutable or can only be changed by authorized users.

[0157] Furthermore, in the example above, although a second strategy for the output data is provided in the template "key," various other methods can be used. For example, the device may have a fixed strategy for the output key, or some means for physically presenting the output data. The second strategy can be preloaded into the device in a form different from the key and referenced by a name or identifier. Alternatively, the second strategy can be referenced by a name or identifier during operation and retrieved from an external source as needed. Alternatively, the second strategy can be physically presented via a removable storage medium. Alternatively, the output may not have an associated strategy if it is desired that its use is not restricted. In this case, no template key is provided.

[0158] In the example above, although the program generates a single output key, this is not a limitation, and more than one output can be generated. Each output can be generated using the same strategy, or different strategies can be associated with each output. In this case, multiple template keys are used as inputs, and each template key is assigned a role to associate with one of the outputs. For example, this could be useful for generating asymmetric key pairs. In this case, the program code would implement the operations for generating asymmetric key pairs. Different strategies would then be associated with the generated public and private keys. For example, these strategies could be provided in separate template keys. Additionally, in the example above, although the program's output is the derived key, the program can provide outputs other than encryption keys. For example, the program could output signed data, with the data to be signed and the signing key as input.

[0159] Furthermore, in the examples above, although objects (programs, templates, and keys) are identified by a cryptographic hash of the object's type and value, other methods can be used to identify the object. For example, any method that makes replacing one object with another impractical could be used to identify these objects. For instance, object identifiers could be bound to objects in the same way as policies, devices could have fixed identifiers for objects, non-secret objects (e.g., programs, templates, and public keys) could be identified directly by their values, or objects could be identified by a cryptographic hash of their values ​​(i.e., excluding their type).

[0160] In the method described above, a program or similar object is provided with a binding strategy. Although the term "program" is used above, the client can provide an opaque "blob" of data, which is then executed as a program on the device. In this case, the strategy is bound to the data.

[0161] In the method described above, the various steps are described as being performed on the client machine 317. However, the client can access the HSM device 21 in various ways. For example, some or all of the steps described as being performed on the client machine 317 can be performed on a separate server, for example, by a web application accessed on the client machine.

[0162] Although some embodiments have been described, these embodiments are presented by way of example only and are not intended to limit the scope of the invention. Indeed, the novel methods and apparatus described herein can be modified in various other forms; in addition, various omissions, substitutions, and changes can be made to the form of the methods and apparatus described herein.

[0163] Other embodiments are described in the following clauses:

[0164] 1. A computer-implemented method, comprising:

[0165] Obtain first data, which includes a representation of computer program code implementing the encryption algorithm;

[0166] Obtain the second data;

[0167] Receive a request to execute a first mechanism, the request including information identifying the first mechanism, and information identifying first data as corresponding to a program and second data as corresponding to input;

[0168] The first mechanism is executed, which includes:

[0169] The first determination is executed, and the first determination includes:

[0170] Determine whether the first strategy associated with the second data allows the second data to be used with the program represented in the first data; and

[0171] If the first determination is successful, then the program represented in the first data is executed with the second data as input.

[0172] 2. The method according to Clause 1, wherein the first determination further includes determining whether the first strategy allows the use of the second data in the first mechanism.

[0173] 3. The method according to any of the preceding clauses, wherein the first policy is a first access control list, the first access control list including an allow list related to the use of the second data.

[0174] 4. The method according to any of the preceding clauses, wherein the first determination further includes determining whether a third strategy associated with the computer program code allows the computer program code to be used with the second data.

[0175] 5. The method described in Clause 4, wherein the third policy is a third access control list, which includes a list of permissions related to the use of the program.

[0176] 6. The method according to any of the preceding clauses further includes:

[0177] Obtain third data, which includes a representation of the output strategy information;

[0178] The request also includes information that identifies the third data as corresponding to the second strategy;

[0179] The execution of the first mechanism also includes associating the second strategy with the output data of the program.

[0180] 7. The method according to Clause 6, wherein the first determination further includes determining whether the first policy allows the second data to be used with the output policy in the third data.

[0181] 8. The method according to Clause 6 or 7, wherein the first determination further includes determining whether a fourth policy associated with the output policy allows the output policy to be used with the program represented in the first data.

[0182] 9. The method according to any of the preceding clauses, wherein the second data is an encryption key.

[0183] 10. The method according to any of the preceding clauses, wherein the computer program code includes one or more functions from a predetermined set of functions.

[0184] 11. The method according to any of the preceding clauses further comprises:

[0185] A representation of the computer program code implementing the encryption algorithm is generated at the first device;

[0186] Sending the first data from the first device to the second device; and

[0187] The first mechanism is executed at the second device.

[0188] 12. The method according to any of the preceding clauses further includes:

[0189] Obtain the fourth data;

[0190] The request also includes information identifying the fourth data as corresponding to the input data, and the request further defines the roles of the second and fourth data.

[0191] The first determination also includes determining whether a fifth strategy associated with the fourth data allows the fourth data to be used with the procedure represented in the first data.

[0192] 13. The method according to Clause 12, wherein the first determination further includes determining whether the fifth strategy allows the fourth data to be used with the second data and / or determining whether the first strategy allows the second data to be used with the fourth data.

[0193] 14. A carrier medium including computer-readable code configured to cause a computer to perform any of the methods described in the preceding clauses.

[0194] 15. An apparatus comprising:

[0195] The input terminal is configured to receive a request to execute a first mechanism, the request including information identifying the first mechanism, and information identifying first data as corresponding to a program and second data as corresponding to input; and

[0196] The processor is configured as follows:

[0197] Obtain first data and obtain second data, wherein the first data includes a representation of computer program code that implements one or more encryption operations;

[0198] The first mechanism is executed, which includes:

[0199] Performing a first determination, the first determination including determining whether a first policy associated with the second data allows the second data to be used with the program represented in the first data; and

[0200] If the first determination is successful, then the program represented in the first data is executed with the second data as input.

[0201] Appendix 1:

[0202] Below is an excerpt of the API definition, which specifies the language that can be used to write computer program code in the example implementation. Below is a list of definitions for the various data types in the example.

[0203]

[0204]

[0205]

[0206]

[0207]

[0208]

[0209]

[0210]

[0211]

[0212]

[0213]

[0214]

[0215]

[0216]

Claims

1. A computer-implemented method, comprising: Obtain first data, the first data including a representation of computer program code implementing the encryption algorithm; Obtain the second data; Receive a request to execute a first mechanism, the request including information identifying the first mechanism, and information identifying the first data as corresponding to a program and the second data as corresponding to input; Executing the first mechanism, wherein executing the first mechanism includes: The first determination is performed, and the first determination includes: Determine whether the first policy associated with the second data allows the second data to be used with the program represented in the first data, and Determine whether another strategy associated with the computer program code allows the computer program code to be used with the second data; and If the first determination is successful, then the program represented in the first data is executed, using the second data as input.

2. The method according to claim 1, wherein, The first determination also includes determining whether the first strategy allows the use of the second data in the first mechanism.

3. The method according to any one of the preceding claims, wherein, The first policy is a first access control list, which includes a list of allowed permissions related to the use of the second data.

4. The method according to claim 1, wherein, The other strategy is a third strategy, and the third strategy is a third access control list, which includes a list of permissions related to the use of the program.

5. The method according to any one of the preceding claims, wherein, The other strategy is a third strategy, and the method further includes: Obtain third data, which includes a representation of the output strategy information; The request also includes information that identifies the third data as corresponding to the second strategy; The execution of the first mechanism also includes associating the second strategy with the output data of the program.

6. The method according to claim 5, wherein, The first determination also includes determining whether the first strategy allows the second data to be used with the output strategy in the third data.

7. The method according to claim 5 or 6, wherein, The first determination also includes determining whether a fourth policy associated with the output policy allows the output policy to be used with the program represented in the first data.

8. The method according to any one of the preceding claims, wherein, The second piece of data is the encryption key.

9. The method according to any one of the preceding claims, wherein, The computer program code includes one or more functions from a predetermined set of functions.

10. The method according to any one of the preceding claims further comprises: A representation of computer program code implementing the encryption algorithm is generated at the first device; The first data is sent from the first device to the second device; as well as The first mechanism is executed at the second device.

11. The method according to any one of the preceding claims, further comprising: Obtain the fourth data; The request further includes information identifying the fourth data as corresponding to the input data, and the request also defines the roles of the second data and the fourth data; The first determination further includes determining whether a fifth strategy associated with the fourth data allows the fourth data to be used with the program represented in the first data.

12. The method according to claim 11, wherein, The first determination also includes determining whether the fifth strategy allows the fourth data to be used with the second data and / or determining whether the first strategy allows the second data to be used with the fourth data.

13. A carrier medium comprising computer-readable code configured to cause a computer to perform the method of any one of the preceding claims.

14. An apparatus comprising: The input terminal is configured to receive a request to execute a first mechanism, the request including information identifying the first mechanism, and information identifying first data as corresponding to a program and second data as corresponding to input; as well as The processor is configured as follows: Obtain the first data and obtain the second data, wherein the first data includes a representation of computer program code that implements one or more encryption operations; Executing the first mechanism, wherein executing the first mechanism includes: The first determination is performed, and the first determination includes: Determine whether the first policy associated with the second data allows the second data to be used with the program represented in the first data, and Determine whether another strategy associated with the computer program code allows the computer program code to be used with the second data; and If the first determination is successful, then the program represented in the first data is executed, using the second data as input.

Citation Information

Patent Citations

  • Tokenized Hardware Security Module

    CN109104281A

  • System and method for electronic check verification over a network

    US20060136332A1