Changeset c2bfb80 for core/java


Ignore:
Timestamp:
Jan 14, 2018 6:48:47 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
889b5ae
Parents:
8ef042a
Message:

Keyring: Separate local and remote dests on /configkeyring
Prohibit local changes on /configkeyring
Remove local keys from keyring on tunnel shutdown or encryption disable
Ensure subsession encryption setting matches primary session
(ticket #2108)

Location:
core/java/src/net/i2p/client/impl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/impl/I2PSessionImpl.java

    r8ef042a rc2bfb80  
    361361            } catch (I2PSessionException ise) {}
    362362        }
     363        // do we need this here? subsession.destroySession() calls primary
     364        Destination d = session.getMyDestination();
     365        if (d != null)
     366            _context.keyRing().remove(d.calculateHash());
    363367    }
    364368   
     
    12111215        if (_log.shouldLog(Log.INFO))
    12121216            _log.info(getPrefix() + "Closing the socket", new Exception("closeSocket"));
     1217        // maybe not the right place for this, but let's be sure
     1218        Destination d = _myDestination;
     1219        if (d != null)
     1220            _context.keyRing().remove(d.calculateHash());
    12131221        synchronized(_stateLock) {
    12141222            changeState(State.CLOSING);
     
    12181226        synchronized (_subsessionLock) {
    12191227            for (SubSession sess : _subsessions) {
     1228                d = sess.getMyDestination();
     1229                if (d != null)
     1230                    _context.keyRing().remove(d.calculateHash());
    12201231                sess.changeState(State.CLOSED);
    12211232                sess.setSessionId(null);
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    r8ef042a rc2bfb80  
    1313import java.security.GeneralSecurityException;
    1414import java.util.Map;
     15import java.util.Properties;
    1516import java.util.concurrent.ConcurrentHashMap;
    1617
     
    2223import net.i2p.data.DataHelper;
    2324import net.i2p.data.Destination;
     25import net.i2p.data.Hash;
    2426import net.i2p.data.Lease;
    2527import net.i2p.data.LeaseSet;
     
    159161        leaseSet.setEncryptionKey(li.getPublicKey());
    160162        leaseSet.setSigningKey(li.getSigningPublicKey());
    161         boolean encrypt = Boolean.parseBoolean(session.getOptions().getProperty("i2cp.encryptLeaseSet"));
    162         String sk = session.getOptions().getProperty("i2cp.leaseSetKey");
     163        // SubSession options aren't updated via the gui, so use the primary options
     164        Properties opts;
     165        if (session instanceof SubSession)
     166            opts = ((SubSession) session).getPrimaryOptions();
     167        else
     168            opts = session.getOptions();
     169        boolean encrypt = Boolean.parseBoolean(opts.getProperty("i2cp.encryptLeaseSet"));
     170        String sk = opts.getProperty("i2cp.leaseSetKey");
     171        Hash h = dest.calculateHash();
    163172        if (encrypt && sk != null) {
    164173            SessionKey key = new SessionKey();
     
    166175                key.fromBase64(sk);
    167176                leaseSet.encrypt(key);
    168                 _context.keyRing().put(session.getMyDestination().calculateHash(), key);
     177                _context.keyRing().put(h, key);
    169178            } catch (DataFormatException dfe) {
    170179                _log.error("Bad leaseset key: " + sk);
    171             }
     180                _context.keyRing().remove(h);
     181            }
     182        } else {
     183            _context.keyRing().remove(h);
    172184        }
    173185        try {
  • core/java/src/net/i2p/client/impl/SubSession.java

    r8ef042a rc2bfb80  
    8585    @Override
    8686    public void updateOptions(Properties options) {}
     87
     88    /**
     89     *  @since 0.9.33
     90     */
     91    public Properties getPrimaryOptions() {
     92        return _primary.getOptions();
     93    }
    8794
    8895    /**
Note: See TracChangeset for help on using the changeset viewer.