/* However, if the two independent 64-bit keys are equal, then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property.  */
static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
/* However, if the two independent 64-bit keys are equal, then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property.  */
static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
{
	int i, ret;
	struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm);
	const u8 *temp_key = key;
	u32 *flags = &tfm->crt_flags;
	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) {
		ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags);
		if (ret < 0)
			return ret;
	}
	memcpy(dctx->key, key, keylen);
	return 0;
}