diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2014-04-04 08:24:03 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-04-04 09:06:14 -0400 |
commit | 0ea481466d1c7cbd9d8f70ddc17a443a6c6fc09b (patch) | |
tree | bed8163ad53745b67b1ea220d0d420fac4764cf6 /arch/x86/crypto | |
parent | 59ecc26004e77e100c700b1d0da7502b0fdadb46 (diff) |
crypto: ghash-clmulni-intel - Use u128 instead of be128 for internal key
The internal key isn't actually in big-endian format so let's switch
to u128 which also happens to allow us to remove a sparse warning.
Based on suggestion by Ard Biesheuvel.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Diffstat (limited to 'arch/x86/crypto')
-rw-r--r-- | arch/x86/crypto/ghash-clmulni-intel_asm.S | 4 | ||||
-rw-r--r-- | arch/x86/crypto/ghash-clmulni-intel_glue.c | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S index 185fad49d86f..5d1e0075ac24 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S | |||
@@ -92,7 +92,7 @@ __clmul_gf128mul_ble: | |||
92 | ret | 92 | ret |
93 | ENDPROC(__clmul_gf128mul_ble) | 93 | ENDPROC(__clmul_gf128mul_ble) |
94 | 94 | ||
95 | /* void clmul_ghash_mul(char *dst, const be128 *shash) */ | 95 | /* void clmul_ghash_mul(char *dst, const u128 *shash) */ |
96 | ENTRY(clmul_ghash_mul) | 96 | ENTRY(clmul_ghash_mul) |
97 | movups (%rdi), DATA | 97 | movups (%rdi), DATA |
98 | movups (%rsi), SHASH | 98 | movups (%rsi), SHASH |
@@ -106,7 +106,7 @@ ENDPROC(clmul_ghash_mul) | |||
106 | 106 | ||
107 | /* | 107 | /* |
108 | * void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, | 108 | * void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, |
109 | * const be128 *shash); | 109 | * const u128 *shash); |
110 | */ | 110 | */ |
111 | ENTRY(clmul_ghash_update) | 111 | ENTRY(clmul_ghash_update) |
112 | cmp $16, %rdx | 112 | cmp $16, %rdx |
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c index d785cf2c529c..88bb7ba8b175 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c | |||
@@ -25,17 +25,17 @@ | |||
25 | #define GHASH_BLOCK_SIZE 16 | 25 | #define GHASH_BLOCK_SIZE 16 |
26 | #define GHASH_DIGEST_SIZE 16 | 26 | #define GHASH_DIGEST_SIZE 16 |
27 | 27 | ||
28 | void clmul_ghash_mul(char *dst, const be128 *shash); | 28 | void clmul_ghash_mul(char *dst, const u128 *shash); |
29 | 29 | ||
30 | void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, | 30 | void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, |
31 | const be128 *shash); | 31 | const u128 *shash); |
32 | 32 | ||
33 | struct ghash_async_ctx { | 33 | struct ghash_async_ctx { |
34 | struct cryptd_ahash *cryptd_tfm; | 34 | struct cryptd_ahash *cryptd_tfm; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | struct ghash_ctx { | 37 | struct ghash_ctx { |
38 | be128 shash; | 38 | u128 shash; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct ghash_desc_ctx { | 41 | struct ghash_desc_ctx { |
@@ -68,11 +68,11 @@ static int ghash_setkey(struct crypto_shash *tfm, | |||
68 | a = be64_to_cpu(x->a); | 68 | a = be64_to_cpu(x->a); |
69 | b = be64_to_cpu(x->b); | 69 | b = be64_to_cpu(x->b); |
70 | 70 | ||
71 | ctx->shash.a = (__be64)((b << 1) | (a >> 63)); | 71 | ctx->shash.a = (b << 1) | (a >> 63); |
72 | ctx->shash.b = (__be64)((a << 1) | (b >> 63)); | 72 | ctx->shash.b = (a << 1) | (b >> 63); |
73 | 73 | ||
74 | if (a >> 63) | 74 | if (a >> 63) |
75 | ctx->shash.b ^= cpu_to_be64(0xc2); | 75 | ctx->shash.b ^= ((u64)0xc2) << 56; |
76 | 76 | ||
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |