From 46dfbe17ecf5febd92a28fa631286bd299bd9dea Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Thu, 28 Jan 2016 08:28:58 +0100 Subject: [PATCH] Replace all le64 "xor" calculations with le64_xor(...). --- include/ntfs-3g/endians.h | 2 ++ ntfsprogs/ntfsdecrypt.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/ntfs-3g/endians.h b/include/ntfs-3g/endians.h index 06f932f3..339c688a 100644 --- a/include/ntfs-3g/endians.h +++ b/include/ntfs-3g/endians.h @@ -340,4 +340,6 @@ #define le32_xor(a, b) ((a) ^ (b)) +#define le64_xor(a, b) ((a) ^ (b)) + #endif /* defined _NTFS_ENDIANS_H */ diff --git a/ntfsprogs/ntfsdecrypt.c b/ntfsprogs/ntfsdecrypt.c index 098138ef..ce3e199a 100644 --- a/ntfsprogs/ntfsdecrypt.c +++ b/ntfsprogs/ntfsdecrypt.c @@ -1301,11 +1301,11 @@ static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset) } /* Apply the IV. */ if (le32_eq(fek->alg_id, CALG_AES_256)) { - ((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset); - ((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset); + ((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x5816657be9161312ULL + offset)); + ((le64*)data)[1] = le64_xor(((le64*)data)[1], cpu_to_le64(0x1989adbe44918961ULL + offset)); } else { /* All other algos (Des, 3Des, DesX) use the same IV. */ - ((le64*)data)[0] ^= cpu_to_le64(0x169119629891ad13ULL + offset); + ((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x169119629891ad13ULL + offset)); } return 512; } @@ -1331,11 +1331,11 @@ static int ntfs_fek_encrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset) */ /* Apply the IV. */ if (le32_eq(fek->alg_id, CALG_AES_256)) { - ((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset); - ((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset); + ((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x5816657be9161312ULL + offset)); + ((le64*)data)[1] = le64_xor(((le64*)data)[1], cpu_to_le64(0x1989adbe44918961ULL + offset)); } else { /* All other algos (Des, 3Des, DesX) use the same IV. */ - ((le64*)data)[0] ^= cpu_to_le64(0x169119629891ad13ULL + offset); + ((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x169119629891ad13ULL + offset)); } if (le32_eq(fek->alg_id, CALG_DESX)) { int k;