update to 1.3.4
This commit is contained in:
parent
5aee72ee33
commit
02c8efb0df
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.telegram.messenger"
|
||||
android:versionCode="122"
|
||||
android:versionName="1.3.2">
|
||||
android:versionCode="126"
|
||||
android:versionName="1.3.4">
|
||||
|
||||
<supports-screens android:anyDensity="true"
|
||||
android:smallScreens="true"
|
||||
|
@ -37,6 +37,9 @@ public class ExportAuthorizationAction extends Action {
|
||||
ConnectionsManager.Instance.performRpc(exportAuthorization, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (delegate == null) {
|
||||
return;
|
||||
}
|
||||
if (error == null) {
|
||||
exportedAuthorization = (TLRPC.TL_auth_exportedAuthorization)response;
|
||||
beginImport();
|
||||
@ -65,6 +68,9 @@ public class ExportAuthorizationAction extends Action {
|
||||
ConnectionsManager.Instance.performRpc(importAuthorization, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (delegate == null) {
|
||||
return;
|
||||
}
|
||||
if (error == null) {
|
||||
delegate.ActionDidFinishExecution(ExportAuthorizationAction.this, null);
|
||||
} else {
|
||||
|
@ -178,6 +178,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final Utilities.TPFactorizedValue factorizedPq = Utilities.getFactorizedValue(pqf);
|
||||
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@ -323,6 +324,10 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Utilities.isGoodPrime(dhInnerData.dh_prime)) {
|
||||
throw new RuntimeException("bad prime");
|
||||
}
|
||||
|
||||
if (!Arrays.equals(authNonce, dhInnerData.nonce)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH nonce");
|
||||
beginHandshake(false);
|
||||
@ -339,12 +344,13 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
b[a] = (byte)(MessagesController.random.nextDouble() * 255);
|
||||
}
|
||||
|
||||
BigInteger dhBI = new BigInteger(1, dhInnerData.dh_prime);
|
||||
BigInteger i_g_b = BigInteger.valueOf(dhInnerData.g);
|
||||
i_g_b = i_g_b.modPow(new BigInteger(1, b), new BigInteger(1, dhInnerData.dh_prime));
|
||||
i_g_b = i_g_b.modPow(new BigInteger(1, b), dhBI);
|
||||
byte[] g_b = i_g_b.toByteArray();
|
||||
|
||||
BigInteger i_authKey = new BigInteger(1, dhInnerData.g_a);
|
||||
i_authKey = i_authKey.modPow(new BigInteger(1, b), new BigInteger(1, dhInnerData.dh_prime));
|
||||
i_authKey = i_authKey.modPow(new BigInteger(1, b), dhBI);
|
||||
|
||||
authKey = i_authKey.toByteArray();
|
||||
if (authKey.length > 256) {
|
||||
|
@ -1224,6 +1224,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
for (TLRPC.TL_contact value : contactsArr) {
|
||||
TLRPC.User user = usersDict.get(value.user_id);
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
contactsDictionery.put(value.user_id, value);
|
||||
contactsPhones.put(user.phone, value);
|
||||
|
||||
@ -4880,6 +4883,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (error == null) {
|
||||
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
||||
if (response instanceof TLRPC.TL_messages_dhConfig) {
|
||||
if (!Utilities.isGoodPrime(res.p)) {
|
||||
acceptingChats.remove(encryptedChat.id);
|
||||
declineSecretChat(encryptedChat.id);
|
||||
return;
|
||||
}
|
||||
|
||||
MessagesStorage.secretPBytes = res.p;
|
||||
MessagesStorage.secretG = res.g;
|
||||
MessagesStorage.lastSecretVersion = res.version;
|
||||
@ -4967,6 +4976,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (error == null) {
|
||||
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
||||
if (response instanceof TLRPC.TL_messages_dhConfig) {
|
||||
if (!Utilities.isGoodPrime(res.p)) {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!((ActionBarActivity)context).isFinishing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
MessagesStorage.secretPBytes = res.p;
|
||||
MessagesStorage.secretG = res.g;
|
||||
MessagesStorage.lastSecretVersion = res.version;
|
||||
|
@ -85,6 +85,14 @@ public class TcpConnection extends PyroClientAdapter {
|
||||
|
||||
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
|
||||
try {
|
||||
try {
|
||||
if (reconnectTimer != null) {
|
||||
reconnectTimer.cancel();
|
||||
reconnectTimer = null;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
Datacenter datacenter = ConnectionsManager.Instance.datacenterWithId(datacenterId);
|
||||
hostAddress = datacenter.getCurrentAddress();
|
||||
hostPort = datacenter.getCurrentPort();
|
||||
|
@ -55,6 +55,10 @@ public class Utilities {
|
||||
public static int statusBarHeight = 0;
|
||||
private final static Integer lock = 1;
|
||||
|
||||
public static String[] goodPrimes = {
|
||||
"C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B"
|
||||
};
|
||||
|
||||
public static class TPFactorizedValue {
|
||||
public long p, q;
|
||||
}
|
||||
@ -84,6 +88,39 @@ public class Utilities {
|
||||
return ApplicationLoader.applicationContext.getCacheDir();
|
||||
}
|
||||
|
||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
int v;
|
||||
for ( int j = 0; j < bytes.length; j++ ) {
|
||||
v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static boolean isGoodPrime(byte[] prime) {
|
||||
String hex = bytesToHex(prime);
|
||||
for (String cached : goodPrimes) {
|
||||
if (cached.equals(hex)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (prime.length != 256 || prime[0] >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BigInteger dhBI = new BigInteger(1, prime);
|
||||
BigInteger dhBI2 = dhBI.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(2));
|
||||
if (!dhBI.isProbablePrime(30) || !dhBI2.isProbablePrime(30)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TPFactorizedValue getFactorizedValue(long what) {
|
||||
long g = doPQNative(what);
|
||||
if (g > 1 && g < what) {
|
||||
|
@ -410,6 +410,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
private void processPhotoMenu(int action) {
|
||||
if (action == 0) {
|
||||
if (parentActivity == null) {
|
||||
return;
|
||||
}
|
||||
TLRPC.Chat chat = MessagesController.Instance.chats.get(chat_id);
|
||||
if (chat.photo != null && chat.photo.photo_big != null) {
|
||||
NotificationCenter.Instance.addToMemCache(53, chat.photo.photo_big);
|
||||
|
@ -157,14 +157,10 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
||||
}
|
||||
|
||||
public void setPage(int page, boolean animated, Bundle params, boolean back) {
|
||||
if(android.os.Build.VERSION.SDK_INT > 11) {
|
||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||
Point displaySize = new Point();
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
if(android.os.Build.VERSION.SDK_INT < 13) {
|
||||
displaySize.set(display.getWidth(), display.getHeight());
|
||||
} else {
|
||||
display.getSize(displaySize);
|
||||
}
|
||||
|
||||
final SlideView outView = views[currentViewNum];
|
||||
final SlideView newView = views[page];
|
||||
|
@ -257,9 +257,11 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
String name = null;
|
||||
if (ringtone != null) {
|
||||
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
||||
if (rng != null) {
|
||||
name = rng.getTitle(ApplicationLoader.applicationContext);
|
||||
rng.stop();
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -276,7 +278,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
|
@ -39,9 +39,11 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
if (delegate != null) {
|
||||
int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight;
|
||||
this.getWindowVisibleDisplayFrame(rect);
|
||||
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||
delegate.onSizeChanged(keyboardHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user