Skip to contentSkip to conversation

crypto: padlock-aes.c replace private copy of bit rotation routines

PATCH In review Harvey Harrison 2 participants 4 messages Apr 15, 2008 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: padlock-aes.c replace private copy of bit rotation routines

Use the generic kernel implementation of the bit-rotation routines. The generic routines to not shift by mod 32, but all callers in the file pass constant values less than 32 making this a non-issue.

---
 drivers/crypto/padlock-aes.c |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)
drivers/crypto/padlock-aes.c +3 -16
index 2f3ad3f..84adbc0 100644
@@ -45,6 +45,7 @@
 
 #include <crypto/algapi.h>
 #include <crypto/aes.h>
+#include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -86,22 +87,8 @@ struct aes_ctx {
 
 /* ====== Key management routines ====== */
 
-static inline uint32_t
-generic_rotr32 (const uint32_t x, const unsigned bits)
-{
-	const unsigned n = bits % 32;
-	return (x >> n) | (x << (32 - n));
-}
-
-static inline uint32_t
-generic_rotl32 (const uint32_t x, const unsigned bits)
-{
-	const unsigned n = bits % 32;
-	return (x << n) | (x >> (32 - n));
-}
-
-#define rotl generic_rotl32
-#define rotr generic_rotr32
+#define rotl rol32
+#define rotr ror32
 
 /*
  * #define byte(x, nr) ((unsigned char)((x) >> (nr*8))) 
Signature · 1 line
1.5.5.144.g3e42
#1 lore raw
Quoted 7 lines · On Tue, 15 Apr 2008 12:16:03 -0700 Harvey Harrison <[email protected]>…

Use the generic kernel implementation of the bit-rotation routines. The generic routines to not shift by mod 32, but all callers in the file pass constant values less than 32 making this a non-issue.

---
 drivers/crypto/padlock-aes.c |   19 +++----------------

git-cryptodev.patch has taken a big chainsaw to the code which you're patching.

#2 lore raw
Quoted 7 lines · Andrew Morton
Quoted 4 lines · On Tue, 15 Apr 2008 12:16:03 -0700 Harvey Harrison <[email protected]>…

Use the generic kernel implementation of the bit-rotation routines. The generic routines to not shift by mod 32, but all callers in the file pass constant values less than 32 making this a non-issue.

Quoted 7 lines
Quoted 3 lines
---
 drivers/crypto/padlock-aes.c |   19 +++----------------

git-cryptodev.patch has taken a big chainsaw to the code which you're patching.

No worries, I'll wait for the crypto merge and see if this is still there.

Harvey

#3 lore raw
In reply to Andrew Morton
Quoted 7 lines · Andrew Morton
Quoted 4 lines · On Tue, 15 Apr 2008 12:16:03 -0700 Harvey Harrison <[email protected]>…

Use the generic kernel implementation of the bit-rotation routines. The generic routines to not shift by mod 32, but all callers in the file pass constant values less than 32 making this a non-issue.

Quoted 6 lines
Quoted 3 lines
---
 drivers/crypto/padlock-aes.c |   19 +++----------------

git-cryptodev.patch has taken a big chainsaw to the code which you're patching.

And after looking through cryptodev.git, this patch is indeed no longer needed.

Harvey