Changeset adf56a1


Ignore:
Timestamp:
Aug 17, 2005 8:16:27 PM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e7be8c6
Parents:
11204b8
git-author:
jrandom <jrandom> (08/17/05 20:16:27)
git-committer:
zzz <zzz@…> (08/17/05 20:16:27)
Message:

2005-08-17 jrandom

  • Revise the SSU peer testing protocol so that Bob verifies Charlie's viability before agreeing to Alice's request. This doesn't work with older SSU peer test builds, but is backwards compatible (older nodes won't ask newer nodes to participate in tests, and newer nodes won't ask older nodes to either).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    r11204b8 radf56a1  
    584584        return packet;
    585585    }
    586 
     586   
     587    /**
     588     * Build a packet as if we are Charlie sending Bob a packet verifying that we will help test Alice.
     589     *
     590     * @return ready to send packet, or null if there was a problem
     591     */
     592    public UDPPacket buildPeerTestToBob(InetAddress bobIP, int bobPort, InetAddress aliceIP, int alicePort, SessionKey aliceIntroKey, long nonce, SessionKey bobCipherKey, SessionKey bobMACKey) {
     593        UDPPacket packet = UDPPacket.acquire(_context);
     594        byte data[] = packet.getPacket().getData();
     595        Arrays.fill(data, 0, data.length, (byte)0x0);
     596        int off = UDPPacket.MAC_SIZE + UDPPacket.IV_SIZE;
     597       
     598        // header
     599        data[off] = PEER_TEST_FLAG_BYTE;
     600        off++;
     601        long now = _context.clock().now() / 1000;
     602        DataHelper.toLong(data, off, 4, now);
     603        if (_log.shouldLog(Log.DEBUG))
     604            _log.debug("Sending peer test " + nonce + " to Bob with time = " + new Date(now*1000));
     605        off += 4;
     606       
     607        // now for the body
     608        DataHelper.toLong(data, off, 4, nonce);
     609        off += 4;
     610        byte ip[] = aliceIP.getAddress();
     611        DataHelper.toLong(data, off, 1, ip.length);
     612        off++;
     613        System.arraycopy(ip, 0, data, off, ip.length);
     614        off += ip.length;
     615        DataHelper.toLong(data, off, 2, alicePort);
     616        off += 2;
     617        System.arraycopy(aliceIntroKey.getData(), 0, data, off, SessionKey.KEYSIZE_BYTES);
     618        off += SessionKey.KEYSIZE_BYTES;
     619       
     620        // we can pad here if we want, maybe randomized?
     621       
     622        // pad up so we're on the encryption boundary
     623        if ( (off % 16) != 0)
     624            off += 16 - (off % 16);
     625        packet.getPacket().setLength(off);
     626        authenticate(packet, bobCipherKey, bobMACKey);
     627        setTo(packet, bobIP, bobPort);
     628        return packet;
     629    }
     630   
    587631    private void setTo(UDPPacket packet, InetAddress ip, int port) {
    588632        packet.getPacket().setAddress(ip);
Note: See TracChangeset for help on using the changeset viewer.