示例#1
0
        public void TestTooBigEncodeDecode()
        {
            var recv    = new ReceivedSessions(Private);
            var session = new DestinationSessions((d, h, inf) => { }, () => null);

            /*
             * var datamessage = new DataMessage( new BufLen( BufUtils.Random( 65000 ) ) );
             *
             * try
             * {
             *  var msg1eg = session.CreateMessage(
             *      Me,
             *      new GarlicCloveDeliveryTunnel(
             *          datamessage,
             *          Destination.IdentHash,
             *          1234 )
             *      );
             *
             *  Assert.Fail();
             * }
             * catch ( Exception )
             * {
             *  Assert.IsTrue( true );
             * }
             */
        }
示例#2
0
        public void TestEncodeDecode()
        {
            var recv    = new ReceivedSessions(Private);
            var session = new DestinationSessions((d, h, inf) => { }, () => null);

            var origmessage = new DeliveryStatusMessage(0x425c);

            /*
             * var msg1eg = session.CreateMessage(
             *  Me,
             *  new GarlicCloveDeliveryTunnel(
             *      origmessage,
             *      Destination.IdentHash,
             *      1234 ) );
             *
             * var msg2aes = session.CreateMessage(
             *  Me,
             *  new GarlicCloveDeliveryTunnel(
             *      origmessage,
             *      Destination.IdentHash,
             *      1234 ) );
             *
             * var dmsg1eg = recv.DecryptMessage( msg1eg.Garlic );
             * var dmsg2aes = recv.DecryptMessage( msg2aes.Garlic );
             *
             * Assert.IsTrue( origmessage.Payload == dmsg1eg.Cloves.First().Message.Payload );
             * Assert.IsTrue( origmessage.Payload == dmsg2aes.Cloves.First().Message.Payload );
             */
        }
示例#3
0
        public void TestBiggerEncodeDecode()
        {
            var recv    = new ReceivedSessions(Private);
            var session = new DestinationSessions((d, h, inf) => { }, () => null);

            var origdsmessage = new DeliveryStatusMessage(0x425c);
            var datamessage   = new DataMessage(new BufLen(BufUtils.Random(16000)));
            var origmessage1  = CreateDatabaseStoreMessage();
            var origmessage2  = CreateDatabaseStoreMessage();
            var origmessage3  = CreateDatabaseStoreMessage();
            var origmessage4  = CreateDatabaseStoreMessage();

            /*
             * var msg1eg = session.CreateMessage(
             *  Me,
             *  new GarlicCloveDeliveryTunnel(
             *      origmessage1,
             *      Destination.IdentHash,
             *      1234 ),
             *  new GarlicCloveDeliveryLocal(
             *      origmessage2 ),
             *  new GarlicCloveDeliveryRouter(
             *      origmessage3,
             *      Destination.IdentHash )
             *  );
             *
             * var msg2aes = session.CreateMessage(
             *  Me,
             *  new GarlicCloveDeliveryTunnel(
             *      origdsmessage,
             *      Destination.IdentHash,
             *      1234 ),
             *  new GarlicCloveDeliveryRouter(
             *      origmessage1,
             *      Destination.IdentHash ),
             *  new GarlicCloveDeliveryLocal(
             *      datamessage ),
             *  new GarlicCloveDeliveryTunnel(
             *      origmessage4,
             *      Destination.IdentHash,
             *      1234 ) );
             *
             * var dmsg1eg = recv.DecryptMessage( msg1eg.Garlic );
             * var dmsg2aes = recv.DecryptMessage( msg2aes.Garlic );
             *
             * Assert.IsTrue( dmsg1eg.Cloves.Count() == 3 );
             * Assert.IsTrue( dmsg2aes.Cloves.Count() == 4 );
             *
             * Assert.IsTrue( dmsg2aes.Cloves[0].Delivery.Delivery == GarlicCloveDelivery.DeliveryMethod.Tunnel );
             * Assert.IsTrue( dmsg2aes.Cloves[1].Delivery.Delivery == GarlicCloveDelivery.DeliveryMethod.Router );
             * Assert.IsTrue( dmsg2aes.Cloves[2].Delivery.Delivery == GarlicCloveDelivery.DeliveryMethod.Local );
             * Assert.IsTrue( dmsg2aes.Cloves[3].Delivery.Delivery == GarlicCloveDelivery.DeliveryMethod.Tunnel );
             *
             * Assert.IsTrue( dmsg1eg.Cloves.All( m => m.Message.MessageType == I2NPMessage.MessageTypes.DatabaseStore ) );
             * Assert.IsTrue( !dmsg2aes.Cloves.All( m => m.Message.MessageType == I2NPMessage.MessageTypes.DatabaseStore ) );
             *
             * Assert.IsTrue( dmsg2aes.Cloves.Where( m => m.Message.MessageType == I2NPMessage.MessageTypes.DeliveryStatus ).
             *  All( m => ( (DeliveryStatusMessage)m.Message ).MessageId == 0x425c ) );
             *
             * Assert.IsTrue( dmsg1eg.Cloves.Where( m => m.Message.MessageType == I2NPMessage.MessageTypes.DatabaseStore ).
             *  All( m => ( (DatabaseStoreMessage)m.Message ).RouterInfo.VerifySignature() ) );
             * Assert.IsTrue( dmsg2aes.Cloves.Where( m => m.Message.MessageType == I2NPMessage.MessageTypes.DatabaseStore ).
             *  All( m => ( (DatabaseStoreMessage)m.Message ).RouterInfo.VerifySignature() ) );
             * Assert.IsTrue( dmsg2aes.Cloves.Where( m => m.Message.MessageType == I2NPMessage.MessageTypes.Data ).
             *  All( m => ( (DataMessage)m.Message ).Payload == datamessage.Payload ) );
             */
        }