From 591b994b754912b0dae9b701512da778e02d8843 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sun, 27 Oct 2019 12:21:22 +0000 Subject: [PATCH] OCMOSJ: Bundle unwrapped ack with LS for ratchet dest --- .../OutboundClientMessageJobHelper.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java b/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java index 544576f35c..57de2924d5 100644 --- a/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java +++ b/router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java @@ -27,6 +27,7 @@ import net.i2p.data.i2np.DeliveryInstructions; import net.i2p.data.i2np.DeliveryStatusMessage; import net.i2p.data.i2np.GarlicMessage; import net.i2p.data.i2np.I2NPMessage; +import net.i2p.router.LeaseSetKeys; import net.i2p.router.RouterContext; import net.i2p.router.TunnelInfo; import net.i2p.router.networkdb.kademlia.MessageWrapper; @@ -156,8 +157,8 @@ class OutboundClientMessageJobHelper { ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), expiration, DeliveryInstructions.LOCAL); - // for now, skip this for ratchet - if (requireAck && recipientPK.getType() == EncType.ELGAMAL_2048) { + // for now, skip this for ratchet if there's no LS to bundle + if (requireAck && (bundledReplyLeaseSet != null || recipientPK.getType() == EncType.ELGAMAL_2048)) { // extend the expiration of the return message PayloadGarlicConfig ackClove = buildAckClove(ctx, from, replyTunnel, replyToken, expiration + ACK_EXTRA_EXPIRATION, skm); @@ -219,11 +220,18 @@ class OutboundClientMessageJobHelper { //ackInstructions.setEncrypted(false); DeliveryStatusMessage dsm = buildDSM(ctx, replyToken); - GarlicMessage msg = wrapDSM(ctx, skm, dsm); - if (msg == null) { - if (log.shouldLog(Log.WARN)) - log.warn("Failed to wrap ack clove"); - return null; + // wrap the DSM if we can + LeaseSetKeys lsk = ctx.keyManager().getKeys(from); + I2NPMessage msg; + if (lsk == null || lsk.isSupported(EncType.ELGAMAL_2048)) { + msg = wrapDSM(ctx, skm, dsm); + if (msg == null) { + if (log.shouldLog(Log.WARN)) + log.warn("Failed to wrap ack clove"); + return null; + } + } else { + msg = dsm; } PayloadGarlicConfig ackClove = new PayloadGarlicConfig(Certificate.NULL_CERT, ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE), -- GitLab