Remove rsa encryption
This commit is contained in:
parent
180d331b80
commit
9366dd7d28
2 changed files with 0 additions and 57 deletions
|
@ -58,7 +58,6 @@ public class OsMoService implements OsMoReactor {
|
|||
private static final String HTTPS_API_PREPARE = "https://api.osmo.mobi/prepare";
|
||||
private static final String HTTP_AUTH = "http://api.osmo.mobi/auth";
|
||||
private static final String HTTPS_AUTH = "https://api.osmo.mobi/auth";
|
||||
private static final boolean USE_RSA_ENCRYPTION = true;
|
||||
|
||||
public static final String REGENERATE_CMD = "TRACKER_REGENERATE_ID";
|
||||
public static final String SIGN_IN_URL = "http://osmo.mobi/signin?key=";
|
||||
|
@ -244,8 +243,6 @@ public class OsMoService implements OsMoReactor {
|
|||
public long motdTimestamp;
|
||||
|
||||
public String motd = "";
|
||||
public Cipher clientEncCypher;
|
||||
public Cipher clientDecCypher;
|
||||
}
|
||||
|
||||
public SessionInfo getCurrentSessionInfo() {
|
||||
|
@ -287,33 +284,12 @@ public class OsMoService implements OsMoReactor {
|
|||
deviceKey = registerOsmoDeviceKey();
|
||||
}
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
KeyPair getMsgPair = null;
|
||||
if (plugin.useHttps() && USE_RSA_ENCRYPTION) {
|
||||
try {
|
||||
KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA");
|
||||
getMsgPair = rsaGen.generateKeyPair();
|
||||
} catch (Exception e1) {
|
||||
if (thread != null) {
|
||||
thread.exc("Private key can't be generated", e1);
|
||||
} else {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
HttpPost httppost = new HttpPost(plugin.useHttps()? HTTPS_API_PREPARE : HTTP_API_PREPARE);
|
||||
try {
|
||||
// Add your data
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
|
||||
nameValuePairs.add(new BasicNameValuePair("app", Version.getFullVersion(app)));
|
||||
nameValuePairs.add(new BasicNameValuePair("key", deviceKey));
|
||||
if(getMsgPair != null && getMsgPair.getPublic() instanceof RSAPublicKey) {
|
||||
nameValuePairs.add(new BasicNameValuePair("encAlgorithm", "RSA"));
|
||||
BigInteger modulus = ((RSAPublicKey) getMsgPair.getPublic()).getModulus();
|
||||
BigInteger pe = ((RSAPublicKey) getMsgPair.getPublic()).getPublicExponent();
|
||||
nameValuePairs.add(new BasicNameValuePair("encClientPublicKey1", modulus.toString()));
|
||||
nameValuePairs.add(new BasicNameValuePair("encClientPublicKey2", pe.toString()));
|
||||
}
|
||||
|
||||
if(app.getSettings().OSMO_USER_PWD.get() != null) {
|
||||
nameValuePairs.add(new BasicNameValuePair("auth", app.getSettings().OSMO_USER_PWD.get()));
|
||||
}
|
||||
|
@ -354,23 +330,6 @@ public class OsMoService implements OsMoReactor {
|
|||
si.hostName = a.substring(0, i);
|
||||
si.port = a.substring(i + 1);
|
||||
si.token = obj.getString("token");
|
||||
try {
|
||||
if(getMsgPair != null && obj.has("encServerPublicKey1")) {
|
||||
si.clientEncCypher = Cipher.getInstance("RSA");
|
||||
PublicKey pk = KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(obj.getString("encServerPublicKey1")),
|
||||
new BigInteger(obj.getString("encServerPublicKey2"))));
|
||||
si.clientEncCypher.init(Cipher.ENCRYPT_MODE, pk);
|
||||
|
||||
si.clientDecCypher = Cipher.getInstance("RSA");
|
||||
si.clientDecCypher.init(Cipher.DECRYPT_MODE, getMsgPair.getPrivate());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (thread != null) {
|
||||
thread.exc("Error exchanging private keys", e);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return si;
|
||||
} catch (ClientProtocolException e) {
|
||||
throw new IOException(e);
|
||||
|
|
|
@ -267,15 +267,6 @@ public class OsMoThread {
|
|||
while ((i = readCommand.indexOf('\n')) != -1) {
|
||||
String cmd = readCommand.substring(0, i);
|
||||
readCommand = readCommand.substring(i + 1);
|
||||
if(sessionInfo != null && sessionInfo.clientDecCypher != null) {
|
||||
try {
|
||||
final byte[] inMsg = android.util.Base64.decode(cmd.getBytes(), android.util.Base64.DEFAULT);
|
||||
final byte[] byts = sessionInfo.clientDecCypher.doFinal(inMsg);
|
||||
cmd = new String(byts);
|
||||
} catch (Exception e) {
|
||||
exc("Error decrypting", e);
|
||||
}
|
||||
}
|
||||
queueOfMessages.add(cmd.replace("\\n", "\n"));
|
||||
}
|
||||
}
|
||||
|
@ -473,13 +464,6 @@ public class OsMoThread {
|
|||
}
|
||||
|
||||
String finalCmd = res.toString().trim();
|
||||
if(sessionInfo != null && sessionInfo.clientEncCypher != null) {
|
||||
try {
|
||||
finalCmd = Base64.encode(sessionInfo.clientEncCypher.doFinal(finalCmd.getBytes()));
|
||||
} catch (Exception e) {
|
||||
exc("Error encrypting", e);
|
||||
}
|
||||
}
|
||||
return finalCmd + "=\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue