Add functionality for crypto thread, mac thread and write thread