lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  2 Aug 2018 14:51:13 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Herbert Xu <herbert@...dor.apana.org.au>
Cc:     Kees Cook <keescook@...omium.org>,
        Geliang Tang <geliangtang@...il.com>,
        Arnd Bergmann <arnd@...db.de>, Haren Myneni <haren@...ibm.com>,
        Anton Vorontsov <anton@...msg.org>,
        Colin Cross <ccross@...roid.com>,
        Tony Luck <tony.luck@...el.com>,
        Zhou Wang <wangzhou1@...ilicon.com>,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 4/9] crypto, lzo: Implement zbufsize()

This implements the worst-case compression size querying interface for
lzo, based on the logic originally used by pstore.

Signed-off-by: Kees Cook <keescook@...omium.org>
---
 crypto/lzo.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/crypto/lzo.c b/crypto/lzo.c
index 218567d717d6..ea18f62c5247 100644
--- a/crypto/lzo.c
+++ b/crypto/lzo.c
@@ -120,6 +120,24 @@ static int lzo_sdecompress(struct crypto_scomp *tfm, const u8 *src,
 	return __lzo_decompress(src, slen, dst, dlen);
 }
 
+static int __lzo_zbufsize(unsigned int slen, unsigned int *dlen)
+{
+	*dlen = lzo1x_worst_compress(slen);
+	return 0;
+}
+
+static int lzo_zbufsize(struct crypto_tfm *tfm, unsigned int slen,
+			unsigned int *dlen)
+{
+	return __lzo_zbufsize(slen, dlen);
+}
+
+static int lzo_szbufsize(struct crypto_scomp *tfm, unsigned int slen,
+			 unsigned int *dlen, void *ctx)
+{
+	return __lzo_zbufsize(slen, dlen);
+}
+
 static struct crypto_alg alg = {
 	.cra_name		= "lzo",
 	.cra_flags		= CRYPTO_ALG_TYPE_COMPRESS,
@@ -129,7 +147,8 @@ static struct crypto_alg alg = {
 	.cra_exit		= lzo_exit,
 	.cra_u			= { .compress = {
 	.coa_compress		= lzo_compress,
-	.coa_decompress		= lzo_decompress } }
+	.coa_decompress		= lzo_decompress,
+	.coa_zbufsize		= lzo_zbufsize } }
 };
 
 static struct scomp_alg scomp = {
@@ -137,6 +156,7 @@ static struct scomp_alg scomp = {
 	.free_ctx		= lzo_free_ctx,
 	.compress		= lzo_scompress,
 	.decompress		= lzo_sdecompress,
+	.zbufsize		= lzo_szbufsize,
 	.base			= {
 		.cra_name	= "lzo",
 		.cra_driver_name = "lzo-scomp",
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ