From e64091c77936f965ee78d3b8a4fe9b5d3ae63b49 Mon Sep 17 00:00:00 2001 From: frank Date: Fri, 17 Feb 2023 21:02:42 +0800 Subject: [PATCH] support passing kdf and node config from receiver when local pairing (#3179) --- VERSION | 2 +- protocol/protobuf/pairing.pb.go | 305 ++++++++++++------------- protocol/protobuf/pairing.proto | 1 - server/pairing/client.go | 18 +- server/pairing/components_test.go | 14 +- server/pairing/payload_manager.go | 164 +++++++++++-- server/pairing/payload_manager_test.go | 36 +-- server/pairing/raw_message_handler.go | 58 ++--- server/pairing/server.go | 18 +- server/pairing/server_pairing_test.go | 16 +- server/pairing/sync_device_test.go | 71 ++++-- 11 files changed, 405 insertions(+), 298 deletions(-) diff --git a/VERSION b/VERSION index 6d24b598d..41ec0ccb0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.131.9 +0.131.10 diff --git a/protocol/protobuf/pairing.pb.go b/protocol/protobuf/pairing.pb.go index 9589f5508..a44250778 100644 --- a/protocol/protobuf/pairing.pb.go +++ b/protocol/protobuf/pairing.pb.go @@ -2435,7 +2435,6 @@ type SyncRawMessage struct { // we need these to be able to login SubAccountsJsonBytes []byte `protobuf:"bytes,2,opt,name=subAccountsJsonBytes,proto3" json:"subAccountsJsonBytes,omitempty"` SettingsJsonBytes []byte `protobuf:"bytes,3,opt,name=settingsJsonBytes,proto3" json:"settingsJsonBytes,omitempty"` - NodeConfigJsonBytes []byte `protobuf:"bytes,4,opt,name=nodeConfigJsonBytes,proto3" json:"nodeConfigJsonBytes,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -2487,13 +2486,6 @@ func (m *SyncRawMessage) GetSettingsJsonBytes() []byte { return nil } -func (m *SyncRawMessage) GetNodeConfigJsonBytes() []byte { - if m != nil { - return m.NodeConfigJsonBytes - } - return nil -} - func init() { proto.RegisterEnum("protobuf.SyncTrustedUser_TrustStatus", SyncTrustedUser_TrustStatus_name, SyncTrustedUser_TrustStatus_value) proto.RegisterEnum("protobuf.SyncVerificationRequest_VerificationStatus", SyncVerificationRequest_VerificationStatus_name, SyncVerificationRequest_VerificationStatus_value) @@ -2539,154 +2531,153 @@ func init() { } var fileDescriptor_d61ab7221f0b5518 = []byte{ - // 2378 bytes of a gzipped FileDescriptorProto + // 2361 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x19, 0x4d, 0x73, 0x1b, 0x49, - 0x75, 0x47, 0x52, 0x2c, 0xe9, 0x49, 0x96, 0x95, 0xb6, 0x77, 0xa3, 0xd8, 0xde, 0x8a, 0x33, 0xcb, - 0xd6, 0x86, 0xaa, 0xc5, 0xbb, 0x95, 0x00, 0x0b, 0x9b, 0x4d, 0xed, 0x2a, 0xb2, 0xd9, 0x38, 0x1f, - 0x8e, 0xab, 0x6d, 0x27, 0x40, 0x51, 0x35, 0xd5, 0x9e, 0x69, 0x5b, 0x8d, 0x47, 0x33, 0xc3, 0x74, - 0xcb, 0x41, 0xdc, 0xb8, 0xf0, 0x03, 0xb8, 0x70, 0xdd, 0x3b, 0x37, 0xaa, 0x96, 0x13, 0x3f, 0x80, - 0x1b, 0x07, 0x2e, 0x54, 0xc1, 0x2f, 0xe0, 0x57, 0x50, 0xfd, 0xba, 0x47, 0x33, 0x23, 0x4b, 0xc6, - 0x29, 0x4e, 0x9c, 0x3c, 0xef, 0xf5, 0x7b, 0xaf, 0x5f, 0xbf, 0xef, 0x27, 0xc3, 0x72, 0xc2, 0x44, - 0x2a, 0xa2, 0xb3, 0xed, 0x24, 0x8d, 0x55, 0x4c, 0x1a, 0xf8, 0xe7, 0x64, 0x7c, 0xba, 0xbe, 0x2a, - 0x27, 0x91, 0xef, 0x49, 0xae, 0x94, 0x88, 0xce, 0xa4, 0x39, 0x5e, 0x77, 0x59, 0x92, 0x84, 0xc2, - 0x67, 0x4a, 0xc4, 0x91, 0x37, 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f, 0x9e, 0x2c, 0xff, 0xac, + 0xb5, 0xf5, 0xc9, 0xa3, 0x5c, 0x91, 0xe3, 0x25, 0x3c, 0x3d, 0xfc, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xa8, 0x44, 0x31, 0x9e, 0x5d, 0x1a, 0x00, 0x00, } diff --git a/protocol/protobuf/pairing.proto b/protocol/protobuf/pairing.proto index 091fd5d4e..01a29bc50 100644 --- a/protocol/protobuf/pairing.proto +++ b/protocol/protobuf/pairing.proto @@ -297,5 +297,4 @@ message SyncRawMessage { // we need these to be able to login bytes subAccountsJsonBytes = 2; bytes settingsJsonBytes = 3; - bytes nodeConfigJsonBytes = 4; } diff --git a/server/pairing/client.go b/server/pairing/client.go index 4f7ac8ffb..cf9fbed14 100644 --- a/server/pairing/client.go +++ b/server/pairing/client.go @@ -5,7 +5,6 @@ import ( "crypto/ecdsa" "crypto/tls" "crypto/x509" - "encoding/json" "encoding/pem" "fmt" "io" @@ -76,7 +75,7 @@ func NewPairingClient(backend *api.GethStatusBackend, c *ConnectionParams, confi return nil, err } - rmpm, err := NewRawMessagePayloadManager(logutils.ZapLogger().Named("Client"), pm.accountPayload, c.aesKey, backend, config.KeystorePath) + rmpm, err := NewRawMessagePayloadManager(logutils.ZapLogger().Named("Client"), pm.accountPayload, c.aesKey, backend, config.GetNodeConfig(), config.GetSettingCurrentNetwork()) if err != nil { return nil, err } @@ -280,19 +279,18 @@ func StartUpPairingClient(backend *api.GethStatusBackend, cs, configJSON string) } func setupClient(backend *api.GethStatusBackend, cs string, configJSON string) (*Client, error) { - var conf PayloadSourceConfig - err := json.Unmarshal([]byte(configJSON), &conf) - if err != nil { - return nil, err - } - ccp := new(ConnectionParams) - err = ccp.FromString(cs) + err := ccp.FromString(cs) if err != nil { return nil, err } - c, err := NewPairingClient(backend, ccp, &AccountPayloadManagerConfig{backend.GetMultiaccountDB(), &conf}) + conf, err := NewPayloadSourceForClient(configJSON, ccp.serverMode) + if err != nil { + return nil, err + } + + c, err := NewPairingClient(backend, ccp, &AccountPayloadManagerConfig{backend.GetMultiaccountDB(), conf}) if err != nil { return nil, err } diff --git a/server/pairing/components_test.go b/server/pairing/components_test.go index 1726a0db2..be6d4fcef 100644 --- a/server/pairing/components_test.go +++ b/server/pairing/components_test.go @@ -114,15 +114,11 @@ func (tpsc *TestPairingServerComponents) SetupPairingServerComponents(t *testing require.NoError(t, err) tpsc.PS, err = NewPairingServer(nil, &Config{ - PK: &tpsc.EphemeralPK.PublicKey, - EK: tpsc.EphemeralAES, - Cert: &tpsc.Cert, - Hostname: tpsc.OutboundIP.String(), - AccountPayloadManagerConfig: &AccountPayloadManagerConfig{ - PayloadSourceConfig: &PayloadSourceConfig{ - KeystorePath: "", - }, - }}) + PK: &tpsc.EphemeralPK.PublicKey, + EK: tpsc.EphemeralAES, + Cert: &tpsc.Cert, + Hostname: tpsc.OutboundIP.String(), + AccountPayloadManagerConfig: &AccountPayloadManagerConfig{}}) require.NoError(t, err) } diff --git a/server/pairing/payload_manager.go b/server/pairing/payload_manager.go index 5ac61e3c3..945262a87 100644 --- a/server/pairing/payload_manager.go +++ b/server/pairing/payload_manager.go @@ -9,20 +9,23 @@ import ( "os" "path/filepath" - "github.com/status-im/status-go/api" - "github.com/golang/protobuf/proto" "go.uber.org/zap" "github.com/status-im/status-go/account/generator" + "github.com/status-im/status-go/api" "github.com/status-im/status-go/eth-node/keystore" "github.com/status-im/status-go/multiaccounts" + "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/protobuf" ) var ( - ErrKeyFileAlreadyExists = errors.New("key file already exists") + ErrKeyFileAlreadyExists = errors.New("key file already exists") + ErrKeyUIDEmptyAsSender = errors.New("keyUID must be provided as sender") + ErrNodeConfigNilAsReceiver = errors.New("node config must be provided as receiver") + ErrPayloadSourceConfigBothSet = errors.New("payloadSourceSenderConfig and payloadSourceReceiverConfig cannot be both set") ) // PayloadManager is the interface for PayloadManagers and wraps the basic functions for fulfilling payload management @@ -49,29 +52,123 @@ type PayloadManager interface { LockPayload() } +type PayloadSourceSenderConfig struct { + KeyUID string `json:"keyUID"` + Password string `json:"password"` +} + +type PayloadSourceReceiverConfig struct { + KDFIterations int `json:"kdfIterations"` + NodeConfig *params.NodeConfig + // this field already exists within params.NodeConfig, but it doesn't support json marshalling, so we need to duplicate it here + RootDataDir string + // corresponding to field current_network from table settings, so that we can override current network from sender + SettingCurrentNetwork string +} + // PayloadSourceConfig represents location and access data of the pairing payload // ONLY available from the application client type PayloadSourceConfig struct { - // required + // required for sender and receiver, there are some different cases: + // 1. for sender, KeystorePath must end with keyUID + // 2. for receiver, KeystorePath must not end with keyUID (because keyUID is not known yet) KeystorePath string `json:"keystorePath"` - // following 2 fields r optional. - // optional cases: - // 1. server mode is Receiving and server side doesn't contain this info - // 2. server mode is Sending and client side doesn't contain this info - // they are required in other cases - KeyUID string `json:"keyUID"` - Password string `json:"password"` - + *PayloadSourceSenderConfig + *PayloadSourceReceiverConfig // Timeout the number of milliseconds after which the pairing server will automatically terminate Timeout uint `json:"timeout"` } +type payloadSourceUnmarshalCallback func(conf *PayloadSourceConfig) (*PayloadSourceConfig, error) + +func NewPayloadSourceForClient(configJSON string, mode Mode) (*PayloadSourceConfig, error) { + return unmarshalPayloadSourceConfig(configJSON, func(conf *PayloadSourceConfig) (*PayloadSourceConfig, error) { + if mode == Sending && conf.NodeConfig == nil { + return nil, ErrNodeConfigNilAsReceiver + } + if mode == Receiving && conf.KeyUID == "" { + return nil, ErrKeyUIDEmptyAsSender + } + return updateRootDataDirToNodeConfig(conf) + }) +} + +func NewPayloadSourceForServer(configJSON string, mode Mode) (*PayloadSourceConfig, error) { + return unmarshalPayloadSourceConfig(configJSON, func(conf *PayloadSourceConfig) (*PayloadSourceConfig, error) { + if mode == Sending && conf.KeyUID == "" { + return nil, ErrKeyUIDEmptyAsSender + } + if mode == Receiving && conf.NodeConfig == nil { + return nil, ErrNodeConfigNilAsReceiver + } + return updateRootDataDirToNodeConfig(conf) + }) +} + +func updateRootDataDirToNodeConfig(conf *PayloadSourceConfig) (*PayloadSourceConfig, error) { + if conf.PayloadSourceReceiverConfig != nil && conf.PayloadSourceReceiverConfig.NodeConfig != nil { + conf.NodeConfig.RootDataDir = conf.RootDataDir + } + return conf, nil +} + +func unmarshalPayloadSourceConfig(configJSON string, successCallback payloadSourceUnmarshalCallback) (*PayloadSourceConfig, error) { + var conf = PayloadSourceConfig{} + err := json.Unmarshal([]byte(configJSON), &conf) + if err != nil { + return nil, err + } + return successCallback(&conf) +} + // AccountPayloadManagerConfig represents the initialisation parameters required for a AccountPayloadManager type AccountPayloadManagerConfig struct { DB *multiaccounts.Database *PayloadSourceConfig } +func (a *AccountPayloadManagerConfig) GetNodeConfig() *params.NodeConfig { + if a.PayloadSourceConfig != nil && a.PayloadSourceConfig.PayloadSourceReceiverConfig != nil { + return a.NodeConfig + } + return nil +} + +func (a *AccountPayloadManagerConfig) GetSettingCurrentNetwork() string { + if a.PayloadSourceConfig != nil && a.PayloadSourceConfig.PayloadSourceReceiverConfig != nil { + return a.SettingCurrentNetwork + } + return "" +} + +func (a *AccountPayloadManagerConfig) GetPayloadSourceSenderConfig() *PayloadSourceSenderConfig { + if a.PayloadSourceConfig != nil && a.PayloadSourceConfig.PayloadSourceSenderConfig != nil { + return a.PayloadSourceSenderConfig + } + return nil +} + +func (a *AccountPayloadManagerConfig) GetPayloadSourceReceiverConfig() *PayloadSourceReceiverConfig { + if a.PayloadSourceConfig != nil && a.PayloadSourceConfig.PayloadSourceReceiverConfig != nil { + return a.PayloadSourceReceiverConfig + } + return nil +} + +func (a *AccountPayloadManagerConfig) GetKeystorePath() string { + if a.PayloadSourceConfig != nil { + return a.KeystorePath + } + return "" +} + +func (a *AccountPayloadManagerConfig) GetTimeout() uint { + if a.PayloadSourceConfig != nil { + return a.Timeout + } + return 0 +} + // AccountPayloadManager is responsible for the whole lifecycle of a AccountPayload type AccountPayloadManager struct { logger *zap.Logger @@ -93,13 +190,17 @@ func NewAccountPayloadManager(aesKey []byte, config *AccountPayloadManagerConfig // A new SHARED AccountPayload p := new(AccountPayload) + accountPayloadRepository, err := NewAccountPayloadRepository(p, config) + if err != nil { + return nil, err + } return &AccountPayloadManager{ logger: l, accountPayload: p, PayloadEncryptionManager: pem, accountPayloadMarshaller: NewPairingPayloadMarshaller(p, l), - payloadRepository: NewAccountPayloadRepository(p, config), + payloadRepository: accountPayloadRepository, }, nil } @@ -357,22 +458,32 @@ type AccountPayloadRepository struct { multiaccountsDB *multiaccounts.Database keystorePath, keyUID string + + kdfIterations int } -func NewAccountPayloadRepository(p *AccountPayload, config *AccountPayloadManagerConfig) *AccountPayloadRepository { +func NewAccountPayloadRepository(p *AccountPayload, config *AccountPayloadManagerConfig) (*AccountPayloadRepository, error) { ppr := &AccountPayloadRepository{ AccountPayload: p, } if config == nil { - return ppr + return ppr, nil } ppr.multiaccountsDB = config.DB - ppr.keystorePath = config.KeystorePath - ppr.keyUID = config.KeyUID - ppr.password = config.Password - return ppr + + if config.GetPayloadSourceSenderConfig() != nil && config.GetPayloadSourceReceiverConfig() != nil { + return nil, ErrPayloadSourceConfigBothSet + } + if config.GetPayloadSourceSenderConfig() != nil { + ppr.keyUID = config.KeyUID + ppr.password = config.Password + } else if config.GetPayloadSourceReceiverConfig() != nil { + ppr.kdfIterations = config.KDFIterations + } + ppr.keystorePath = config.GetKeystorePath() + return ppr, nil } func (apr *AccountPayloadRepository) LoadFromSource() error { @@ -515,6 +626,7 @@ func (apr *AccountPayloadRepository) storeKeys(keyStorePath string) error { } func (apr *AccountPayloadRepository) storeMultiAccount() error { + apr.multiaccount.KDFIterations = apr.kdfIterations return apr.multiaccountsDB.SaveAccount(*apr.multiaccount) } @@ -526,7 +638,7 @@ type RawMessagePayloadManager struct { payloadRepository *RawMessageRepository } -func NewRawMessagePayloadManager(logger *zap.Logger, accountPayload *AccountPayload, aesKey []byte, backend *api.GethStatusBackend, keystorePath string) (*RawMessagePayloadManager, error) { +func NewRawMessagePayloadManager(logger *zap.Logger, accountPayload *AccountPayload, aesKey []byte, backend *api.GethStatusBackend, nodeConfig *params.NodeConfig, settingCurrentNetwork string) (*RawMessagePayloadManager, error) { l := logger.Named("RawMessagePayloadManager") pem, err := NewPayloadEncryptionManager(aesKey, l) if err != nil { @@ -536,7 +648,7 @@ func NewRawMessagePayloadManager(logger *zap.Logger, accountPayload *AccountPayl logger: l, accountPayload: accountPayload, PayloadEncryptionManager: pem, - payloadRepository: NewRawMessageRepository(backend, keystorePath, accountPayload), + payloadRepository: NewRawMessageRepository(backend, accountPayload, nodeConfig, settingCurrentNetwork), }, nil } @@ -565,16 +677,18 @@ func (r *RawMessagePayloadManager) ResetPayload() { type RawMessageRepository struct { payload []byte syncRawMessageHandler *SyncRawMessageHandler - keystorePath string accountPayload *AccountPayload + nodeConfig *params.NodeConfig + settingCurrentNetwork string } -func NewRawMessageRepository(backend *api.GethStatusBackend, keystorePath string, accountPayload *AccountPayload) *RawMessageRepository { +func NewRawMessageRepository(backend *api.GethStatusBackend, accountPayload *AccountPayload, config *params.NodeConfig, settingCurrentNetwork string) *RawMessageRepository { return &RawMessageRepository{ syncRawMessageHandler: NewSyncRawMessageHandler(backend), - keystorePath: keystorePath, payload: make([]byte, 0), accountPayload: accountPayload, + nodeConfig: config, + settingCurrentNetwork: settingCurrentNetwork, } } @@ -596,5 +710,5 @@ func (r *RawMessageRepository) StoreToSource() error { if accountPayload == nil || accountPayload.multiaccount == nil { return fmt.Errorf("no known multiaccount when storing raw messages") } - return r.syncRawMessageHandler.HandleRawMessage(accountPayload.multiaccount, accountPayload.password, r.keystorePath, r.payload) + return r.syncRawMessageHandler.HandleRawMessage(accountPayload.multiaccount, accountPayload.password, r.nodeConfig, r.settingCurrentNetwork, r.payload) } diff --git a/server/pairing/payload_manager_test.go b/server/pairing/payload_manager_test.go index 776315cb7..9ae4acc7b 100644 --- a/server/pairing/payload_manager_test.go +++ b/server/pairing/payload_manager_test.go @@ -136,8 +136,10 @@ func (pms *PayloadMarshallerSuite) SetupTest() { DB: db1, PayloadSourceConfig: &PayloadSourceConfig{ KeystorePath: keystore1, - KeyUID: keyUID, - Password: password, + PayloadSourceSenderConfig: &PayloadSourceSenderConfig{ + KeyUID: keyUID, + Password: password, + }, }, } @@ -145,8 +147,10 @@ func (pms *PayloadMarshallerSuite) SetupTest() { DB: db2, PayloadSourceConfig: &PayloadSourceConfig{ KeystorePath: keystore2, - KeyUID: keyUID, - Password: password, + PayloadSourceSenderConfig: &PayloadSourceSenderConfig{ + KeyUID: keyUID, + Password: password, + }, }, } } @@ -160,8 +164,9 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_LoadPayloads() { pp := new(AccountPayload) // Make and LoadFromSource PairingPayloadRepository 1 - ppr := NewAccountPayloadRepository(pp, pms.config1) - err := ppr.LoadFromSource() + ppr, err := NewAccountPayloadRepository(pp, pms.config1) + pms.Require().NoError(err) + err = ppr.LoadFromSource() pms.Require().NoError(err) // TEST PairingPayloadRepository 1 LoadFromSource() @@ -193,8 +198,9 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_MarshalToProtobuf() { pp := new(AccountPayload) // Make and LoadFromSource PairingPayloadRepository 1 - ppr := NewAccountPayloadRepository(pp, pms.config1) - err := ppr.LoadFromSource() + ppr, err := NewAccountPayloadRepository(pp, pms.config1) + pms.Require().NoError(err) + err = ppr.LoadFromSource() pms.Require().NoError(err) // Make and Load PairingPayloadMarshaller 1 @@ -222,8 +228,9 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_UnmarshalProtobuf() { pp := new(AccountPayload) // Make and LoadFromSource PairingPayloadRepository 1 - ppr := NewAccountPayloadRepository(pp, pms.config1) - err := ppr.LoadFromSource() + ppr, err := NewAccountPayloadRepository(pp, pms.config1) + pms.Require().NoError(err) + err = ppr.LoadFromSource() pms.Require().NoError(err) // Make and Load PairingPayloadMarshaller 1 @@ -275,8 +282,9 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_StorePayloads() { pp := new(AccountPayload) // Make and LoadFromSource PairingPayloadRepository 1 - ppr := NewAccountPayloadRepository(pp, pms.config1) - err := ppr.LoadFromSource() + ppr, err := NewAccountPayloadRepository(pp, pms.config1) + pms.Require().NoError(err) + err = ppr.LoadFromSource() pms.Require().NoError(err) // Make and Load PairingPayloadMarshaller 1 @@ -295,8 +303,8 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_StorePayloads() { pms.Require().NoError(err) // Make and Load PairingPayloadRepository 2 - ppr2 := NewAccountPayloadRepository(pp2, pms.config2) - + ppr2, err := NewAccountPayloadRepository(pp2, pms.config2) + require.NoError(pms.T(), err) err = ppr2.StoreToSource() pms.Require().NoError(err) diff --git a/server/pairing/raw_message_handler.go b/server/pairing/raw_message_handler.go index 7d9f08f37..f50379db0 100644 --- a/server/pairing/raw_message_handler.go +++ b/server/pairing/raw_message_handler.go @@ -5,17 +5,13 @@ import ( "encoding/json" "fmt" "path/filepath" - "strings" - - "github.com/google/uuid" - - "github.com/status-im/status-go/multiaccounts/settings" "github.com/golang/protobuf/proto" "github.com/status-im/status-go/api" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/protobuf" ) @@ -81,45 +77,26 @@ func (s *SyncRawMessageHandler) PrepareRawMessage(keyUID string) ([]byte, error) return nil, err } - nodeConfig := s.backend.StatusNode().Config() - dataDir := nodeConfig.DataDir - disabledDataDir := nodeConfig.ShhextConfig.BackupDisabledDataDir - defer func() { - // restore data dir - nodeConfig.DataDir = dataDir - nodeConfig.ShhextConfig.BackupDisabledDataDir = disabledDataDir - }() - nodeConfig.DataDir = strings.Replace(dataDir, nodeConfig.RootDataDir, "", 1) - nodeConfig.ShhextConfig.BackupDisabledDataDir = strings.Replace(disabledDataDir, nodeConfig.RootDataDir, "", 1) - if syncRawMessage.NodeConfigJsonBytes, err = json.Marshal(nodeConfig); err != nil { - return nil, err - } return proto.Marshal(syncRawMessage) } -func (s *SyncRawMessageHandler) HandleRawMessage(account *multiaccounts.Account, password, keystorePath string, payload []byte) error { - rawMessages, subAccounts, setting, nodeConfig, err := s.unmarshalSyncRawMessage(payload) +func (s *SyncRawMessageHandler) HandleRawMessage(account *multiaccounts.Account, password string, nodeConfig *params.NodeConfig, settingCurrentNetwork string, payload []byte) error { + rawMessages, subAccounts, setting, err := s.unmarshalSyncRawMessage(payload) if err != nil { return err } - newKeystoreDir := filepath.Join(keystorePath, account.KeyUID) + s.backend.UpdateRootDataDir(nodeConfig.RootDataDir) + // because client don't know keyUID before received data, we need help client to update keystore dir + newKeystoreDir := filepath.Join(nodeConfig.KeyStoreDir, account.KeyUID) + nodeConfig.KeyStoreDir = newKeystoreDir accountManager := s.backend.AccountManager() - err = accountManager.InitKeystore(newKeystoreDir) + err = accountManager.InitKeystore(filepath.Join(nodeConfig.RootDataDir, newKeystoreDir)) if err != nil { return err } - - //TODO root data dir should be passed from client, following is a temporary solution - nodeConfig.RootDataDir = filepath.Dir(keystorePath) - nodeConfig.KeyStoreDir = filepath.Join(filepath.Base(keystorePath), account.KeyUID) - installationID := uuid.New().String() - nodeConfig.ShhextConfig.InstallationID = installationID - setting.InstallationID = installationID - - //TODO we need a better way(e.g. pass from client when doing local pair?) to handle this, following is a temporary solution - nodeConfig.LogDir = nodeConfig.RootDataDir - nodeConfig.LogFile = "geth.log" + setting.InstallationID = nodeConfig.ShhextConfig.InstallationID + setting.CurrentNetwork = settingCurrentNetwork err = s.backend.StartNodeWithAccountAndInitialConfig(*account, password, *setting, nodeConfig, subAccounts) if err != nil { @@ -133,28 +110,23 @@ func (s *SyncRawMessageHandler) HandleRawMessage(account *multiaccounts.Account, return messenger.HandleSyncRawMessages(rawMessages) } -func (s *SyncRawMessageHandler) unmarshalSyncRawMessage(payload []byte) ([]*protobuf.RawMessage, []*accounts.Account, *settings.Settings, *params.NodeConfig, error) { +func (s *SyncRawMessageHandler) unmarshalSyncRawMessage(payload []byte) ([]*protobuf.RawMessage, []*accounts.Account, *settings.Settings, error) { var ( syncRawMessage protobuf.SyncRawMessage subAccounts []*accounts.Account setting *settings.Settings - nodeConfig *params.NodeConfig ) err := proto.Unmarshal(payload, &syncRawMessage) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } err = json.Unmarshal(syncRawMessage.SubAccountsJsonBytes, &subAccounts) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } err = json.Unmarshal(syncRawMessage.SettingsJsonBytes, &setting) if err != nil { - return nil, nil, nil, nil, err + return nil, nil, nil, err } - err = json.Unmarshal(syncRawMessage.NodeConfigJsonBytes, &nodeConfig) - if err != nil { - return nil, nil, nil, nil, err - } - return syncRawMessage.RawMessages, subAccounts, setting, nodeConfig, nil + return syncRawMessage.RawMessages, subAccounts, setting, nil } diff --git a/server/pairing/server.go b/server/pairing/server.go index 4115531ee..c3e35cb9e 100644 --- a/server/pairing/server.go +++ b/server/pairing/server.go @@ -5,17 +5,15 @@ import ( "crypto/elliptic" "crypto/rand" "crypto/tls" - "encoding/json" "fmt" "net" "time" - "github.com/status-im/status-go/api" - "github.com/status-im/status-go/server" - "github.com/gorilla/sessions" + "github.com/status-im/status-go/api" "github.com/status-im/status-go/logutils" + "github.com/status-im/status-go/server" ) type Server struct { @@ -61,7 +59,8 @@ func makeCookieStore() (*sessions.CookieStore, error) { // NewPairingServer returns a *Server init from the given *Config func NewPairingServer(backend *api.GethStatusBackend, config *Config) (*Server, error) { logger := logutils.ZapLogger().Named("Server") - pm, err := NewAccountPayloadManager(config.EK, config.AccountPayloadManagerConfig, logger) + accountPayloadManagerConfig := config.AccountPayloadManagerConfig + pm, err := NewAccountPayloadManager(config.EK, accountPayloadManagerConfig, logger) if err != nil { return nil, err } @@ -71,7 +70,7 @@ func NewPairingServer(backend *api.GethStatusBackend, config *Config) (*Server, return nil, err } - rmpm, err := NewRawMessagePayloadManager(logger, pm.accountPayload, config.EK, backend, config.KeystorePath) + rmpm, err := NewRawMessagePayloadManager(logger, pm.accountPayload, config.EK, backend, accountPayloadManagerConfig.GetNodeConfig(), accountPayloadManagerConfig.GetSettingCurrentNetwork()) if err != nil { return nil, err } @@ -89,7 +88,7 @@ func NewPairingServer(backend *api.GethStatusBackend, config *Config) (*Server, cookieStore: cs, rawMessagePayloadManager: rmpm, } - s.SetTimeout(config.Timeout) + s.SetTimeout(config.GetTimeout()) return s, nil } @@ -189,13 +188,12 @@ func MakeFullPairingServer(backend *api.GethStatusBackend, mode Mode, storeConfi // StartUpPairingServer generates a Server, starts the pairing server in the correct mode // and returns the ConnectionParams string to allow a Client to make a successful connection. func StartUpPairingServer(backend *api.GethStatusBackend, mode Mode, configJSON string) (string, error) { - var conf PayloadSourceConfig - err := json.Unmarshal([]byte(configJSON), &conf) + conf, err := NewPayloadSourceForServer(configJSON, mode) if err != nil { return "", err } - ps, err := MakeFullPairingServer(backend, mode, &conf) + ps, err := MakeFullPairingServer(backend, mode, conf) if err != nil { return "", err } diff --git a/server/pairing/server_pairing_test.go b/server/pairing/server_pairing_test.go index e17a0a48f..d3cc854d2 100644 --- a/server/pairing/server_pairing_test.go +++ b/server/pairing/server_pairing_test.go @@ -74,6 +74,10 @@ func (s *PairingServerSuite) TestMultiTimeout() { s.Require().False(s.PS.IsRunning()) } +func newAccountPayloadManagerConfig() *AccountPayloadManagerConfig { + return &AccountPayloadManagerConfig{} +} + func (s *PairingServerSuite) TestPairingServer_StartPairing() { // Replace PairingServer.PayloadManager with a MockEncryptOnlyPayloadManager pm, err := NewMockEncryptOnlyPayloadManager(s.EphemeralAES) @@ -101,9 +105,7 @@ func (s *PairingServerSuite) TestPairingServer_StartPairing() { err = ccp.FromString(qr) s.Require().NoError(err) - c, err := NewPairingClient(nil, ccp, &AccountPayloadManagerConfig{ - PayloadSourceConfig: &PayloadSourceConfig{KeystorePath: ""}, - }) + c, err := NewPairingClient(nil, ccp, newAccountPayloadManagerConfig()) s.Require().NoError(err) // Compare cert values @@ -164,9 +166,7 @@ func (s *PairingServerSuite) sendingSetup() *Client { err = ccp.FromString(qr) s.Require().NoError(err) - c, err := NewPairingClient(nil, ccp, &AccountPayloadManagerConfig{ - PayloadSourceConfig: &PayloadSourceConfig{KeystorePath: ""}, - }) + c, err := NewPairingClient(nil, ccp, newAccountPayloadManagerConfig()) s.Require().NoError(err) // Replace PairingClient.PayloadManager with a MockEncryptOnlyPayloadManager @@ -277,9 +277,7 @@ func (s *PairingServerSuite) TestGetOutboundIPWithFullServerE2e() { err = ccp.FromString(qr) s.Require().NoError(err) - c, err := NewPairingClient(nil, ccp, &AccountPayloadManagerConfig{ - PayloadSourceConfig: &PayloadSourceConfig{KeystorePath: ""}, - }) + c, err := NewPairingClient(nil, ccp, newAccountPayloadManagerConfig()) s.Require().NoError(err) thing, err := makeThingToSay() diff --git a/server/pairing/sync_device_test.go b/server/pairing/sync_device_test.go index d8529ee36..bd646d8a5 100644 --- a/server/pairing/sync_device_test.go +++ b/server/pairing/sync_device_test.go @@ -3,7 +3,6 @@ package pairing import ( "context" "encoding/json" - "fmt" "os" "path/filepath" "testing" @@ -33,6 +32,8 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa const keystoreDir = "keystore" +const currentNetwork = "mainnet_rpc" + func TestSyncDeviceSuite(t *testing.T) { suite.Run(t, new(SyncDeviceSuite)) } @@ -85,7 +86,7 @@ func (s *SyncDeviceSuite) prepareBackendWithAccount(tmpdir string) *api.GethStat account.Name = settings.Name - nodeConfig, err := defaultNodeConfig(tmpdir, settings.InstallationID, account.KeyUID) + nodeConfig, err := defaultNodeConfig(settings.InstallationID, account.KeyUID) require.NoError(s.T(), err) walletDerivedAccount := derivedAddresses[pathDefaultWallet] @@ -135,9 +136,22 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsSender() { require.NoError(s.T(), err) err = serverBackend.OpenAccounts() require.NoError(s.T(), err) - serverKeystorePath := filepath.Join(serverTmpDir, keystoreDir) - configJSON := fmt.Sprintf(`{"KeystorePath":"%s"}`, serverKeystorePath) - cs, err := StartUpPairingServer(serverBackend, Receiving, configJSON) + serverNodeConfig, err := defaultNodeConfig(uuid.New().String(), "") + require.NoError(s.T(), err) + expectedKDFIterations := 1024 + serverKeystoreDir := filepath.Join(serverTmpDir, keystoreDir) + serverPayloadSourceConfig := PayloadSourceConfig{ + KeystorePath: serverKeystoreDir, + PayloadSourceReceiverConfig: &PayloadSourceReceiverConfig{ + KDFIterations: expectedKDFIterations, + NodeConfig: serverNodeConfig, + RootDataDir: serverTmpDir, + SettingCurrentNetwork: currentNetwork, + }, + } + serverConfigBytes, err := json.Marshal(serverPayloadSourceConfig) + require.NoError(s.T(), err) + cs, err := StartUpPairingServer(serverBackend, Receiving, string(serverConfigBytes)) require.NoError(s.T(), err) // generate some data for the client @@ -151,14 +165,16 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsSender() { clientActiveAccount, err := clientBackend.GetActiveAccount() require.NoError(s.T(), err) clientKeystorePath := filepath.Join(clientTmpDir, keystoreDir, clientActiveAccount.KeyUID) - var config = PayloadSourceConfig{ + clientPayloadSourceConfig := PayloadSourceConfig{ KeystorePath: clientKeystorePath, - KeyUID: clientActiveAccount.KeyUID, - Password: s.password, + PayloadSourceSenderConfig: &PayloadSourceSenderConfig{ + KeyUID: clientActiveAccount.KeyUID, + Password: s.password, + }, } - configBytes, err := json.Marshal(config) + clientConfigBytes, err := json.Marshal(clientPayloadSourceConfig) require.NoError(s.T(), err) - err = StartUpPairingClient(clientBackend, cs, string(configBytes)) + err = StartUpPairingClient(clientBackend, cs, string(clientConfigBytes)) require.NoError(s.T(), err) require.NoError(s.T(), clientBackend.Logout()) @@ -171,6 +187,7 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsSender() { serverActiveAccount, err := serverBackend.GetActiveAccount() require.NoError(s.T(), err) require.Equal(s.T(), serverActiveAccount.Name, clientActiveAccount.Name) + require.Equal(s.T(), serverActiveAccount.KDFIterations, expectedKDFIterations) } func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsReceiver() { @@ -188,8 +205,10 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsReceiver() { serverKeystorePath := filepath.Join(serverTmpDir, keystoreDir, serverActiveAccount.KeyUID) var config = PayloadSourceConfig{ KeystorePath: serverKeystorePath, - KeyUID: serverActiveAccount.KeyUID, - Password: s.password, + PayloadSourceSenderConfig: &PayloadSourceSenderConfig{ + KeyUID: serverActiveAccount.KeyUID, + Password: s.password, + }, } configBytes, err := json.Marshal(config) require.NoError(s.T(), err) @@ -208,9 +227,22 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsReceiver() { require.NoError(s.T(), err) err = clientBackend.OpenAccounts() require.NoError(s.T(), err) - clientKeystorePath := filepath.Join(clientTmpDir, keystoreDir) - configJSON := fmt.Sprintf(`{"KeystorePath":"%s"}`, clientKeystorePath) - err = StartUpPairingClient(clientBackend, cs, configJSON) + clientNodeConfig, err := defaultNodeConfig(uuid.New().String(), "") + require.NoError(s.T(), err) + expectedKDFIterations := 2048 + clientKeystoreDir := filepath.Join(clientTmpDir, keystoreDir) + clientPayloadSourceConfig := PayloadSourceConfig{ + KeystorePath: clientKeystoreDir, + PayloadSourceReceiverConfig: &PayloadSourceReceiverConfig{ + KDFIterations: expectedKDFIterations, + NodeConfig: clientNodeConfig, + RootDataDir: clientTmpDir, + SettingCurrentNetwork: currentNetwork, + }, + } + clientConfigBytes, err := json.Marshal(clientPayloadSourceConfig) + require.NoError(s.T(), err) + err = StartUpPairingClient(clientBackend, cs, string(clientConfigBytes)) require.NoError(s.T(), err) require.NoError(s.T(), serverBackend.Logout()) @@ -224,6 +256,7 @@ func (s *SyncDeviceSuite) TestPairingSyncDeviceClientAsReceiver() { clientActiveAccount, err := clientBackend.GetActiveAccount() require.NoError(s.T(), err) require.Equal(s.T(), serverActiveAccount.Name, clientActiveAccount.Name) + require.Equal(s.T(), clientActiveAccount.KDFIterations, expectedKDFIterations) } func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) { @@ -273,18 +306,18 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive } networkRawMessage := json.RawMessage(networksJSON) settings.Networks = &networkRawMessage - settings.CurrentNetwork = "mainnet_rpc" + settings.CurrentNetwork = currentNetwork return settings, nil } -func defaultNodeConfig(tmpdir, installationID, keyUID string) (*params.NodeConfig, error) { +func defaultNodeConfig(installationID, keyUID string) (*params.NodeConfig, error) { // Set mainnet nodeConfig := ¶ms.NodeConfig{} nodeConfig.NetworkID = 1 nodeConfig.LogLevel = "ERROR" - nodeConfig.DataDir = filepath.Join(tmpdir, "ethereum/mainnet_rpc") - nodeConfig.KeyStoreDir = filepath.Join(tmpdir, keystoreDir, keyUID) + nodeConfig.DataDir = filepath.Join("ethereum/mainnet_rpc") + nodeConfig.KeyStoreDir = filepath.Join(keystoreDir, keyUID) nodeConfig.UpstreamConfig = params.UpstreamRPCConfig{ Enabled: true, URL: "https://mainnet.infura.io/v3/800c641949d64d768a5070a1b0511938",