Changeset 3f3d43d


Ignore:
Timestamp:
Aug 22, 2009 10:55:37 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
7e54774
Parents:
faeb58f7
Message:
  • Streaming, I2PSession: Prep for SessionKeyManager? work in the router - Comment out, deprecate, and javadoc for unused keys and tags, they are vestiges of end-to-end crypto
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • apps/ministreaming/java/src/net/i2p/client/streaming/package.html

    rfaeb58f7 r3f3d43d  
    1717appropriate {@link net.i2p.client.streaming.I2PSocketManager#connect} call.</p>
    1818
    19 <p>There is a simple pair of demo applications available as well - {@link
    20 net.i2p.client.streaming.StreamSinkServer} listens to a destination and dumps
    21 the data from all sockets it accepts to individual files, while {@link
    22 net.i2p.client.streaming.StreamSinkClient} connects to a particular destination
     19<p>There is a simple pair of demo applications available as well -
     20net.i2p.client.streaming.StreamSinkServer listens to a destination and dumps
     21the data from all sockets it accepts to individual files, while
     22net.i2p.client.streaming.StreamSinkClient connects to a particular destination
    2323and sends a specific amount of random data then disconnects.</p>
    2424</body></html>
  • apps/streaming/java/src/net/i2p/client/streaming/Connection.java

    rfaeb58f7 r3f3d43d  
    355355    }
    356356   
     357/*********
    357358    private class PingNotifier implements ConnectionManager.PingNotifier {
    358359        private long _startedPingOn;
     
    368369        }
    369370    }
     371*********/
    370372   
    371373    List ackPackets(long ackThrough, long nacks[]) {
     
    549551    }
    550552   
     553    /** ignore tag issues */
    551554    private void killOutstandingPackets() {
    552         boolean tagsCancelled = false;
     555        //boolean tagsCancelled = false;
    553556        synchronized (_outboundPackets) {
    554557            for (Iterator iter = _outboundPackets.values().iterator(); iter.hasNext(); ) {
    555558                PacketLocal pl = (PacketLocal)iter.next();
    556                 if ( (pl.getTagsSent() != null) && (pl.getTagsSent().size() > 0) )
    557                     tagsCancelled = true;
     559                //if ( (pl.getTagsSent() != null) && (pl.getTagsSent().size() > 0) )
     560                //    tagsCancelled = true;
    558561                pl.cancelled();
    559562            }
     
    561564            _outboundPackets.notifyAll();
    562565        }           
    563         if (tagsCancelled)
    564             _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
     566        //if (tagsCancelled)
     567        //    _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
    565568    }
    566569   
     
    11411144                // in case things really suck, the other side may have lost thier
    11421145                // session tags (e.g. they restarted), so jump back to ElGamal.
    1143                 int failTagsAt = _options.getMaxResends() - 2;
    1144                 if ( (newWindowSize == 1) && (numSends == failTagsAt) ) {
    1145                     if (_log.shouldLog(Log.WARN))
    1146                         _log.warn("Optimistically failing tags at resend " + numSends);
    1147                     _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
    1148                 }
     1146                //int failTagsAt = _options.getMaxResends() - 2;
     1147                //if ( (newWindowSize == 1) && (numSends == failTagsAt) ) {
     1148                //    if (_log.shouldLog(Log.WARN))
     1149                //        _log.warn("Optimistically failing tags at resend " + numSends);
     1150                //    _context.sessionKeyManager().failTags(_remotePeer.getPublicKey());
     1151                //}
    11491152               
    11501153                if (numSends - 1 > _options.getMaxResends()) {
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionManager.java

    rfaeb58f7 r3f3d43d  
    350350        }
    351351    }
     352
     353    /** blocking */
    352354    public boolean ping(Destination peer, long timeoutMs) {
    353         return ping(peer, timeoutMs, true);
     355        return ping(peer, timeoutMs, true, null);
    354356    }
    355357    public boolean ping(Destination peer, long timeoutMs, boolean blocking) {
    356         return ping(peer, timeoutMs, blocking, null, null, null);
    357     }
    358 
     358        return ping(peer, timeoutMs, blocking, null);
     359    }
     360
     361    /**
     362     * @deprecated I2PSession ignores tags, use non-tag variant
     363     * @param keyToUse ignored
     364     * @param tagsToSend ignored
     365     */
    359366    public boolean ping(Destination peer, long timeoutMs, boolean blocking, SessionKey keyToUse, Set tagsToSend, PingNotifier notifier) {
     367        return ping(peer, timeoutMs, blocking, notifier);
     368    }
     369
     370    public boolean ping(Destination peer, long timeoutMs, boolean blocking, PingNotifier notifier) {
    360371        Long id = new Long(_context.random().nextLong(Packet.MAX_STREAM_ID-1)+1);
    361372        PacketLocal packet = new PacketLocal(_context, peer);
     
    364375        packet.setFlag(Packet.FLAG_SIGNATURE_INCLUDED);
    365376        packet.setOptionalFrom(_session.getMyDestination());
    366         if ( (keyToUse != null) && (tagsToSend != null) ) {
    367             packet.setKeyUsed(keyToUse);
    368             packet.setTagsSent(tagsToSend);
    369         }
     377        //if ( (keyToUse != null) && (tagsToSend != null) ) {
     378        //    packet.setKeyUsed(keyToUse);
     379        //    packet.setTagsSent(tagsToSend);
     380        //}
    370381       
    371382        PingRequest req = new PingRequest(peer, packet, notifier);
     
    436447        public void pong() {
    437448            _log.debug("Ping successful");
    438             _context.sessionKeyManager().tagsDelivered(_peer.getPublicKey(), _packet.getKeyUsed(), _packet.getTagsSent());
     449            //_context.sessionKeyManager().tagsDelivered(_peer.getPublicKey(), _packet.getKeyUsed(), _packet.getTagsSent());
    439450            synchronized (ConnectionManager.PingRequest.this) {
    440451                _ponged = true;
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionPacketHandler.java

    rfaeb58f7 r3f3d43d  
    264264               
    265265                // ACK the tags we delivered so we can use them
    266                 if ( (p.getKeyUsed() != null) && (p.getTagsSent() != null)
    267                       && (p.getTagsSent().size() > 0) ) {
    268                     _context.sessionKeyManager().tagsDelivered(p.getTo().getPublicKey(),
    269                                                                p.getKeyUsed(),
    270                                                                p.getTagsSent());
    271                 }
     266                //if ( (p.getKeyUsed() != null) && (p.getTagsSent() != null)
     267                //      && (p.getTagsSent().size() > 0) ) {
     268                //    _context.sessionKeyManager().tagsDelivered(p.getTo().getPublicKey(),
     269                //                                               p.getKeyUsed(),
     270                //                                               p.getTagsSent());
     271                //}
    272272                if (_log.shouldLog(Log.DEBUG))
    273273                    _log.debug("Packet acked after " + p.getAckTime() + "ms: " + p);
  • apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java

    rfaeb58f7 r3f3d43d  
    4848    public void setTo(Destination to) { _to = to; }
    4949   
     50    /**
     51     * @deprecated should always return null
     52     */
    5053    public SessionKey getKeyUsed() { return _keyUsed; }
    51     public void setKeyUsed(SessionKey key) { _keyUsed = key; }
    52    
     54
     55    /**
     56     * @deprecated I2PSession throws out the tags
     57     */
     58    public void setKeyUsed(SessionKey key) {
     59        if (key != null)
     60            _log.error("Who is sending tags thru the streaming lib?");
     61        _keyUsed = key;
     62    }
     63   
     64    /**
     65     * @deprecated should always return null or an empty set
     66     */
    5367    public Set getTagsSent() { return _tagsSent; }
     68
     69    /**
     70     * @deprecated I2PSession throws out the tags
     71     */
    5472    public void setTagsSent(Set tags) {
     73        if (tags != null && tags.size() > 0)
     74            _log.error("Who is sending tags thru the streaming lib? " + tags.size());
    5575        if ( (_tagsSent != null) && (_tagsSent.size() > 0) && (tags.size() > 0) ) {
    5676            //int old = _tagsSent.size();
  • apps/streaming/java/src/net/i2p/client/streaming/PacketQueue.java

    rfaeb58f7 r3f3d43d  
    3737    /**
    3838     * Add a new packet to be sent out ASAP
     39     *
     40     * keys and tags disabled since dropped in I2PSession
    3941     */
    4042    public void enqueue(PacketLocal packet) {
    4143        packet.prepare();
    4244       
    43         SessionKey keyUsed = packet.getKeyUsed();
    44         if (keyUsed == null)
    45             keyUsed = new SessionKey();
    46         Set tagsSent = packet.getTagsSent();
    47         if (tagsSent == null)
    48             tagsSent = new HashSet(0);
     45        //SessionKey keyUsed = packet.getKeyUsed();
     46        //if (keyUsed == null)
     47        //    keyUsed = new SessionKey();
     48        //Set tagsSent = packet.getTagsSent();
     49        //if (tagsSent == null)
     50        //    tagsSent = new HashSet(0);
    4951
    5052        // cache this from before sendMessage
     
    9395                //sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent, expires);
    9496                // I2PSessionMuxedImpl
    95                 sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent, expires,
     97                //sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent, expires,
     98                //                 I2PSession.PROTO_STREAMING, I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
     99                // I2PSessionMuxedImpl no tags
     100                sent = _session.sendMessage(packet.getTo(), buf, 0, size, null, null, expires,
    96101                                 I2PSession.PROTO_STREAMING, I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
    97102            else
     
    99104                //sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent, 0);
    100105                // I2PSessionMuxedImpl
    101                 sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent,
     106                //sent = _session.sendMessage(packet.getTo(), buf, 0, size, keyUsed, tagsSent,
     107                //                 I2PSession.PROTO_STREAMING, I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
     108                // I2PSessionMuxedImpl no tags
     109                sent = _session.sendMessage(packet.getTo(), buf, 0, size, null, null,
    102110                                 I2PSession.PROTO_STREAMING, I2PSession.PORT_UNSPECIFIED, I2PSession.PORT_UNSPECIFIED);
    103111            end = _context.clock().now();
     
    130138                c.disconnect(false);
    131139        } else {
    132             packet.setKeyUsed(keyUsed);
    133             packet.setTagsSent(tagsSent);
     140            //packet.setKeyUsed(keyUsed);
     141            //packet.setTagsSent(tagsSent);
    134142            packet.incrementSends();
    135143            if (_log.shouldLog(Log.DEBUG)) {
    136                 String msg = "SEND " + packet + (tagsSent.size() > 0
    137                              ? " with " + tagsSent.size() + " tags"
    138                              : "")
     144                String msg = "SEND " + packet
    139145                             + " send # " + packet.getNumSends()
    140146                             + " sendTime: " + (end-begin)
  • core/java/src/net/i2p/client/I2CPMessageProducer.java

    rfaeb58f7 r3f3d43d  
    9494     * Package up and send the payload to the router for delivery
    9595     *
     96     * @param tag unused - no end-to-end crypto
     97     * @param tags unused - no end-to-end crypto
     98     * @param key unused - no end-to-end crypto
     99     * @param newKey unused - no end-to-end crypto
    96100     */
    97101    public void sendMessage(I2PSessionImpl session, Destination dest, long nonce, byte[] payload, SessionTag tag,
     
    136140     * Create a new signed payload and send it off to the destination
    137141     *
     142     * @param tag unused - no end-to-end crypto
     143     * @param tags unused - no end-to-end crypto
     144     * @param key unused - no end-to-end crypto
     145     * @param newKey unused - no end-to-end crypto
    138146     */
    139147    private Payload createPayload(Destination dest, byte[] payload, SessionTag tag, SessionKey key, Set tags,
  • core/java/src/net/i2p/client/I2PSessionImpl.java

    rfaeb58f7 r3f3d43d  
    356356    public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
    357357   
     358    /**
     359     * @param keyUsed unused - no end-to-end crypto
     360     * @param tagsSent unused - no end-to-end crypto
     361     */
    358362    public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
    359363                                        Set tagsSent) throws I2PSessionException;
     
    361365    public abstract void receiveStatus(int msgId, long nonce, int status);
    362366
     367/****** no end-to-end crypto
    363368    protected static final Set createNewTags(int num) {
    364369        Set tags = new HashSet();
     
    367372        return tags;
    368373    }
     374*******/
    369375
    370376    /**
  • core/java/src/net/i2p/client/I2PSessionImpl2.java

    rfaeb58f7 r3f3d43d  
    134134    }
    135135   
     136    /**
     137     * @param keyUsed unused - no end-to-end crypto
     138     * @param tagsSent unused - no end-to-end crypto
     139     */
    136140    @Override
    137141    public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException {
    138142        return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent, 0);
    139143    }
     144
     145    /**
     146     * @param keyUsed unused - no end-to-end crypto
     147     * @param tagsSent unused - no end-to-end crypto
     148     */
    140149    public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent)
    141150                   throws I2PSessionException {
    142151        return sendMessage(dest, payload, offset, size, keyUsed, tagsSent, 0);
    143152    }
     153
     154    /**
     155     * @param keyUsed unused - no end-to-end crypto
     156     * @param tagsSent unused - no end-to-end crypto
     157     */
    144158    public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent, long expires)
    145159                   throws I2PSessionException {
     
    197211    private static final int NUM_TAGS = 50;
    198212
     213    /**
     214     * @param keyUsed unused - no end-to-end crypto
     215     * @param tagsSent unused - no end-to-end crypto
     216     */
    199217    protected boolean sendBestEffort(Destination dest, byte payload[], SessionKey keyUsed, Set tagsSent, long expires)
    200218                    throws I2PSessionException {
    201         SessionKey key = null;
    202         SessionKey newKey = null;
    203         SessionTag tag = null;
    204         Set sentTags = null;
    205         int oldTags = 0;
     219        //SessionKey key = null;
     220        //SessionKey newKey = null;
     221        //SessionTag tag = null;
     222        //Set sentTags = null;
     223        //int oldTags = 0;
    206224        long begin = _context.clock().now();
    207225        /***********
     
    257275        if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
    258276        MessageState state = new MessageState(_context, nonce, getPrefix());
    259         state.setKey(key);
    260         state.setTags(sentTags);
    261         state.setNewKey(newKey);
     277        //state.setKey(key);
     278        //state.setTags(sentTags);
     279        //state.setNewKey(newKey);
    262280        state.setTo(dest);
    263         if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key);
    264 
    265         if (keyUsed != null) {
     281        //if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Setting key = " + key);
     282
     283        //if (keyUsed != null) {
    266284            //if (I2CPMessageProducer.END_TO_END_CRYPTO) {
    267285            //    if (newKey != null)
     
    270288            //        keyUsed.setData(key.getData());
    271289            //} else {
    272                 keyUsed.setData(SessionKey.INVALID_KEY.getData());
     290            //    keyUsed.setData(SessionKey.INVALID_KEY.getData());
    273291            //}
    274         }
    275         if (tagsSent != null) {
    276             if (sentTags != null) {
    277                 tagsSent.addAll(sentTags);
    278             }
    279         }
     292        //}
     293        //if (tagsSent != null) {
     294        //    if (sentTags != null) {
     295        //        tagsSent.addAll(sentTags);
     296        //    }
     297        //}
    280298
    281299        if (_log.shouldLog(Log.DEBUG)) _log.debug("before sync state");
     
    292310                       + " sync took " + (inSendingSync-beforeSendingSync)
    293311                       + " add took " + (afterSendingSync-inSendingSync));
    294         _producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey, expires);
     312        //_producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey, expires);
     313        _producer.sendMessage(this, dest, nonce, payload, null, null, null, null, expires);
    295314       
    296315        // since this is 'best effort', all we're waiting for is a status update
  • core/java/src/net/i2p/client/I2PSessionMuxedImpl.java

    rfaeb58f7 r3f3d43d  
    129129    }
    130130
     131    /**
     132     * @param keyUsed unused - no end-to-end crypto
     133     * @param tagsSent unused - no end-to-end crypto
     134     */
    131135    @Override
    132136    public boolean sendMessage(Destination dest, byte[] payload, int offset, int size,
     
    136140    }
    137141
     142    /**
     143     * @param keyUsed unused - no end-to-end crypto
     144     * @param tagsSent unused - no end-to-end crypto
     145     */
    138146    @Override
    139147    public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent,
     
    143151
    144152    /**
     153     *  @param keyUsed unused - no end-to-end crypto
     154     *  @param tagsSent unused - no end-to-end crypto
    145155     *  @param proto 1-254 or 0 for unset; recommended:
    146156     *         I2PSession.PROTO_UNSPECIFIED
  • core/java/src/net/i2p/crypto/HMAC256Generator.java

    rfaeb58f7 r3f3d43d  
    1313/**
    1414 * Calculate the HMAC-SHA256 of a key+message.  All the good stuff occurs
    15  * in {@link org.bouncycastle.crypto.macs.HMac} and
     15 * in {@link org.bouncycastle.crypto.macs.I2PHMac} and
    1616 * {@link org.bouncycastle.crypto.digests.MD5Digest}.
    1717 *
  • core/java/src/net/i2p/crypto/HMACGenerator.java

    rfaeb58f7 r3f3d43d  
    1616/**
    1717 * Calculate the HMAC-MD5 of a key+message.  All the good stuff occurs
    18  * in {@link org.bouncycastle.crypto.macs.HMac} and
     18 * in {@link org.bouncycastle.crypto.macs.I2PHMac} and
    1919 * {@link org.bouncycastle.crypto.digests.MD5Digest}.
    2020 *
Note: See TracChangeset for help on using the changeset viewer.