コード例 #1
0
        /// <see cref="VerificationRule.Verify" />
        public override VerificationResult Verify(IVerificationContext context)
        {
            IKsiSignature     signature                 = GetSignature(context);
            CalendarHashChain calendarHashChain         = GetCalendarHashChain(signature, true);
            CalendarHashChain extendedCalendarHashChain = calendarHashChain == null
                ? context.GetExtendedLatestCalendarHashChain()
                : context.GetExtendedCalendarHashChain(calendarHashChain.PublicationTime);

            if (extendedCalendarHashChain == null)
            {
                throw new KsiVerificationException("Received invalid extended calendar hash chain from context extension function: null.");
            }

            return(signature.GetLastAggregationHashChainRootHash() != extendedCalendarHashChain.InputHash
                ? new VerificationResult(GetRuleName(), VerificationResultCode.Fail, VerificationError.Cal02)
                : new VerificationResult(GetRuleName(), VerificationResultCode.Ok));
        }
        /// <see cref="VerificationRule.Verify" />
        public override VerificationResult Verify(IVerificationContext context)
        {
            IKsiSignature     signature                 = GetSignature(context);
            CalendarHashChain calendarHashChain         = GetCalendarHashChain(signature, true);
            CalendarHashChain extendedCalendarHashChain = calendarHashChain?.PublicationData == null
                ? context.GetExtendedLatestCalendarHashChain()
                : context.GetExtendedCalendarHashChain(calendarHashChain.PublicationData.PublicationTime);

            if (extendedCalendarHashChain == null)
            {
                throw new KsiVerificationException("Received invalid extended calendar hash chain from context extension function: null.");
            }

            ReadOnlyCollection <AggregationHashChain> aggregationHashChains = GetAggregationHashChains(signature, false);
            ulong aggregationTime = aggregationHashChains[aggregationHashChains.Count - 1].AggregationTime;

            return(aggregationTime != extendedCalendarHashChain.AggregationTime
                ? new VerificationResult(GetRuleName(), VerificationResultCode.Fail, VerificationError.Cal03)
                : new VerificationResult(GetRuleName(), VerificationResultCode.Ok));
        }