From 72c111bac465b62d4a800a53e9804e48f7ae76ea Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sat, 1 Dec 2012 14:32:01 +0100 Subject: [PATCH] Fix (stupid) crc32 keyfile endianess bug. --- lib/tcrypt/tcrypt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index 801f68e..4d6d4aa 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -428,7 +428,6 @@ static int pool_keyfile(struct crypt_device *cd, unsigned char data[TCRYPT_KEYFILE_LEN]; int i, j, fd, data_size; uint32_t crc; - unsigned char *crc_c = (unsigned char*)&crc; log_dbg("TCRYPT: using keyfile %s.", keyfile); @@ -448,10 +447,10 @@ static int pool_keyfile(struct crypt_device *cd, for (i = 0, j = 0, crc = ~0U; i < data_size; i++) { crc = crypt_crc32(crc, &data[i], 1); - pool[j++] += crc_c[3]; - pool[j++] += crc_c[2]; - pool[j++] += crc_c[1]; - pool[j++] += crc_c[0]; + pool[j++] += (unsigned char)(crc >> 24); + pool[j++] += (unsigned char)(crc >> 16); + pool[j++] += (unsigned char)(crc >> 8); + pool[j++] += (unsigned char)(crc); j %= TCRYPT_KEY_POOL_LEN; } -- 2.7.4