Cryptography can take many forms. It can be used to protect data in flight or data at rest, to authenticate a user, or provide a digital signature for banking or finance applications. Cryptography provides the building blocks applications use to protect the intellectual property that differentiates one customer from another.
Over the years, as Linux on System z has taken on a strong leadership role with Web- and Internet-facing applications, the value of Java and access to cryptography from Java has become paramount. Since Java is the most widely used language for Web applications, these applications have assumed the roles of protecting the confidentiality and integrity of data in the enterprise and the authentication of users and their authorization to various functions or data.
Hardware cryptography available on System z brings added business value to Java applications when running on Linux. The Crypto Express3 or Crypto Express4 cards in accelerator mode can provide cost-saving offload options, freeing up the processor to do other work as well as yielding drastic improvements in speed. The Central Processor Assist for Cryptographic Function (CPACF) capabilities, also available to Java applications, provide additional savings in processing time, which means better overall application throughput and cost savings. Banks and financial institutions can take advantage of the robust secure key and banking functions available on the Crypto Express3 and Crypto Express4 cards in coprocessor mode.
Writing a Java program that uses cryptographic functions from a library that exploits the System z cryptographic hardware can seem complex. It involves several components that must work together: the Linux kernel with a crypto device driver, System z-specific crypto libraries, openCryptoki with specific tokens, the Java Cryptography Architecture (JCA) with the Java Cryptography Extension (JCE) Application Program Interface (API) and the appropriate Java provider.
Here we demonstrate how to set up Linux on System z for an application to exploit cryptographic hardware features of the System z architecture using a simple Java program for encrypting and decrypting a message using the Advanced Encryption Standard (AES). However, let’s first briefly describe the cryptographic hardware features supported by the System z platform and the software stack needed to exploit these features in a Java program.
System z Cryptographic Hardware
The System z architecture provides CPACF on its processors, which is a free installation option for all System z servers in countries that aren’t subject to U.S. export regulations for cryptography. CPACF provides instructions that compute hash functions (SHA-1, SHA-224, SHA-256, SHA-386 and SHA-512), cryptographic functions to encrypt or decrypt messages using Data Encryption Standard (DES), triple DES, AES-128, AES-192 and AES-256 using several modes of operations (ECB, CBC, CFB, OFB, CTR, XTS, CCM and GCM), support for message authentication codes such as CBC-MAC, CMAC and GMAC, and a pseudo random generator. Depending on the size of the message to be encrypted, some modes of operation implemented in CPACF are more than 10 times faster than software implementations.
Crypto Express Adapters support offloading cryptographic functions to an adapter card, freeing the CPUs to perform other work. Linux can exploit Crypto Express Adapters both in accelerator mode, identified as CEX2A, CEX3A and CEX4A, and coprocessor mode, identified as CEX2C, CEX3C and CEX4C. Crypto Express Adapters in accelerator mode and coprocessor mode provide functions for RSA clear key encryption and decryption with the accelerators, providing better performance than the coprocessors. In addition, the Crypto Express coprocessors provide a true random number generator and functions for secure key cryptography, according to the Common Cryptographic Architecture (CCA).
With clear key cryptography, cryptographic keys are stored in memory. With secure key cryptography, all keys stored in memory are encrypted. These keys can only be decrypted and used to encrypt or decrypt messages inside a tamper-proof Hardware Security Module (HSM) such as the Crypto Express coprocessors. It can be addressed using an API defined in the CCA. Figure 1 shows the use of both clear key and secure key cryptography.
The Linux Crypto Software Stack
The crypto software stack in this example is required for a Java application to exploit cryptographic hardware; it consists of three layers: