Ejemplo n.º 1
0
  void authenticateDH(String us, String pw) throws Exception {
    long key = dh.createEncryptionKey(dh_resp);

    DesCipher des = new DesCipher(DH.longToBytes(key));

    byte user[] = new byte[256];
    byte passwd[] = new byte[64];
    int i;
    System.arraycopy(us.getBytes(), 0, user, 0, us.length());
    if (us.length() < 256) {
      for (i = us.length(); i < 256; i++) {
        user[i] = 0;
      }
    }
    System.arraycopy(pw.getBytes(), 0, passwd, 0, pw.length());
    if (pw.length() < 64) {
      for (i = pw.length(); i < 64; i++) {
        passwd[i] = 0;
      }
    }

    des.encryptText(user, user, DH.longToBytes(key));
    des.encryptText(passwd, passwd, DH.longToBytes(key));

    os.write(user);
    os.write(passwd);

    readSecurityResult("VNC authentication");
  }
Ejemplo n.º 2
0
  void authenticateVNC(String pw) throws Exception {
    byte[] challenge = new byte[16];
    readFully(challenge);

    if (pw.length() > 8) pw = pw.substring(0, 8); // Truncate to 8 chars

    // Truncate password on the first zero byte.
    int firstZero = pw.indexOf(0);
    if (firstZero != -1) pw = pw.substring(0, firstZero);

    byte[] key = {0, 0, 0, 0, 0, 0, 0, 0};
    System.arraycopy(pw.getBytes(), 0, key, 0, pw.length());

    DesCipher des = new DesCipher(key);

    des.encrypt(challenge, 0, challenge, 0);
    des.encrypt(challenge, 8, challenge, 8);

    os.write(challenge);

    readSecurityResult("VNC authentication");
  }