diff src/main/java/com/glavsoft/rfb/protocol/auth/VncAuthentication.java @ 52:472a9bcacb21 draft default tip

TightVNC 2.7.1.0
author you@cr.ie.u-ryukyu.ac.jp
date Wed, 07 Aug 2013 19:01:17 +0900
parents 4689cc86d6cb
children
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/protocol/auth/VncAuthentication.java	Tue Jul 03 13:20:49 2012 +0900
+++ b/src/main/java/com/glavsoft/rfb/protocol/auth/VncAuthentication.java	Wed Aug 07 19:01:17 2013 +0900
@@ -1,4 +1,4 @@
-// Copyright (C) 2010, 2011 GlavSoft LLC.
+// Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
 // All rights reserved.
 //
 //-------------------------------------------------------------------------
@@ -50,6 +50,7 @@
 	throws TransportException, FatalException {
 		byte [] challenge = reader.readBytes(16);
 		String password = passwordRetriever.getPassword();
+        if (null == password) return false;
 		byte [] key = new byte[8];
         System.arraycopy(password.getBytes(), 0, key, 0, Math.min(key.length, password.getBytes().length));
 	    writer.write(encrypt(challenge, key));
@@ -58,8 +59,6 @@
 
   /**
 	 * Encript challenge by key using DES
-	 * @param challenge
-	 * @param key
 	 * @return encripted bytes
 	 * @throws CryptoException on problem with DES algorithm support or smth about
 	 */
@@ -70,8 +69,7 @@
 		    SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
 		    Cipher desCipher = Cipher.getInstance("DES/ECB/NoPadding");
 		    desCipher.init(Cipher.ENCRYPT_MODE, secretKey);
-		    byte[] textEncrypted = desCipher.doFinal(challenge);
-		    return textEncrypted;
+            return desCipher.doFinal(challenge);
 		} catch (NoSuchAlgorithmException e) {
 			throw new CryptoException("Cannot encrypt challenge", e);
 		} catch (NoSuchPaddingException e) {