Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+24 -28
View File
@@ -30,12 +30,23 @@ import java.security.*;
public class ClientAuthenticator {
private static final byte P_Bytes[] = {(byte) 0xFB, (byte) 0x46, (byte) 0x56, (byte) 0xB4, (byte) 0xBE, (byte) 0x81, (byte) 0xA4,
(byte) 0x2C, (byte) 0x37, (byte) 0xC4, (byte) 0xA2, (byte) 0x61, (byte) 0x4A, (byte) 0xAC, (byte) 0x65, (byte) 0x90,
(byte) 0x31, (byte) 0xB6, (byte) 0x83, (byte) 0x26, (byte) 0x63, (byte) 0x94, (byte) 0x08, (byte) 0x95, (byte) 0x56,
(byte) 0x8D, (byte) 0x5E, (byte) 0xBF, (byte) 0x94, (byte) 0x10, (byte) 0x5A, (byte) 0x37, (byte) 0xB6, (byte) 0x82,
(byte) 0x1A, (byte) 0x75, (byte) 0x2B, (byte) 0xF1, (byte) 0x94, (byte) 0xB7, (byte) 0x7E, (byte) 0x56, (byte) 0xC6,
(byte) 0xD1, (byte) 0xF5, (byte) 0x18, (byte) 0xE1, (byte) 0xA5, (byte) 0x13, (byte) 0x9E, (byte) 0xC1, (byte) 0x85,
(byte) 0x98, (byte) 0xB7, (byte) 0x32, (byte) 0xDB, (byte) 0x38, (byte) 0x09, (byte) 0x1A, (byte) 0xF8, (byte) 0x5C,
(byte) 0xDA, (byte) 0x4F, (byte) 0x9F, (byte) 0x67, (byte) 0x93, (byte) 0x72, (byte) 0x8F, (byte) 0x75, (byte) 0x4F,
(byte) 0x0B, (byte) 0xBD, (byte) 0x69, (byte) 0x61, (byte) 0x97, (byte) 0x1F, (byte) 0xEE, (byte) 0xFB, (byte) 0x5B,
(byte) 0xB0, (byte) 0x85, (byte) 0xC4, (byte) 0x27, (byte) 0x7E, (byte) 0x41, (byte) 0x42, (byte) 0xC2, (byte) 0xF1,
(byte) 0xDA, (byte) 0x64, (byte) 0x8F, (byte) 0x4E, (byte) 0x28, (byte) 0xFD, (byte) 0x2A, (byte) 0x63};
private static final BigInteger P = new BigInteger(1, P_Bytes);
private static final BigInteger G = BigInteger.valueOf(5);
private final AbstractConnection origin;
private ByteBuffer buffer = ByteBuffer.allocate(100);
private byte[] secretKeyBytes = new byte[16];
private SecretKeySpec BFKey;
private Cipher cipher;
private byte[] iVecEnc = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
private byte[] iVecDec = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@@ -75,7 +86,7 @@ public class ClientAuthenticator {
private void calcKeys(AbstractConnection origin, byte[] clientPublicKeyBytes) {
try {
// get the forwarded client public key, in byte[] form.
// get the forwarded client public key, in byte[] form.
// Convert client public key to a BigInteger
BigInteger clientPublicKeyBI = new BigInteger(1, clientPublicKeyBytes);
@@ -128,14 +139,14 @@ public class ClientAuthenticator {
try {
read = origin.getSocketChannel().read(this.buffer);
} catch (IOException e) {
if (e.getLocalizedMessage() != null && !e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))
Logger.error(e);
origin.disconnect();
return 0;
if (e.getLocalizedMessage() != null && !e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))
Logger.error(e);
origin.disconnect();
return 0;
}
if (read == -1) {
Logger.info("EOF on Socket Channel, Disconnecting " + origin.getLocalAddressAndPortAsString());
Logger.info("EOF on Socket Channel, Disconnecting " + origin.getLocalAddressAndPortAsString());
origin.disconnect();
return read;
}
@@ -143,7 +154,7 @@ public class ClientAuthenticator {
this.totalRead += read;
if (this.totalRead > 100)
Logger.error( "Possible Spam warning: "
Logger.error("Possible Spam warning: "
+ origin.getSocketChannel().socket().toString());
// Not all arrived yet, so wait for more
@@ -168,7 +179,7 @@ public class ClientAuthenticator {
// Calculate Blowfish Secret Key and make ciphers streams.
this.BFKey = new SecretKeySpec(this.secretKeyBytes, "Blowfish");
// Initialize cipher and Ivecs.
// Initialize cipher and Ivecs.
// Ivecs must be run through the cipher once
// to prep the cipher for cfb mode.
this.cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");
@@ -217,7 +228,7 @@ public class ClientAuthenticator {
//Line up the iVecEncOffset.. fall through is intentional
if (iVecEncOffset != 0)
if ((this.iVecEncOffset + dataIn.limit()) < 8) {
//This handles cases where the net msg + offset won't reach 8 bytes total
//This handles cases where the net msg + offset won't reach 8 bytes total
//prevents BufferUnderflowException in small net messages. -
int newEncOffset = this.iVecEncOffset + dataIn.limit();
for (int i = this.iVecEncOffset; i < newEncOffset; i++) {
@@ -337,8 +348,8 @@ public class ClientAuthenticator {
this.iVecDecOffset = 0;
}
}
}
} catch (Exception e) {
Logger.error("ClientAuth.decrypt()" + e);
@@ -363,19 +374,4 @@ public class ClientAuthenticator {
return initialized;
}
private static final byte P_Bytes[] = {(byte) 0xFB, (byte) 0x46, (byte) 0x56, (byte) 0xB4, (byte) 0xBE, (byte) 0x81, (byte) 0xA4,
(byte) 0x2C, (byte) 0x37, (byte) 0xC4, (byte) 0xA2, (byte) 0x61, (byte) 0x4A, (byte) 0xAC, (byte) 0x65, (byte) 0x90,
(byte) 0x31, (byte) 0xB6, (byte) 0x83, (byte) 0x26, (byte) 0x63, (byte) 0x94, (byte) 0x08, (byte) 0x95, (byte) 0x56,
(byte) 0x8D, (byte) 0x5E, (byte) 0xBF, (byte) 0x94, (byte) 0x10, (byte) 0x5A, (byte) 0x37, (byte) 0xB6, (byte) 0x82,
(byte) 0x1A, (byte) 0x75, (byte) 0x2B, (byte) 0xF1, (byte) 0x94, (byte) 0xB7, (byte) 0x7E, (byte) 0x56, (byte) 0xC6,
(byte) 0xD1, (byte) 0xF5, (byte) 0x18, (byte) 0xE1, (byte) 0xA5, (byte) 0x13, (byte) 0x9E, (byte) 0xC1, (byte) 0x85,
(byte) 0x98, (byte) 0xB7, (byte) 0x32, (byte) 0xDB, (byte) 0x38, (byte) 0x09, (byte) 0x1A, (byte) 0xF8, (byte) 0x5C,
(byte) 0xDA, (byte) 0x4F, (byte) 0x9F, (byte) 0x67, (byte) 0x93, (byte) 0x72, (byte) 0x8F, (byte) 0x75, (byte) 0x4F,
(byte) 0x0B, (byte) 0xBD, (byte) 0x69, (byte) 0x61, (byte) 0x97, (byte) 0x1F, (byte) 0xEE, (byte) 0xFB, (byte) 0x5B,
(byte) 0xB0, (byte) 0x85, (byte) 0xC4, (byte) 0x27, (byte) 0x7E, (byte) 0x41, (byte) 0x42, (byte) 0xC2, (byte) 0xF1,
(byte) 0xDA, (byte) 0x64, (byte) 0x8F, (byte) 0x4E, (byte) 0x28, (byte) 0xFD, (byte) 0x2A, (byte) 0x63};
private static final BigInteger P = new BigInteger(1, P_Bytes);
private static final BigInteger G = BigInteger.valueOf(5);
}