Implement MAC and replay prevention