Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
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
tg
Commits
de089530
Commit
de089530
authored
Oct 18, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed encrypted messages
parent
3765e69d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
38 deletions
+57
-38
CHANGELOG
CHANGELOG
+2
-0
encrypted_scheme17.tl
encrypted_scheme17.tl
+3
-3
queries.c
queries.c
+26
-19
structures.c
structures.c
+26
-16
No files found.
CHANGELOG
View file @
de089530
1.0.6
* layer 18 support
1.0.5
* listening socket (tcp and unix) for commands
1.0.4
...
...
encrypted_scheme17.tl
View file @
de089530
---types---
decryptedMessageLayer#
99a438cf
layer:int message:DecryptedMessage = DecryptedMessageLayer;
decryptedMessageLayer#
1be31789
layer:int message:DecryptedMessage = DecryptedMessageLayer;
decryptedMessage_l16#1f814f1f random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService_l16#aa48327d random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessage#20
a6d4e2
in_seq_no:int out_seq_no:int ttl:int random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#
9bb84a4e
in_seq_no:int out_seq_no:int random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessage#20
4d3878
in_seq_no:int out_seq_no:int ttl:int random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#
73164160
in_seq_no:int out_seq_no:int random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia;
decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
...
...
queries.c
View file @
de089530
...
...
@@ -896,14 +896,15 @@ void tgl_do_send_encr_msg_action (struct tgl_message *M, void (*callback)(void *
out_int
(
CODE_decrypted_message_service_l16
);
}
else
{
out_int
(
CODE_decrypted_message_layer
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
out_int
(
TGL_ENCRYPTED_LAYER
);
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
)
-
2
);
out_int
(
CODE_decrypted_message_service
);
}
out_long
(
M
->
id
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
if
(
P
->
encr_chat
.
layer
>=
17
)
{
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
));
if
(
P
->
encr_chat
.
layer
<
17
)
{
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
}
switch
(
M
->
action
.
type
)
{
...
...
@@ -945,17 +946,19 @@ void tgl_do_send_encr_msg (struct tgl_message *M, void (*callback)(void *callbac
out_long
(
M
->
id
);
encr_start
();
if
(
P
->
encr_chat
.
layer
<=
16
)
{
out_int
(
CODE_decrypted_message_l16
);
out_int
(
CODE_decrypted_message_
service_
l16
);
}
else
{
out_int
(
CODE_decrypted_message_layer
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
out_int
(
TGL_ENCRYPTED_LAYER
);
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
)
-
2
);
out_int
(
CODE_decrypted_message
);
}
out_long
(
M
->
id
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
if
(
P
->
encr_chat
.
layer
>=
17
)
{
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
));
if
(
P
->
encr_chat
.
layer
<
17
)
{
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
}
else
{
out_int
(
0
);
}
out_cstring
((
void
*
)
M
->
message
,
M
->
message_len
);
...
...
@@ -1692,17 +1695,19 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra
out_long
(
r
);
encr_start
();
if
(
P
->
encr_chat
.
layer
<=
16
)
{
out_int
(
CODE_decrypted_message_l16
);
out_int
(
CODE_decrypted_message_
service_
l16
);
}
else
{
out_int
(
CODE_decrypted_message_layer
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
out_int
(
TGL_ENCRYPTED_LAYER
);
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
));
out_int
(
CODE_decrypted_message
);
}
out_long
(
r
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
if
(
P
->
encr_chat
.
layer
>=
17
)
{
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
)
+
2
);
if
(
P
->
encr_chat
.
layer
<
17
)
{
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
}
else
{
out_int
(
0
);
}
out_string
(
""
);
...
...
@@ -2146,17 +2151,19 @@ void tgl_do_send_location(tgl_peer_id_t id, double latitude, double longitude, v
out_long
(
r
);
encr_start
();
if
(
P
->
encr_chat
.
layer
<=
16
)
{
out_int
(
CODE_decrypted_message_l16
);
out_int
(
CODE_decrypted_message_
service_
l16
);
}
else
{
out_int
(
CODE_decrypted_message_layer
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
out_int
(
TGL_ENCRYPTED_LAYER
);
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
));
out_int
(
CODE_decrypted_message
);
}
out_long
(
r
);
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
if
(
P
->
encr_chat
.
layer
>=
17
)
{
out_int
(
2
*
P
->
encr_chat
.
in_seq_no
+
(
P
->
encr_chat
.
admin_id
!=
tgl_state
.
our_id
));
out_int
(
2
*
P
->
encr_chat
.
out_seq_no
+
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
)
+
2
);
if
(
P
->
encr_chat
.
layer
<
17
)
{
out_random
(
15
+
4
*
(
lrand48
()
%
3
));
}
else
{
out_int
(
0
);
}
out_string
(
""
);
...
...
structures.c
View file @
de089530
...
...
@@ -1235,26 +1235,22 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) {
in_end
=
in_ptr
+
ll
;
x
=
fetch_int
();
if
(
x
==
CODE_decrypted_message_layer
)
{
ll
=
prefetch_strlen
();
fetch_str
(
ll
);
// random_bytes
int
layer
=
fetch_int
();
assert
(
layer
>=
0
);
if
(
P
&&
((
P
->
flags
)
&
FLAG_CREATED
))
{
bl_do_encr_chat_set_layer
((
void
*
)
P
,
layer
);
}
x
=
fetch_int
();
}
assert
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
||
x
==
CODE_decrypted_message_l16
||
x
==
CODE_decrypted_message_service_l16
);
//assert (id == fetch_long ());
long
long
new_id
=
fetch_long
();
if
(
P
&&
P
->
encr_chat
.
layer
>=
17
)
{
assert
(
new_id
==
id
);
}
ll
=
prefetch_strlen
();
fetch_str
(
ll
);
// random_bytes
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
)
{
//x = fetch_int ();
//assert (x == CODE_decrypted_message || x == CODE_decrypted_message_service);
out_seq_no
=
fetch_int
();
in_seq_no
=
fetch_int
();
if
(
in_seq_no
/
2
!=
P
->
encr_chat
.
in_seq_no
+
1
)
{
vlogprintf
(
E_WARNING
,
"Hole in seq in secret chat. in_seq_no = %d, expect_seq_no = %d
\n
"
,
in_seq_no
/
2
,
P
->
encr_chat
.
in_seq_no
+
1
);
if
(
in_seq_no
/
2
!=
P
->
encr_chat
.
in_seq_no
)
{
vlogprintf
(
E_WARNING
,
"Hole in seq in secret chat. in_seq_no = %d, expect_seq_no = %d
\n
"
,
in_seq_no
/
2
,
P
->
encr_chat
.
in_seq_no
);
drop
=
1
;
}
if
((
in_seq_no
&
1
)
!=
1
-
(
P
->
encr_chat
.
admin_id
==
tgl_state
.
our_id
)
||
...
...
@@ -1272,9 +1268,21 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) {
}
//vlogprintf (E_WARNING, "in = %d, out = %d\n", in_seq_no, out_seq_no);
//P->encr_chat.in_seq_no = in_seq_no / 2;
x
=
fetch_int
();
}
assert
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
||
x
==
CODE_decrypted_message_l16
||
x
==
CODE_decrypted_message_service_l16
);
//assert (id == fetch_long ());
long
long
new_id
=
fetch_long
();
if
(
P
&&
P
->
encr_chat
.
layer
>=
17
)
{
assert
(
new_id
==
id
);
}
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_service
)
{
if
(
x
==
CODE_decrypted_message
)
{
fetch_int
();
// ttl
}
}
else
{
ll
=
prefetch_strlen
();
fetch_str
(
ll
);
// random_bytes
}
if
(
x
==
CODE_decrypted_message
||
x
==
CODE_decrypted_message_l16
)
{
l
=
prefetch_strlen
();
...
...
@@ -1285,8 +1293,8 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) {
}
else
{
start
=
in_ptr
;
if
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_action
))
<
0
)
{
vlogprintf
(
E_ERROR
,
"Skipped %ld int out of %ld. Magic = 0x%08x
\n
"
,
(
long
)(
in_ptr
-
start
),
(
long
)(
in_end
-
start
),
*
start
);
assert
(
0
)
;
vlogprintf
(
E_ERROR
,
"
Can not decrypt:
Skipped %ld int out of %ld. Magic = 0x%08x
\n
"
,
(
long
)(
in_ptr
-
start
),
(
long
)(
in_end
-
start
),
*
start
);
drop
=
1
;
}
end
=
in_ptr
;
}
...
...
@@ -1320,7 +1328,9 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) {
}
}
if
(
!
drop
)
{
bl_do_encr_chat_update_seq
((
void
*
)
P
,
in_seq_no
/
2
,
out_seq_no
/
2
);
if
(
in_seq_no
>=
0
&&
out_seq_no
>=
0
)
{
bl_do_encr_chat_update_seq
((
void
*
)
P
,
in_seq_no
/
2
+
1
,
out_seq_no
/
2
);
}
}
}
...
...
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