diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-10-20 08:06:36 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-10-24 09:10:54 -0400 |
commit | 58990986f1cba40c23c0c10592ace08616de3ffa (patch) | |
tree | 84466698a28860d1457c804b857b2e97d1995fcb /arch/x86/crypto/twofish_glue_3way.c | |
parent | e080b17a8cec92ef42343989ae65c73c25529346 (diff) |
crypto: x86/glue_helper - use le128 instead of u128 for CTR mode
'u128' currently used for CTR mode is on little-endian 'long long' swapped
and would require extra swap operations by SSE/AVX code. Use of le128
instead of u128 allows IV calculations to be done with vector registers
easier.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/crypto/twofish_glue_3way.c')
-rw-r--r-- | arch/x86/crypto/twofish_glue_3way.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c index aa3eb358b7e8..13e63b3e1dfb 100644 --- a/arch/x86/crypto/twofish_glue_3way.c +++ b/arch/x86/crypto/twofish_glue_3way.c | |||
@@ -62,15 +62,15 @@ void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src) | |||
62 | } | 62 | } |
63 | EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); | 63 | EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); |
64 | 64 | ||
65 | void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) | 65 | void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) |
66 | { | 66 | { |
67 | be128 ctrblk; | 67 | be128 ctrblk; |
68 | 68 | ||
69 | if (dst != src) | 69 | if (dst != src) |
70 | *dst = *src; | 70 | *dst = *src; |
71 | 71 | ||
72 | u128_to_be128(&ctrblk, iv); | 72 | le128_to_be128(&ctrblk, iv); |
73 | u128_inc(iv); | 73 | le128_inc(iv); |
74 | 74 | ||
75 | twofish_enc_blk(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); | 75 | twofish_enc_blk(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); |
76 | u128_xor(dst, dst, (u128 *)&ctrblk); | 76 | u128_xor(dst, dst, (u128 *)&ctrblk); |
@@ -78,7 +78,7 @@ void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) | |||
78 | EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr); | 78 | EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr); |
79 | 79 | ||
80 | void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, | 80 | void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, |
81 | u128 *iv) | 81 | le128 *iv) |
82 | { | 82 | { |
83 | be128 ctrblks[3]; | 83 | be128 ctrblks[3]; |
84 | 84 | ||
@@ -88,12 +88,12 @@ void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, | |||
88 | dst[2] = src[2]; | 88 | dst[2] = src[2]; |
89 | } | 89 | } |
90 | 90 | ||
91 | u128_to_be128(&ctrblks[0], iv); | 91 | le128_to_be128(&ctrblks[0], iv); |
92 | u128_inc(iv); | 92 | le128_inc(iv); |
93 | u128_to_be128(&ctrblks[1], iv); | 93 | le128_to_be128(&ctrblks[1], iv); |
94 | u128_inc(iv); | 94 | le128_inc(iv); |
95 | u128_to_be128(&ctrblks[2], iv); | 95 | le128_to_be128(&ctrblks[2], iv); |
96 | u128_inc(iv); | 96 | le128_inc(iv); |
97 | 97 | ||
98 | twofish_enc_blk_xor_3way(ctx, (u8 *)dst, (u8 *)ctrblks); | 98 | twofish_enc_blk_xor_3way(ctx, (u8 *)dst, (u8 *)ctrblks); |
99 | } | 99 | } |