move crypto options and some cleanup.
Subsystems (3)
From: Jan Glauber <[email protected]>
[S390] move crypto options and some cleanup.
This patch moves the config options for the s390 crypto instructions to the standard "Hardware crypto devices" menu. In addition some cleanup has been done: use a flag for supported keylengths, add a warning about machien limitation, return ENOTSUPP in case the hardware has no support, remove superfluous printks and update email addresses.
Signed-off-by Jan Glauber <[email protected]>
Signed-off-by Martin Schwidefsky <[email protected]>
---
arch/s390/crypto/Kconfig | 60 +++++++ arch/s390/crypto/aes_s390.c | 47 ++---- arch/s390/crypto/crypt_s390.h | 280 +++++++++++++++++------------------- arch/s390/crypto/crypt_s390_query.c | 3 arch/s390/crypto/des_check_key.c | 3 arch/s390/crypto/des_s390.c | 8 - arch/s390/crypto/sha1_s390.c | 81 ++++------ arch/s390/crypto/sha256_s390.c | 9 - arch/s390/defconfig | 8 - crypto/Kconfig | 49 ------ 10 files changed, 271 insertions(+), 277 deletions(-)
arch/s390/crypto/aes_s390.c +23 -24
@@ -4,7 +4,7 @@* s390 implementation of the AES Cipher Algorithm. * * s390 Version: -* Copyright (C) 2005 IBM Deutschland GmbH, IBM Corporation +* Copyright (C) 2005-2007 IBM Deutschland GmbH, IBM Corporation * Author(s): Jan Glauber ([email protected]) * * Derived from "crypto/aes.c"
@@ -27,9 +27,11 @@/* data block size for all key lengths */ #define AES_BLOCK_SIZE 16 -static int has_aes_128 =0 ; -static int has_aes_192 =0 ; -static int has_aes_256 =0 ; +#define AES_KEYLEN_128 1 +#define AES_KEYLEN_192 2 +#define AES_KEYLEN_256 4 + +static char keylen_flag =0 ;struct s390_aes_ctx {u8 iv[AES_BLOCK_SIZE ];
@@ -47,20 +49,19 @@ static int aes_set_key(struct crypto_tfmswitch (key_len) {case 16 : -if (!has_aes_128) +if (!(keylen_flag &AES_KEYLEN_128 )) goto fail;break ;case 24 : -if (!has_aes_192) +if (!(keylen_flag &AES_KEYLEN_192 )) goto fail;break ;case 32 : -if (!has_aes_256) +if (!(keylen_flag &AES_KEYLEN_256 )) goto fail;break ;default : -/* invalid key length */ goto fail;break ; }
@@ -322,34 +323,32 @@ static int __init aes_init(void)int ret;if (crypt_s390_func_available (KM_AES_128_ENCRYPT )) - has_aes_128 =1 ; + keylen_flag |=AES_KEYLEN_128 ;if (crypt_s390_func_available (KM_AES_192_ENCRYPT )) - has_aes_192 =1 ; + keylen_flag |=AES_KEYLEN_192 ;if (crypt_s390_func_available (KM_AES_256_ENCRYPT )) - has_aes_256 =1 ; + keylen_flag |=AES_KEYLEN_256 ; + +if (!keylen_flag) +return -ENOTSUPP ; -if (!has_aes_128 && !has_aes_192 && !has_aes_256) -return -ENOSYS ; +/* z9 109 and z9 BC/EC only support 128 bit key length */ +if (keylen_flag ==AES_KEYLEN_128 ) +printk (KERN_INFO +"aes_s390: hardware acceleration only available for" +"128 bit keys\n" ); ret =crypto_register_alg (&aes_alg); -if (ret !=0 ) { -printk (KERN_INFO "crypt_s390: aes-s390 couldn't be loaded.\n" ); +if (ret) goto aes_err; - } ret =crypto_register_alg (&ecb_aes_alg); -if (ret !=0 ) { -printk (KERN_INFO -"crypt_s390: ecb-aes-s390 couldn't be loaded.\n" ); +if (ret) goto ecb_aes_err; - } ret =crypto_register_alg (&cbc_aes_alg); -if (ret !=0 ) { -printk (KERN_INFO -"crypt_s390: cbc-aes-s390 couldn't be loaded.\n" ); +if (ret) goto cbc_aes_err; - } out:return ret;
arch/s390/crypto/crypt_s390.h +138 -142
410 lines not on this page · raw message
arch/s390/crypto/crypt_s390_query.c +2 -1
@@ -5,7 +5,8 @@* Testing module for querying processor crypto capabilities. * * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation -* Author(s): Thomas Spatzier ([email protected]) +* Author(s): Thomas Spatzier +* Jan Glauber ([email protected]) * * 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
arch/s390/crypto/des_check_key.c +2 -1
@@ -11,7 +11,8 @@* * s390 Version: * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation -* Author(s): Thomas Spatzier ([email protected]) +* Author(s): Thomas Spatzier +* Jan Glauber ([email protected]) * * Derived from "crypto/des.c" * Copyright (c) 1992 Dana L. How.
arch/s390/crypto/des_s390.c +4 -4
@@ -3,9 +3,9 @@* * s390 implementation of the DES Cipher Algorithm. * -* Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation -* Author(s): Thomas Spatzier ([email protected]) -* +* Copyright (c) 2003,2007 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): Thomas Spatzier +* Jan Glauber ([email protected]) * * 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
@@ -557,7 +557,7 @@ static int init(void)if (!crypt_s390_func_available (KM_DEA_ENCRYPT ) || !crypt_s390_func_available (KM_TDEA_128_ENCRYPT ) || !crypt_s390_func_available (KM_TDEA_192_ENCRYPT )) -return -ENOSYS ; +return -ENOTSUPP ; ret =crypto_register_alg (&des_alg);if (ret)
arch/s390/crypto/Kconfig +60 -0
60 lines not on this page · raw message
arch/s390/crypto/sha1_s390.c +36 -45
156 lines not on this page · raw message
arch/s390/crypto/sha256_s390.c +2 -7
@@ -143,15 +143,10 @@ static struct crypto_alg alg = {static int init (void ) { -int ret; -if (!crypt_s390_func_available (KIMD_SHA_256 )) -return -ENOSYS ; +return -ENOTSUPP ; - ret =crypto_register_alg (&alg); -if (ret !=0 ) -printk (KERN_INFO "crypt_s390: sha256_s390 couldn't be loaded." ); -return ret; +return crypto_register_alg (&alg); } static void __exit fini(void)
arch/s390/defconfig +4 -4
@@ -723,9 +723,7 @@ CONFIG_CRYPTO_MANAGER=y # CONFIG_CRYPTO_MD4 is not set # CONFIG_CRYPTO_MD5 is not set # CONFIG_CRYPTO_SHA1 is not set -# CONFIG_CRYPTO_SHA1_S390 is not set # CONFIG_CRYPTO_SHA256 is not set -# CONFIG_CRYPTO_SHA256_S390 is not set # CONFIG_CRYPTO_SHA512 is not set # CONFIG_CRYPTO_WP512 is not set # CONFIG_CRYPTO_TGR192 is not set
@@ -734,12 +732,10 @@ CONFIG_CRYPTO_ECB=m CONFIG_CRYPTO_CBC=y # CONFIG_CRYPTO_LRW is not set # CONFIG_CRYPTO_DES is not set -# CONFIG_CRYPTO_DES_S390 is not set # CONFIG_CRYPTO_BLOWFISH is not set # CONFIG_CRYPTO_TWOFISH is not set # CONFIG_CRYPTO_SERPENT is not set # CONFIG_CRYPTO_AES is not set -# CONFIG_CRYPTO_AES_S390 is not set # CONFIG_CRYPTO_CAST5 is not set # CONFIG_CRYPTO_CAST6 is not set # CONFIG_CRYPTO_TEA is not set
@@ -754,6 +750,10 @@ CONFIG_CRYPTO_CBC=y # # Hardware crypto devices # +# CONFIG_CRYPTO_SHA1_S390 is not set +# CONFIG_CRYPTO_SHA256_S390 is not set +# CONFIG_CRYPTO_DES_S390 is not set +# CONFIG_CRYPTO_AES_S390 is not set # # Library routines
crypto/Kconfig +0 -49
73 lines not on this page · raw message