forked from I2P_Developers/i2p.i2p
NTCP2 remove unused code
This commit is contained in:
@ -75,34 +75,6 @@ public final class ChaChaCore {
|
|||||||
return (key[offset] & 0xFF) | ((key[offset + 1] & 0xFF) << 8) | ((key[offset + 2] & 0xFF) << 16) | ((key[offset + 3] & 0xFF) << 24);
|
return (key[offset] & 0xFF) | ((key[offset + 1] & 0xFF) << 8) | ((key[offset + 2] & 0xFF) << 16) | ((key[offset + 3] & 0xFF) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes a ChaCha20 block with a 128-bit key.
|
|
||||||
*
|
|
||||||
* @param output The output block, which must consist of at
|
|
||||||
* least 16 words.
|
|
||||||
* @param key The buffer containing the key.
|
|
||||||
* @param offset Offset of the key in the buffer.
|
|
||||||
*/
|
|
||||||
public static void initKey128(int[] output, byte[] key, int offset)
|
|
||||||
{
|
|
||||||
output[0] = char4('e', 'x', 'p', 'a');
|
|
||||||
output[1] = char4('n', 'd', ' ', '1');
|
|
||||||
output[2] = char4('6', '-', 'b', 'y');
|
|
||||||
output[3] = char4('t', 'e', ' ', 'k');
|
|
||||||
output[4] = fromLittleEndian(key, offset);
|
|
||||||
output[5] = fromLittleEndian(key, offset + 4);
|
|
||||||
output[6] = fromLittleEndian(key, offset + 8);
|
|
||||||
output[7] = fromLittleEndian(key, offset + 12);
|
|
||||||
output[8] = output[4];
|
|
||||||
output[9] = output[5];
|
|
||||||
output[10] = output[6];
|
|
||||||
output[11] = output[7];
|
|
||||||
output[12] = 0;
|
|
||||||
output[13] = 0;
|
|
||||||
output[14] = 0;
|
|
||||||
output[15] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a ChaCha20 block with a 256-bit key.
|
* Initializes a ChaCha20 block with a 256-bit key.
|
||||||
*
|
*
|
||||||
|
@ -39,18 +39,13 @@ public class HandshakeState implements Destroyable {
|
|||||||
private final boolean isInitiator;
|
private final boolean isInitiator;
|
||||||
private DHState localKeyPair;
|
private DHState localKeyPair;
|
||||||
private DHState localEphemeral;
|
private DHState localEphemeral;
|
||||||
private DHState localHybrid;
|
|
||||||
private DHState remotePublicKey;
|
private DHState remotePublicKey;
|
||||||
private DHState remoteEphemeral;
|
private DHState remoteEphemeral;
|
||||||
private DHState remoteHybrid;
|
|
||||||
private DHState fixedEphemeral;
|
private DHState fixedEphemeral;
|
||||||
private DHState fixedHybrid;
|
|
||||||
private int action;
|
private int action;
|
||||||
private final int requirements;
|
private final int requirements;
|
||||||
private int patternIndex;
|
private int patternIndex;
|
||||||
// not supported
|
// not supported
|
||||||
private static final byte[] preSharedKey = null;
|
|
||||||
// not supported
|
|
||||||
private static final byte[] prologue = null;
|
private static final byte[] prologue = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,10 +364,6 @@ public class HandshakeState implements Destroyable {
|
|||||||
symmetric.mixPublicKey(localKeyPair);
|
symmetric.mixPublicKey(localKeyPair);
|
||||||
if ((requirements & FALLBACK_PREMSG) != 0) {
|
if ((requirements & FALLBACK_PREMSG) != 0) {
|
||||||
symmetric.mixPublicKey(remoteEphemeral);
|
symmetric.mixPublicKey(remoteEphemeral);
|
||||||
if (remoteHybrid != null)
|
|
||||||
symmetric.mixPublicKey(remoteHybrid);
|
|
||||||
if (preSharedKey != null)
|
|
||||||
symmetric.mixPublicKeyIntoCK(remoteEphemeral);
|
|
||||||
}
|
}
|
||||||
if ((requirements & REMOTE_PREMSG) != 0)
|
if ((requirements & REMOTE_PREMSG) != 0)
|
||||||
symmetric.mixPublicKey(remotePublicKey);
|
symmetric.mixPublicKey(remotePublicKey);
|
||||||
@ -381,10 +372,6 @@ public class HandshakeState implements Destroyable {
|
|||||||
symmetric.mixPublicKey(remotePublicKey);
|
symmetric.mixPublicKey(remotePublicKey);
|
||||||
if ((requirements & FALLBACK_PREMSG) != 0) {
|
if ((requirements & FALLBACK_PREMSG) != 0) {
|
||||||
symmetric.mixPublicKey(localEphemeral);
|
symmetric.mixPublicKey(localEphemeral);
|
||||||
if (localHybrid != null)
|
|
||||||
symmetric.mixPublicKey(localHybrid);
|
|
||||||
if (preSharedKey != null)
|
|
||||||
symmetric.mixPublicKeyIntoCK(localEphemeral);
|
|
||||||
}
|
}
|
||||||
if ((requirements & LOCAL_PREMSG) != 0)
|
if ((requirements & LOCAL_PREMSG) != 0)
|
||||||
symmetric.mixPublicKey(localKeyPair);
|
symmetric.mixPublicKey(localKeyPair);
|
||||||
@ -511,8 +498,6 @@ public class HandshakeState implements Destroyable {
|
|||||||
|
|
||||||
// If the protocol is using pre-shared keys, then also mix
|
// If the protocol is using pre-shared keys, then also mix
|
||||||
// the local ephemeral key into the chaining key.
|
// the local ephemeral key into the chaining key.
|
||||||
if (preSharedKey != null)
|
|
||||||
symmetric.mixKey(message, messagePosn, len);
|
|
||||||
messagePosn += len;
|
messagePosn += len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -664,8 +649,6 @@ public class HandshakeState implements Destroyable {
|
|||||||
|
|
||||||
// If the protocol is using pre-shared keys, then also mix
|
// If the protocol is using pre-shared keys, then also mix
|
||||||
// the remote ephemeral key into the chaining key.
|
// the remote ephemeral key into the chaining key.
|
||||||
if (preSharedKey != null)
|
|
||||||
symmetric.mixKey(message, messageOffset, len);
|
|
||||||
messageOffset += len;
|
messageOffset += len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -815,20 +798,12 @@ public class HandshakeState implements Destroyable {
|
|||||||
localKeyPair.destroy();
|
localKeyPair.destroy();
|
||||||
if (localEphemeral != null)
|
if (localEphemeral != null)
|
||||||
localEphemeral.destroy();
|
localEphemeral.destroy();
|
||||||
if (localHybrid != null)
|
|
||||||
localHybrid.destroy();
|
|
||||||
if (remotePublicKey != null)
|
if (remotePublicKey != null)
|
||||||
remotePublicKey.destroy();
|
remotePublicKey.destroy();
|
||||||
if (remoteEphemeral != null)
|
if (remoteEphemeral != null)
|
||||||
remoteEphemeral.destroy();
|
remoteEphemeral.destroy();
|
||||||
if (remoteHybrid != null)
|
|
||||||
remoteHybrid.destroy();
|
|
||||||
if (fixedEphemeral != null)
|
if (fixedEphemeral != null)
|
||||||
fixedEphemeral.destroy();
|
fixedEphemeral.destroy();
|
||||||
if (fixedHybrid != null)
|
|
||||||
fixedHybrid.destroy();
|
|
||||||
if (preSharedKey != null)
|
|
||||||
Noise.destroy(preSharedKey);
|
|
||||||
if (prologue != null)
|
if (prologue != null)
|
||||||
Noise.destroy(prologue);
|
Noise.destroy(prologue);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user