hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/crypto/xts.h
....@@ -8,28 +8,19 @@
88
99 #define XTS_BLOCK_SIZE 16
1010
11
-#define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x))
12
-
1311 static inline int xts_check_key(struct crypto_tfm *tfm,
1412 const u8 *key, unsigned int keylen)
1513 {
16
- u32 *flags = &tfm->crt_flags;
17
-
1814 /*
1915 * key consists of keys of equal size concatenated, therefore
2016 * the length must be even.
2117 */
22
- if (keylen % 2) {
23
- *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
18
+ if (keylen % 2)
2419 return -EINVAL;
25
- }
2620
2721 /* ensure that the AES and tweak key are not identical */
28
- if (fips_enabled &&
29
- !crypto_memneq(key, key + (keylen / 2), keylen / 2)) {
30
- *flags |= CRYPTO_TFM_RES_WEAK_KEY;
22
+ if (fips_enabled && !crypto_memneq(key, key + (keylen / 2), keylen / 2))
3123 return -EINVAL;
32
- }
3324
3425 return 0;
3526 }
....@@ -41,18 +32,14 @@
4132 * key consists of keys of equal size concatenated, therefore
4233 * the length must be even.
4334 */
44
- if (keylen % 2) {
45
- crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
35
+ if (keylen % 2)
4636 return -EINVAL;
47
- }
4837
4938 /* ensure that the AES and tweak key are not identical */
50
- if ((fips_enabled || crypto_skcipher_get_flags(tfm) &
51
- CRYPTO_TFM_REQ_WEAK_KEY) &&
52
- !crypto_memneq(key, key + (keylen / 2), keylen / 2)) {
53
- crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
39
+ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &
40
+ CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
41
+ !crypto_memneq(key, key + (keylen / 2), keylen / 2))
5442 return -EINVAL;
55
- }
5643
5744 return 0;
5845 }