drivers: misc: Add support for nCipher HSM devices
PATCH v2 1/1 drivers: misc: Add support for nCipher HSM devices
From: David Kim <[email protected]>
This is the driver for nCipher’s Solo and Solo XC hardware security modules. These modules implement a proprietary command set (the ’nCore API’) to perform cryptographic operations - key generation, signature, and so on. HSM commands and their replies are passed in a serialised binary format over the PCIe bus via a shared memory region. Multiple commands may be in-flight at any one time - command processing is multi-threaded and asynchronous. A write operation may, therefore, deliver multiple commands, and multiple replies may be retrieved in one read operation.
The HSM is supported by software supplied by nCipher. The driver supports only a single user-space connection, so the support software includes a daemon called ‘hardserver’ . This accepts network or Unix- domain socket connections from client applications, and multiplexes / demultiplexes commands and replies from these clients to one or more HSM devices.
The nCipher support software includes a variety of command-line and graphical tools for HSM management, and a number of libraries which interface between numerous industry-standard APIs and the nCore API commands implemented by the HSM. On Linux, the JCE (Java Cryptography Extensions) and C-language PKCS#11 interfaces are supported.
Previously, the support software included the kernel driver as source code, which is built against the host machine’s kernel headers when the support software is installed. For most standard OS distributions this isn’t a problem, but many users in security- sensitive environments (such as banking services) remove all unnecessary components for their own in-house distributions. For these users, the need to support compiling and loading of externally- supplied kernel modules is problematic, and adds extra friction when the kernel needs to be updated.
In general, users who have an nCipher PCI HSM will be able to download the required support software from nCipher. The devices themselves are subject to export control restrictions under US and EU law, and because of this we are unable to make the software freely available, or offer detailed technical support, in all territories.
--- MAINTAINERS | 9 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/ncipher/Kconfig | 8 + drivers/misc/ncipher/Makefile | 7 + drivers/misc/ncipher/fsl.c | 881 +++++++++++++++++ drivers/misc/ncipher/fsl.h | 116 +++ drivers/misc/ncipher/hostif.c | 1522 +++++++++++++++++++++++++++++ drivers/misc/ncipher/i21555.c | 623 ++++++++++++ drivers/misc/ncipher/i21555.h | 64 ++ drivers/misc/ncipher/solo.h | 315 ++++++ include/uapi/linux/nshield_solo.h | 159 +++ 12 files changed, 3706 insertions(+) create mode 100644 drivers/misc/ncipher/Kconfig create mode 100644 drivers/misc/ncipher/Makefile create mode 100644 drivers/misc/ncipher/fsl.c create mode 100644 drivers/misc/ncipher/fsl.h create mode 100644 drivers/misc/ncipher/hostif.c create mode 100644 drivers/misc/ncipher/i21555.c create mode 100644 drivers/misc/ncipher/i21555.h create mode 100644 drivers/misc/ncipher/solo.h create mode 100644 include/uapi/linux/nshield_solo.h
MAINTAINERS +9 -0
@@ -11319,6 +11319,15 @@ NATSEMI ETHERNET DRIVER (DP8381x) S: Orphan F: drivers/net/ethernet/natsemi/natsemi.c +NCIPHER NSHIELD HARDWARE SECURITY MODULE DRIVERS +M: Tim Magee <[email protected]> +M: David Kim <[email protected]> +M: Hamish Cameron <[email protected]> +W: https://www.ncipher.com/products/general-purpose-hsms/nshield-solo +L: [email protected] +S: Supported +F: drivers/misc/ncipher/ + NCR 5380 SCSI DRIVERS M: Finn Thain <[email protected]> M: Michael Schmitz <[email protected]>
drivers/misc/Kconfig +1 -0
@@ -480,4 +480,5 @@ source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" +source "drivers/misc/ncipher/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -57,3 +57,4 @@ obj-y += cardreader/ obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o +obj-$(CONFIG_NCIPHER) += ncipher/
drivers/misc/ncipher/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# Enable support for nCipher's nShield Solo and Solo XC +config HSM_NCIPHER_NSHIELD_SOLO + tristate "nCipher Solo and Solo XC family of PCIe HSMs" + depends on PCI + help + Select this as built-in or module if you expect to use + a Hardware Security Module from nCipher's Solo or Solo XC range.
drivers/misc/ncipher/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for nCipher nShield HSM drivers +# + +obj-$(CONFIG_HSM_NCIPHER_NSHIELD_SOLO) := nshield_solo.o +nshield_solo-y := hostif.o fsl.o i21555.o
drivers/misc/ncipher/fsl.c new file +881 -0
881 lines not on this page · raw message
drivers/misc/ncipher/fsl.h new file +116 -0
116 lines not on this page · raw message
drivers/misc/ncipher/hostif.c new file +1522 -0
1,522 lines not on this page · raw message
drivers/misc/ncipher/i21555.c new file +623 -0
442 lines not on this page · raw message
drivers/misc/ncipher/i21555.h new file +64 -0
64 lines not on this page · raw message
drivers/misc/ncipher/solo.h new file +315 -0
315 lines not on this page · raw message
include/uapi/linux/nshield_solo.h new file +159 -0
159 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 12 lines
2.24.1 David Kim Senior Software Engineer Tel: +44 1223 703449 nCipher Security One Station Square Cambridge CB1 2GA United Kingdom
Part of the diff is not shown here. View the raw message.
Greg KH
maintainerQuoted 10 lines · Dave Kim
From: David Kim <[email protected]>
This is the driver for nCipher’s Solo and Solo XC hardware security modules. These modules implement a proprietary command set (the ’nCore API’) to perform cryptographic operations - key generation, signature, and so on. HSM commands and their replies are passed in a serialised binary format over the PCIe bus via a shared memory region. Multiple commands may be in-flight at any one time - command processing is multi-threaded and asynchronous. A write operation may, therefore, deliver multiple commands, and multiple replies may be retrieved in one read operation.
If this is "just" a crypto accelerator, why isn't this driver using the existing in-kernel hardware crypto api? What is lacking from it that you need here?
thanks,
greg k-h
Quoted 10 lines
Quoted 10 lines
This is the driver for nCipher’s Solo and Solo XC hardware security modules. These modules implement a proprietary command set (the ’nCore API’) to perform cryptographic operations - key generation, signature, and so on. HSM commands and their replies are passed in a serialised binary format over the PCIe bus via a shared memory region. Multiple commands may be in-flight at any one time - command processing is multi-threaded and asynchronous. A write operation may, therefore, deliver multiple commands, and multiple replies may be retrieved in one
Quoted 4 lines
read operation.
If this is "just" a crypto accelerator, why isn't this driver using the existing in- kernel hardware crypto api? What is lacking from it that you need here?
Hi Greg,
A cryptographic accelerator uses key material which is stored on, and managed by, the host machine. Hardware security modules, such as nCipher’s Solo products, retain key material (i.e. secrets) within the secure boundary of the device, and implement various forms of access control to restrict use of that key material.
nCipher's product range started, in the early 1990s, as cryptographic accelerators. The series of hardware security modules served by this driver still does do cryptography but their main function is the generation, management and use of keys within a secure boundary.
The driver doesn't do any cryptography. It provides the link between the userspace software and the HSM's firmware. Cryptography is done within the HSM's secure boundary.
Regards
Dave
Greg KH
maintainerQuoted 15 lines · David
Quoted 10 lines
Quoted 10 lines
This is the driver for nCipher’s Solo and Solo XC hardware security modules. These modules implement a proprietary command set (the ’nCore API’) to perform cryptographic operations - key generation, signature, and so on. HSM commands and their replies are passed in a serialised binary format over the PCIe bus via a shared memory region. Multiple commands may be in-flight at any one time - command processing is multi-threaded and asynchronous. A write operation may, therefore, deliver multiple commands, and multiple replies may be retrieved in one
Quoted 4 lines
read operation.
If this is "just" a crypto accelerator, why isn't this driver using the existing in- kernel hardware crypto api? What is lacking from it that you need here?
Quoted 7 lines
Hi Greg,
A cryptographic accelerator uses key material which is stored on, and managed by, the host machine. Hardware security modules, such as nCipher’s Solo products, retain key material (i.e. secrets) within the secure boundary of the device, and implement various forms of access control to restrict use of that key material.
nCipher's product range started, in the early 1990s, as cryptographic accelerators. The series of hardware security modules served by this driver still does do cryptography but their main function is the generation, management and use of keys within a secure boundary.
The driver doesn't do any cryptography. It provides the link between the userspace software and the HSM's firmware. Cryptography is done within the HSM's secure boundary.
So this should tie into the correct crypto/key apis that the kernel has and not create a brand new user/kernel api, right?
Please work with the crypto kernel developers to get this right, I can't take this until they agree that this code and api is correct.
thanks,
greg k-h
Quoted 15 lines
Quoted 6 lines
A cryptographic accelerator uses key material which is stored on, and managed by, the host machine. Hardware security modules, such as nCipher’s Solo products, retain key material (i.e. secrets) within the secure boundary of the device, and implement various forms of access control to restrict use of that key material.
Quoted 8 lines
nCipher's product range started, in the early 1990s, as cryptographic accelerators. The series of hardware security modules served by this driver still does do cryptography but their main function is the generation, management and use of keys within a secure boundary.
The driver doesn't do any cryptography. It provides the link between the userspace software and the HSM's firmware. Cryptography is done within the HSM's secure boundary.
Quoted 5 lines
So this should tie into the correct
crypto/keyapis that the kernel has and not create a brand new user/kernel api, right?Please work with the crypto kernel developers to get this right, I can't take this until they agree that this code and api is correct.
Although it is technically possible for us to use the linux crypto APIs, that doesn't fit in with how our hardware is meant to be used. Please see the explanation below from Ian, one of our architects. If you feel that our driver should instead be targeted to drivers/crypto, I can resubmit our patch to the crypto list and we'll discuss with the crypto maintainers.
Thanks,
Dave
Ian's reply:
The Linux Kernel Crypto API
(https://www.kernel.org/doc/html/latest/crypto/intro.html) allows callers to apply cryptographic transformations to input data. There is a socket-based interface (https://www.kernel.org/doc/html/latest/crypto/userspace-if.html ) which makes these available to user-space. The documentation also mentions the libkcapi library (http://www.chronox.de/libkcapi.html) which is a C wrapper round the socket interface.
The basic mode of operation for all of these is: (a) create a transformation object (or handle), (b) call a “set key” function to supply key data, (c) call an encrypt or decrypt function to apply the transformation.
This interface is appropriate when the caller has the key data itself available. In the user-space case, key data is supplied via the ALG_SET_KEY option passed to setsockopt(). For the in-kernel interface, this is via various setkey() function pointers in structures defined in include/linux/crypto.h.
The nCipher Solo device is a “Hardware Security Module”, the purpose of which is to protect key data in various ways; its functionality goes beyond simply providing implementations of cryptographic algorithms. In other words, the user of an HSM doesn’t generally possess the key data itself, but requests access to it via the HSM interface. Key data itself remains within the (physical and logical) “security boundary” of the HSM, and access to it is subject to various checks and policies. For instance, a smartcard which allows a digital signature to be made when the user has correctly entered a PIN is acting as a simple hardware security module.
Our customers use Solo HSMs where they have a need (often legally mandated) to keep key data protected by a separate subsystem. Many require compliance with the FIPS 140 standard
(https://csrc.nist.gov/publications/detail/fips/140/2/final) or the eIDAS regulations (https://ec.europa.eu/futurium/en/eidas-observatory). So, while it would be possible to implement a “set key” function to deliver key material to the HSM in order to perform an operation, this would not meet the protection requirements of these standards, and would be of no use to customers.
Greg KH
maintainerQuoted 22 lines · David
Quoted 15 lines
Quoted 6 lines
A cryptographic accelerator uses key material which is stored on, and managed by, the host machine. Hardware security modules, such as nCipher’s Solo products, retain key material (i.e. secrets) within the secure boundary of the device, and implement various forms of access control to restrict use of that key material.
Quoted 8 lines
nCipher's product range started, in the early 1990s, as cryptographic accelerators. The series of hardware security modules served by this driver still does do cryptography but their main function is the generation, management and use of keys within a secure boundary.
The driver doesn't do any cryptography. It provides the link between the userspace software and the HSM's firmware. Cryptography is done within the HSM's secure boundary.
Quoted 5 lines
So this should tie into the correct
crypto/keyapis that the kernel has and not create a brand new user/kernel api, right?Please work with the crypto kernel developers to get this right, I can't take this until they agree that this code and api is correct.
Quoted 5 lines
Although it is technically possible for us to use the linux crypto APIs, that doesn't fit in with how our hardware is meant to be used. Please see the explanation below from Ian, one of our architects. If you feel that our driver should instead be targeted to
drivers/crypto, I can resubmit our patch to the crypto list and we'll discuss with the crypto maintainers.
As I said, please submit and get approval from the crypto developers/maintainers first. I need that before I can accept a brand-new api for a one-off device that then needs to be supported for 40+ years.
thanks,
greg k-h