From 9fafc253b76952bd8b4a19fa5e1c099d0e17491d Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Thu, 21 Feb 2019 14:58:58 +0000 Subject: [PATCH] Data: Always set unpublished flag for inner LS (Enc LS2) Fix setDestination() --- .../java/src/net/i2p/data/EncryptedLeaseSet.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/java/src/net/i2p/data/EncryptedLeaseSet.java b/core/java/src/net/i2p/data/EncryptedLeaseSet.java index 0d70b9010e..6e782f64db 100644 --- a/core/java/src/net/i2p/data/EncryptedLeaseSet.java +++ b/core/java/src/net/i2p/data/EncryptedLeaseSet.java @@ -88,7 +88,12 @@ public class EncryptedLeaseSet extends LeaseSet2 { */ @Override public void setDestination(Destination dest) { - super.setDestination(dest); + if (_signature != null && _destination != null) { + if (!dest.equals(_destination)) + throw new IllegalStateException(); + } else { + _destination = dest; + } SigningPublicKey spk = dest.getSigningPublicKey(); SigType type = spk.getType(); if (type != SigType.EdDSA_SHA512_Ed25519 && @@ -295,6 +300,9 @@ public class EncryptedLeaseSet extends LeaseSet2 { if (_signature == null) throw new IllegalStateException("not signed"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // inner LS is always unpublished + int saveFlags = _flags; + setUnpublished(); try { // Inner layer - type - data covered by sig baos.write(KEY_TYPE_LS2); @@ -305,6 +313,8 @@ public class EncryptedLeaseSet extends LeaseSet2 { throw new IllegalStateException("Error encrypting LS2", dfe); } catch (IOException ioe) { throw new IllegalStateException("Error encrypting LS2", ioe); + } finally { + _flags = saveFlags; } I2PAppContext ctx = I2PAppContext.getGlobalContext(); @@ -453,7 +463,11 @@ public class EncryptedLeaseSet extends LeaseSet2 { public void sign(SigningPrivateKey key) throws DataFormatException { Log log = I2PAppContext.getGlobalContext().logManager().getLog(EncryptedLeaseSet.class); // now sign inner with the unblinded key + // inner LS is always unpublished + int saveFlags = _flags; + setUnpublished(); super.sign(key); + _flags = saveFlags; if (log.shouldDebug()) { log.debug("Sign inner with key: " + key.getType() + ' ' + key.toBase64()); log.debug("Corresponding pubkey: " + key.toPublic().toBase64()); -- GitLab