public void TestGetOutputHash() { AggregationHashChain aggregationHashChain = GetAggregationHashChainFromFile(Resources.AggregationHashChain_Ok); AggregationHashChainResult result = new AggregationHashChainResult(1, aggregationHashChain.InputHash); result = aggregationHashChain.GetOutputHash(result); Assert.AreEqual(new DataHash(Base16.Decode("0116FF519501549E59F94952234BEAE90D1AB708901AF7B3F92B88B6A441969541")), result.Hash, "Unexpected output hash."); Assert.AreEqual(29, result.Level, "Unexpected level."); }
/// <see cref="VerificationRule.Verify" /> public override VerificationResult Verify(IVerificationContext context) { ReadOnlyCollection <AggregationHashChain> aggregationHashChains = GetAggregationHashChains(GetSignature(context), true); AggregationHashChainResult chainResult = null; foreach (AggregationHashChain aggregationHashChain in aggregationHashChains) { if (chainResult == null) { chainResult = new AggregationHashChainResult(0, aggregationHashChain.InputHash); } if (aggregationHashChain.InputHash != chainResult.Hash) { Logger.Debug("Aggregation hash chains not consistent. Aggregation hash chain input hash {0} does not match previous aggregation hash chain output hash {1}.", aggregationHashChain.InputHash, chainResult.Hash); return(new VerificationResult(GetRuleName(), VerificationResultCode.Fail, VerificationError.Int01)); } chainResult = aggregationHashChain.GetOutputHash(chainResult); } return(new VerificationResult(GetRuleName(), VerificationResultCode.Ok)); }