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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180521173617.31625-10-krisman@collabora.co.uk>
Date:   Mon, 21 May 2018 14:36:11 -0300
From:   Gabriel Krisman Bertazi <krisman@...labora.co.uk>
To:     viro@...IV.linux.org.uk
Cc:     jra@...gle.com, tytso@....edu, olaf@....com,
        darrick.wong@...cle.com, kernel@...ts.collabora.co.uk,
        linux-fsdevel@...r.kernel.org, david@...morbit.com, jack@...e.cz,
        linux-kernel@...r.kernel.org,
        Gabriel Krisman Bertazi <krisman@...labora.co.uk>
Subject: [PATCH v2 09/15] nls: Add optional normalization and casefold hooks

Signed-off-by: Gabriel Krisman Bertazi <krisman@...labora.co.uk>
---
 include/linux/nls.h | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/include/linux/nls.h b/include/linux/nls.h
index 72698d524b42..efd3712f0e81 100644
--- a/include/linux/nls.h
+++ b/include/linux/nls.h
@@ -4,6 +4,7 @@
 
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/errno.h>
 
 /* Unicode has changed over the years.  Unicode code points no longer
  * fit into 16 bits; as of Unicode 5 valid code points range from 0
@@ -38,7 +39,12 @@ struct nls_ops {
 				   unsigned int c);
 	unsigned char (*uppercase)(const struct nls_table *charset,
 				   unsigned int c);
-
+	int (*casefold)(const struct nls_table *charset,
+			const unsigned char *str, size_t len,
+			unsigned char **folded);
+	int (*normalize)(const struct nls_table *charset,
+			 const unsigned char *str, size_t len,
+			 unsigned char **normalized);
 };
 
 struct nls_table {
@@ -156,6 +162,26 @@ static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
 	return nls_strncasecmp(t, s1, len, s2, len);
 }
 
+static inline int nls_casefold(const struct nls_table *charset,
+			       const unsigned char *str, size_t len,
+			       unsigned char **folded)
+{
+	if (charset->ops->casefold)
+		return charset->ops->casefold(charset, str, len, folded);
+
+	return -ENOTSUPP;
+}
+
+static inline int nls_normalize(const struct nls_table *charset,
+				const unsigned char *str, size_t len,
+				unsigned char **normalized)
+{
+	if (charset->ops->normalize)
+		return charset->ops->normalize(charset, str, len, normalized);
+
+	return -ENOTSUPP;
+}
+
 /*
  * nls_nullsize - return length of null character for codepage
  * @codepage - codepage for which to return length of NULL terminator
-- 
2.17.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ