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
cf98ef00
Commit
cf98ef00
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fixed a replay issue on auth confirm
parent
fa4f0eec
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
auth/callback.go
+5
-5
5 additions, 5 deletions
auth/callback.go
auth/confirm.go
+5
-6
5 additions, 6 deletions
auth/confirm.go
storage/auth/store.go
+4
-3
4 additions, 3 deletions
storage/auth/store.go
storage/auth/store_test.go
+4
-4
4 additions, 4 deletions
storage/auth/store_test.go
with
18 additions
and
18 deletions
auth/callback.go
+
5
−
5
View file @
cf98ef00
...
...
@@ -213,7 +213,7 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
if
mgr
,
err
:=
m
.
storage
.
E2e
()
.
GetPartner
(
sr
.
GetPartner
());
mgr
!=
nil
||
err
==
nil
{
jww
.
WARN
.
Printf
(
"Cannot confirm auth for %s, channel already "
+
"exists."
,
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Fail
(
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Done
(
sr
.
GetPartner
())
return
}
...
...
@@ -221,7 +221,7 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
baseFmt
,
partnerPubKey
,
err
:=
handleBaseFormat
(
cmixMsg
,
grp
)
if
err
!=
nil
{
jww
.
WARN
.
Printf
(
"Failed to handle auth confirm: %s"
,
err
)
m
.
storage
.
Auth
()
.
Fail
(
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Done
(
sr
.
GetPartner
())
return
}
...
...
@@ -236,7 +236,7 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
if
!
success
{
jww
.
WARN
.
Printf
(
"Recieved auth confirmation failed its mac "
+
"check"
)
m
.
storage
.
Auth
()
.
Fail
(
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Done
(
sr
.
GetPartner
())
return
}
...
...
@@ -244,7 +244,7 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
if
err
!=
nil
{
jww
.
WARN
.
Printf
(
"Failed to unmarshal auth confirmation's "
+
"encrypted payload: %s"
,
err
)
m
.
storage
.
Auth
()
.
Fail
(
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Done
(
sr
.
GetPartner
())
return
}
...
...
@@ -252,7 +252,7 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
if
err
:=
m
.
doConfirm
(
sr
,
grp
,
partnerPubKey
,
sr
.
GetMyPrivKey
(),
sr
.
GetPartnerHistoricalPubKey
(),
ecrFmt
.
GetOwnership
());
err
!=
nil
{
jww
.
WARN
.
Printf
(
"Confirmation failed: %s"
,
err
)
m
.
storage
.
Auth
()
.
Fail
(
sr
.
GetPartner
())
m
.
storage
.
Auth
()
.
Done
(
sr
.
GetPartner
())
return
}
}
...
...
This diff is collapsed.
Click to expand it.
auth/confirm.go
+
5
−
6
View file @
cf98ef00
...
...
@@ -40,10 +40,11 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
return
0
,
errors
.
Errorf
(
"failed to find a pending Auth Request: %s"
,
err
)
}
defer
storage
.
Auth
()
.
Done
(
partner
.
ID
)
// verify the passed contact matches what is stored
if
storedContact
.
DhPubKey
.
Cmp
(
partner
.
DhPubKey
)
!=
0
{
storage
.
Auth
()
.
Fail
(
partner
.
ID
)
storage
.
Auth
()
.
Done
(
partner
.
ID
)
return
0
,
errors
.
WithMessage
(
err
,
"Pending Auth Request has different "
+
"pubkey than stored"
)
}
...
...
@@ -64,7 +65,6 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
salt
:=
make
([]
byte
,
saltSize
)
_
,
err
=
rng
.
Read
(
salt
)
if
err
!=
nil
{
storage
.
Auth
()
.
Fail
(
partner
.
ID
)
return
0
,
errors
.
Wrap
(
err
,
"Failed to generate salt for "
+
"confirmation"
)
}
...
...
@@ -104,10 +104,9 @@ func ConfirmRequestAuth(partner contact.Contact, rng io.Reader,
p
:=
storage
.
E2e
()
.
GetE2ESessionParams
()
if
err
:=
storage
.
E2e
()
.
AddPartner
(
partner
.
ID
,
partner
.
DhPubKey
,
newPrivKey
,
p
,
p
);
err
!=
nil
{
storage
.
Auth
()
.
Fail
(
partner
.
ID
)
return
0
,
errors
.
Errorf
(
"Failed to create channel with partner (%s) "
+
"on confirmation: %+v"
,
partner
.
ID
,
err
)
jww
.
WARN
.
Printf
(
"Failed to create channel with partner (%s) "
+
"on confirmation, this is likley a replay: %s"
,
partner
.
ID
,
err
.
Error
())
}
// delete the in progress negotiation
...
...
This diff is collapsed.
Click to expand it.
storage/auth/store.go
+
4
−
3
View file @
cf98ef00
...
...
@@ -355,17 +355,18 @@ func (s *Store) GetRequest(partner *id.ID) (RequestType, *SentRequest, contact.C
}
}
//
Fail
is one of two calls after using a request. This one is to be used when
//
Done
is one of two calls after using a request. This one is to be used when
// the use is unsuccessful. It will allow any thread waiting on access to
// continue using the structure.
// It does not return an error because an error is not handleable.
func
(
s
*
Store
)
Fail
(
partner
*
id
.
ID
)
{
func
(
s
*
Store
)
Done
(
partner
*
id
.
ID
)
{
s
.
mux
.
RLock
()
r
,
ok
:=
s
.
requests
[
*
partner
]
s
.
mux
.
RUnlock
()
if
!
ok
{
jww
.
ERROR
.
Panicf
(
"Request cannot be failed, not found: %s"
,
partner
)
jww
.
ERROR
.
Panicf
(
"Request cannot be finished, not "
+
"found: %s"
,
partner
)
return
}
...
...
This diff is collapsed.
Click to expand it.
storage/auth/store_test.go
+
4
−
4
View file @
cf98ef00
...
...
@@ -526,11 +526,11 @@ func TestStore_Fail(t *testing.T) {
}
}()
s
.
Fail
(
c
.
ID
)
s
.
Done
(
c
.
ID
)
// Check if the request's mutex is locked
if
reflect
.
ValueOf
(
&
s
.
requests
[
*
c
.
ID
]
.
mux
)
.
Elem
()
.
FieldByName
(
"state"
)
.
Int
()
!=
0
{
t
.
Errorf
(
"
Fail
() did not unlock mutex."
)
t
.
Errorf
(
"
Done
() did not unlock mutex."
)
}
}
...
...
@@ -540,11 +540,11 @@ func TestStore_Fail_RequestNotInMap(t *testing.T) {
defer
func
()
{
if
r
:=
recover
();
r
==
nil
{
t
.
Errorf
(
"
Fail
() did not panic when the request is not in map."
)
t
.
Errorf
(
"
Done
() did not panic when the request is not in map."
)
}
}()
s
.
Fail
(
id
.
NewIdFromUInt
(
rand
.
Uint64
(),
id
.
User
,
t
))
s
.
Done
(
id
.
NewIdFromUInt
(
rand
.
Uint64
(),
id
.
User
,
t
))
}
// Happy path: receive request.
...
...
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