Skip to content

Commit 1cd83fb

Browse files
author
Mikulas Patocka
committed
dm-integrity: prefer synchronous hash interface
The previous patch preferred async interface for the purpose of testing. However, the synchronous interface is faster, so it should be preferred. Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 5076d45 commit 1cd83fb

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

drivers/md/dm-integrity.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,13 +4354,33 @@ static int get_mac(struct crypto_shash **shash, struct crypto_ahash **ahash,
43544354
int r;
43554355

43564356
if (a->alg_string) {
4357+
if (shash) {
4358+
*shash = crypto_alloc_shash(a->alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
4359+
if (IS_ERR(*shash)) {
4360+
*shash = NULL;
4361+
goto try_ahash;
4362+
}
4363+
if (a->key) {
4364+
r = crypto_shash_setkey(*shash, a->key, a->key_size);
4365+
if (r) {
4366+
*error = error_key;
4367+
return r;
4368+
}
4369+
} else if (crypto_shash_get_flags(*shash) & CRYPTO_TFM_NEED_KEY) {
4370+
*error = error_key;
4371+
return -ENOKEY;
4372+
}
4373+
return 0;
4374+
}
4375+
try_ahash:
43574376
if (ahash) {
43584377
*ahash = crypto_alloc_ahash(a->alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
43594378
if (IS_ERR(*ahash)) {
4379+
*error = error_alg;
4380+
r = PTR_ERR(*ahash);
43604381
*ahash = NULL;
4361-
goto try_shash;
4382+
return r;
43624383
}
4363-
43644384
if (a->key) {
43654385
r = crypto_ahash_setkey(*ahash, a->key, a->key_size);
43664386
if (r) {
@@ -4371,29 +4391,10 @@ static int get_mac(struct crypto_shash **shash, struct crypto_ahash **ahash,
43714391
*error = error_key;
43724392
return -ENOKEY;
43734393
}
4374-
43754394
return 0;
43764395
}
4377-
4378-
try_shash:
4379-
*shash = crypto_alloc_shash(a->alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
4380-
if (IS_ERR(*shash)) {
4381-
*error = error_alg;
4382-
r = PTR_ERR(*shash);
4383-
*shash = NULL;
4384-
return r;
4385-
}
4386-
4387-
if (a->key) {
4388-
r = crypto_shash_setkey(*shash, a->key, a->key_size);
4389-
if (r) {
4390-
*error = error_key;
4391-
return r;
4392-
}
4393-
} else if (crypto_shash_get_flags(*shash) & CRYPTO_TFM_NEED_KEY) {
4394-
*error = error_key;
4395-
return -ENOKEY;
4396-
}
4396+
*error = error_alg;
4397+
return -ENOENT;
43974398
}
43984399

43994400
return 0;

0 commit comments

Comments
 (0)