A unified framework for analyzing security of protocols