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>] [day] [month] [year] [list]
Date:	Wed, 16 Apr 2008 11:29:31 -0700
From:	Harvey Harrison <harvey.harrison@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Jiri Benc <jbenc@...e.cz>, LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH-mm 2/3] mac80211: michael.c use get/put_unaligned helpers

Signed-off-by: Harvey Harrison <harvey.harrison@...il.com>
---
 net/mac80211/michael.c |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/net/mac80211/michael.c b/net/mac80211/michael.c
index 36bb3bb..698d7b3 100644
--- a/net/mac80211/michael.c
+++ b/net/mac80211/michael.c
@@ -27,35 +27,20 @@ static void michael_block(u32 val, u32 *l, u32 *r)
 	*l += *r;
 }
 
-static u32 michael_get16(u8 *data)
-{
-	return le16_to_cpu(get_unaligned((__le16 *)data));
-}
-
-static u32 michael_get32(u8 *data)
-{
-	return le32_to_cpu(get_unaligned((__le32 *)data));
-}
-
-static void michael_put32(u32 val, u8 *data)
-{
-	put_unaligned(cpu_to_le32(val), (__le32 *)data);
-}
-
 void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
 		 u8 *data, size_t data_len, u8 *mic)
 {
 	u32 l, r, val;
 	size_t block, blocks, left;
 
-	l = michael_get32(key);
-	r = michael_get32(key + 4);
+	l = get_unaligned_le32(key);
+	r = get_unaligned_le32(key + 4);
 
 	/* A pseudo header (DA, SA, Priority, 0, 0, 0) is used in Michael MIC
 	 * calculation, but it is _not_ transmitted */
-	michael_block(michael_get32(da), &l, &r);
-	michael_block(michael_get16(da) | (michael_get16(sa) << 16), &l, &r);
-	michael_block(michael_get32(&sa[2]), &l, &r);
+	michael_block(get_unaligned_le32(da), &l, &r);
+	michael_block(get_unaligned_le16(da) | (get_unaligned_le16(sa) << 16), &l, &r);
+	michael_block(get_unaligned_le32(sa + 2), &l, &r);
 	michael_block(priority, &l, &r);
 
 	/* Real data */
@@ -63,7 +48,7 @@ void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
 	left = data_len % 4;
 
 	for (block = 0; block < blocks; block++)
-		michael_block(michael_get32(&data[block * 4]), &l, &r);
+		michael_block(get_unaligned_le32(data + (block * 4)), &l, &r);
 
 	/* Partial block of 0..3 bytes and padding: 0x5a + 4..7 zeros to make
 	 * total length a multiple of 4. */
@@ -76,6 +61,6 @@ void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
 	michael_block(val, &l, &r);
 	michael_block(0, &l, &r);
 
-	michael_put32(l, mic);
-	michael_put32(r, mic + 4);
+	put_unaligned_le32(l, mic);
+	put_unaligned_le32(r, mic + 4);
 }
-- 
1.5.5.144.g3e42


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ