aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-08-13 00:16:39 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-09-20 21:41:02 -0400
commit560c06ae1ab7c677002ea3b6ac83521bf12ee07d (patch)
tree374ed69a7e23ba9d07458d20672aac6ae552ae51 /arch/s390/crypto
parent25cdbcd9e5d20e431f829cafce48a418830011f4 (diff)
[CRYPTO] api: Get rid of flags argument to setkey
Now that the tfm is passed directly to setkey instead of the ctx, we no longer need to pass the &tfm->crt_flags pointer. This patch also gets rid of a few unnecessary checks on the key length for ciphers as the cipher layer guarantees that the key length is within the bounds specified by the algorithm. Rather than testing dia_setkey every time, this patch does it only once during crypto_alloc_tfm. The redundant check from crypto_digest_setkey is also removed. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/s390/crypto')
-rw-r--r--arch/s390/crypto/aes_s390.c3
-rw-r--r--arch/s390/crypto/des_s390.c13
2 files changed, 10 insertions, 6 deletions
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index 5713c7e5bd16..c7c43c9de0d9 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -38,9 +38,10 @@ struct s390_aes_ctx {
38}; 38};
39 39
40static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, 40static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
41 unsigned int key_len, u32 *flags) 41 unsigned int key_len)
42{ 42{
43 struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm); 43 struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm);
44 u32 *flags = &tfm->crt_flags;
44 45
45 switch (key_len) { 46 switch (key_len) {
46 case 16: 47 case 16:
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index b3f7496a79b4..170757b3451d 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -45,9 +45,10 @@ struct crypt_s390_des3_192_ctx {
45}; 45};
46 46
47static int des_setkey(struct crypto_tfm *tfm, const u8 *key, 47static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
48 unsigned int keylen, u32 *flags) 48 unsigned int keylen)
49{ 49{
50 struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm); 50 struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm);
51 u32 *flags = &tfm->crt_flags;
51 int ret; 52 int ret;
52 53
53 /* test if key is valid (not a weak key) */ 54 /* test if key is valid (not a weak key) */
@@ -167,11 +168,12 @@ static struct crypto_alg des_alg = {
167 * 168 *
168 */ 169 */
169static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, 170static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key,
170 unsigned int keylen, u32 *flags) 171 unsigned int keylen)
171{ 172{
172 int i, ret; 173 int i, ret;
173 struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm); 174 struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm);
174 const u8* temp_key = key; 175 const u8 *temp_key = key;
176 u32 *flags = &tfm->crt_flags;
175 177
176 if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { 178 if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) {
177 *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; 179 *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED;
@@ -303,11 +305,12 @@ static struct crypto_alg des3_128_alg = {
303 * 305 *
304 */ 306 */
305static int des3_192_setkey(struct crypto_tfm *tfm, const u8 *key, 307static int des3_192_setkey(struct crypto_tfm *tfm, const u8 *key,
306 unsigned int keylen, u32 *flags) 308 unsigned int keylen)
307{ 309{
308 int i, ret; 310 int i, ret;
309 struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm); 311 struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm);
310 const u8* temp_key = key; 312 const u8 *temp_key = key;
313 u32 *flags = &tfm->crt_flags;
311 314
312 if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && 315 if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
313 memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2], 316 memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],