diff --git a/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java b/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java index da110a8f..637cddcd 100644 --- a/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java +++ b/moonlight-common/src/com/limelight/nvstream/http/NvHTTP.java @@ -436,7 +436,7 @@ public class NvHTTP { } public PairingManager.PairState pair(String pin) throws Exception { - return pm.pair(uniqueId, pin); + return pm.pair(pin); } public static LinkedList getAppListByReader(Reader r) throws XmlPullParserException, IOException { diff --git a/moonlight-common/src/com/limelight/nvstream/http/PairingManager.java b/moonlight-common/src/com/limelight/nvstream/http/PairingManager.java index cc2e10e6..4d089a11 100644 --- a/moonlight-common/src/com/limelight/nvstream/http/PairingManager.java +++ b/moonlight-common/src/com/limelight/nvstream/http/PairingManager.java @@ -166,7 +166,7 @@ public class PairingManager { return PairState.PAIRED; } - public PairState pair(String uniqueId, String pin) throws MalformedURLException, IOException, XmlPullParserException, CertificateException, InvalidKeyException, NoSuchAlgorithmException, SignatureException, ShortBufferException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException { + public PairState pair(String pin) throws MalformedURLException, IOException, XmlPullParserException, CertificateException, InvalidKeyException, NoSuchAlgorithmException, SignatureException, ShortBufferException, IllegalBlockSizeException, BadPaddingException, NoSuchPaddingException { // Generate a salt for hashing the PIN byte[] salt = generateRandomBytes(16); @@ -176,12 +176,12 @@ public class PairingManager { // Send the salt and get the server cert. This doesn't have a read timeout // because the user must enter the PIN before the server responds - String getCert = http.openHttpConnectionToString(http.baseUrlHttps + - "/pair?uniqueid="+uniqueId+"&devicename=roth&updateState=1&phrase=getservercert&salt="+ + String getCert = http.openHttpConnectionToString(http.baseUrlHttp + + "/pair?"+http.buildUniqueIdUuidString()+"&devicename=roth&updateState=1&phrase=getservercert&salt="+ bytesToHex(salt)+"&clientcert="+bytesToHex(pemCertBytes), false); if (!NvHTTP.getXmlString(getCert, "paired").equals("1")) { - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); return PairState.FAILED; } X509Certificate serverCert = extractPlainCert(getCert); @@ -191,11 +191,11 @@ public class PairingManager { byte[] encryptedChallenge = encryptAes(randomChallenge, aesKey); // Send the encrypted challenge to the server - String challengeResp = http.openHttpConnectionToString(http.baseUrlHttps + - "/pair?uniqueid="+uniqueId+"&devicename=roth&updateState=1&clientchallenge="+bytesToHex(encryptedChallenge), + String challengeResp = http.openHttpConnectionToString(http.baseUrlHttp + + "/pair?"+http.buildUniqueIdUuidString()+"&devicename=roth&updateState=1&clientchallenge="+bytesToHex(encryptedChallenge), true); if (!NvHTTP.getXmlString(challengeResp, "paired").equals("1")) { - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); return PairState.FAILED; } @@ -210,11 +210,11 @@ public class PairingManager { byte[] clientSecret = generateRandomBytes(16); byte[] challengeRespHash = toSHA1Bytes(concatBytes(concatBytes(serverChallenge, cert.getSignature()), clientSecret)); byte[] challengeRespEncrypted = encryptAes(challengeRespHash, aesKey); - String secretResp = http.openHttpConnectionToString(http.baseUrlHttps + - "/pair?uniqueid="+uniqueId+"&devicename=roth&updateState=1&serverchallengeresp="+bytesToHex(challengeRespEncrypted), + String secretResp = http.openHttpConnectionToString(http.baseUrlHttp + + "/pair?"+http.buildUniqueIdUuidString()+"&devicename=roth&updateState=1&serverchallengeresp="+bytesToHex(challengeRespEncrypted), true); if (!NvHTTP.getXmlString(secretResp, "paired").equals("1")) { - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); return PairState.FAILED; } @@ -226,7 +226,7 @@ public class PairingManager { // Ensure the authenticity of the data if (!verifySignature(serverSecret, serverSignature, serverCert)) { // Cancel the pairing process - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); // Looks like a MITM return PairState.FAILED; @@ -236,7 +236,7 @@ public class PairingManager { byte[] serverChallengeRespHash = toSHA1Bytes(concatBytes(concatBytes(randomChallenge, serverCert.getSignature()), serverSecret)); if (!Arrays.equals(serverChallengeRespHash, serverResponse)) { // Cancel the pairing process - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); // Probably got the wrong PIN return PairState.PIN_WRONG; @@ -244,19 +244,19 @@ public class PairingManager { // Send the server our signed secret byte[] clientPairingSecret = concatBytes(clientSecret, signData(clientSecret, pk)); - String clientSecretResp = http.openHttpConnectionToString(http.baseUrlHttps + - "/pair?uniqueid="+uniqueId+"&devicename=roth&updateState=1&clientpairingsecret="+bytesToHex(clientPairingSecret), + String clientSecretResp = http.openHttpConnectionToString(http.baseUrlHttp + + "/pair?"+http.buildUniqueIdUuidString()+"&devicename=roth&updateState=1&clientpairingsecret="+bytesToHex(clientPairingSecret), true); if (!NvHTTP.getXmlString(clientSecretResp, "paired").equals("1")) { - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); return PairState.FAILED; } // Do the initial challenge (seems neccessary for us to show as paired) String pairChallenge = http.openHttpConnectionToString(http.baseUrlHttps + - "/pair?uniqueid="+uniqueId+"&devicename=roth&updateState=1&phrase=pairchallenge", true); + "/pair?"+http.buildUniqueIdUuidString()+"&devicename=roth&updateState=1&phrase=pairchallenge", true); if (!NvHTTP.getXmlString(pairChallenge, "paired").equals("1")) { - http.openHttpConnectionToString(http.baseUrlHttps + "/unpair?uniqueid="+uniqueId, true); + http.openHttpConnectionToString(http.baseUrlHttp + "/unpair?"+http.buildUniqueIdUuidString(), true); return PairState.FAILED; }