summaryrefslogtreecommitdiffstats
path: root/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java')
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java42
1 files changed, 3 insertions, 39 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java b/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
index 0afafd0..d1ac1ad 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
@@ -7,16 +7,8 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.SecretKeySpec;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,16 +74,7 @@ public class VncConnection implements Closeable {
byte[] pw_bytes = passwd.getBytes();
pw_bytes = Arrays.copyOf(pw_bytes, 8);
// Encrypt
- Cipher des;
- try {
- des = Cipher.getInstance("DES/ECB/NoPadding");
- des.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(reverseBits(pw_bytes), 0, pw_bytes.length, "DES"));
- out.write(des.doFinal(challenge));
- } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException
- | BadPaddingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ out.write(WeakCrypto.vncEncrypt(pw_bytes, challenge));
// check reply
int securityReply = in.readInt();
if (securityReply != 0) {
@@ -108,7 +91,8 @@ public class VncConnection implements Closeable {
in.readFully(msg);
LOGGER.info(new String(msg, StandardCharsets.ISO_8859_1));
} catch (IOException e) {
- // Nothing, we're already kinda handling an error, so if we can't fetch the message, ignore
+ // Nothing, we're already kinda handling an error, so if we can't fetch the
+ // message, ignore
}
}
@@ -128,24 +112,4 @@ public class VncConnection implements Closeable {
}
}
- /*
- *
- */
-
- private byte[] reverseBits(byte[] b) {
- byte[] result = new byte[b.length];
- for (int i = 0; i < b.length; i++) {
- result[i] = reverseBits(b[i]);
- }
- return result;
- }
-
- private byte reverseBits(byte input) {
- byte result = 0x00;
- for (int i = 0; i < 8; i++) {
- result |= ((byte) ((input & (0x01 << i)) >>> i) << 7 - i);
- }
- return result;
- }
-
}