I am trying to generate Message authentication code (MAC) based on a given key and mac+data file in order to verify message integrity. I tried to do it via the following method. However, the MAC generated does not seem to match. How is my method wrong?
Mac+Data file = 32B MAC + Data
I need to utilise the Crypto.Hash library
from Crypto.Hash import SHA256
hasher = SHA256.new()
hasher.update(key_data)
hasher.update(data)
mac_generated = hasher.digest()