diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-10-30 05:25:15 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-09 17:15:34 -0500 |
commit | 06ace7a9bafeb9047352707eb79e8eaa0dfdf5f2 (patch) | |
tree | fa22bbc2e8ea5bee00b6aec353783144b6f8735a /arch/x86_64 | |
parent | 2df15fffc612b53b2c8e4ff3c981a82441bc00ae (diff) |
[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>
Diffstat (limited to 'arch/x86_64')
-rw-r--r-- | arch/x86_64/crypto/aes.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/arch/x86_64/crypto/aes.c b/arch/x86_64/crypto/aes.c index acfdaa28791e..19996854b490 100644 --- a/arch/x86_64/crypto/aes.c +++ b/arch/x86_64/crypto/aes.c | |||
@@ -74,8 +74,6 @@ static inline u8 byte(const u32 x, const unsigned n) | |||
74 | return x >> (n << 3); | 74 | return x >> (n << 3); |
75 | } | 75 | } |
76 | 76 | ||
77 | #define u32_in(x) le32_to_cpu(*(const __le32 *)(x)) | ||
78 | |||
79 | struct aes_ctx | 77 | struct aes_ctx |
80 | { | 78 | { |
81 | u32 key_length; | 79 | u32 key_length; |
@@ -234,6 +232,7 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, | |||
234 | u32 *flags) | 232 | u32 *flags) |
235 | { | 233 | { |
236 | struct aes_ctx *ctx = ctx_arg; | 234 | struct aes_ctx *ctx = ctx_arg; |
235 | const __le32 *key = (const __le32 *)in_key; | ||
237 | u32 i, j, t, u, v, w; | 236 | u32 i, j, t, u, v, w; |
238 | 237 | ||
239 | if (key_len != 16 && key_len != 24 && key_len != 32) { | 238 | if (key_len != 16 && key_len != 24 && key_len != 32) { |
@@ -243,10 +242,10 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, | |||
243 | 242 | ||
244 | ctx->key_length = key_len; | 243 | ctx->key_length = key_len; |
245 | 244 | ||
246 | D_KEY[key_len + 24] = E_KEY[0] = u32_in(in_key); | 245 | D_KEY[key_len + 24] = E_KEY[0] = le32_to_cpu(key[0]); |
247 | D_KEY[key_len + 25] = E_KEY[1] = u32_in(in_key + 4); | 246 | D_KEY[key_len + 25] = E_KEY[1] = le32_to_cpu(key[1]); |
248 | D_KEY[key_len + 26] = E_KEY[2] = u32_in(in_key + 8); | 247 | D_KEY[key_len + 26] = E_KEY[2] = le32_to_cpu(key[2]); |
249 | D_KEY[key_len + 27] = E_KEY[3] = u32_in(in_key + 12); | 248 | D_KEY[key_len + 27] = E_KEY[3] = le32_to_cpu(key[3]); |
250 | 249 | ||
251 | switch (key_len) { | 250 | switch (key_len) { |
252 | case 16: | 251 | case 16: |
@@ -256,17 +255,17 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, | |||
256 | break; | 255 | break; |
257 | 256 | ||
258 | case 24: | 257 | case 24: |
259 | E_KEY[4] = u32_in(in_key + 16); | 258 | E_KEY[4] = le32_to_cpu(key[4]); |
260 | t = E_KEY[5] = u32_in(in_key + 20); | 259 | t = E_KEY[5] = le32_to_cpu(key[5]); |
261 | for (i = 0; i < 8; ++i) | 260 | for (i = 0; i < 8; ++i) |
262 | loop6 (i); | 261 | loop6 (i); |
263 | break; | 262 | break; |
264 | 263 | ||
265 | case 32: | 264 | case 32: |
266 | E_KEY[4] = u32_in(in_key + 16); | 265 | E_KEY[4] = le32_to_cpu(key[4]); |
267 | E_KEY[5] = u32_in(in_key + 20); | 266 | E_KEY[5] = le32_to_cpu(key[5]); |
268 | E_KEY[6] = u32_in(in_key + 24); | 267 | E_KEY[6] = le32_to_cpu(key[6]); |
269 | t = E_KEY[7] = u32_in(in_key + 28); | 268 | t = E_KEY[7] = le32_to_cpu(key[7]); |
270 | for (i = 0; i < 7; ++i) | 269 | for (i = 0; i < 7; ++i) |
271 | loop8(i); | 270 | loop8(i); |
272 | break; | 271 | break; |