| .. | .. |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | #define XTS_BLOCK_SIZE 16 |
|---|
| 10 | 10 | |
|---|
| 11 | | -#define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x)) |
|---|
| 12 | | - |
|---|
| 13 | 11 | static inline int xts_check_key(struct crypto_tfm *tfm, |
|---|
| 14 | 12 | const u8 *key, unsigned int keylen) |
|---|
| 15 | 13 | { |
|---|
| 16 | | - u32 *flags = &tfm->crt_flags; |
|---|
| 17 | | - |
|---|
| 18 | 14 | /* |
|---|
| 19 | 15 | * key consists of keys of equal size concatenated, therefore |
|---|
| 20 | 16 | * the length must be even. |
|---|
| 21 | 17 | */ |
|---|
| 22 | | - if (keylen % 2) { |
|---|
| 23 | | - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; |
|---|
| 18 | + if (keylen % 2) |
|---|
| 24 | 19 | return -EINVAL; |
|---|
| 25 | | - } |
|---|
| 26 | 20 | |
|---|
| 27 | 21 | /* 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)) |
|---|
| 31 | 23 | return -EINVAL; |
|---|
| 32 | | - } |
|---|
| 33 | 24 | |
|---|
| 34 | 25 | return 0; |
|---|
| 35 | 26 | } |
|---|
| .. | .. |
|---|
| 41 | 32 | * key consists of keys of equal size concatenated, therefore |
|---|
| 42 | 33 | * the length must be even. |
|---|
| 43 | 34 | */ |
|---|
| 44 | | - if (keylen % 2) { |
|---|
| 45 | | - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
|---|
| 35 | + if (keylen % 2) |
|---|
| 46 | 36 | return -EINVAL; |
|---|
| 47 | | - } |
|---|
| 48 | 37 | |
|---|
| 49 | 38 | /* 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)) |
|---|
| 54 | 42 | return -EINVAL; |
|---|
| 55 | | - } |
|---|
| 56 | 43 | |
|---|
| 57 | 44 | return 0; |
|---|
| 58 | 45 | } |
|---|