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:   Tue,  6 Nov 2018 11:40:05 +0530
From:   Sharat Masetty <smasetty@...eaurora.org>
To:     freedreno@...ts.freedesktop.org
Cc:     dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
        chris@...is-wilson.co.uk, jcrouse@...eaurora.org,
        robdclark@...il.com, linux-kernel@...r.kernel.org,
        Sharat Masetty <smasetty@...eaurora.org>
Subject: [PATCH 2/3] include/linux/ascii85: Add ascii85_encode_to_buf()

Add a new function which, in addition to ascii85 encoding to buffer
also returns the length of the encoded string. The length return enables
iteration over the output buffer space. This helps with efficient encoding
of larger buffers, since we avoid an additional memcpy/scnprintf.

Signed-off-by: Sharat Masetty <smasetty@...eaurora.org>
---
 include/linux/ascii85.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/linux/ascii85.h b/include/linux/ascii85.h
index 4cc4020..3665899 100644
--- a/include/linux/ascii85.h
+++ b/include/linux/ascii85.h
@@ -23,8 +23,12 @@
 {
 	int i;
 
-	if (in == 0)
-		return "z";
+	if (in == 0) {
+		out[0] = 'z';
+		out[1] = '\0';
+
+		return out;
+	}
 
 	out[5] = '\0';
 	for (i = 5; i--; ) {
@@ -35,4 +39,15 @@
 	return out;
 }
 
+static inline size_t
+ascii85_encode_to_buf(u32 in, char *out)
+{
+	ascii85_encode(in, out);
+
+	if (in == 0)
+		return 1;
+
+	return 5;
+}
+
 #endif
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ