Changeset 4eb9368 for core


Ignore:
Timestamp:
Jan 30, 2019 8:23:09 PM (22 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
68567cb
Parents:
c555bb6c
Message:

I2CP: Fixes for CreateLeaseset2 message with multiple keys

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

Legend:

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

    rc555bb6c r4eb9368  
    1010 */
    1111
     12import java.util.List;
    1213import java.util.Properties;
    1314import java.util.Set;
     
    364365     */
    365366    public void createLeaseSet(I2PSessionImpl session, LeaseSet leaseSet, SigningPrivateKey signingPriv,
    366                                PrivateKey priv) throws I2PSessionException {
     367                               List<PrivateKey> privs) throws I2PSessionException {
    367368        CreateLeaseSetMessage msg;
    368369        int type = leaseSet.getType();
    369         if (type == DatabaseEntry.KEY_TYPE_LEASESET)
     370        if (type == DatabaseEntry.KEY_TYPE_LEASESET) {
    370371            msg = new CreateLeaseSetMessage();
    371         else
    372             msg = new CreateLeaseSet2Message();
     372            msg.setPrivateKey(privs.get(0));
     373        } else {
     374            CreateLeaseSet2Message msg2 = new CreateLeaseSet2Message();
     375            for (PrivateKey priv : privs) {
     376                msg2.addPrivateKey(priv);
     377            }
     378            msg = msg2;
     379        }
    373380        msg.setLeaseSet(leaseSet);
    374         msg.setPrivateKey(priv);
    375381        msg.setSigningPrivateKey(signingPriv);
    376382        SessionId sid = session.getSessionId();
  • core/java/src/net/i2p/client/impl/RequestLeaseSetMessageHandler.java

    rc555bb6c r4eb9368  
    316316                spk = new SigningPrivateKey(dummy);
    317317            }
    318             session.getProducer().createLeaseSet(session, leaseSet, spk, li.getPrivateKey());
     318            session.getProducer().createLeaseSet(session, leaseSet, spk, li.getPrivateKeys());
    319319            session.setLeaseSet(leaseSet);
    320320            if (_log.shouldDebug())
  • core/java/src/net/i2p/data/i2cp/CreateLeaseSet2Message.java

    rc555bb6c r4eb9368  
    139139    @Override
    140140    protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
     141        int type = _leaseSet.getType();
    141142        if (_sessionId == null || _leaseSet == null ||
    142             (_leaseSet.getType() != DatabaseEntry.KEY_TYPE_META_LS2 && (_signingPrivateKey == null || _privateKey == null)))
     143            (type != DatabaseEntry.KEY_TYPE_META_LS2 && (_signingPrivateKey == null || _privateKey == null)))
    143144            throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    144145        int size = 4 // sessionId
     
    152153            os.write(_leaseSet.getType());
    153154            _leaseSet.writeBytes(os);
    154             if (_leaseSet.getType() != DatabaseEntry.KEY_TYPE_META_LS2) {
     155            if (type != DatabaseEntry.KEY_TYPE_META_LS2) {
    155156                _signingPrivateKey.writeBytes(os);
    156                 _privateKey.writeBytes(os);
     157                for (PrivateKey pk : getPrivateKeys()) {
     158                    pk.writeBytes(os);
     159                }
    157160            }
    158161        } catch (DataFormatException dfe) {
Note: See TracChangeset for help on using the changeset viewer.