TPM (Trusted Platform Module) and HSM (Hardware Security Module) are considered as cryptoprocessor, but what are the differences exactly?
Does one of them has more advantages than another?
Trusted Platform Modules
A Trusted Platform Module (TPM) is a hardware chip on the computer’s motherboard that stores cryptographic keys used for encryption. Many laptop computers include a TPM, but if the system doesn’t include it, it is not feasible to add one. Once enabled, the Trusted Platform Module provides full disk encryption capabilities. It becomes the "root of trust" for the system to provide integrity and authentication to the boot process. It keeps hard drives locked/sealed until the system completes a system verification, or authentication check.
The TPM includes a unique RSA key burned into it, which is used for asymmetric encryption. Additionally, it can generate, store, and protect other keys used in the encryption and decryption process.
Hardware Security Modules
A hardware security module (HSM) is a security device you can add to a system to manage, generate, and securely store cryptographic keys.
High performance HSMs are external devices connected to a network using TCP/IP. Smaller HSMs come as expansion cards you install within a server, or as devices you plug into computer ports.
One of the noteworthy differences between the two is that HSMs are removable or external devices. In comparison, a TPM is a chip embedded into the motherboard. You can easily add an HSM to a system or a network, but if a system didn’t ship with a TPM, it’s not feasible to add one later. Both provide secure encryption capabilities by storing and using RSA keys.
Sorry, but I think there are some gaps in this conversation:
The primary difference is in use. TPMs are meant to provide a hardware root of trust to enable secure computing by providing a secure key storage enclave with minimal cryptographic functions primarily in the signing and signature verification space. Some one did outline the primary use cases ... storage of drive encryption keys and validation of signatures on boot loaders, kernels, and device drivers. Note, much of this can be accomplished without a TPM (secure boot with bios that support Windows WHQL including default Microsoft keys), password based disk encryption. TPMs typically cost between $7 USD (as part of the bill of materials for a custom board) to $15 USD (as a pluggable module for after market modification). TPMs can include smart card reader / virtual smart card functionality.
HSMs typically have two primary, closely related functions. The first function is hardware enabled / accelerated cryptographic functions including encipherment, decipherment, key generation, PRNG functions, and related signing/signature validation functions. Typically these are hardware accelerated by onboard FPGA or ASIC (or a combination). The second function typically is a smart card reader with / without virtual smart card for key / certification storage with enhanced (PIN) based protections. The integration of the two provides a powerful model for using hardware to generate a non-exportable certificate embedded within the virtual smart card. HSMs can run from tens of thousands of dollars (for chassis based solutions) to thousands of dollars (for PCIE cards) to 100s of dollars (USB) to 10s of dollars (for H-SDC versions).
In my experience, TPMs are primarily used for key storage, HSMs are primarily used for hardware accelerated cryptography with key storage.
TPMs are very exactly specified parts wrt to function and security level they provide (https://www.trustedcomputinggroup.org).
It has fixed function, is a rather low cost and yet high security chip (less than $2.00). The purpose is to serve as a ‚root of trust‘ on a platform. Also they are tested and certified to withstand a defined level of side-channel/observing attacks, semi-invasive/fault attacks and even invasive attacks.
In contrast the term HSM essentially just says „hardware security module“ and this leads to an ambiguity and variety of interpretations.
Traditionally an HSM is module that is optimized to generate AES, RSA or ECC keys and certificates in very high performance. Imagine you run a web-server that shall be able to quickly establish hundreds or thousands of https (SSL/TLS) session. This requires a massive crypto performance (i.e. key generation). HSMs do this - very fast! They are not necessarily well protected sophisticated against attacks, since they are usually operated in a secure environment. However they typically are packaged in a way that provides tamper resistance and evidence. Big difference to TPMs: these modules cost $1000s upwards. It‘s low volume specially designed silicon and comes e.g. on PCIexpress boards where the customer can scale the required performance by plugging in multiple HSMs on his motherboard/rack. The TPM market is north of 100mio pcs/yr. And by definition there is 1 TPM ‚bound‘ (=mostly ‚soldered‘) to the platform.
Other forms of „HSM“ interpretations: Some use the term HSM ambiguously e.g. even for the TrustZone in the ARM-A series family or anything where there is a dedicated security processor in a more general (multi-core) CPU.
TPMs are verifying, that computer runs only signed code. It usually builtin motherboard.
HSM used to store private or symmetric keys for encryption.Usually it is separate network deivce.
TPM chips often are embedded onto a motherboard, but not always. HSM are almost always external.
My motherboard actually supports adding a TPM chip via a header.
TPM can replicate some HSM functionality, but a HSM cannot replace a TPM. TPM allows a root of trust for booting.