Verify Checksum of Firmware Image

Easy Python Verification Asked at Western Digital
Solve this problem

Validate a firmware image whose last four bytes hold a little-endian CRC-32 over everything before them, and report whether the image is intact.

Constraints

  • Input is a bytes object.
  • An image shorter than 5 bytes must raise ValueError.
  • Use zlib.crc32 over the payload only.
  • Return a dict with valid, stored_crc and computed_crc.
  • Do not modify the input.
Starter codePython
1import zlib2 3def verify_image(image):4    # TODO5    return {}