Blame view
include/crypto/xts.h
1.1 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
ce0045561 crypto: xts: add ... |
2 3 4 5 |
#ifndef _CRYPTO_XTS_H #define _CRYPTO_XTS_H #include <crypto/b128ops.h> |
f1c131b45 crypto: xts - Con... |
6 |
#include <crypto/internal/skcipher.h> |
28856a9e5 crypto: xts - con... |
7 |
#include <linux/fips.h> |
ce0045561 crypto: xts: add ... |
8 |
|
ce0045561 crypto: xts: add ... |
9 |
#define XTS_BLOCK_SIZE 16 |
28856a9e5 crypto: xts - con... |
10 11 12 |
static inline int xts_check_key(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { |
28856a9e5 crypto: xts - con... |
13 14 15 16 |
/* * key consists of keys of equal size concatenated, therefore * the length must be even. */ |
674f368a9 crypto: remove CR... |
17 |
if (keylen % 2) |
28856a9e5 crypto: xts - con... |
18 |
return -EINVAL; |
28856a9e5 crypto: xts - con... |
19 20 |
/* ensure that the AES and tweak key are not identical */ |
c4c4db0d5 crypto: remove CR... |
21 |
if (fips_enabled && !crypto_memneq(key, key + (keylen / 2), keylen / 2)) |
28856a9e5 crypto: xts - con... |
22 |
return -EINVAL; |
28856a9e5 crypto: xts - con... |
23 24 25 |
return 0; } |
f1c131b45 crypto: xts - Con... |
26 27 28 29 30 31 32 |
static inline int xts_verify_key(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { /* * key consists of keys of equal size concatenated, therefore * the length must be even. */ |
674f368a9 crypto: remove CR... |
33 |
if (keylen % 2) |
f1c131b45 crypto: xts - Con... |
34 |
return -EINVAL; |
f1c131b45 crypto: xts - Con... |
35 36 |
/* ensure that the AES and tweak key are not identical */ |
231baecde crypto: clarify n... |
37 38 |
if ((fips_enabled || (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) && |
c4c4db0d5 crypto: remove CR... |
39 |
!crypto_memneq(key, key + (keylen / 2), keylen / 2)) |
f1c131b45 crypto: xts - Con... |
40 |
return -EINVAL; |
f1c131b45 crypto: xts - Con... |
41 42 43 |
return 0; } |
ce0045561 crypto: xts: add ... |
44 |
#endif /* _CRYPTO_XTS_H */ |