From 7aab78fb52aed50a2f25ecf34d0c2a18d56a4543 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 25 Feb 2017 12:19:47 +0100 Subject: [PATCH] Fix broken SHA512 in LUKS due to union refactoring in tmps variable --- OpenCL/inc_luks_aes.cl | 19 +++++++++++++++++++ OpenCL/inc_luks_serpent.cl | 19 +++++++++++++++++++ OpenCL/inc_luks_twofish.cl | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/OpenCL/inc_luks_aes.cl b/OpenCL/inc_luks_aes.cl index 865bc87a2..f78549816 100644 --- a/OpenCL/inc_luks_aes.cl +++ b/OpenCL/inc_luks_aes.cl @@ -3271,6 +3271,25 @@ void luks_af_sha512_then_aes_decrypt (__global luks_t *luks_bufs, __global luks_ #define OFFSET_PER_BLOCK (16 / 4) #define OFFSET_PER_SECTOR (BLOCKS_PER_SECTOR * OFFSET_PER_BLOCK) + // move data from out64 to out32 + + tmps->out32[ 0] = l32_from_64_S (tmps->out64[0]); + tmps->out32[ 1] = h32_from_64_S (tmps->out64[0]); + tmps->out32[ 2] = l32_from_64_S (tmps->out64[1]); + tmps->out32[ 3] = h32_from_64_S (tmps->out64[1]); + tmps->out32[ 4] = l32_from_64_S (tmps->out64[2]); + tmps->out32[ 5] = h32_from_64_S (tmps->out64[2]); + tmps->out32[ 6] = l32_from_64_S (tmps->out64[3]); + tmps->out32[ 7] = h32_from_64_S (tmps->out64[3]); + tmps->out32[ 8] = l32_from_64_S (tmps->out64[4]); + tmps->out32[ 9] = h32_from_64_S (tmps->out64[4]); + tmps->out32[10] = l32_from_64_S (tmps->out64[5]); + tmps->out32[11] = h32_from_64_S (tmps->out64[5]); + tmps->out32[12] = l32_from_64_S (tmps->out64[6]); + tmps->out32[13] = h32_from_64_S (tmps->out64[6]); + tmps->out32[14] = l32_from_64_S (tmps->out64[7]); + tmps->out32[15] = h32_from_64_S (tmps->out64[7]); + // decrypt AF data and do the AF merge inline u32 mk[16] = { 0 }; diff --git a/OpenCL/inc_luks_serpent.cl b/OpenCL/inc_luks_serpent.cl index ef5bec7e3..8e99b5cff 100644 --- a/OpenCL/inc_luks_serpent.cl +++ b/OpenCL/inc_luks_serpent.cl @@ -3271,6 +3271,25 @@ void luks_af_sha512_then_serpent_decrypt (__global luks_t *luks_bufs, __global l #define OFFSET_PER_BLOCK (16 / 4) #define OFFSET_PER_SECTOR (BLOCKS_PER_SECTOR * OFFSET_PER_BLOCK) + // move data from out64 to out32 + + tmps->out32[ 0] = l32_from_64_S (tmps->out64[0]); + tmps->out32[ 1] = h32_from_64_S (tmps->out64[0]); + tmps->out32[ 2] = l32_from_64_S (tmps->out64[1]); + tmps->out32[ 3] = h32_from_64_S (tmps->out64[1]); + tmps->out32[ 4] = l32_from_64_S (tmps->out64[2]); + tmps->out32[ 5] = h32_from_64_S (tmps->out64[2]); + tmps->out32[ 6] = l32_from_64_S (tmps->out64[3]); + tmps->out32[ 7] = h32_from_64_S (tmps->out64[3]); + tmps->out32[ 8] = l32_from_64_S (tmps->out64[4]); + tmps->out32[ 9] = h32_from_64_S (tmps->out64[4]); + tmps->out32[10] = l32_from_64_S (tmps->out64[5]); + tmps->out32[11] = h32_from_64_S (tmps->out64[5]); + tmps->out32[12] = l32_from_64_S (tmps->out64[6]); + tmps->out32[13] = h32_from_64_S (tmps->out64[6]); + tmps->out32[14] = l32_from_64_S (tmps->out64[7]); + tmps->out32[15] = h32_from_64_S (tmps->out64[7]); + // decrypt AF data and do the AF merge inline u32 mk[16] = { 0 }; diff --git a/OpenCL/inc_luks_twofish.cl b/OpenCL/inc_luks_twofish.cl index 8c53e4f3d..134385bf2 100644 --- a/OpenCL/inc_luks_twofish.cl +++ b/OpenCL/inc_luks_twofish.cl @@ -3271,6 +3271,25 @@ void luks_af_sha512_then_twofish_decrypt (__global luks_t *luks_bufs, __global l #define OFFSET_PER_BLOCK (16 / 4) #define OFFSET_PER_SECTOR (BLOCKS_PER_SECTOR * OFFSET_PER_BLOCK) + // move data from out64 to out32 + + tmps->out32[ 0] = l32_from_64_S (tmps->out64[0]); + tmps->out32[ 1] = h32_from_64_S (tmps->out64[0]); + tmps->out32[ 2] = l32_from_64_S (tmps->out64[1]); + tmps->out32[ 3] = h32_from_64_S (tmps->out64[1]); + tmps->out32[ 4] = l32_from_64_S (tmps->out64[2]); + tmps->out32[ 5] = h32_from_64_S (tmps->out64[2]); + tmps->out32[ 6] = l32_from_64_S (tmps->out64[3]); + tmps->out32[ 7] = h32_from_64_S (tmps->out64[3]); + tmps->out32[ 8] = l32_from_64_S (tmps->out64[4]); + tmps->out32[ 9] = h32_from_64_S (tmps->out64[4]); + tmps->out32[10] = l32_from_64_S (tmps->out64[5]); + tmps->out32[11] = h32_from_64_S (tmps->out64[5]); + tmps->out32[12] = l32_from_64_S (tmps->out64[6]); + tmps->out32[13] = h32_from_64_S (tmps->out64[6]); + tmps->out32[14] = l32_from_64_S (tmps->out64[7]); + tmps->out32[15] = h32_from_64_S (tmps->out64[7]); + // decrypt AF data and do the AF merge inline u32 mk[16] = { 0 };