From df8beba5855630e0d21ef853a7da34016f3bd56e Mon Sep 17 00:00:00 2001 From: Savva Mitrofanov Date: Wed, 28 Jun 2023 20:33:14 +0300 Subject: [PATCH] MdePkg/BaseLib: Correct CRC-16-ANSI implementation The ANSI implementation assumes that initial value should be 0xFFFF and the result shouldn't be inverted Fixes: 92288f4 ("MdePkg/BaseLib: Add CRC16-ANSI and CRC32c implementations") Signed-off-by: Savva Mitrofanov --- MdePkg/Library/BaseLib/CheckSum.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseLib/CheckSum.c b/MdePkg/Library/BaseLib/CheckSum.c index b6a0765731..57d324c82b 100644 --- a/MdePkg/Library/BaseLib/CheckSum.c +++ b/MdePkg/Library/BaseLib/CheckSum.c @@ -678,13 +678,13 @@ CalculateCrc16Ansi ( Buf = Buffer; - Crc = ~InitialValue; + Crc = InitialValue; while (Length-- != 0) { Crc = mCrc16LookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8); } - return ~Crc; + return Crc; } GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT32 mCrc32cLookupTable[256] = {