public AES_SPA(List <List <string> > messages, List <List <int> > hammingWeight) { this.messages = messages; this.hammingWeights = hammingWeight; this.allVariantsOfNumbersUpTo256Bin = new List <string>(); this.possibleKeyBytes = new List <List <string> >(); this.Key = new string[16]; GenerateAllVariantsOfNumersUpTo256(); this.messages = CollectionExtension.ConvertListOfListToBin(messages); }
private int GetCountOfPossibleKeysTo1Byte(int iteration) { var oldList = new List <string>(); var newList = new List <string>(); for (var i = 0; i < messages.Count; i++) { newList = GeneratePossibleListOfKeys(messages[i][iteration], hammingWeights[i][iteration]); if (i == 0) { oldList.AddRange(newList); } else { oldList = newList.Intersect(oldList).ToList(); } } Key[iteration] = (oldList.Count == 1) ? NumberExtension.ConvertBinToHex(oldList.First()) : string.Empty; possibleKeyBytes.Add(CollectionExtension.ConvertListOfBinToHex(oldList)); return(oldList.Count); }
public AES PrintResults() { Console.WriteLine($"Last operation - {lastOperation} \nMessage: {CollectionExtension.ConvertListToString(State)}"); return(this); }