Esempio n. 1
0
 public I2PSessionConfig(I2PDestination dest, I2PMapping map, I2PDate date, I2PSigningPrivateKey privsignkey)
 {
     Destination       = dest;
     Map               = map != null ? map : new I2PMapping();
     Date              = date != null ? date : new I2PDate(DateTime.Now);
     PrivateSigningKey = privsignkey;
 }
Esempio n. 2
0
 public I2PRouterAddress(BufRef buf)
 {
     Cost           = buf.Read8();
     Expiration     = new I2PDate(buf);
     TransportStyle = new I2PString(buf);
     Options        = new I2PMapping(buf);
 }
Esempio n. 3
0
        public I2PRouterInfo(BufRef reader, bool verifysig)
        {
            var startview = new BufRef(reader);

            Identity      = new I2PRouterIdentity(reader);
            PublishedDate = new I2PDate(reader);

            int addrcount = reader.Read8();
            var addresses = new List <I2PRouterAddress>();

            for (int i = 0; i < addrcount; ++i)
            {
                addresses.Add(new I2PRouterAddress(reader));
            }
            Adresses = addresses.ToArray();

            reader.Seek(reader.Read8() * 32);   // peer_size. Unused.

            Options = new I2PMapping(reader);
            var payloadend = new BufRef(reader);

            Data      = new BufLen(startview, 0, reader - startview);
            Signature = new I2PSignature(reader, Identity.Certificate);

            if (verifysig)
            {
                var versig = VerifySignature();
                if (!versig)
                {
                    throw new InvalidOperationException("I2PRouterInfo signature check failed");
                }
            }
        }
Esempio n. 4
0
        public I2PRouterInfo(
            I2PRouterIdentity identity,
            I2PDate publisheddate,
            I2PRouterAddress[] adresses,
            I2PMapping options,
            I2PSigningPrivateKey privskey)
        {
            Identity      = identity;
            PublishedDate = publisheddate;
            Adresses      = adresses;
            Options       = options;

            var dest = new List <byte>();

            Identity.Write(dest);
            PublishedDate.Write(dest);
            dest.Add((byte)Adresses.Length);
            foreach (var addr in Adresses)
            {
                addr.Write(dest);
            }
            dest.Add(0);   // Always zero
            Options.Write(dest);
            Data = new BufLen(dest.ToArray());

            Signature = new I2PSignature(new BufRefLen(I2PSignature.DoSign(privskey, Data)), privskey.Certificate);
        }
Esempio n. 5
0
        public I2PRouterAddress(IPAddress addr, int port, byte cost, string transportstyle)
        {
            Cost           = cost;
            Expiration     = I2PDate.Zero;
            TransportStyle = new I2PString(transportstyle);
            Options        = new I2PMapping();

            Options["host"] = addr.ToString();
            Options["port"] = port.ToString();
        }
Esempio n. 6
0
        public I2PSessionConfig(BufRef reader)
        {
            var start = new BufRefLen(reader);

            Destination = new I2PDestination(reader);
            Options     = new I2PMapping(reader);
            Date        = new I2PDate(reader);

            SignedBuf = new BufLen(start, 0, reader - start);

            Signature = new I2PSignature(reader, Destination.Certificate);
        }