Skip to content
Snippets Groups Projects
Commit bbeb82a7 authored by Josh Brooks's avatar Josh Brooks
Browse files

Fixed for noTLS pathway in local Environment

parent 86a30823
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ func (cl *Client) InitNetwork() error {
}
runPermissioning := err != ErrNoPermissioning
if runPermissioning {
err = cl.setupPermissioning()
......
......@@ -85,7 +85,7 @@ func (cl *Client) sendRegistrationMessage(registrationCode string,
if !ok {
return nil, errors.New("Failed to find permissioning host")
}
fmt.Println("in reg, pub key ", publicKeyRSA)
response, err := cl.receptionManager.Comms.
SendRegistrationMessage(host,
&pb.UserRegistration{
......@@ -130,6 +130,7 @@ func (cl *Client) requestNonce(salt, regHash []byte,
if !ok {
return nil, nil, errors.Errorf("Failed to find host with ID %s", gwID.String())
}
nonceResponse, err := cl.receptionManager.Comms.
SendRequestNonceMessage(host,
&pb.NonceRequest{
......@@ -152,7 +153,6 @@ func (cl *Client) requestNonce(salt, regHash []byte,
err := errors.New(fmt.Sprintf("requestNonce: nonceResponse error: %s", nonceResponse.Error))
return nil, nil, err
}
// Use Client keypair to sign Server nonce
return nonceResponse.Nonce, nonceResponse.DHPubKey, nil
......@@ -301,7 +301,6 @@ func (cl *Client) GenerateKeys(rsaPrivKey *rsa.PrivateKey,
cl.session = user.NewSession(cl.storage, usr, pubKey, privKey, cmixPubKey,
cmixPrivKey, e2ePubKey, e2ePrivKey, salt, cmixGrp, e2eGrp, password)
//store the session
return cl.session.StoreSession()
}
......
......@@ -21,7 +21,6 @@ const SaltSize = 256
//RegisterWithPermissioning registers the user and returns the User ID.
// Returns an error if registration fails.
func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string) (*id.User, error) {
//Check the regState is in proper state for registration
if cl.session.GetRegState() != user.KeyGenComplete {
return nil, errors.Errorf("Attempting to register before key generation!")
......@@ -52,7 +51,6 @@ func (cl *Client) RegisterWithPermissioning(preCan bool, registrationCode string
for n, k := range nodeKeyMap {
cl.session.PushNodeKey(&n, k)
}
//update the state
err := cl.session.SetRegState(user.PermissioningComplete)
if err != nil {
......@@ -166,7 +164,6 @@ func (cl *Client) RegisterWithNodes() error {
//Load the registration signature
regSignature := session.GetRegistrationValidationSignature()
var wg sync.WaitGroup
errChan := make(chan error, len(cl.ndf.Gateways))
......@@ -193,7 +190,6 @@ func (cl *Client) RegisterWithNodes() error {
}()
}
}
wg.Wait()
//See if the registration returned errors at all
var errs error
......@@ -250,6 +246,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat
if err != nil {
errMsg := fmt.Sprintf("Register: Failed requesting nonce from gateway: %+v", err)
errorChan <- errors.New(errMsg)
return
}
// Load server DH pubkey
......@@ -261,6 +258,7 @@ func (cl *Client) registerWithNode(index int, salt, registrationValidationSignat
if err != nil {
errMsg := fmt.Sprintf("Register: Unable to confirm nonce: %v", err)
errorChan <- errors.New(errMsg)
return
}
nodeID := cl.topology.GetNodeAtIndex(index)
key := user.NodeKeys{
......@@ -289,6 +287,7 @@ func (cl *Client) registerWithPermissioning(registrationCode string,
return nil, errors.Errorf("Register: Unable to send registration message: %+v", err)
}
}
globals.Log.INFO.Println("Register: successfully passed Registration message")
return regValidSig, nil
......
......@@ -196,7 +196,7 @@ func sessionInitialization() (*id.User, string, *api.Client) {
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
......@@ -220,8 +220,12 @@ func sessionInitialization() (*id.User, string, *api.Client) {
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
for errRegister := error(nil); errRegister != nil; {
for errRegister != nil {
_, errRegister = client.RegisterWithPermissioning(userId != 0, regCode)
if errRegister != nil {
globals.Log.FATAL.Panicf("Could Not Register User: %s",
......
......@@ -23,13 +23,13 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo
//Put the hash in a message
msg := &mixmessages.NDFHash{Hash: ndfHash}
host, ok := comms.GetHost(PermissioningAddrID)
regHost, ok := comms.GetHost(PermissioningAddrID)
if !ok {
return nil, errors.New("Failed to find permissioning host")
}
globals.Log.FATAL.Printf("about to request ndf")
//Send the hash to registration
response, err := comms.RequestNdf(host, msg)
response, err := comms.RequestNdf(regHost, msg)
if err != nil {
errMsg := fmt.Sprintf("Failed to get ndf from permissioning: %v", err)
if errMsg == noNDFErr.Error() {
......@@ -45,8 +45,6 @@ func PollNdf(currentDef *ndf.NetworkDefinition, comms *client.Comms) (*ndf.Netwo
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))
//Otherwise pull the ndf out of the response
......
......@@ -392,7 +392,6 @@ func (s *SessionObj) PushNodeKey(id *id.Node, key NodeKeys) {
func (s *SessionObj) RegisterPermissioningSignature(sig []byte) error {
s.LockStorage()
defer s.UnlockStorage()
err := s.SetRegState(PermissioningComplete)
if err != nil {
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