Changeset 3cd12ec for router


Ignore:
Timestamp:
Jan 27, 2019 3:59:34 PM (17 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3fca0f6
Parents:
0889a75
Message:

LS2: Select first supported encryption key from leaseset
OCMOSJ: Fail if unsupported crypto or bad ls type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java

    r0889a75 r3cd12ec  
    99
    1010import net.i2p.client.SendMessageOptions;
     11import net.i2p.crypto.EncType;
    1112import net.i2p.crypto.SessionKeyManager;
    1213import net.i2p.crypto.TagSetHandle;
     
    312313        }
    313314    }
    314    
     315
    315316    /**
    316317     *  @param force to force including a reply lease set
     
    375376     *  Choose a lease from his leaseset to send the message to. Sets _lease.
    376377     *  Sets _wantACK if it's new or changed.
     378     *  Does several checks to see if we can actually send to this leaseset,
     379     *  and returns nonzero failure code if unable to.
     380     *
    377381     *  @return 0 on success, or a MessageStatusMessage failure code
    378382     */
     
    388392            }
    389393        }
    390         if (_leaseSet.getType() == DatabaseEntry.KEY_TYPE_META_LS2) {
    391             // can't send to a meta LS
     394
     395        int lsType = _leaseSet.getType();
     396        // Can't send to a meta LS.
     397        // TODO Encrypted LS2 must have been previously decrypted.
     398        if (lsType != DatabaseEntry.KEY_TYPE_LEASESET &&
     399            lsType != DatabaseEntry.KEY_TYPE_LS2) {
    392400            return MessageStatusMessage.STATUS_SEND_FAILURE_BAD_LEASESET;
    393401        }
     402        PublicKey pk = _leaseSet.getEncryptionKey();
     403        if (pk == null)
     404            return MessageStatusMessage.STATUS_SEND_FAILURE_BAD_LEASESET;
     405        EncType encType = pk.getType();
     406        if (encType == null || !encType.isAvailable())
     407            return MessageStatusMessage.STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION;
    394408
    395409        // Use the same lease if it's still good
Note: See TracChangeset for help on using the changeset viewer.