Skip to contentSkip to conversation

s390 (8/9): crypto api.

PATCH New Martin Schwidefsky 1 participant 1 message Apr 21, 2004

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390 (8/9): crypto api.

[PATCH] s390: crypto api.

From: Martin Schwidefsky <[email protected]>

Add support for z990 crypto instructions to in-kernel crypto api.

diffstat:

 Documentation/s390/crypto/crypto-API.txt |   83 ++++++
 arch/s390/Makefile                       |    2 
 arch/s390/crypto/Makefile                |    8 
 arch/s390/crypto/crypt_z990.h            |  374 +++++++++++++++++++++++++++++++
 arch/s390/crypto/crypt_z990_query.c      |  111 +++++++++
 arch/s390/crypto/crypto_des.h            |   18 +
 arch/s390/crypto/des_check_key.c         |  130 ++++++++++
 arch/s390/crypto/des_z990.c              |  284 +++++++++++++++++++++++
 arch/s390/crypto/sha1_z990.c             |  167 +++++++++++++
 arch/s390/defconfig                      |    2 
 crypto/Kconfig                           |   12 
 11 files changed, 1190 insertions(+), 1 deletion(-)
Documentation/s390/crypto/crypto-API.txt +83 -0
diff -urN linux-2.6/Documentation/s390/crypto/crypto-API.txt linux-2.6-s390/Documentation/s390/crypto/crypto-API.txt
@@ -0,0 +1,83 @@
+crypto-API support for z990 Message Security Assist (MSA) instructions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+AUTHOR:	Thomas Spatzier ([email protected])
+
+
+1. Introduction crypto-API
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+See Documentation/crypto/api-intro.txt for an introduction/description of the
+kernel crypto API.
+According to api-intro.txt support for z990 crypto instructions has been added
+in the algorithm api layer of the crypto API. Several files containing z990
+optimized implementations of crypto algorithms are placed in the
+arch/s390/crypto directory.
+
+
+2. Probing for availability of MSA
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+It should be possible to use Kernels with the z990 crypto implementations both
+on machines with MSA available an on those without MSA (pre z990 or z990
+without MSA). Therefore a simple probing mechanisms has been implemented:
+In the init function of each crypto module the availability of MSA and of the
+respective crypto algorithm in particular will be tested. If the algorithm is
+available the module will load and register its algorithm with the crypto API.
+
+If the respective crypto algorithm is not available, the init function will
+return -ENOSYS. In that case a fallback to the standard software implementation
+of the crypto algorithm must be taken ( -> the standard crypto modules are
+also build when compiling the kernel).
+
+
+3. Ensuring z990 crypto module preference
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If z990 crypto instructions are available the optimized modules should be
+preferred instead of standard modules.
+
+3.1. compiled-in modules
+~~~~~~~~~~~~~~~~~~~~~~~~
+For compiled-in modules it has to be ensured that the z990 modules are linked
+before the standard crypto modules. Then, on system startup the init functions
+of z990 crypto modules will be called first and query for availability of z990
+crypto instructions. If instruction is available, the z990 module will register
+its crypto algorithm implementation -> the load of the standard module will fail
+since the algorithm is already registered.
+If z990 crypto instruction is not available the load of the z990 module will
+fail -> the standard module will load and register its algorithm.
+
+3.2. dynamic modules
+~~~~~~~~~~~~~~~~~~~~
+A system administrator has to take care of giving preference to z990 crypto
+modules. If MSA is available appropriate lines have to be added to
+/etc/modprobe.conf.
+
+Example:	z990 crypto instruction for SHA1 algorithm is available
+
+		add the following line to /etc/modprobe.conf (assuming the
+		z990 crypto modules for SHA1 is called sha1_z990):
+
+		alias sha1 sha1_z990
+
+		-> when the sha1 algorithm is requested through the crypto API
+		(which has a module autoloader) the z990 module will be loaded.
+
+TBD:	a userspace module probin mechanism
+	something like 'probe sha1 sha1_z990 sha1' in modprobe.conf
+	-> try module sha1_z990, if it fails to load load standard module sha1
+	the 'probe' statement is currently not supported in modprobe.conf
+
+
+4. Currently implemented z990 crypto algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The following crypto algorithms with z990 MSA support are currently implemented.
+The name of each algorithm under which it is registered in crypto API and the
+name of the respective module is given in square brackets.
+
+- SHA1 Digest Algorithm [sha1 -> sha1_z990]
+- DES Encrypt/Decrypt Algorithm (64bit key) [des -> des_z990]
+- Tripple DES Encrypt/Decrypt Algorithm (128bit key) [des3_ede128 -> des_z990]
+- Tripple DES Encrypt/Decrypt Algorithm (192bit key) [des3_ede -> des_z990]
+
+In order to load, for example, the sha1_z990 module when the sha1 algorithm is
+requested (see 3.2.) add 'alias sha1 sha1_z990' to /etc/modprobe.conf.
+
arch/s390/Makefile +1 -1
diff -urN linux-2.6/arch/s390/Makefile linux-2.6-s390/arch/s390/Makefile
@@ -44,7 +44,7 @@
 head-$(CONFIG_ARCH_S390X)	+= arch/$(ARCH)/kernel/head64.o
 head-y				+= arch/$(ARCH)/kernel/init_task.o
 
-core-y		+= arch/$(ARCH)/mm/ arch/$(ARCH)/kernel/ \
+core-y		+= arch/$(ARCH)/mm/ arch/$(ARCH)/kernel/ arch/$(ARCH)/crypto/ \
 		   arch/$(ARCH)/appldata/
 libs-y		+= arch/$(ARCH)/lib/
 drivers-y	+= drivers/s390/
arch/s390/crypto/Makefile +8 -0
diff -urN linux-2.6/arch/s390/crypto/Makefile linux-2.6-s390/arch/s390/crypto/Makefile
@@ -0,0 +1,8 @@
+#
+# Cryptographic API
+#
+
+obj-$(CONFIG_CRYPTO_SHA1_Z990) += sha1_z990.o
+obj-$(CONFIG_CRYPTO_DES_Z990) += des_z990.o des_check_key.o
+
+obj-$(CONFIG_CRYPTO_TEST) += crypt_z990_query.o
arch/s390/crypto/crypt_z990.h +374 -0

374 lines not on this page · raw message

arch/s390/crypto/crypt_z990_query.c +111 -0

111 lines not on this page · raw message

arch/s390/crypto/crypto_des.h +18 -0
diff -urN linux-2.6/arch/s390/crypto/crypto_des.h linux-2.6-s390/arch/s390/crypto/crypto_des.h
@@ -0,0 +1,18 @@
+/* 
+ * Cryptographic API.
+ *
+ * Function for checking keys for the DES and Tripple DES Encryption
+ * algorithms.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#ifndef __CRYPTO_DES_H__
+#define __CRYPTO_DES_H__
+
+extern int crypto_des_check_key(const u8*, unsigned int, u32*);
+
+#endif //__CRYPTO_DES_H__
arch/s390/crypto/des_check_key.c +130 -0

130 lines not on this page · raw message

arch/s390/crypto/des_z990.c +284 -0

284 lines not on this page · raw message

arch/s390/crypto/sha1_z990.c +167 -0

167 lines not on this page · raw message

arch/s390/defconfig +2 -0
diff -urN linux-2.6/arch/s390/defconfig linux-2.6-s390/arch/s390/defconfig
@@ -490,9 +490,11 @@
 # CONFIG_CRYPTO_MD4 is not set
 # CONFIG_CRYPTO_MD5 is not set
 # CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA1_Z990 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
 # CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_DES_Z990 is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
 # CONFIG_CRYPTO_TWOFISH is not set
 # CONFIG_CRYPTO_SERPENT is not set
crypto/Kconfig +12 -0
diff -urN linux-2.6/crypto/Kconfig linux-2.6-s390/crypto/Kconfig
@@ -39,6 +39,12 @@
 	depends on CRYPTO
 	help
 	  SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
+	  
+config CRYPTO_SHA1_Z990
+	tristate "SHA1 digest algorithm for IBM zSeries z990"
+	depends on CRYPTO && ARCH_S390
+	help
+	  SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
 
 config CRYPTO_SHA256
 	tristate "SHA256 digest algorithm"
@@ -67,6 +73,12 @@
 	help
 	  DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
 
+config CRYPTO_DES_Z990
+	tristate "DES and Triple DES cipher algorithms for IBM zSeries z990"
+	depends on CRYPTO && ARCH_S390
+	help
+	  DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
+
 config CRYPTO_BLOWFISH
 	tristate "Blowfish cipher algorithm"
 	depends on CRYPTO