aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2025-05-04 21:33:21 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2025-05-05 18:20:46 +0800
commit1052671ca118b79fa3f5de281bba850aaf20bbf5 (patch)
tree10a3f0de9902c7eb1b2d16c8b4956f3c79bc2bc0 /crypto
parentcrypto: ahash - Enforce MAX_SYNC_HASH_REQSIZE for sync ahash (diff)
downloadwireguard-linux-1052671ca118b79fa3f5de281bba850aaf20bbf5.tar.xz
wireguard-linux-1052671ca118b79fa3f5de281bba850aaf20bbf5.zip
crypto: ahash - Add core export and import
Add crypto_ahash_export_core and crypto_ahash_import_core. For now they only differ from the normal export/import functions when going through shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ahash.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 736e9fb5d0a4..344bf1b43e71 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -698,6 +698,16 @@ static int ahash_def_finup(struct ahash_request *req)
return ahash_def_finup_finish1(req, err);
}
+int crypto_ahash_export_core(struct ahash_request *req, void *out)
+{
+ struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
+
+ if (likely(tfm->using_shash))
+ return crypto_shash_export_core(ahash_request_ctx(req), out);
+ return crypto_ahash_alg(tfm)->export(req, out);
+}
+EXPORT_SYMBOL_GPL(crypto_ahash_export_core);
+
int crypto_ahash_export(struct ahash_request *req, void *out)
{
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -708,6 +718,19 @@ int crypto_ahash_export(struct ahash_request *req, void *out)
}
EXPORT_SYMBOL_GPL(crypto_ahash_export);
+int crypto_ahash_import_core(struct ahash_request *req, const void *in)
+{
+ struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
+
+ if (likely(tfm->using_shash))
+ return crypto_shash_import_core(prepare_shash_desc(req, tfm),
+ in);
+ if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
+ return -ENOKEY;
+ return crypto_ahash_alg(tfm)->import(req, in);
+}
+EXPORT_SYMBOL_GPL(crypto_ahash_import_core);
+
int crypto_ahash_import(struct ahash_request *req, const void *in)
{
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -716,7 +739,7 @@ int crypto_ahash_import(struct ahash_request *req, const void *in)
return crypto_shash_import(prepare_shash_desc(req, tfm), in);
if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
return -ENOKEY;
- return crypto_ahash_alg(tfm)->import(req, in);
+ return crypto_ahash_import_core(req, in);
}
EXPORT_SYMBOL_GPL(crypto_ahash_import);