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
e8c091dd
Commit
e8c091dd
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Make connect/authenticated.go more test-able
parent
d374c03a
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!510
Release
,
!216
Xx 3895/authenticated connection
,
!207
WIP: Client Restructure
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
connect/authenticated.go
+20
-6
20 additions, 6 deletions
connect/authenticated.go
with
20 additions
and
6 deletions
connect/authenticated.go
+
20
−
6
View file @
e8c091dd
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"gitlab.com/xx_network/primitives/netTime"
"sync"
"sync"
"time"
)
)
// Constant error messages
// Constant error messages
...
@@ -62,11 +63,24 @@ func ConnectWithAuthentication(recipient contact.Contact, myId *id.ID,
...
@@ -62,11 +63,24 @@ func ConnectWithAuthentication(recipient contact.Contact, myId *id.ID,
conn
,
err
:=
Connect
(
recipient
,
myId
,
myDhPrivKey
,
rng
,
grp
,
net
,
p
)
conn
,
err
:=
Connect
(
recipient
,
myId
,
myDhPrivKey
,
rng
,
grp
,
net
,
p
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Errorf
(
"failed to establish connection "
+
return
nil
,
errors
.
Errorf
(
"failed to establish connection "
+
"with recipient %s: %v"
,
recipient
.
ID
,
err
)
"with recipient %s: %
+
v"
,
recipient
.
ID
,
err
)
}
}
// Build the authenticated connection and return
return
connectWithAuthentication
(
conn
,
timeStart
,
recipient
,
salt
,
myRsaPrivKey
,
rng
,
net
,
p
)
}
// connectWithAuthentication builds and sends an IdentityAuthentication to
// the server. This will wait until the round it sends on completes or a
// timeout occurs.
func
connectWithAuthentication
(
conn
Connection
,
timeStart
time
.
Time
,
recipient
contact
.
Contact
,
salt
[]
byte
,
myRsaPrivKey
*
rsa
.
PrivateKey
,
rng
*
fastRNG
.
StreamGenerator
,
net
cmix
.
Client
,
p
Params
)
(
AuthenticatedConnection
,
error
)
{
// Construct message to prove your identity to the server
// Construct message to prove your identity to the server
payload
,
err
:=
makeClientAuthRequest
(
conn
.
GetPartner
(),
rng
,
myRsaPrivKey
,
salt
)
payload
,
err
:=
buildClientAuthRequest
(
conn
.
GetPartner
(),
rng
,
myRsaPrivKey
,
salt
)
if
err
!=
nil
{
if
err
!=
nil
{
// Close connection on an error
// Close connection on an error
errClose
:=
conn
.
Close
()
errClose
:=
conn
.
Close
()
...
@@ -164,9 +178,9 @@ func StartAuthenticatedServer(cb AuthenticatedCallback,
...
@@ -164,9 +178,9 @@ func StartAuthenticatedServer(cb AuthenticatedCallback,
// Register the waiter for a connection establishment
// Register the waiter for a connection establishment
connCb
:=
Callback
(
func
(
connection
Connection
)
{
connCb
:=
Callback
(
func
(
connection
Connection
)
{
// Upon establishing a connection, register a listener for the
// Upon establishing a connection, register a listener for the
// client's identity proof. If a identity authentication
// client's identity proof. If a
n
identity authentication
// message is received and validated, an authenticated connection will
// message is received and validated, an authenticated connection will
// be passed along via the
c
allback
// be passed along via the
AuthenticatedC
allback
connection
.
RegisterListener
(
catalog
.
ConnectionAuthenticationRequest
,
connection
.
RegisterListener
(
catalog
.
ConnectionAuthenticationRequest
,
buildAuthConfirmationHandler
(
cb
,
connection
))
buildAuthConfirmationHandler
(
cb
,
connection
))
})
})
...
@@ -174,8 +188,8 @@ func StartAuthenticatedServer(cb AuthenticatedCallback,
...
@@ -174,8 +188,8 @@ func StartAuthenticatedServer(cb AuthenticatedCallback,
net
,
p
)
net
,
p
)
}
}
// authenticatedHandler provides an implementation for the
AuthenticatedConnection
// authenticatedHandler provides an implementation for the
// interface.
//
AuthenticatedConnection
interface.
type
authenticatedHandler
struct
{
type
authenticatedHandler
struct
{
Connection
Connection
isAuthenticated
bool
isAuthenticated
bool
...
...
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