[CRYPTO] Use standard byte order macros wherever possible
A lot of crypto code needs to read/write a 32-bit/64-bit words in a specific gender. Many of them open code them by reading/writing one byte at a time. This patch converts all the applicable usages over to use the standard byte order macros. This is based on a previous patch by Denis Vlasenko. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
David S. Miller
parent
2df15fffc6
commit
06ace7a9ba
@@ -37,6 +37,8 @@
|
||||
* Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the
|
||||
* Third Edition.
|
||||
*/
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
@@ -621,13 +623,11 @@ static const u8 calc_sb_tbl[512] = {
|
||||
* whitening subkey number m. */
|
||||
|
||||
#define INPACK(n, x, m) \
|
||||
x = in[4 * (n)] ^ (in[4 * (n) + 1] << 8) \
|
||||
^ (in[4 * (n) + 2] << 16) ^ (in[4 * (n) + 3] << 24) ^ ctx->w[m]
|
||||
x = le32_to_cpu(src[n]) ^ ctx->w[m]
|
||||
|
||||
#define OUTUNPACK(n, x, m) \
|
||||
x ^= ctx->w[m]; \
|
||||
out[4 * (n)] = x; out[4 * (n) + 1] = x >> 8; \
|
||||
out[4 * (n) + 2] = x >> 16; out[4 * (n) + 3] = x >> 24
|
||||
dst[n] = cpu_to_le32(x)
|
||||
|
||||
#define TF_MIN_KEY_SIZE 16
|
||||
#define TF_MAX_KEY_SIZE 32
|
||||
@@ -804,6 +804,8 @@ static int twofish_setkey(void *cx, const u8 *key,
|
||||
static void twofish_encrypt(void *cx, u8 *out, const u8 *in)
|
||||
{
|
||||
struct twofish_ctx *ctx = cx;
|
||||
const __le32 *src = (const __le32 *)in;
|
||||
__le32 *dst = (__le32 *)out;
|
||||
|
||||
/* The four 32-bit chunks of the text. */
|
||||
u32 a, b, c, d;
|
||||
@@ -839,6 +841,8 @@ static void twofish_encrypt(void *cx, u8 *out, const u8 *in)
|
||||
static void twofish_decrypt(void *cx, u8 *out, const u8 *in)
|
||||
{
|
||||
struct twofish_ctx *ctx = cx;
|
||||
const __le32 *src = (const __le32 *)in;
|
||||
__le32 *dst = (__le32 *)out;
|
||||
|
||||
/* The four 32-bit chunks of the text. */
|
||||
u32 a, b, c, d;
|
||||
|
Reference in New Issue
Block a user