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 /drivers | |
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 'drivers')
-rw-r--r-- | drivers/crypto/padlock-aes.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index 71407c578afe..963e03dcb1ba 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
@@ -99,9 +99,6 @@ byte(const uint32_t x, const unsigned n) | |||
99 | return x >> (n << 3); | 99 | return x >> (n << 3); |
100 | } | 100 | } |
101 | 101 | ||
102 | #define uint32_t_in(x) le32_to_cpu(*(const uint32_t *)(x)) | ||
103 | #define uint32_t_out(to, from) (*(uint32_t *)(to) = cpu_to_le32(from)) | ||
104 | |||
105 | #define E_KEY ctx->E | 102 | #define E_KEY ctx->E |
106 | #define D_KEY ctx->D | 103 | #define D_KEY ctx->D |
107 | 104 | ||
@@ -294,6 +291,7 @@ static int | |||
294 | aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) | 291 | aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t *flags) |
295 | { | 292 | { |
296 | struct aes_ctx *ctx = aes_ctx(ctx_arg); | 293 | struct aes_ctx *ctx = aes_ctx(ctx_arg); |
294 | const __le32 *key = (const __le32 *)in_key; | ||
297 | uint32_t i, t, u, v, w; | 295 | uint32_t i, t, u, v, w; |
298 | uint32_t P[AES_EXTENDED_KEY_SIZE]; | 296 | uint32_t P[AES_EXTENDED_KEY_SIZE]; |
299 | uint32_t rounds; | 297 | uint32_t rounds; |
@@ -313,10 +311,10 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t | |||
313 | ctx->E = ctx->e_data; | 311 | ctx->E = ctx->e_data; |
314 | ctx->D = ctx->e_data; | 312 | ctx->D = ctx->e_data; |
315 | 313 | ||
316 | E_KEY[0] = uint32_t_in (in_key); | 314 | E_KEY[0] = le32_to_cpu(key[0]); |
317 | E_KEY[1] = uint32_t_in (in_key + 4); | 315 | E_KEY[1] = le32_to_cpu(key[1]); |
318 | E_KEY[2] = uint32_t_in (in_key + 8); | 316 | E_KEY[2] = le32_to_cpu(key[2]); |
319 | E_KEY[3] = uint32_t_in (in_key + 12); | 317 | E_KEY[3] = le32_to_cpu(key[3]); |
320 | 318 | ||
321 | /* Prepare control words. */ | 319 | /* Prepare control words. */ |
322 | memset(&ctx->cword, 0, sizeof(ctx->cword)); | 320 | memset(&ctx->cword, 0, sizeof(ctx->cword)); |
@@ -343,17 +341,17 @@ aes_set_key(void *ctx_arg, const uint8_t *in_key, unsigned int key_len, uint32_t | |||
343 | break; | 341 | break; |
344 | 342 | ||
345 | case 24: | 343 | case 24: |
346 | E_KEY[4] = uint32_t_in (in_key + 16); | 344 | E_KEY[4] = le32_to_cpu(key[4]); |
347 | t = E_KEY[5] = uint32_t_in (in_key + 20); | 345 | t = E_KEY[5] = le32_to_cpu(key[5]); |
348 | for (i = 0; i < 8; ++i) | 346 | for (i = 0; i < 8; ++i) |
349 | loop6 (i); | 347 | loop6 (i); |
350 | break; | 348 | break; |
351 | 349 | ||
352 | case 32: | 350 | case 32: |
353 | E_KEY[4] = uint32_t_in (in_key + 16); | 351 | E_KEY[4] = le32_to_cpu(in_key[4]); |
354 | E_KEY[5] = uint32_t_in (in_key + 20); | 352 | E_KEY[5] = le32_to_cpu(in_key[5]); |
355 | E_KEY[6] = uint32_t_in (in_key + 24); | 353 | E_KEY[6] = le32_to_cpu(in_key[6]); |
356 | t = E_KEY[7] = uint32_t_in (in_key + 28); | 354 | t = E_KEY[7] = le32_to_cpu(in_key[7]); |
357 | for (i = 0; i < 7; ++i) | 355 | for (i = 0; i < 7; ++i) |
358 | loop8 (i); | 356 | loop8 (i); |
359 | break; | 357 | break; |