Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
bef2cbbd
Verified
Commit
bef2cbbd
authored
3 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Try to avoid more olm loops
parent
dba2fb52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1456
passed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Olm.cpp
+22
-13
22 additions, 13 deletions
src/Olm.cpp
with
22 additions
and
13 deletions
src/Olm.cpp
+
22
−
13
View file @
bef2cbbd
...
...
@@ -214,12 +214,14 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
const
auto
my_key
=
olm
::
client
()
->
identity_keys
().
curve25519
;
bool
failed_decryption
=
false
;
for
(
const
auto
&
cipher
:
msg
.
ciphertext
)
{
// We skip messages not meant for the current device.
if
(
cipher
.
first
!=
my_key
)
{
nhlog
::
crypto
()
->
debug
(
"Skipping message for {} since we are {}."
,
cipher
.
first
,
my_key
);
return
;
continue
;
}
const
auto
type
=
cipher
.
second
.
type
;
...
...
@@ -234,6 +236,7 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
msg
.
sender
,
msg
.
sender_key
,
cipher
.
second
);
}
else
{
nhlog
::
crypto
()
->
error
(
"Undecryptable olm message!"
);
failed_decryption
=
true
;
continue
;
}
}
...
...
@@ -423,22 +426,28 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey
}
return
;
}
else
{
failed_decryption
=
true
;
}
}
try
{
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
targets
;
for
(
auto
[
device_id
,
key
]
:
otherUserDeviceKeys
.
device_keys
)
{
if
(
key
.
keys
.
at
(
"curve25519:"
+
device_id
)
==
msg
.
sender_key
)
targets
[
msg
.
sender
].
push_back
(
device_id
);
}
if
(
failed_decryption
)
{
try
{
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
targets
;
for
(
auto
[
device_id
,
key
]
:
otherUserDeviceKeys
.
device_keys
)
{
if
(
key
.
keys
.
at
(
"curve25519:"
+
device_id
)
==
msg
.
sender_key
)
targets
[
msg
.
sender
].
push_back
(
device_id
);
}
send_encrypted_to_device_messages
(
targets
,
mtx
::
events
::
DeviceEvent
<
mtx
::
events
::
msg
::
Dummy
>
{},
true
);
nhlog
::
crypto
()
->
info
(
"Recovering from broken olm channel with {}:{}"
,
msg
.
sender
,
msg
.
sender_key
);
}
catch
(
std
::
exception
&
e
)
{
nhlog
::
crypto
()
->
error
(
"Failed to recover from broken olm sessions: {}"
,
e
.
what
());
send_encrypted_to_device_messages
(
targets
,
mtx
::
events
::
DeviceEvent
<
mtx
::
events
::
msg
::
Dummy
>
{},
true
);
nhlog
::
crypto
()
->
info
(
"Recovering from broken olm channel with {}:{}"
,
msg
.
sender
,
msg
.
sender_key
);
}
catch
(
std
::
exception
&
e
)
{
nhlog
::
crypto
()
->
error
(
"Failed to recover from broken olm sessions: {}"
,
e
.
what
());
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment