Skip to content
Snippets Groups Projects
Commit ed09e127 authored by Jake Taylor's avatar Jake Taylor
Browse files

fix protouser cmd initialization path

parent 07153b57
No related branches found
No related tags found
1 merge request!510Release
......@@ -589,7 +589,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
jww.FATAL.Panicf("%v", err)
}
err = xxdk.NewProtoClient_Unsafe(string(ndfJSON), storeDir,
knownReception, err = xxdk.NewProtoClient_Unsafe(string(ndfJSON), storeDir,
pass, protoUser)
} else if userIDprefix != "" {
err = xxdk.NewVanityClient(string(ndfJSON), storeDir,
......
......@@ -163,14 +163,14 @@ func OpenCmix(storageDir string, password []byte,
// predefined cryptographic which defines a user. This is designed for some
// specific deployment procedures and is generally unsafe.
func NewProtoClient_Unsafe(ndfJSON, storageDir string, password []byte,
protoUser *user.Proto) error {
protoUser *user.Proto) (ReceptionIdentity, error) {
jww.INFO.Printf("NewProtoClient_Unsafe")
usr := user.NewUserFromProto(protoUser)
def, err := ParseNDF(ndfJSON)
if err != nil {
return err
return ReceptionIdentity{}, err
}
cmixGrp, e2eGrp := DecodeGroups(def)
......@@ -178,7 +178,13 @@ func NewProtoClient_Unsafe(ndfJSON, storageDir string, password []byte,
storageSess, err := CheckVersionAndSetupStorage(def, storageDir,
password, usr, cmixGrp, e2eGrp, protoUser.RegCode)
if err != nil {
return err
return ReceptionIdentity{}, err
}
identity, err := buildReceptionIdentity(protoUser.ReceptionID, protoUser.ReceptionSalt,
protoUser.ReceptionRSA, e2eGrp, protoUser.E2eDhPrivateKey)
if err != nil {
return ReceptionIdentity{}, err
}
storageSess.SetReceptionRegistrationValidationSignature(
......@@ -192,10 +198,10 @@ func NewProtoClient_Unsafe(ndfJSON, storageDir string, password []byte,
err = storageSess.ForwardRegistrationStatus(
storage.PermissioningComplete)
if err != nil {
return err
return ReceptionIdentity{}, err
}
return nil
return identity, nil
}
// LoadCmix initializes a Cmix object from existing storage and starts the network
......
......@@ -98,8 +98,8 @@ func LoginLegacy(client *Cmix, params E2EParams, callbacks AuthCallbacks) (
return nil, err
}
m.e2eIdentity, err = buildReceptionIdentity(userInfo, m.e2e.GetGroup(),
m.e2e.GetHistoricalDHPrivkey())
m.e2eIdentity, err = buildReceptionIdentity(userInfo.ReceptionID, userInfo.ReceptionSalt,
userInfo.ReceptionRSA, m.e2e.GetGroup(), m.e2e.GetHistoricalDHPrivkey())
return m, err
}
......@@ -157,7 +157,7 @@ func LoginWithProtoClient(storageDir string, password []byte,
return nil, err
}
err = NewProtoClient_Unsafe(newBaseNdf, storageDir, password,
receptionIdentity, err := NewProtoClient_Unsafe(newBaseNdf, storageDir, password,
protoUser)
if err != nil {
return nil, err
......@@ -174,10 +174,6 @@ func LoginWithProtoClient(storageDir string, password []byte,
if err != nil {
return nil, err
}
userInfo := user.NewUserFromProto(protoUser)
receptionIdentity, err := buildReceptionIdentity(userInfo,
c.GetStorage().GetE2EGroup(), protoUser.E2eDhPrivateKey)
return Login(c, callbacks, receptionIdentity, e2eParams)
}
......
......@@ -176,9 +176,10 @@ func (r ReceptionIdentity) GetContact() contact.Contact {
// buildReceptionIdentity creates a new ReceptionIdentity
// from the given user.Info
func buildReceptionIdentity(userInfo user.Info, e2eGrp *cyclic.Group, dHPrivkey *cyclic.Int) (ReceptionIdentity, error) {
saltCopy := make([]byte, len(userInfo.ReceptionSalt))
copy(saltCopy, userInfo.ReceptionSalt)
func buildReceptionIdentity(receptionId *id.ID, receptionSalt []byte, receptionRsa *rsa.PrivateKey,
e2eGrp *cyclic.Group, dHPrivkey *cyclic.Int) (ReceptionIdentity, error) {
saltCopy := make([]byte, len(receptionSalt))
copy(saltCopy, receptionSalt)
grp, err := e2eGrp.MarshalJSON()
if err != nil {
......@@ -190,8 +191,8 @@ func buildReceptionIdentity(userInfo user.Info, e2eGrp *cyclic.Group, dHPrivkey
}
return ReceptionIdentity{
ID: userInfo.ReceptionID.DeepCopy(),
RSAPrivatePem: rsa.CreatePrivateKeyPem(userInfo.ReceptionRSA),
ID: receptionId.DeepCopy(),
RSAPrivatePem: rsa.CreatePrivateKeyPem(receptionRsa),
Salt: saltCopy,
DHKeyPrivate: privKey,
E2eGrp: grp,
......
......@@ -76,14 +76,15 @@ func NewPrecannedClient(precannedID uint, defJSON, storageDir string,
dhPrivKey := generatePrecanDHKeypair(precannedID, e2eGrp)
protoUser := CreatePrecannedUser(precannedID, rngStream)
identity, err := buildReceptionIdentity(protoUser, e2eGrp, dhPrivKey)
userInfo := CreatePrecannedUser(precannedID, rngStream)
identity, err := buildReceptionIdentity(userInfo.ReceptionID, userInfo.ReceptionSalt,
userInfo.ReceptionRSA, e2eGrp, dhPrivKey)
if err != nil {
return ReceptionIdentity{}, err
}
store, err := CheckVersionAndSetupStorage(def, storageDir, password,
protoUser, cmixGrp, e2eGrp, "")
userInfo, cmixGrp, e2eGrp, "")
if err != nil {
return ReceptionIdentity{}, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment