public void TestSignatureRightLinks() { KsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_Extended); TestVerificationContext context = new TestVerificationContext() { Signature = signature, ExtendedCalendarHashChain = signature.CalendarHashChain }; Verify(context, VerificationResultCode.Ok); }
public void TestSignatureExtendedCalendarHashChainRootHash() { // Check signature KsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_With_Publication_Record); TestVerificationContext context = new TestVerificationContext() { Signature = signature, ExtendedCalendarHashChain = signature.CalendarHashChain }; Verify(context, VerificationResultCode.Ok); }
public void TestSignatureExtendedCalendarHashChainLengthDiffers() { KsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_Extended); TlvTagBuilder builder = GetBuilder(signature); builder.RemoveChildTag(signature.CalendarHashChain[signature.CalendarHashChain.Count - 1]); TestVerificationContext context = new TestVerificationContext() { Signature = signature, ExtendedCalendarHashChain = new CalendarHashChain(builder.BuildTag()) }; Verify(context, VerificationResultCode.Fail, VerificationError.Cal04); }
public void TestSignatureExtendedCalendarHashChainElementDiffers() { KsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_Extended); TlvTagBuilder builder = GetBuilder(signature); builder.ReplaceChildTag(signature.CalendarHashChain[signature.CalendarHashChain.Count - 1], new RawTag((uint)LinkDirection.Right, false, false, Base16.Decode("01580192B0D06E48884432DFFC26A67C6C685BEAF0252B9DD2A0B4B05D1724C5F2"))); TestVerificationContext context = new TestVerificationContext() { Signature = signature, ExtendedCalendarHashChain = new CalendarHashChain(builder.BuildTag()) }; Verify(context, VerificationResultCode.Fail, VerificationError.Cal04); }
private static TlvTagBuilder GetBuilder(KsiSignature signature) { TlvTagBuilder builder = new TlvTagBuilder(Constants.CalendarHashChain.TagType, false, false); foreach (ITlvTag child in signature.CalendarHashChain) { CalendarHashChain.Link link = child as CalendarHashChain.Link; if (link != null && link.Type == (uint)LinkDirection.Right) { // add a left link, this does not make the verification to fail. builder.AddChildTag(new RawTag((uint)LinkDirection.Left, false, false, Base16.Decode("01580192B0D06E48884432DFFC26A67C6C685BEAF0252B9DD2A0B4B05D1724C5F2"))); } builder.AddChildTag(child); } return(builder); }