public bool DetectCheck(ISecureValue value) { if (!Enable) { return(false); } if (mode == TamperDetectionMode.CheckSum) { if (!checkSumDic.ContainsKey(value)) { checkSumDic[value] = value.Sum(); return(false); } return(checkSumDic[value] != value.Sum()); } else if (mode == TamperDetectionMode.CRC) { if (!crcDic.ContainsKey(value)) { crcDic[value] = value.CRC(); return(false); } return(crcDic[value] != value.CRC()); } else if (mode == TamperDetectionMode.Hash) { if (!hashDic.ContainsKey(value)) { hashDic[value] = value.Hash(); return(false); } return(hashDic[value] != value.Hash()); } return(false); }
internal void UpdateInternal(ISecureValue value) { if (!Enable) { return; } if (mode == TamperDetectionMode.CheckSum) { checkSumDic[value] = value.Sum(); } else if (mode == TamperDetectionMode.CRC) { crcDic[value] = value.CRC(); } else if (mode == TamperDetectionMode.Hash) { hashDic[value] = value.Hash(); } }
internal void AddSecureValue(ISecureValue value) { checkSumDic[value] = (mode == TamperDetectionMode.CheckSum && Enable) ? value.Sum() : 0; crcDic[value] = (mode == TamperDetectionMode.CRC && Enable) ? value.CRC() : 0; hashDic[value] = (mode == TamperDetectionMode.Hash && Enable) ? value.Hash() : null; }