/// <see cref="VerificationRule.Verify" /> public override VerificationResult Verify(IVerificationContext context) { CalendarHashChain calendarHashChain = GetSignature(context).CalendarHashChain; // If calendar hash chain is missing, verification successful if (calendarHashChain == null) { return(new VerificationResult(GetRuleName(), VerificationResultCode.Ok)); } IEnumerator <CalendarHashChain.Link> linksEnumerator = calendarHashChain.GetLeftLinksEnumerator(); CalendarHashChain.Link link = linksEnumerator.MoveNext() ? linksEnumerator.Current : null; while (link != null) { if (link.Value.Algorithm.IsObsolete(calendarHashChain.PublicationTime)) { Logger.Debug("Calendar hash chain contains obsolete aggregation algorithm at publication time. Algorithm: {0}; Publication time: {1}", link.Value.Algorithm.Name, calendarHashChain.PublicationTime); return(new VerificationResult(GetRuleName(), VerificationResultCode.Fail, VerificationError.Int16)); } link = linksEnumerator.MoveNext() ? linksEnumerator.Current : null; } return(new VerificationResult(GetRuleName(), VerificationResultCode.Ok)); }
/// <summary> /// Get first deprecated hash algorithm from calendar hash chain. /// </summary> /// <param name="calendarHashChain"></param> /// <returns></returns> public static HashAlgorithm GetDeprecatedHashAlgorithm(CalendarHashChain calendarHashChain) { IEnumerator <CalendarHashChain.Link> linksEnumerator = calendarHashChain.GetLeftLinksEnumerator(); CalendarHashChain.Link link = linksEnumerator.MoveNext() ? linksEnumerator.Current : null; while (link != null) { if (link.Value.Algorithm.IsDeprecated(calendarHashChain.PublicationTime)) { return(link.Value.Algorithm); } link = linksEnumerator.MoveNext() ? linksEnumerator.Current : null; } return(null); }