CrcLib.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /** @file
  2. Interface header file for the CRC library class.
  3. @copyright
  4. Copyright 2016 - 2018 Intel Corporation. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _CRC_LIB_H_
  8. #define _CRC_LIB_H_
  9. #include <Uefi.h>
  10. /**
  11. Calculate a 16-bit CRC.
  12. The algorithm used is MSB-first form of the ITU-T Recommendation V.41, which
  13. uses an initial value of 0x0000 and a polynomial of 0x1021. It is the same
  14. algorithm used by XMODEM.
  15. The output CRC location is not updated until the calculation is finished, so
  16. it is possible to pass a structure as the data, and the CRC field of the same
  17. structure as the output location for the calculated CRC. The CRC field should
  18. be set to zero before calling this function. Once the CRC field is updated by
  19. this function, running it again over the structure produces a CRC of zero.
  20. @param[in] Data A pointer to the target data.
  21. @param[in] DataSize The target data size.
  22. @param[out] CrcOut A pointer to the return location of the CRC.
  23. @retval EFI_SUCCESS The CRC was calculated successfully.
  24. @retval EFI_INVALID_PARAMETER A null pointer was provided.
  25. **/
  26. EFI_STATUS
  27. CalculateCrc16 (
  28. IN VOID *Data,
  29. IN UINTN DataSize,
  30. OUT UINT16 *CrcOut
  31. );
  32. #endif // _CRC_LIB_H_