Skip to contentSkip to conversation

crypto: s390 des3 - permit weak keys unless REQ_WEAK_KEY set

PATCH In review Jarod Wilson 3 participants 3 messages Jun 8, 2009 – Jun 18, 2009

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

PATCH 1/1 crypto: s390 des3 - permit weak keys unless REQ_WEAK_KEY set

Just started running fips cavs test vectors through an s390x system for giggles, and discovered that I missed patching s390's arch-specific des3 implementation w/an earlier des3 patch to permit weak keys.

This change adds the same flag tweaks as ad79cdd77fc1466e45cf923890f66bcfe7c43f12 for s390's des3 implementation, yields expected test results now.

---
 arch/s390/crypto/des_s390.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
arch/s390/crypto/des_s390.c +3 -3
index 4aba83b..2bc479a 100644
@@ -250,8 +250,9 @@ static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key,
 	const u8 *temp_key = key;
 	u32 *flags = &tfm->crt_flags;
 
-	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) {
-		*flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED;
+	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE)) &&
+	    (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
+		*flags |= CRYPTO_TFM_RES_WEAK_KEY;
 		return -EINVAL;
 	}
 	for (i = 0; i < 2; i++, temp_key += DES_KEY_SIZE) {
@@ -411,9 +412,9 @@ static int des3_192_setkey(struct crypto_tfm *tfm, const u8 *key,
 
 	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
 	    memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],
-		   DES_KEY_SIZE))) {
#1 lore raw
Quoted 18 lines · Jarod Wilson

Just started running fips cavs test vectors through an s390x system for giggles, and discovered that I missed patching s390's arch-specific des3 implementation w/an earlier des3 patch to permit weak keys.

This change adds the same flag tweaks as ad79cdd77fc1466e45cf923890f66bcfe7c43f12 for s390's des3 implementation, yields expected test results now.

---
 arch/s390/crypto/des_s390.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
arch/s390/crypto/des_s390.c +0 -0
index 4aba83b..2bc479a 100644

arch/s390/crypto/des_s390.c static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, · line 256

Quoted 9 lines
arch/s390/crypto/des_s390.c +3 -2
@@ -250,8 +250,9 @@ static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key,
 	const u8 *temp_key = key;
 	u32 *flags = &tfm->crt_flags;
 
-	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) {
-		*flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED;
+	if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE)) &&
+	    (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
+		*flags |= CRYPTO_TFM_RES_WEAK_KEY;
 		return -EINVAL;

I think this should go in via crypt-dev. Herbert?

maintainer
#2 lore raw
In reply to Jarod Wilson
Quoted 8 lines · Jarod Wilson

Just started running fips cavs test vectors through an s390x system for giggles, and discovered that I missed patching s390's arch-specific des3 implementation w/an earlier des3 patch to permit weak keys.

This change adds the same flag tweaks as ad79cdd77fc1466e45cf923890f66bcfe7c43f12 for s390's des3 implementation, yields expected test results now.

Patch applied to cryptodev. Thanks Jarod!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt