Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems that the majority of commercially available hardware HSMs are only designed to allow authenticated users to generate, store, and use cryptographic keys with various cryptographic algorithms implemented within the firmware of the HSM.

Reading the datasheets it looks like I can use the provided API to make my (external) application interact with the HSM and use its cryptographic muscles, maybe using keys generated/stored within the HSM. But, it seems that long term storage of the data/objects cryptographically processed by the HSM within the HSM boundary is not available.

Why aren’t there any HSMs that allow for user code and user data to be persistently stored and managed within the physically protected memory space of the HSM?

Does anybody have experience with HSMs and could point me towards a commercially available hardware HSM solution that at the least allows me to store some registers beyond cryptographic keys?

Ideally I would like my application to be stored at rest in the HSM boundary, executed by the same processor that runs the crypto provided by the HSM and to persisytently store a few registers within the HSM's protected area.

share|improve this question
up vote 14 down vote accepted

The Thales nShield HSM (previously nCipher) allow for generic programming. This is a rather expensive option; it must first be enabled in the HSM (through a "feature file" which is signed by Thales and specific to the serial number of a HSM), and then the extra code can run as long as it is signed with a key known to the HSM for such usage.

With that option, you will get a C compiler with a reduced C library, and some API which give access to the HSM features. The internal OS allows for one process (but multi-threaded) and cryptographic operations are done with transactions; there are also transactions to exchange arbitrary binary blobs with the external world (the host PC). The core CPU is not very powerful (think 60 MHz ARM or PowerPC) but there is some substantial RAM (megabytes, even dozens of megabytes).

Thales/nCipher HSM do not have a lot of permanent storage features (there are a few kilobytes of EEPROM but that's all). Actually, the HSM only stores a master key (which you cannot access), and everything, including the "keys" which are "in the HSM" are off-loaded, with encryption. You can do the same: store your data stored on the host, sent back to your internal module; the data is encrypted with one of the keys (which are virtually "in the HSM"), and your code in the HSM does the decryption.

share|improve this answer
Resources available for application development: • 16MB standard RAM, • 32 MB RAM for JVM development • 8 KB non-volatile RAM for secure user memory • Real-time clock – Drew Lex Nov 28 '12 at 0:36
Does anybody know the approximate cost for the development tools and HSM? – Drew Lex Dec 6 '12 at 22:07
Thales would probably be eager to respond to you, but the order of magnitude would be 10000$ (I am not entitled to give prices, but don't expect it to be as cheap as a PC, even a big one). – Thomas Pornin Dec 7 '12 at 1:04
@ThomasPornin would there be any recommendations against using a (way cheaper) TPM and use its sealed storage feature? – Steve DL Aug 21 '14 at 13:49

The reason that there are no HSMs that allow user code to be stored is that isn't what they are for. HSMs a) take the cryptographic load off of systems, and b) (arguably to some) make enterprise cryptographic security better through the use of hardened, single-purpose boxes.

Allowing user code to be stored dilutes the purpose of the HSM, having some detrimental effects:

  • Shows them down: putting HSM system resources to other uses makes them less available for their needed purpose
  • Increases their attack surface: it is easier to harden a box if it has as few entry and exit points as possible. Adding all sorts of functionality would greatly decrease their security
  • User code and data could be used as an attack vector. Why would you want a high security system processing user generated data of unknown nature?

It sounds inviting to use HSMs for purposes other then their stated use, they are expensive and powerful, however it's not a good idea, so those types of features generally aren't offered.

share|improve this answer
I have found one HSM family that allows for third party applications to be run by the HSM - CodeSafe™ Developer Kit which is supported by some nCipher HSMs. – Drew Lex Nov 27 '12 at 9:14

The Utimaco/Sophos HSM has got plenty of FLASH for internal storage of keys, which you can manage via (for instance) the PKCS#11 interface.

If you want to develop your own cryptographic algorithms or security protocols , there is also an SDK available. The CPU is a bit exotic (Texas Instruments DSP), but it is fully programmable in C and comes with a simulator. Code loading is simple and very well-thought through, with proper authentication and possibly code encryption.

Bonus point: certain models have partial support for FIPS 140-2 Level 4 (that is, active zeroization of root secrets in case of physical attack), if that sort of stuff makes your boat float. Of course, keep in mind that if you develop your own firmware, the FIPS certification is not valid anymore.

share|improve this answer

SafeNet HSMs allow for the loading of custom code into the module. Depending on the requirements, there are different options available.

share|improve this answer
Mark, welcome to Information Security. If you have a commercial relationship with a vendor you are referring to, it is considered good form to disclose this relationship in your answer. See the FAQ... – AviD May 30 '13 at 9:22

All IBM HSMs allow development of custom firmware that can be loaded and executed in the HSM with the same level of security as the standard IBM firmware - in other words, the complete security provided by the HSM. The custom firmware can either be developed as an add-on to the standard IBM firmware, so that you get all of the standard HSM commands PLUS your custom ones - or you can completely replace the set of firmware providing IBM's command set with something you develop yourself. For some information on custom programmng related to the current IBM HSM family, see the "custom programming" section of the documentation library here, and this more detailed page of custom programming information. On the general product information section of that same web site, you will find this summary of the custom programming capabilities:

Custom Programming

Using toolkits available from IBM under custom contract, you can implement your own applications for the coprocessor, or you can extend IBM's CCA application. You can make a fast start on your custom application development when you extend CCA using its flexible access-control system and many existing services.

Each toolkit user will be issued a unique identifier by IBM along with a code-signing key. This allows customer coprocessor software to be signed. Custom software is developed using conventional C-language compilers. Debugging programs are provided as part of the toolkit. You or your customers can then load coprocessor software in a normal server environment. Using the PKI-based outbound authentication capabilities of the coprocessor's control program, you can securely administer the coprocessor environment, even from remote locations. Auditors can inspect the coprocessor's digitally signed status response to confirm that the coprocessor remains untampered and running uniquely identified software.

A customer can obtain the toolkit and develop the customer firmware on their own, or they can contract with experts at IBM to develop the custom code for them.

share|improve this answer
This kind of sounds like an advert. Especially with this question being almost two years old. – Chris Murray Aug 21 '14 at 13:44
Googling "Todd Arnold IBM" seems to confirm your intuition @ChrisMurray but to be honest most answers on this thread advertise a product or another... – Steve DL Aug 21 '14 at 13:48

Most HSM's allow for using custom code, but in general you have to ask the specific vendor, it's not something that they advertise. Often it breaks certification. On the other hand, running applications that can e.g. validate the input can make for a much more secure experience. Generally these applications are sandboxed and need to be signed. Of course, if you are a big enough customer it's also possible to talk about customization by the vendor itself.

You should expect vendor specific API's and weird architectures.

There was a Java based HSM from SafeNet that was specifically targeting development of signed applications to run on the HSM, but I understood that it was discontinued (it was sufficiently expensive that I haven't even laid eyes on it).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.