generic sha_update and sha_final for s390
Subsystems (3)
PATCH 1/4 generic sha_update and sha_final for s390
The sha_{update|final} functions are similar for every sha variant. Since that is error-prone and redundant replace these functions by a shared generic implementation for s390.
--- arch/s390/crypto/Makefile | 4 - arch/s390/crypto/sha.h | 34 +++++++++++++++ arch/s390/crypto/sha1_s390.c | 91 ++--------------------------------------- arch/s390/crypto/sha256_s390.c | 90 ++-------------------------------------- arch/s390/crypto/sha_common.c | 90 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 171 deletions(-)
arch/s390/crypto/Makefile +2 -2
@@ -2,8 +2,8 @@ # Cryptographic API # -obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o -obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o +obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o sha_common.o +obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o sha_common.o obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o obj-$(CONFIG_S390_PRNG) += prng.o
arch/s390/crypto/sha.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Cryptographic API. +* +* s390 generic implementation of the SHA Secure Hash Algorithms. +* +* Copyright IBM Corp. 2007 +* Author(s): 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 +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +* +*/ +#ifndef _CRYPTO_ARCH_S390_SHA_H +#define _CRYPTO_ARCH_S390_SHA_H + +#include <linux/crypto.h> +#include <crypto/sha.h> + +/* must be big enough for the largest SHA variant */ +#define SHA_MAX_BLOCK_SIZE SHA256_BLOCK_SIZE + +struct s390_sha_ctx { +u64 count;/* message length in bytes */ +u32 state[8 ]; +u8 buf[2 *SHA_MAX_BLOCK_SIZE ]; +int func;/* KIMD function to use */ +}; + +void s390_sha_update (struct crypto_tfm *tfm,const u8 *data,unsigned int len); +void s390_sha_final (struct crypto_tfm *tfm,u8 *out); + +#endif
arch/s390/crypto/sha1_s390.c +6 -85
128 lines not on this page · raw message
arch/s390/crypto/sha256_s390.c +6 -84
121 lines not on this page · raw message
arch/s390/crypto/sha_common.c new file +90 -0
90 lines not on this page · raw message
arch/s390/crypto/Makefile line 6
Quoted 12 lines · * Jan Glauber | 2008-03-03 17:19:43 [+0100]:
Index: cryptodev-2.6/arch/s390/crypto/Makefile
===================================================================arch/s390/crypto/Makefile +2
-2@@ -2,8 +2,8 @@ # Cryptographic API # -obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o -obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o +obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o sha_common.o +obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o sha_common.o
So this is a little trick to avoid select in Kconfig? nice :)
Quoted 8 lines
obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o obj-$(CONFIG_S390_PRNG) += prng.o
Index:cryptodev-2.6/arch/s390/crypto/sha.h
===================================================================
arch/s390/crypto/sha.h line 6
Quoted 6 lines
arch/s390/crypto/sha.h new file +6
-0@@ -0,0 +1,34 @@ +/* +* Cryptographic API. +* +* s390 generic implementation of the SHA Secure Hash Algorithms. +* +* Copyright IBM Corp. 2007
Just a nitpick: shouldn't this be the year you wrote the code? I really don't know.
Sebastian
Quoted 14 lines · Sebastian Siewior
arch/s390/crypto/sha.h line 6
Quoted 11 lines · * Jan Glauber | 2008-03-03 17:19:43 [+0100]:
Index:
cryptodev-2.6/arch/s390/crypto/sha.h
===================================================================arch/s390/crypto/sha.h new file +6
-0@@ -0,0 +1,34 @@ +/* +* Cryptographic API. +* +* s390 generic implementation of the SHA Secure Hash Algorithms. +* +* Copyright IBM Corp. 2007 Just a nitpick: shouldn't this be the year you wrote the code? I really don't know.
It actually is the year I wrote the code, I just had to wait for the hardware announcement ;-
Cheers, Jan
Quoted 1 line
Sebastian