aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/ahash.c5
-rw-r--r--crypto/shash.c4
-rw-r--r--include/crypto/hash.h6
3 files changed, 13 insertions, 2 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 9c1dc8d6106a..d19b52324cf5 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -451,6 +451,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
451 struct ahash_alg *alg = crypto_ahash_alg(hash); 451 struct ahash_alg *alg = crypto_ahash_alg(hash);
452 452
453 hash->setkey = ahash_nosetkey; 453 hash->setkey = ahash_nosetkey;
454 hash->has_setkey = false;
454 hash->export = ahash_no_export; 455 hash->export = ahash_no_export;
455 hash->import = ahash_no_import; 456 hash->import = ahash_no_import;
456 457
@@ -463,8 +464,10 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
463 hash->finup = alg->finup ?: ahash_def_finup; 464 hash->finup = alg->finup ?: ahash_def_finup;
464 hash->digest = alg->digest; 465 hash->digest = alg->digest;
465 466
466 if (alg->setkey) 467 if (alg->setkey) {
467 hash->setkey = alg->setkey; 468 hash->setkey = alg->setkey;
469 hash->has_setkey = true;
470 }
468 if (alg->export) 471 if (alg->export)
469 hash->export = alg->export; 472 hash->export = alg->export;
470 if (alg->import) 473 if (alg->import)
diff --git a/crypto/shash.c b/crypto/shash.c
index ecb1e3d39bf0..88a27de79848 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -355,8 +355,10 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
355 crt->finup = shash_async_finup; 355 crt->finup = shash_async_finup;
356 crt->digest = shash_async_digest; 356 crt->digest = shash_async_digest;
357 357
358 if (alg->setkey) 358 if (alg->setkey) {
359 crt->setkey = shash_async_setkey; 359 crt->setkey = shash_async_setkey;
360 crt->has_setkey = true;
361 }
360 if (alg->export) 362 if (alg->export)
361 crt->export = shash_async_export; 363 crt->export = shash_async_export;
362 if (alg->import) 364 if (alg->import)
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 3d69c93d50e8..6361892ea737 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -204,6 +204,7 @@ struct crypto_ahash {
204 unsigned int keylen); 204 unsigned int keylen);
205 205
206 unsigned int reqsize; 206 unsigned int reqsize;
207 bool has_setkey;
207 struct crypto_tfm base; 208 struct crypto_tfm base;
208}; 209};
209 210
@@ -375,6 +376,11 @@ static inline void *ahash_request_ctx(struct ahash_request *req)
375int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key, 376int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
376 unsigned int keylen); 377 unsigned int keylen);
377 378
379static inline bool crypto_ahash_has_setkey(struct crypto_ahash *tfm)
380{
381 return tfm->has_setkey;
382}
383
378/** 384/**
379 * crypto_ahash_finup() - update and finalize message digest 385 * crypto_ahash_finup() - update and finalize message digest
380 * @req: reference to the ahash_request handle that holds all information 386 * @req: reference to the ahash_request handle that holds all information