summaryrefslogtreecommitdiff
path: root/crypto/skcipher.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2018-12-20 15:35:07 +0100
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2018-12-20 15:35:07 +0100
commit6e603ea6e028001e3d56dc56822cb9c1cf2908f9 (patch)
treeecde2ff65bcb3ef7f0379d9ccc5eb30d6033f8f3 /crypto/skcipher.c
parent50d4fb1dc129955ab571c1dd7bf14cd07cc5984d (diff)
parent7271e588c712517a184f75744b6e94d05c8251a4 (diff)
downloadlinux-crypto-6e603ea6e028001e3d56dc56822cb9c1cf2908f9.tar.gz
linux-crypto-6e603ea6e028001e3d56dc56822cb9c1cf2908f9.zip
Merge tag 'v4.20-rc7' of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into fbdev-for-next
Linux 4.20-rc7 Sync with upstream (which now contains fbdev-v4.20 changes) to prepare a base for fbdev-v4.21 changes.
Diffstat (limited to 'crypto/skcipher.c')
-rw-r--r--crypto/skcipher.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/skcipher.c b/crypto/skcipher.c
index 0bd8c6ca..4caab81d 100644
--- a/crypto/skcipher.c
+++ b/crypto/skcipher.c
@@ -949,6 +949,30 @@ struct crypto_skcipher *crypto_alloc_skcipher(const char *alg_name,
}
EXPORT_SYMBOL_GPL(crypto_alloc_skcipher);
+struct crypto_sync_skcipher *crypto_alloc_sync_skcipher(
+ const char *alg_name, u32 type, u32 mask)
+{
+ struct crypto_skcipher *tfm;
+
+ /* Only sync algorithms allowed. */
+ mask |= CRYPTO_ALG_ASYNC;
+
+ tfm = crypto_alloc_tfm(alg_name, &crypto_skcipher_type2, type, mask);
+
+ /*
+ * Make sure we do not allocate something that might get used with
+ * an on-stack request: check the request size.
+ */
+ if (!IS_ERR(tfm) && WARN_ON(crypto_skcipher_reqsize(tfm) >
+ MAX_SYNC_SKCIPHER_REQSIZE)) {
+ crypto_free_skcipher(tfm);
+ return ERR_PTR(-EINVAL);
+ }
+
+ return (struct crypto_sync_skcipher *)tfm;
+}
+EXPORT_SYMBOL_GPL(crypto_alloc_sync_skcipher);
+
int crypto_has_skcipher2(const char *alg_name, u32 type, u32 mask)
{
return crypto_type_has_alg(alg_name, &crypto_skcipher_type2,