From 8fb7bd264fa308fa3d7a9bae9a8f1813488bfb5c Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 2 Aug 2018 11:48:55 +0000
Subject: [PATCH] NTCP2: Remove debug code

---
 .../noise/protocol/ChaChaPolyCipherState.java | 22 -------------------
 .../noise/protocol/CipherState.java           |  5 -----
 .../transport/ntcp/InboundEstablishState.java |  5 -----
 .../transport/ntcp/OutboundNTCP2State.java    |  5 -----
 4 files changed, 37 deletions(-)

diff --git a/router/java/src/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java b/router/java/src/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java
index 6d50e1de42..20a239d157 100644
--- a/router/java/src/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java
+++ b/router/java/src/com/southernstorm/noise/protocol/ChaChaPolyCipherState.java
@@ -41,8 +41,6 @@ public class ChaChaPolyCipherState implements CipherState {
 	private final byte[] polyKey;
 	private long n;
 	private boolean haskey;
-	// I2P debug to be removed
-	private byte[] initialKey;
 	
 	/**
 	 * Constructs a new cipher state for the "ChaChaPoly" algorithm.
@@ -82,9 +80,6 @@ public class ChaChaPolyCipherState implements CipherState {
 
 	@Override
 	public void initializeKey(byte[] key, int offset) {
-		// I2P debug to be removed
-		initialKey = new byte[32];
-		System.arraycopy(key, 0, initialKey, 0, 32);
 		ChaChaCore.initKey256(input, key, offset);
 		n = 0;
 		haskey = true;
@@ -293,16 +288,6 @@ public class ChaChaPolyCipherState implements CipherState {
 		n = nonce;
 	}
 
-	/**
-	 *  I2P debug to be removed
-	 *  @return null if none yet
-	 */
-	public byte[] getKey() {
-		if (!haskey)
-			return null;
-		return initialKey;
-	}
-
 	/**
 	 *  I2P debug
 	 */
@@ -312,13 +297,6 @@ public class ChaChaPolyCipherState implements CipherState {
 		buf.append("  Cipher State:\n" +
 		           "    nonce: ");
 		buf.append(n);
-		buf.append("\n" +
-		           "    init key: ");
-		// I2P debug to be removed
-		if (haskey)
-			buf.append(net.i2p.data.Base64.encode(initialKey));
-		else
-			buf.append("null");
 		buf.append("\n    poly key: ");
 		if (haskey)
 			buf.append(net.i2p.data.Base64.encode(polyKey));
diff --git a/router/java/src/com/southernstorm/noise/protocol/CipherState.java b/router/java/src/com/southernstorm/noise/protocol/CipherState.java
index 66fd8bda57..3168139f4b 100644
--- a/router/java/src/com/southernstorm/noise/protocol/CipherState.java
+++ b/router/java/src/com/southernstorm/noise/protocol/CipherState.java
@@ -155,9 +155,4 @@ public interface CipherState extends Destroyable {
 	 * value goes backwards then security may be compromised.
 	 */
 	void setNonce(long nonce);
-
-	/**
-	 *  I2P debug to be removed
-	 */
-	public byte[] getKey();
 }
diff --git a/router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java b/router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java
index 53221104df..daf339d07c 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/InboundEstablishState.java
@@ -901,9 +901,6 @@ class InboundEstablishState extends EstablishBase implements NTCP2Payload.Payloa
         CipherStatePair ckp = _handshakeState.split();
         CipherState rcvr = ckp.getReceiver();
         CipherState sender = ckp.getSender();
-        // debug, to be removed
-        byte[] k_ab = rcvr.getKey();
-        byte[] k_ba = sender.getKey();
 
         // Data phase SipHash keys
         byte[][] sipkeys = generateSipHashKeys(_context, _handshakeState);
@@ -918,8 +915,6 @@ class InboundEstablishState extends EstablishBase implements NTCP2Payload.Payloa
         } else {
             if (_log.shouldDebug()) {
                 _log.debug("Finished establishment for " + this +
-                          "\nGenerated ChaCha key for A->B: " + Base64.encode(k_ab) +
-                          "\nGenerated ChaCha key for B->A: " + Base64.encode(k_ba) +
                           "\nGenerated SipHash key for A->B: " + Base64.encode(sip_ab) +
                           "\nGenerated SipHash key for B->A: " + Base64.encode(sip_ba));
             }
diff --git a/router/java/src/net/i2p/router/transport/ntcp/OutboundNTCP2State.java b/router/java/src/net/i2p/router/transport/ntcp/OutboundNTCP2State.java
index 56d50f74f2..64beb3a24e 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/OutboundNTCP2State.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/OutboundNTCP2State.java
@@ -404,9 +404,6 @@ class OutboundNTCP2State implements EstablishState {
         CipherStatePair ckp = _handshakeState.split();
         CipherState rcvr = ckp.getReceiver();
         CipherState sender = ckp.getSender();
-        // debug, to be removed
-        byte[] k_ab = sender.getKey();
-        byte[] k_ba = rcvr.getKey();
 
         // Data phase SipHash keys
         byte[][] sipkeys = generateSipHashKeys(_context, _handshakeState);
@@ -415,8 +412,6 @@ class OutboundNTCP2State implements EstablishState {
 
         if (_log.shouldDebug()) {
             _log.debug("Finished establishment for " + this +
-                      "\nGenerated ChaCha key for A->B: " + Base64.encode(k_ab) +
-                      "\nGenerated ChaCha key for B->A: " + Base64.encode(k_ba) +
                       "\nGenerated SipHash key for A->B: " + Base64.encode(sip_ab) +
                       "\nGenerated SipHash key for B->A: " + Base64.encode(sip_ba));
         }
-- 
GitLab