Consolidated error checking in AES encryption and decryption