Beispiel #1
0
        public void TestKsiSignatureExtendWithCalendarHashChainHasLessRightLinks()
        {
            IKsiSignature signature = GetKsiSignatureFromFile(Resources.KsiSignature_Ok);
            KsiException  ex        = Assert.Throws <KsiException>(delegate
            {
                signature.Extend(GetCalendarHashChain(true));
            });

            Assert.That(ex.Message, Does.StartWith("Right links of signature calendar hash chain and extended calendar hash chain do not match"), "Unexpected error message");
        }
        public void ExtendStaticNoSuitablePublicationYetTest()
        {
            IKsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_New);
            Ksi           ksi       = GetStaticKsi(Resources.KsiService_ExtendResponsePdu_RequestId_1043101455, 1043101455);

            KsiException ex = Assert.Throws <KsiException>(delegate
            {
                ksi.Extend(signature);
            });

            Assert.That(ex.Message.StartsWith("No suitable publication yet"), "Unexpected exception message: " + ex.Message);
        }
        public void CreateSignatureWithAggregationChainFailHashMismatchTest()
        {
            // cannot add new aggregation hash chain, it's output hash and base signature input hash mismatch
            KsiException ex = Assert.Throws <KsiException>(delegate
            {
                CreateSignatureWithAggregationChainAndVerify(
                    TestUtil.GetSignature(Resources.KsiSignature_Ok_LevelCorrection3),
                    new DataHash(Base16.Decode("01580192B0D06E48884432DFFC26A67C6C685BEAF0252B9DD2A0B4B05D1724C5F2")),
                    new AggregationHashChain.Link[]
                {
                    new AggregationHashChain.Link(LinkDirection.Left, new DataHash(Base16.Decode("0114F9189A45A30D856029F9537FD20C9C7342B82A2D949072AB195D95D7B32ECB"))),
                    new AggregationHashChain.Link(LinkDirection.Left, new DataHash(Base16.Decode("01D4F6E36871BA12449CA773F2A36F9C0112FC74EBE164C8278D213042C772E3AB"))),
                });
            });

            Assert.That(ex.Message.StartsWith("The aggregation hash chain cannot be added as lowest level chain. It's output hash does not match base signature input hash"),
                        "Unexpected exception message: " + ex.Message);
        }
        public void CreateSignatureWithAggregationChainFailWrongLevelCorrectionTest()
        {
            IKsiSignature signature = TestUtil.GetSignature(Resources.KsiSignature_Ok_LevelCorrection3);

            // new chain does not fit, base signature first level correction is not big enough
            KsiException ex1 = Assert.Throws <KsiException>(delegate
            {
                CreateSignatureWithAggregationChainAndVerify(
                    signature,
                    new DataHash(Base16.Decode("01580192B0D06E48884432DFFC26A67C6C685BEAF0252B9DD2A0B4B05D1724C5F2")),
                    new AggregationHashChain.Link[]
                {
                    new AggregationHashChain.Link(LinkDirection.Left, new DataHash(Base16.Decode("018D982C6911831201C5CF15E937514686A2169E2AD57BA36FD92CBEBD99A67E34")), 1),
                    new AggregationHashChain.Link(LinkDirection.Left, new DataHash(Base16.Decode("0114F9189A45A30D856029F9537FD20C9C7342B82A2D949072AB195D95D7B32ECB"))),
                    new AggregationHashChain.Link(LinkDirection.Left, new DataHash(Base16.Decode("01D4F6E36871BA12449CA773F2A36F9C0112FC74EBE164C8278D213042C772E3AB"))),
                });
            });

            Assert.That(ex1.Message.StartsWith(
                            "The aggregation hash chain cannot be added as lowest level chain. It's output level (4) is bigger than level correction of the first link of the first aggregation hash chain of the base signature (3)"),
                        "Unexpected exception message: " + ex1.Message);

            // new chain does not fit, base signature first level correction is not big enough
            KsiException ex2 = Assert.Throws <KsiException>(delegate
            {
                CreateSignatureWithAggregationChainAndVerify(
                    signature,
                    new DataHash(Base16.Decode("019D982C6911831201C5CF15E937514686A2169E2AD57BA36FD92CBEBD99A67E32")),
                    new AggregationHashChain.Link[]
                {
                    new AggregationHashChain.Link(LinkDirection.Right, new DataHash(Base16.Decode("01680192B0D06E48884432DFFC26A67C6C685BEAF0252B9DD2A0B4B05D1724C5F1")), 2),
                    new AggregationHashChain.Link(LinkDirection.Right, new DataHash(Base16.Decode("015950DCA0E23E65EF56D68AF94718951567EBC2EF1F54357732530FC25D925340"))),
                });
            });

            Assert.That(ex2.Message.StartsWith(
                            "The aggregation hash chain cannot be added as lowest level chain. It's output level (4) is bigger than level correction of the first link of the first aggregation hash chain of the base signature (3)"),
                        "Unexpected exception message: " + ex1.Message);
        }
        /// <summary>
        /// Create aggregator configuration changed event arguments class instance.
        /// </summary>
        /// <param name="exception">Exception thrown while processing aggregator configuration request</param>
        /// <param name="ksiService">KsiService that made the aggregator configuration request</param>
        public AggregatorConfigChangedEventArgs(KsiException exception, IKsiService ksiService)

        {
            Exception  = exception;
            KsiService = ksiService;
        }
Beispiel #6
0
        /// <summary>
        /// Create extender configuration changed event arguments class instance.
        /// </summary>
        /// <param name="exception">Exception thrown while processing extender configuration request</param>
        /// <param name="ksiService">KsiService that made the extender configuration request</param>
        public ExtenderConfigChangedEventArgs(KsiException exception, IKsiService ksiService)

        {
            Exception  = exception;
            KsiService = ksiService;
        }