/* However, if the first two or last two independent 64-bit keys are equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property.  */
static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
/* However, if the first two or last two independent 64-bit keys are equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property.  */
static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
{
	const u32 *K = (const u32 *)key;
	struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm);
	u32 *expkey = dctx->expkey;
	u32 *flags = &tfm->crt_flags;
	if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) ||
		     !((K[2] ^ K[4]) | (K[3] ^ K[5]))) &&
		     (*flags & CRYPTO_TFM_REQ_WEAK_KEY))
	{
		*flags |= CRYPTO_TFM_RES_WEAK_KEY;
		return -EINVAL;
	}
	des_ekey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE;
	dkey(expkey, key); expkey += DES_EXPKEY_WORDS; key += DES_KEY_SIZE;
	des_ekey(expkey, key);
	return 0;
}