diff options
Diffstat (limited to 'crypto/wp512.c')
-rw-r--r-- | crypto/wp512.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/crypto/wp512.c b/crypto/wp512.c index fd6e20e1f291..b226a126cfae 100644 --- a/crypto/wp512.c +++ b/crypto/wp512.c | |||
@@ -22,8 +22,10 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <asm/byteorder.h> | ||
25 | #include <asm/scatterlist.h> | 26 | #include <asm/scatterlist.h> |
26 | #include <linux/crypto.h> | 27 | #include <linux/crypto.h> |
28 | #include <linux/types.h> | ||
27 | 29 | ||
28 | #define WP512_DIGEST_SIZE 64 | 30 | #define WP512_DIGEST_SIZE 64 |
29 | #define WP384_DIGEST_SIZE 48 | 31 | #define WP384_DIGEST_SIZE 48 |
@@ -778,19 +780,10 @@ static void wp512_process_buffer(struct wp512_ctx *wctx) { | |||
778 | u64 block[8]; /* mu(buffer) */ | 780 | u64 block[8]; /* mu(buffer) */ |
779 | u64 state[8]; /* the cipher state */ | 781 | u64 state[8]; /* the cipher state */ |
780 | u64 L[8]; | 782 | u64 L[8]; |
781 | u8 *buffer = wctx->buffer; | 783 | const __be64 *buffer = (const __be64 *)wctx->buffer; |
782 | 784 | ||
783 | for (i = 0; i < 8; i++, buffer += 8) { | 785 | for (i = 0; i < 8; i++) |
784 | block[i] = | 786 | block[i] = be64_to_cpu(buffer[i]); |
785 | (((u64)buffer[0] ) << 56) ^ | ||
786 | (((u64)buffer[1] & 0xffL) << 48) ^ | ||
787 | (((u64)buffer[2] & 0xffL) << 40) ^ | ||
788 | (((u64)buffer[3] & 0xffL) << 32) ^ | ||
789 | (((u64)buffer[4] & 0xffL) << 24) ^ | ||
790 | (((u64)buffer[5] & 0xffL) << 16) ^ | ||
791 | (((u64)buffer[6] & 0xffL) << 8) ^ | ||
792 | (((u64)buffer[7] & 0xffL) ); | ||
793 | } | ||
794 | 787 | ||
795 | state[0] = block[0] ^ (K[0] = wctx->hash[0]); | 788 | state[0] = block[0] ^ (K[0] = wctx->hash[0]); |
796 | state[1] = block[1] ^ (K[1] = wctx->hash[1]); | 789 | state[1] = block[1] ^ (K[1] = wctx->hash[1]); |
@@ -1069,7 +1062,7 @@ static void wp512_final(void *ctx, u8 *out) | |||
1069 | u8 *bitLength = wctx->bitLength; | 1062 | u8 *bitLength = wctx->bitLength; |
1070 | int bufferBits = wctx->bufferBits; | 1063 | int bufferBits = wctx->bufferBits; |
1071 | int bufferPos = wctx->bufferPos; | 1064 | int bufferPos = wctx->bufferPos; |
1072 | u8 *digest = out; | 1065 | __be64 *digest = (__be64 *)out; |
1073 | 1066 | ||
1074 | buffer[bufferPos] |= 0x80U >> (bufferBits & 7); | 1067 | buffer[bufferPos] |= 0x80U >> (bufferBits & 7); |
1075 | bufferPos++; | 1068 | bufferPos++; |
@@ -1088,17 +1081,8 @@ static void wp512_final(void *ctx, u8 *out) | |||
1088 | memcpy(&buffer[WP512_BLOCK_SIZE - WP512_LENGTHBYTES], | 1081 | memcpy(&buffer[WP512_BLOCK_SIZE - WP512_LENGTHBYTES], |
1089 | bitLength, WP512_LENGTHBYTES); | 1082 | bitLength, WP512_LENGTHBYTES); |
1090 | wp512_process_buffer(wctx); | 1083 | wp512_process_buffer(wctx); |
1091 | for (i = 0; i < WP512_DIGEST_SIZE/8; i++) { | 1084 | for (i = 0; i < WP512_DIGEST_SIZE/8; i++) |
1092 | digest[0] = (u8)(wctx->hash[i] >> 56); | 1085 | digest[i] = cpu_to_be64(wctx->hash[i]); |
1093 | digest[1] = (u8)(wctx->hash[i] >> 48); | ||
1094 | digest[2] = (u8)(wctx->hash[i] >> 40); | ||
1095 | digest[3] = (u8)(wctx->hash[i] >> 32); | ||
1096 | digest[4] = (u8)(wctx->hash[i] >> 24); | ||
1097 | digest[5] = (u8)(wctx->hash[i] >> 16); | ||
1098 | digest[6] = (u8)(wctx->hash[i] >> 8); | ||
1099 | digest[7] = (u8)(wctx->hash[i] ); | ||
1100 | digest += 8; | ||
1101 | } | ||
1102 | wctx->bufferBits = bufferBits; | 1086 | wctx->bufferBits = bufferBits; |
1103 | wctx->bufferPos = bufferPos; | 1087 | wctx->bufferPos = bufferPos; |
1104 | } | 1088 | } |