Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
50a92dc4
Commit
50a92dc4
authored
Dec 23, 2013
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to 1.3.5
parent
02c8efb0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
24 deletions
+55
-24
AndroidManifest.xml
TMessagesProj/src/main/AndroidManifest.xml
+1
-1
HandshakeAction.java
...src/main/java/org/telegram/messenger/HandshakeAction.java
+11
-9
MessagesController.java
.../main/java/org/telegram/messenger/MessagesController.java
+29
-13
Utilities.java
...sProj/src/main/java/org/telegram/messenger/Utilities.java
+14
-1
No files found.
TMessagesProj/src/main/AndroidManifest.xml
View file @
50a92dc4
...
...
@@ -2,7 +2,7 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"org.telegram.messenger"
android:versionCode=
"126"
android:versionName=
"1.3.
4
"
>
android:versionName=
"1.3.
5
"
>
<supports-screens
android:anyDensity=
"true"
android:smallScreens=
"true"
...
...
TMessagesProj/src/main/java/org/telegram/messenger/HandshakeAction.java
View file @
50a92dc4
...
...
@@ -324,7 +324,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
return
;
}
if
(!
Utilities
.
isGoodPrime
(
dhInnerData
.
dh_prime
))
{
if
(!
Utilities
.
isGoodPrime
(
dhInnerData
.
dh_prime
,
dhInnerData
.
g
))
{
throw
new
RuntimeException
(
"bad prime"
);
}
...
...
@@ -344,15 +344,17 @@ 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
),
dhBI
);
byte
[]
g_b
=
i_g_b
.
toByteArray
();
BigInteger
p
=
new
BigInteger
(
1
,
dhInnerData
.
dh_prime
);
BigInteger
g_b
=
BigInteger
.
valueOf
(
dhInnerData
.
g
);
BigInteger
g_a
=
new
BigInteger
(
1
,
dhInnerData
.
g_a
);
if
(!
Utilities
.
isGoodGaAndGb
(
g_a
,
g_b
,
p
))
{
throw
new
RuntimeException
(
"bad prime"
);
}
BigInteger
i_authKey
=
new
BigInteger
(
1
,
dhInnerData
.
g_a
);
i_authKey
=
i_authKey
.
modPow
(
new
BigInteger
(
1
,
b
),
dhBI
);
g_b
=
g_b
.
modPow
(
new
BigInteger
(
1
,
b
),
p
);
g_a
=
g_a
.
modPow
(
new
BigInteger
(
1
,
b
),
p
);
authKey
=
i_authKey
.
toByteArray
();
authKey
=
g_a
.
toByteArray
();
if
(
authKey
.
length
>
256
)
{
byte
[]
correctedAuth
=
new
byte
[
256
];
System
.
arraycopy
(
authKey
,
1
,
correctedAuth
,
0
,
256
);
...
...
@@ -390,7 +392,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
TLRPC
.
TL_client_DH_inner_data
clientInnerData
=
new
TLRPC
.
TL_client_DH_inner_data
();
clientInnerData
.
nonce
=
authNonce
;
clientInnerData
.
server_nonce
=
authServerNonce
;
clientInnerData
.
g_b
=
g_b
;
clientInnerData
.
g_b
=
g_b
.
toByteArray
()
;
clientInnerData
.
retry_id
=
0
;
SerializedData
os
=
new
SerializedData
();
clientInnerData
.
serializeToStream
(
os
);
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
View file @
50a92dc4
...
...
@@ -4811,8 +4811,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public
void
processAcceptedSecretChat
(
final
TLRPC
.
EncryptedChat
encryptedChat
)
{
BigInteger
p
=
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
);
BigInteger
i_authKey
=
new
BigInteger
(
1
,
encryptedChat
.
g_a_or_b
);
i_authKey
=
i_authKey
.
modPow
(
new
BigInteger
(
1
,
encryptedChat
.
a_or_b
),
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
));
if
(!
Utilities
.
isGoodGaAndGb
(
null
,
i_authKey
,
p
))
{
declineSecretChat
(
encryptedChat
.
id
);
return
;
}
i_authKey
=
i_authKey
.
modPow
(
new
BigInteger
(
1
,
encryptedChat
.
a_or_b
),
p
);
byte
[]
authKey
=
i_authKey
.
toByteArray
();
if
(
authKey
.
length
>
256
)
{
...
...
@@ -4883,7 +4890,7 @@ 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
))
{
if
(!
Utilities
.
isGoodPrime
(
res
.
p
,
res
.
g
))
{
acceptingChats
.
remove
(
encryptedChat
.
id
);
declineSecretChat
(
encryptedChat
.
id
);
return
;
...
...
@@ -4899,19 +4906,27 @@ public class MessagesController implements NotificationCenter.NotificationCenter
salt
[
a
]
=
(
byte
)((
byte
)(
random
.
nextDouble
()
*
255
)
^
res
.
random
[
a
]);
}
encryptedChat
.
a_or_b
=
salt
;
BigInteger
i_g_b
=
BigInteger
.
valueOf
(
MessagesStorage
.
secretG
);
i_g_b
=
i_g_b
.
modPow
(
new
BigInteger
(
1
,
salt
),
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
));
byte
[]
g_b
=
i_g_b
.
toByteArray
();
if
(
g_b
.
length
>
256
)
{
BigInteger
p
=
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
);
BigInteger
g_b
=
BigInteger
.
valueOf
(
MessagesStorage
.
secretG
);
g_b
=
g_b
.
modPow
(
new
BigInteger
(
1
,
salt
),
p
);
BigInteger
g_a
=
new
BigInteger
(
1
,
encryptedChat
.
g_a
);
if
(!
Utilities
.
isGoodGaAndGb
(
g_a
,
g_b
,
p
))
{
acceptingChats
.
remove
(
encryptedChat
.
id
);
declineSecretChat
(
encryptedChat
.
id
);
return
;
}
byte
[]
g_b_bytes
=
g_b
.
toByteArray
();
if
(
g_b_bytes
.
length
>
256
)
{
byte
[]
correctedAuth
=
new
byte
[
256
];
System
.
arraycopy
(
g_b
,
1
,
correctedAuth
,
0
,
256
);
g_b
=
correctedAuth
;
System
.
arraycopy
(
g_b
_bytes
,
1
,
correctedAuth
,
0
,
256
);
g_b
_bytes
=
correctedAuth
;
}
BigInteger
i_authKey
=
new
BigInteger
(
1
,
encryptedChat
.
g_a
);
i_authKey
=
i_authKey
.
modPow
(
new
BigInteger
(
1
,
salt
),
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
));
g_a
=
g_a
.
modPow
(
new
BigInteger
(
1
,
salt
),
p
);
byte
[]
authKey
=
i_authKey
.
toByteArray
();
byte
[]
authKey
=
g_a
.
toByteArray
();
if
(
authKey
.
length
>
256
)
{
byte
[]
correctedAuth
=
new
byte
[
256
];
System
.
arraycopy
(
authKey
,
authKey
.
length
-
256
,
correctedAuth
,
0
,
256
);
...
...
@@ -4930,7 +4945,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
encryptedChat
.
auth_key
=
authKey
;
TLRPC
.
TL_messages_acceptEncryption
req2
=
new
TLRPC
.
TL_messages_acceptEncryption
();
req2
.
g_b
=
g_b
;
req2
.
g_b
=
g_b
_bytes
;
req2
.
peer
=
new
TLRPC
.
TL_inputEncryptedChat
();
req2
.
peer
.
chat_id
=
encryptedChat
.
id
;
req2
.
peer
.
access_hash
=
encryptedChat
.
access_hash
;
...
...
@@ -4976,7 +4991,7 @@ 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
))
{
if
(!
Utilities
.
isGoodPrime
(
res
.
p
,
res
.
g
))
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -4996,6 +5011,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
for
(
int
a
=
0
;
a
<
256
;
a
++)
{
salt
[
a
]
=
(
byte
)((
byte
)(
random
.
nextDouble
()
*
255
)
^
res
.
random
[
a
]);
}
BigInteger
i_g_a
=
BigInteger
.
valueOf
(
MessagesStorage
.
secretG
);
i_g_a
=
i_g_a
.
modPow
(
new
BigInteger
(
1
,
salt
),
new
BigInteger
(
1
,
MessagesStorage
.
secretPBytes
));
byte
[]
g_a
=
i_g_a
.
toByteArray
();
...
...
TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
View file @
50a92dc4
...
...
@@ -100,7 +100,10 @@ public class Utilities {
return
new
String
(
hexChars
);
}
public
static
boolean
isGoodPrime
(
byte
[]
prime
)
{
public
static
boolean
isGoodPrime
(
byte
[]
prime
,
int
g
)
{
if
(!(
g
>=
2
&&
g
<=
7
))
{
return
false
;
}
String
hex
=
bytesToHex
(
prime
);
for
(
String
cached
:
goodPrimes
)
{
if
(
cached
.
equals
(
hex
))
{
...
...
@@ -121,6 +124,16 @@ public class Utilities {
return
true
;
}
public
static
boolean
isGoodGaAndGb
(
BigInteger
g_a
,
BigInteger
g_b
,
BigInteger
p
)
{
if
(
g_a
!=
null
&&
g_a
.
compareTo
(
BigInteger
.
valueOf
(
1
))
!=
1
)
{
return
false
;
}
if
(
g_b
!=
null
&&
p
!=
null
&&
g_b
.
compareTo
(
p
.
subtract
(
BigInteger
.
valueOf
(
1
)))
!=
-
1
)
{
return
false
;
}
return
true
;
}
public
static
TPFactorizedValue
getFactorizedValue
(
long
what
)
{
long
g
=
doPQNative
(
what
);
if
(
g
>
1
&&
g
<
what
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment