mirror of
https://github.com/torvalds/linux
synced 2024-10-15 15:59:15 +00:00
crypto: xts - use blocksize constant
XTS has fixed blocksize of 16. Define XTS_BLOCK_SIZE and use in place of crypto_cipher_blocksize(). Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
81559f9ad3
commit
f9d2691fc9
|
@ -24,6 +24,8 @@
|
||||||
#include <crypto/b128ops.h>
|
#include <crypto/b128ops.h>
|
||||||
#include <crypto/gf128mul.h>
|
#include <crypto/gf128mul.h>
|
||||||
|
|
||||||
|
#define XTS_BLOCK_SIZE 16
|
||||||
|
|
||||||
struct priv {
|
struct priv {
|
||||||
struct crypto_cipher *child;
|
struct crypto_cipher *child;
|
||||||
struct crypto_cipher *tweak;
|
struct crypto_cipher *tweak;
|
||||||
|
@ -96,7 +98,7 @@ static int crypt(struct blkcipher_desc *d,
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned int avail;
|
unsigned int avail;
|
||||||
const int bs = crypto_cipher_blocksize(ctx->child);
|
const int bs = XTS_BLOCK_SIZE;
|
||||||
struct sinfo s = {
|
struct sinfo s = {
|
||||||
.tfm = crypto_cipher_tfm(ctx->child),
|
.tfm = crypto_cipher_tfm(ctx->child),
|
||||||
.fn = fn
|
.fn = fn
|
||||||
|
@ -177,7 +179,7 @@ static int init_tfm(struct crypto_tfm *tfm)
|
||||||
if (IS_ERR(cipher))
|
if (IS_ERR(cipher))
|
||||||
return PTR_ERR(cipher);
|
return PTR_ERR(cipher);
|
||||||
|
|
||||||
if (crypto_cipher_blocksize(cipher) != 16) {
|
if (crypto_cipher_blocksize(cipher) != XTS_BLOCK_SIZE) {
|
||||||
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||||
crypto_free_cipher(cipher);
|
crypto_free_cipher(cipher);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -192,7 +194,7 @@ static int init_tfm(struct crypto_tfm *tfm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this check isn't really needed, leave it here just in case */
|
/* this check isn't really needed, leave it here just in case */
|
||||||
if (crypto_cipher_blocksize(cipher) != 16) {
|
if (crypto_cipher_blocksize(cipher) != XTS_BLOCK_SIZE) {
|
||||||
crypto_free_cipher(cipher);
|
crypto_free_cipher(cipher);
|
||||||
crypto_free_cipher(ctx->child);
|
crypto_free_cipher(ctx->child);
|
||||||
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
|
||||||
|
|
Loading…
Reference in a new issue