A formal study of two physical countermeasures against side channel attacks