mirror of https://gitee.com/openkylin/linux.git
crypto: clarify name of WEAK_KEY request flag
CRYPTO_TFM_REQ_WEAK_KEY confuses newcomers to the crypto API because it sounds like it is requesting a weak key. Actually, it is requesting that weak keys be forbidden (for algorithms that have the notion of "weak keys"; currently only DES and XTS do). Also it is only one letter away from CRYPTO_TFM_RES_WEAK_KEY, with which it can be easily confused. (This in fact happened in the UX500 driver, though just in some debugging messages.) Therefore, make the intent clear by renaming it to CRYPTO_TFM_REQ_FORBID_WEAK_KEYS. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
37ebffff65
commit
231baecdef
|
@ -38,7 +38,7 @@ static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
|
|||
|
||||
/* check for weak keys */
|
||||
if (!des_ekey(tmp, key) &&
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ static int des3_setkey(struct crypto_tfm *tfm, const u8 *key,
|
|||
if (!(crypto_memneq(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
|
||||
crypto_memneq(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],
|
||||
DES_KEY_SIZE)) &&
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ static int des_set_key(struct crypto_tfm *tfm, const u8 *key,
|
|||
* weak key detection code.
|
||||
*/
|
||||
ret = des_ekey(tmp, key);
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ static int des3_ede_set_key(struct crypto_tfm *tfm, const u8 *key,
|
|||
|
||||
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_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -789,7 +789,7 @@ static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
|
|||
/* Expand to tmp */
|
||||
ret = des_ekey(tmp, key);
|
||||
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ int __des3_ede_setkey(u32 *expkey, u32 *flags, const u8 *key,
|
|||
|
||||
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_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -706,7 +706,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
crypto_aead_clear_flags(tfm, ~0);
|
||||
if (template[i].wk)
|
||||
crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_aead_set_flags(tfm,
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
|
||||
if (template[i].klen > MAX_KEYLEN) {
|
||||
pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n",
|
||||
|
@ -820,7 +821,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
crypto_aead_clear_flags(tfm, ~0);
|
||||
if (template[i].wk)
|
||||
crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_aead_set_flags(tfm,
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
if (template[i].klen > MAX_KEYLEN) {
|
||||
pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n",
|
||||
d, j, algo, template[i].klen, MAX_KEYLEN);
|
||||
|
@ -1078,7 +1080,7 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
|
|||
|
||||
crypto_cipher_clear_flags(tfm, ~0);
|
||||
if (template[i].wk)
|
||||
crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
|
||||
ret = crypto_cipher_setkey(tfm, template[i].key,
|
||||
template[i].klen);
|
||||
|
@ -1194,8 +1196,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
|
|||
|
||||
crypto_skcipher_clear_flags(tfm, ~0);
|
||||
if (template[i].wk)
|
||||
crypto_skcipher_set_flags(tfm,
|
||||
CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
|
||||
ret = crypto_skcipher_setkey(tfm, template[i].key,
|
||||
template[i].klen);
|
||||
|
@ -1265,8 +1266,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
|
|||
j++;
|
||||
crypto_skcipher_clear_flags(tfm, ~0);
|
||||
if (template[i].wk)
|
||||
crypto_skcipher_set_flags(tfm,
|
||||
CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
|
||||
ret = crypto_skcipher_setkey(tfm, template[i].key,
|
||||
template[i].klen);
|
||||
|
|
|
@ -50,7 +50,7 @@ struct hash_testvec {
|
|||
* @ctext: Pointer to ciphertext
|
||||
* @len: Length of @ptext and @ctext in bytes
|
||||
* @fail: If set to one, the test need to fail
|
||||
* @wk: Does the test need CRYPTO_TFM_REQ_WEAK_KEY
|
||||
* @wk: Does the test need CRYPTO_TFM_REQ_FORBID_WEAK_KEYS?
|
||||
* ( e.g. test needs to fail due to a weak key )
|
||||
* @np: numbers of SG to distribute data in (from 1 to MAX_TAP)
|
||||
* @tap: How to distribute data in @np SGs
|
||||
|
@ -91,7 +91,7 @@ struct cipher_testvec {
|
|||
* @anp: Numbers of SG to distribute assoc data in
|
||||
* @fail: setkey() failure expected?
|
||||
* @novrfy: Decryption verification failure expected?
|
||||
* @wk: Does the test need CRYPTO_TFM_REQ_WEAK_KEY?
|
||||
* @wk: Does the test need CRYPTO_TFM_REQ_FORBID_WEAK_KEYS?
|
||||
* (e.g. setkey() needs to fail due to a weak key)
|
||||
* @klen: Length of @key in bytes
|
||||
* @plen: Length of @ptext in bytes
|
||||
|
|
|
@ -785,7 +785,7 @@ static int atmel_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
|||
}
|
||||
|
||||
err = des_ekey(tmp, key);
|
||||
if (err == 0 && (ctfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (err == 0 && (ctfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
ctfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -1818,7 +1818,7 @@ static int des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
|||
if (keylen == DES_KEY_SIZE) {
|
||||
if (des_ekey(tmp, key) == 0) {
|
||||
if (crypto_ablkcipher_get_flags(cipher) &
|
||||
CRYPTO_TFM_REQ_WEAK_KEY) {
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) {
|
||||
u32 flags = CRYPTO_TFM_RES_WEAK_KEY;
|
||||
|
||||
crypto_ablkcipher_set_flags(cipher, flags);
|
||||
|
@ -2872,7 +2872,7 @@ static int aead_authenc_setkey(struct crypto_aead *cipher,
|
|||
|
||||
if (des_ekey(tmp, keys.enckey) == 0) {
|
||||
if (crypto_aead_get_flags(cipher) &
|
||||
CRYPTO_TFM_REQ_WEAK_KEY) {
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) {
|
||||
crypto_aead_set_flags(cipher, flags);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ static int ccp_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
|||
|
||||
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_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -352,7 +352,8 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,
|
|||
dev_dbg(dev, "weak 3DES key");
|
||||
return -EINVAL;
|
||||
} else if (!des_ekey(tmp, key) &&
|
||||
(crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
(crypto_tfm_get_flags(tfm) &
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
dev_dbg(dev, "weak DES key");
|
||||
return -EINVAL;
|
||||
|
|
|
@ -1961,7 +1961,8 @@ static int hifn_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
|||
u32 tmp[DES_EXPKEY_WORDS];
|
||||
int ret = des_ekey(tmp, key);
|
||||
|
||||
if (unlikely(ret == 0) && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(ret == 0) &&
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -940,7 +940,7 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key,
|
|||
}
|
||||
|
||||
ret = des_ekey(tmp, key);
|
||||
if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -847,7 +847,7 @@ static int ablk_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
|||
goto out;
|
||||
|
||||
if (*flags & CRYPTO_TFM_RES_WEAK_KEY) {
|
||||
if (*flags & CRYPTO_TFM_REQ_WEAK_KEY) {
|
||||
if (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) {
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
*flags &= ~CRYPTO_TFM_RES_WEAK_KEY;
|
||||
|
@ -1125,7 +1125,7 @@ static int aead_setup(struct crypto_aead *tfm, unsigned int authsize)
|
|||
goto out;
|
||||
|
||||
if (*flags & CRYPTO_TFM_RES_WEAK_KEY) {
|
||||
if (*flags & CRYPTO_TFM_REQ_WEAK_KEY) {
|
||||
if (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
|
|
|
@ -286,7 +286,7 @@ static int mv_cesa_des_setkey(struct crypto_skcipher *cipher, const u8 *key,
|
|||
}
|
||||
|
||||
ret = des_ekey(tmp, key);
|
||||
if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -772,7 +772,7 @@ static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
|||
}
|
||||
|
||||
err = des_ekey(tmp, key);
|
||||
if (err == 0 && (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (err == 0 && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -662,7 +662,7 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
|||
pr_debug("enter, keylen: %d\n", keylen);
|
||||
|
||||
/* Do we need to test against weak key? */
|
||||
if (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY) {
|
||||
if (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) {
|
||||
u32 tmp[DES_EXPKEY_WORDS];
|
||||
int ret = des_ekey(tmp, key);
|
||||
|
||||
|
|
|
@ -759,7 +759,8 @@ static int spacc_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
|
|||
}
|
||||
|
||||
if (unlikely(!des_ekey(tmp, key)) &&
|
||||
(crypto_ablkcipher_get_flags(cipher) & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
(crypto_ablkcipher_get_flags(cipher) &
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -180,8 +180,8 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key,
|
|||
u32 tmp[DES_EXPKEY_WORDS];
|
||||
|
||||
ret = des_ekey(tmp, key);
|
||||
if (!ret && crypto_ablkcipher_get_flags(ablk) &
|
||||
CRYPTO_TFM_REQ_WEAK_KEY)
|
||||
if (!ret && (crypto_ablkcipher_get_flags(ablk) &
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS))
|
||||
goto weakkey;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ static int rk_tdes_setkey(struct crypto_ablkcipher *cipher,
|
|||
|
||||
if (keylen == DES_KEY_SIZE) {
|
||||
if (!des_ekey(tmp, key) &&
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
(tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -517,7 +517,7 @@ int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
|||
flags = crypto_skcipher_get_flags(tfm);
|
||||
|
||||
ret = des_ekey(tmp, key);
|
||||
if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
|
||||
dev_dbg(ss->dev, "Weak key %u\n", keylen);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -1535,7 +1535,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
|
|||
}
|
||||
|
||||
if (unlikely(crypto_ablkcipher_get_flags(cipher) &
|
||||
CRYPTO_TFM_REQ_WEAK_KEY) &&
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) &&
|
||||
!des_ekey(tmp, key)) {
|
||||
crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_WEAK_KEY);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -1000,10 +1000,11 @@ static int des_ablkcipher_setkey(struct crypto_ablkcipher *cipher,
|
|||
}
|
||||
|
||||
ret = des_ekey(tmp, key);
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(ret == 0) &&
|
||||
(*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_REQ_WEAK_KEY",
|
||||
__func__);
|
||||
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1034,18 +1035,19 @@ static int des3_ablkcipher_setkey(struct crypto_ablkcipher *cipher,
|
|||
/* Checking key interdependency for weak key detection. */
|
||||
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_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_REQ_WEAK_KEY",
|
||||
__func__);
|
||||
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
ret = des_ekey(tmp, key + i*DES_KEY_SIZE);
|
||||
if (unlikely(ret == 0) && (*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||
if (unlikely(ret == 0) &&
|
||||
(*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
|
||||
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
|
||||
pr_debug(DEV_DBG_NAME " [%s]: "
|
||||
"CRYPTO_TFM_REQ_WEAK_KEY", __func__);
|
||||
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ static int derive_key_aes(const u8 *master_key,
|
|||
tfm = NULL;
|
||||
goto out;
|
||||
}
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
req = skcipher_request_alloc(tfm, GFP_NOFS);
|
||||
if (!req) {
|
||||
res = -ENOMEM;
|
||||
|
@ -257,7 +257,7 @@ allocate_skcipher_for_mode(struct fscrypt_mode *mode, const u8 *raw_key,
|
|||
mode->friendly_name,
|
||||
crypto_skcipher_alg(tfm)->base.cra_driver_name);
|
||||
}
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
err = crypto_skcipher_setkey(tfm, raw_key, mode->keysize);
|
||||
if (err)
|
||||
goto err_free_tfm;
|
||||
|
|
|
@ -610,7 +610,8 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
|
|||
full_alg_name);
|
||||
goto out_free;
|
||||
}
|
||||
crypto_skcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(crypt_stat->tfm,
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
rc = 0;
|
||||
out_free:
|
||||
kfree(full_alg_name);
|
||||
|
@ -1590,7 +1591,7 @@ ecryptfs_process_key_cipher(struct crypto_skcipher **key_tfm,
|
|||
"[%s]; rc = [%d]\n", full_alg_name, rc);
|
||||
goto out;
|
||||
}
|
||||
crypto_skcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
crypto_skcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
|
||||
if (*key_size == 0)
|
||||
*key_size = crypto_skcipher_default_keysize(*key_tfm);
|
||||
get_random_bytes(dummy_key, *key_size);
|
||||
|
|
|
@ -47,8 +47,8 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm,
|
|||
}
|
||||
|
||||
/* ensure that the AES and tweak key are not identical */
|
||||
if ((fips_enabled || crypto_skcipher_get_flags(tfm) &
|
||||
CRYPTO_TFM_REQ_WEAK_KEY) &&
|
||||
if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &
|
||||
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
|
||||
!crypto_memneq(key, key + (keylen / 2), keylen / 2)) {
|
||||
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
#define CRYPTO_TFM_REQ_MASK 0x000fff00
|
||||
#define CRYPTO_TFM_RES_MASK 0xfff00000
|
||||
|
||||
#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
|
||||
#define CRYPTO_TFM_REQ_FORBID_WEAK_KEYS 0x00000100
|
||||
#define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
|
||||
#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
|
||||
#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
|
||||
|
|
Loading…
Reference in New Issue