Skip to content
Snippets Groups Projects
Commit 36f0138f authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'xx-1757' into 'release'

Xx 1757

See merge request !312
parents 83962ea9 2b397166
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,6 @@ func (cl *Client) InitNetwork() error { ...@@ -27,7 +27,6 @@ func (cl *Client) InitNetwork() error {
} }
runPermissioning := err != ErrNoPermissioning runPermissioning := err != ErrNoPermissioning
if runPermissioning { if runPermissioning {
err = cl.setupPermissioning() err = cl.setupPermissioning()
...@@ -50,6 +49,7 @@ func (cl *Client) InitNetwork() error { ...@@ -50,6 +49,7 @@ func (cl *Client) InitNetwork() error {
// DisableTls disables tls for communications // DisableTls disables tls for communications
func (cl *Client) DisableTls() { func (cl *Client) DisableTls() {
globals.Log.INFO.Println("Running client without tls") globals.Log.INFO.Println("Running client without tls")
cl.receptionManager.Comms.DisableAuth()
cl.receptionManager.Tls = false cl.receptionManager.Tls = false
} }
......
...@@ -85,7 +85,7 @@ func (cl *Client) sendRegistrationMessage(registrationCode string, ...@@ -85,7 +85,7 @@ func (cl *Client) sendRegistrationMessage(registrationCode string,
if !ok { if !ok {
return nil, errors.New("Failed to find permissioning host") return nil, errors.New("Failed to find permissioning host")
} }
fmt.Println("in reg, pub key ", publicKeyRSA)
response, err := cl.receptionManager.Comms. response, err := cl.receptionManager.Comms.
SendRegistrationMessage(host, SendRegistrationMessage(host,
&pb.UserRegistration{ &pb.UserRegistration{
...@@ -130,6 +130,7 @@ func (cl *Client) requestNonce(salt, regHash []byte, ...@@ -130,6 +130,7 @@ func (cl *Client) requestNonce(salt, regHash []byte,
if !ok { if !ok {
return nil, nil, errors.Errorf("Failed to find host with ID %s", gwID.String()) return nil, nil, errors.Errorf("Failed to find host with ID %s", gwID.String())
} }
nonceResponse, err := cl.receptionManager.Comms. nonceResponse, err := cl.receptionManager.Comms.
SendRequestNonceMessage(host, SendRequestNonceMessage(host,
&pb.NonceRequest{ &pb.NonceRequest{
...@@ -152,7 +153,6 @@ func (cl *Client) requestNonce(salt, regHash []byte, ...@@ -152,7 +153,6 @@ func (cl *Client) requestNonce(salt, regHash []byte,
err := errors.New(fmt.Sprintf("requestNonce: nonceResponse error: %s", nonceResponse.Error)) err := errors.New(fmt.Sprintf("requestNonce: nonceResponse error: %s", nonceResponse.Error))
return nil, nil, err return nil, nil, err
} }
// Use Client keypair to sign Server nonce // Use Client keypair to sign Server nonce
return nonceResponse.Nonce, nonceResponse.DHPubKey, nil return nonceResponse.Nonce, nonceResponse.DHPubKey, nil
...@@ -301,7 +301,6 @@ func (cl *Client) GenerateKeys(rsaPrivKey *rsa.PrivateKey, ...@@ -301,7 +301,6 @@ func (cl *Client) GenerateKeys(rsaPrivKey *rsa.PrivateKey,
cl.session = user.NewSession(cl.storage, usr, pubKey, privKey, cmixPubKey, cl.session = user.NewSession(cl.storage, usr, pubKey, privKey, cmixPubKey,
cmixPrivKey, e2ePubKey, e2ePrivKey, salt, cmixGrp, e2eGrp, password) cmixPrivKey, e2ePubKey, e2ePrivKey, salt, cmixGrp, e2eGrp, password)
//store the session //store the session
return cl.session.StoreSession() return cl.session.StoreSession()
} }
......
...@@ -21,7 +21,6 @@ const SaltSize = 256 ...@@ -21,7 +21,6 @@ const SaltSize = 256
//RegisterWithPermissioning registers the user and returns the User ID. //RegisterWithPermissioning registers the user and returns the User ID.
// Returns an error if registration fails. // Returns an error if registration fails.
func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string) (*id.User, error) { func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string) (*id.User, error) {
//Check the regState is in proper state for registration //Check the regState is in proper state for registration
if cl.session.GetRegState() != user.KeyGenComplete { if cl.session.GetRegState() != user.KeyGenComplete {
return nil, errors.Errorf("Attempting to register before key generation!") return nil, errors.Errorf("Attempting to register before key generation!")
...@@ -52,7 +51,6 @@ func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string ...@@ -52,7 +51,6 @@ func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string
for n, k := range nodeKeyMap { for n, k := range nodeKeyMap {
cl.session.PushNodeKey(&n, k) cl.session.PushNodeKey(&n, k)
} }
//update the state //update the state
err := cl.session.SetRegState(user.PermissioningComplete) err := cl.session.SetRegState(user.PermissioningComplete)
if err != nil { if err != nil {
...@@ -166,7 +164,6 @@ func (cl *Client) RegisterWithNodes() error { ...@@ -166,7 +164,6 @@ func (cl *Client) RegisterWithNodes() error {
//Load the registration signature //Load the registration signature
regSignature := session.GetRegistrationValidationSignature() regSignature := session.GetRegistrationValidationSignature()
var wg sync.WaitGroup var wg sync.WaitGroup
errChan := make(chan error, len(cl.ndf.Gateways)) errChan := make(chan error, len(cl.ndf.Gateways))
...@@ -193,7 +190,6 @@ func (cl *Client) RegisterWithNodes() error { ...@@ -193,7 +190,6 @@ func (cl *Client) RegisterWithNodes() error {
}() }()
} }
} }
wg.Wait() wg.Wait()
//See if the registration returned errors at all //See if the registration returned errors at all
var errs error var errs error
...@@ -250,6 +246,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat ...@@ -250,6 +246,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat
if err != nil { if err != nil {
errMsg := fmt.Sprintf("Register: Failed requesting nonce from gateway: %+v", err) errMsg := fmt.Sprintf("Register: Failed requesting nonce from gateway: %+v", err)
errorChan <- errors.New(errMsg) errorChan <- errors.New(errMsg)
return
} }
// Load server DH pubkey // Load server DH pubkey
...@@ -261,6 +258,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat ...@@ -261,6 +258,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat
if err != nil { if err != nil {
errMsg := fmt.Sprintf("Register: Unable to confirm nonce: %v", err) errMsg := fmt.Sprintf("Register: Unable to confirm nonce: %v", err)
errorChan <- errors.New(errMsg) errorChan <- errors.New(errMsg)
return
} }
nodeID := cl.topology.GetNodeAtIndex(index) nodeID := cl.topology.GetNodeAtIndex(index)
key := user.NodeKeys{ key := user.NodeKeys{
...@@ -289,6 +287,7 @@ func (cl *Client) registerWithPermissioning(registrationCode string, ...@@ -289,6 +287,7 @@ func (cl *Client) registerWithPermissioning(registrationCode string,
return nil, errors.Errorf("Register: Unable to send registration message: %+v", err) return nil, errors.Errorf("Register: Unable to send registration message: %+v", err)
} }
} }
globals.Log.INFO.Println("Register: successfully passed Registration message") globals.Log.INFO.Println("Register: successfully passed Registration message")
return regValidSig, nil return regValidSig, nil
......
...@@ -196,7 +196,7 @@ func sessionInitialization() (*id.User, string, *api.Client) { ...@@ -196,7 +196,7 @@ func sessionInitialization() (*id.User, string, *api.Client) {
regCode = id.NewUserFromUints(&[4]uint64{0, 0, 0, userId}).RegistrationCode() regCode = id.NewUserFromUints(&[4]uint64{0, 0, 0, userId}).RegistrationCode()
} }
globals.Log.INFO.Printf("Attempting to register with code %s...", regCode) globals.Log.INFO.Printf("Building keys...")
var privKey *rsa.PrivateKey var privKey *rsa.PrivateKey
...@@ -220,8 +220,12 @@ func sessionInitialization() (*id.User, string, *api.Client) { ...@@ -220,8 +220,12 @@ func sessionInitialization() (*id.User, string, *api.Client) {
globals.Log.FATAL.Panicf("%+v", err) globals.Log.FATAL.Panicf("%+v", err)
} }
globals.Log.INFO.Printf("Attempting to register with code %s...", regCode)
errRegister := fmt.Errorf("")
uid = client.GetCurrentUser()
//Attempt to register user with same keys until a success occurs //Attempt to register user with same keys until a success occurs
for errRegister := error(nil); errRegister != nil; { for errRegister != nil {
_, errRegister = client.RegisterWithPermissioning(userId != 0, regCode) _, errRegister = client.RegisterWithPermissioning(userId != 0, regCode)
if errRegister != nil { if errRegister != nil {
globals.Log.FATAL.Panicf("Could Not Register User: %s", globals.Log.FATAL.Panicf("Could Not Register User: %s",
......
...@@ -7,7 +7,6 @@ require ( ...@@ -7,7 +7,6 @@ require (
github.com/golang/protobuf v1.3.2 github.com/golang/protobuf v1.3.2
github.com/google/go-cmp v0.4.0 // indirect github.com/google/go-cmp v0.4.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/smartystreets/assertions v1.0.1 // indirect github.com/smartystreets/assertions v1.0.1 // indirect
...@@ -17,11 +16,10 @@ require ( ...@@ -17,11 +16,10 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.1 github.com/spf13/viper v1.6.1
gitlab.com/elixxir/comms v0.0.0-20200106224700-3bc86e95b8af gitlab.com/elixxir/comms v0.0.0-20200108181118-c0b7fae36425
gitlab.com/elixxir/crypto v0.0.0-20200108005412-8159c60663f9 gitlab.com/elixxir/crypto v0.0.0-20200108005412-8159c60663f9
gitlab.com/elixxir/primitives v0.0.0-20200108174340-0922447aec92 gitlab.com/elixxir/primitives v0.0.0-20200108174340-0922447aec92
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876
golang.org/x/sys v0.0.0-20200107162124-548cf772de50 // indirect golang.org/x/sys v0.0.0-20200107162124-548cf772de50 // indirect
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb // indirect
gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/ini.v1 v1.51.1 // indirect
) )
This diff is collapsed.
...@@ -23,13 +23,12 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo ...@@ -23,13 +23,12 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo
//Put the hash in a message //Put the hash in a message
msg := &mixmessages.NDFHash{Hash: ndfHash} msg := &mixmessages.NDFHash{Hash: ndfHash}
host, ok := comms.GetHost(PermissioningAddrID) regHost, ok := comms.GetHost(PermissioningAddrID)
if !ok { if !ok {
return nil, errors.New("Failed to find permissioning host") return nil, errors.New("Failed to find permissioning host")
} }
//Send the hash to registration //Send the hash to registration
response, err := comms.RequestNdf(host, msg) response, err := comms.RequestNdf(regHost, msg)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("Failed to get ndf from permissioning: %v", err) errMsg := fmt.Sprintf("Failed to get ndf from permissioning: %v", err)
if errMsg == noNDFErr.Error() { if errMsg == noNDFErr.Error() {
...@@ -40,13 +39,11 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo ...@@ -40,13 +39,11 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo
} }
//If there was no error and the response is nil, client's ndf is up-to-date //If there was no error and the response is nil, client's ndf is up-to-date
if response == nil { if response == nil || response.Ndf == nil {
globals.Log.DEBUG.Printf("Client NDF up-to-date") globals.Log.DEBUG.Printf("Client NDF up-to-date")
return nil, nil return nil, nil
} }
//FixMe: use verify instead? Probs need to add a signature to ndf, like in registration's getupdate?
globals.Log.INFO.Printf("Remote NDF: %s", string(response.Ndf)) globals.Log.INFO.Printf("Remote NDF: %s", string(response.Ndf))
//Otherwise pull the ndf out of the response //Otherwise pull the ndf out of the response
......
...@@ -392,7 +392,6 @@ func (s *SessionObj) PushNodeKey(id *id.Node, key NodeKeys) { ...@@ -392,7 +392,6 @@ func (s *SessionObj) PushNodeKey(id *id.Node, key NodeKeys) {
func (s *SessionObj) RegisterPermissioningSignature(sig []byte) error { func (s *SessionObj) RegisterPermissioningSignature(sig []byte) error {
s.LockStorage() s.LockStorage()
defer s.UnlockStorage() defer s.UnlockStorage()
err := s.SetRegState(PermissioningComplete) err := s.SetRegState(PermissioningComplete)
if err != nil { if err != nil {
return errors.Wrap(err, "Could not store permissioning signature") return errors.Wrap(err, "Could not store permissioning signature")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment