Changeset 7d11fb26 for core/java


Ignore:
Timestamp:
Feb 3, 2019 12:59:53 PM (18 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
0e710f87
Parents:
d7808cd
Message:

I2CP: Remove revocation private key from CreateLeaseset2 message
Use correct key to sign SessionConfig? with offline keys
LeaseSetKeys? cleanups

Location:
core/java/src/net/i2p
Files:
5 edited

Legend:

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

    rd7808cd r7d11fb26  
    363363     * the caller does that.
    364364     *
     365     * @param signingPriv ignored for LS2
    365366     */
    366367    public void createLeaseSet(I2PSessionImpl session, LeaseSet leaseSet, SigningPrivateKey signingPriv,
     
    371372            msg = new CreateLeaseSetMessage();
    372373            msg.setPrivateKey(privs.get(0));
     374            msg.setSigningPrivateKey(signingPriv);
    373375        } else {
    374376            CreateLeaseSet2Message msg2 = new CreateLeaseSet2Message();
     
    379381        }
    380382        msg.setLeaseSet(leaseSet);
    381         msg.setSigningPrivateKey(signingPriv);
    382383        SessionId sid = session.getSessionId();
    383384        if (sid == null) {
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    rd7808cd r7d11fb26  
    305305        try {
    306306            leaseSet.sign(session.getPrivateKey());
    307             // Workaround for unparsable serialized signing private key for revocation
    308             // Send him a dummy DSA_SHA1 private key since it's unused anyway
    309             // See CreateLeaseSetMessage.doReadMessage()
    310             // For LS1 only
    311307            SigningPrivateKey spk = li.getSigningPrivateKey();
    312             if (!_context.isRouterContext() && spk.getType() != SigType.DSA_SHA1 &&
    313                 !(leaseSet instanceof LeaseSet2)) {
     308            if (isLS2) {
     309                // no revocation key in LS2
     310                spk = null;
     311            } else if (!_context.isRouterContext() && spk.getType() != SigType.DSA_SHA1) {
     312                // Workaround for unparsable serialized signing private key for revocation
     313                // Send him a dummy DSA_SHA1 private key since it's unused anyway
     314                // See CreateLeaseSetMessage.doReadMessage()
     315                // For LS1 only
    314316                byte[] dummy = new byte[SigningPrivateKey.KEYSIZE_BYTES];
    315317                _context.random().nextBytes(dummy);
    316318                spk = new SigningPrivateKey(dummy);
     319                if (_log.shouldDebug())
     320                    _log.debug("Generated random dummy SPK " + spk);
    317321            }
    318322            session.getProducer().createLeaseSet(session, leaseSet, spk, li.getPrivateKeys());
  • core/java/src/net/i2p/data/i2cp/CreateLeaseSet2Message.java

    rd7808cd r7d11fb26  
    1919import net.i2p.data.PrivateKey;
    2020import net.i2p.data.PublicKey;
    21 import net.i2p.data.SigningPrivateKey;
    2221
    2322/**
    2423 * Like CreateLeaseSetMessage, but supports both old
    2524 * and new LeaseSet types, including LS2, Meta, and Encrypted.
     25 * Revocation keys are not present.
     26 * Multiple public/private encryption keys are possible.
    2627 *
    2728 * For LS2:
    2829 * Same as CreateLeaseSetMessage, but has a netdb type before
    29  * the LeaseSet. SigningPrivateKey and PrivateKey(s) are
     30 * the LeaseSet. PrivateKeys are
    3031 * serialized after the LeaseSet, not before, so we can
    3132 * infer the types from the LeaseSet.
    3233 *
    3334 * For Meta LS:
    34  * SigningPrivateKey and PrivateKey are not present.
     35 * PrivateKeys are not present.
    3536 *
    3637 * For Encrypted LS:
     
    106107                if (stype == null)
    107108                    throw new I2CPMessageException("Unsupported sig type");
    108                 _signingPrivateKey = new SigningPrivateKey(stype);
    109                 _signingPrivateKey.readBytes(in);
    110109                if (type == DatabaseEntry.KEY_TYPE_LS2 ||
    111110                    type == DatabaseEntry.KEY_TYPE_ENCRYPTED_LS2) {
     
    141140        int type = _leaseSet.getType();
    142141        if (_sessionId == null || _leaseSet == null ||
    143             (type != DatabaseEntry.KEY_TYPE_META_LS2 && (_signingPrivateKey == null || _privateKey == null)))
     142            (type != DatabaseEntry.KEY_TYPE_META_LS2 && _privateKey == null))
    144143            throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    145144        int size = 4 // sessionId
    146145                 + 1 // type
    147                  + _leaseSet.size()
    148                  + _signingPrivateKey.length()
    149                  + _privateKey.length();
     146                 + _leaseSet.size();
     147        if (type != DatabaseEntry.KEY_TYPE_META_LS2) {
     148            for (PrivateKey pk : getPrivateKeys()) {
     149                size += pk.length();
     150            }
     151        }
    150152        ByteArrayOutputStream os = new ByteArrayOutputStream(size);
    151153        try {
     
    154156            _leaseSet.writeBytes(os);
    155157            if (type != DatabaseEntry.KEY_TYPE_META_LS2) {
    156                 _signingPrivateKey.writeBytes(os);
    157158                for (PrivateKey pk : getPrivateKeys()) {
    158159                    pk.writeBytes(os);
     
    174175        StringBuilder buf = new StringBuilder();
    175176        buf.append("[CreateLeaseSet2Message: ");
    176         buf.append("\n\tLeaseSet: ").append(getLeaseSet());
    177         buf.append("\n\tSigningPrivateKey: ").append(getSigningPrivateKey());
    178         buf.append("\n\tPrivateKey: ").append(getPrivateKey());
     177        buf.append("\n\tLeaseSet: ").append(_leaseSet);
     178        if (_leaseSet.getType() != DatabaseEntry.KEY_TYPE_META_LS2) {
     179            for (PrivateKey pk : getPrivateKeys()) {
     180                buf.append("\n\tPrivateKey: ").append(pk);
     181            }
     182        }
    179183        buf.append("\n\tSessionId: ").append(getSessionId());
    180184        buf.append("]");
  • core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java

    rd7808cd r7d11fb26  
    2929    protected SessionId _sessionId;
    3030    protected LeaseSet _leaseSet;
    31     protected SigningPrivateKey _signingPrivateKey;
     31    private SigningPrivateKey _signingPrivateKey;
    3232    protected PrivateKey _privateKey;
    3333
  • core/java/src/net/i2p/data/i2cp/SessionConfig.java

    rd7808cd r7d11fb26  
    347347        _options = DataHelper.readProperties(rawConfig);
    348348        _creationDate = DataHelper.readDate(rawConfig);
    349         _signature = new Signature(_destination.getSigningPublicKey().getType());
     349        SigningPublicKey spk = getTransientSigningPublicKey();
     350        if (spk == null)
     351            spk = _destination.getSigningPublicKey();
     352        _signature = new Signature(spk.getType());
    350353        _signature.readBytes(rawConfig);
    351354    }
Note: See TracChangeset for help on using the changeset viewer.