Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
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
elixxir
client
Commits
e8875de6
Commit
e8875de6
authored
3 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Fix garbled message bug
parent
67f70846
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!170
Release
,
!120
Add 0 byte to message contents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/message/garbled.go
+59
-52
59 additions, 52 deletions
network/message/garbled.go
network/message/handler.go
+4
-1
4 additions, 1 deletion
network/message/handler.go
with
63 additions
and
53 deletions
network/message/garbled.go
+
59
−
52
View file @
e8875de6
...
...
@@ -57,65 +57,72 @@ func (m *Manager) handleGarbledMessages() {
var
failedMsgs
[]
format
.
Message
//try to decrypt every garbled message, excising those who's counts are too high
for
grbldMsg
,
count
,
timestamp
,
has
:=
garbledMsgs
.
Next
();
has
;
grbldMsg
,
count
,
timestamp
,
has
=
garbledMsgs
.
Next
()
{
fingerprint
:=
grbldMsg
.
GetKeyFP
()
// Check if the key is there, process it if it is
if
key
,
isE2E
:=
e2eKv
.
PopKey
(
fingerprint
);
isE2E
{
jww
.
INFO
.
Printf
(
"[GARBLE] Check E2E for %s, KEYFP: %s"
,
grbldMsg
.
Digest
(),
grbldMsg
.
GetKeyFP
())
// Decrypt encrypted message
msg
,
err
:=
key
.
Decrypt
(
grbldMsg
)
if
err
==
nil
{
// get the sender
sender
:=
key
.
GetSession
()
.
GetPartner
()
//remove from the buffer if decryption is successful
garbledMsgs
.
Remove
(
grbldMsg
)
//if it exists, check against all in the list
modifiedContents
:=
append
([]
byte
{
0
},
grbldMsg
.
GetContents
()
...
)
identity
:=
m
.
Session
.
GetUser
()
.
GetContact
()
.
ID
_
,
forMe
,
_
:=
m
.
Session
.
GetEdge
()
.
Check
(
identity
,
grbldMsg
.
GetIdentityFP
(),
modifiedContents
)
if
forMe
{
fingerprint
:=
grbldMsg
.
GetKeyFP
()
// Check if the key is there, process it if it is
if
key
,
isE2E
:=
e2eKv
.
PopKey
(
fingerprint
);
isE2E
{
jww
.
INFO
.
Printf
(
"[GARBLE] Check E2E for %s, KEYFP: %s"
,
grbldMsg
.
Digest
(),
grbldMsg
.
GetKeyFP
())
// Decrypt encrypted message
msg
,
err
:=
key
.
Decrypt
(
grbldMsg
)
if
err
==
nil
{
// get the sender
sender
:=
key
.
GetSession
()
.
GetPartner
()
//remove from the buffer if decryption is successful
garbledMsgs
.
Remove
(
grbldMsg
)
jww
.
INFO
.
Printf
(
"[GARBLE] message decoded as E2E from "
+
"%s, msgDigest: %s"
,
sender
,
grbldMsg
.
Digest
())
jww
.
INFO
.
Printf
(
"[GARBLE] message decoded as E2E from "
+
"%s, msgDigest: %s"
,
sender
,
grbldMsg
.
Digest
())
//handle the successfully decrypted message
xxMsg
,
ok
:=
m
.
partitioner
.
HandlePartition
(
sender
,
message
.
E2E
,
msg
.
GetContents
(),
key
.
GetSession
()
.
GetRelationshipFingerprint
())
if
ok
{
m
.
Switchboard
.
Speak
(
xxMsg
)
continue
}
}
}
else
{
// todo: figure out how to get the ephermal reception id in here.
// we have the raw data, but do not know what address space was
// used int he round
// todo: figure out how to get the round id, the recipient id, and the round timestamp
/*
ephid, err := ephemeral.Marshal(garbledMsg.GetEphemeralRID())
if err!=nil{
jww.WARN.Printf("failed to get the ephemeral id for a garbled " +
"message, clearing the message: %+v", err)
garbledMsgs.Remove(garbledMsg)
continue
//handle the successfully decrypted message
xxMsg
,
ok
:=
m
.
partitioner
.
HandlePartition
(
sender
,
message
.
E2E
,
msg
.
GetContents
(),
key
.
GetSession
()
.
GetRelationshipFingerprint
())
if
ok
{
m
.
Switchboard
.
Speak
(
xxMsg
)
continue
}
}
}
else
{
// todo: figure out how to get the ephermal reception id in here.
// we have the raw data, but do not know what address space was
// used int he round
// todo: figure out how to get the round id, the recipient id, and the round timestamp
/*
ephid, err := ephemeral.Marshal(garbledMsg.GetEphemeralRID())
if err!=nil{
jww.WARN.Printf("failed to get the ephemeral id for a garbled " +
"message, clearing the message: %+v", err)
garbledMsgs.Remove(garbledMsg)
continue
}
ephid.Clear(m.)*/
ephid.Clear(m.)*/
raw
:=
message
.
Receive
{
Payload
:
grbldMsg
.
Marshal
(),
MessageType
:
message
.
Raw
,
Sender
:
&
id
.
ID
{},
EphemeralID
:
ephemeral
.
Id
{},
Timestamp
:
time
.
Time
{},
Encryption
:
message
.
None
,
RecipientID
:
&
id
.
ID
{},
RoundId
:
0
,
RoundTimestamp
:
time
.
Time
{},
raw
:=
message
.
Receive
{
Payload
:
grbldMsg
.
Marshal
(),
MessageType
:
message
.
Raw
,
Sender
:
&
id
.
ID
{},
EphemeralID
:
ephemeral
.
Id
{},
Timestamp
:
time
.
Time
{},
Encryption
:
message
.
None
,
RecipientID
:
&
id
.
ID
{},
RoundId
:
0
,
RoundTimestamp
:
time
.
Time
{},
}
im
:=
fmt
.
Sprintf
(
"[GARBLE] RAW Message reprecessed: keyFP: %v, "
+
"msgDigest: %s"
,
grbldMsg
.
GetKeyFP
(),
grbldMsg
.
Digest
())
jww
.
INFO
.
Print
(
im
)
m
.
Internal
.
Events
.
Report
(
1
,
"MessageReception"
,
"Garbled"
,
im
)
m
.
Session
.
GetGarbledMessages
()
.
Add
(
grbldMsg
)
m
.
Switchboard
.
Speak
(
raw
)
}
im
:=
fmt
.
Sprintf
(
"[GARBLE] RAW Message reprecessed: keyFP: %v, "
+
"msgDigest: %s"
,
grbldMsg
.
GetKeyFP
(),
grbldMsg
.
Digest
())
jww
.
INFO
.
Print
(
im
)
m
.
Internal
.
Events
.
Report
(
1
,
"MessageReception"
,
"Garbled"
,
im
)
m
.
Session
.
GetGarbledMessages
()
.
Add
(
grbldMsg
)
m
.
Switchboard
.
Speak
(
raw
)
}
// fail the message if any part of the decryption fails,
// unless it is the last attempts and has been in the buffer long
// enough, in which case remove it
...
...
This diff is collapsed.
Click to expand it.
network/message/handler.go
+
4
−
1
View file @
e8875de6
...
...
@@ -71,7 +71,10 @@ func (m *Manager) handleMessage(ecrMsg format.Message, bundle Bundle, edge *edge
"check: %v (expected-default) vs %v (received)"
,
identity
.
EphId
,
identity
.
Source
,
expectedFP
,
ecrMsg
.
GetIdentityFP
())
}
im
:=
fmt
.
Sprintf
(
"Garbled/RAW Message: keyFP: %v, round: %d"
+
"msgDigest: %s, not determined to be for client"
,
msg
.
GetKeyFP
(),
bundle
.
Round
,
msg
.
Digest
())
m
.
Internal
.
Events
.
Report
(
1
,
"MessageReception"
,
"Garbled"
,
im
)
m
.
Session
.
GetGarbledMessages
()
.
Add
(
msg
)
return
}
...
...
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