Added PairingPayloadSourceConfig to group app client params

This commit is contained in:
Samuel Hawksby-Robinson 2022-08-31 12:58:59 +01:00
parent 32dccf1359
commit ea3ae8b213
3 changed files with 28 additions and 20 deletions

View File

@ -27,12 +27,18 @@ type PayloadManager interface {
EncryptPlain(plaintext []byte) ([]byte, error)
}
// PairingPayloadSourceConfig represents location and access data of the pairing payload
// ONLY available from the application client
type PairingPayloadSourceConfig struct {
KeystorePath string `json:"keystorePath"`
KeyUID string `json:"keyUID"`
Password string `json:"password"`
}
// PairingPayloadManagerConfig represents the initialisation parameters required for a PairingPayloadManager
type PairingPayloadManagerConfig struct {
DB *multiaccounts.Database
KeystorePath string
KeyUID string
Password string
DB *multiaccounts.Database
PairingPayloadSourceConfig
}
// PairingPayloadManager is responsible for the whole lifecycle of a PairingPayload

View File

@ -117,17 +117,21 @@ func (pms *PayloadMarshallerSuite) SetupTest() {
pms.Require().NoError(err)
pms.config1 = &PairingPayloadManagerConfig{
DB: db1,
KeystorePath: keystore1,
KeyUID: keyUID,
Password: password,
DB: db1,
PairingPayloadSourceConfig: PairingPayloadSourceConfig{
KeystorePath: keystore1,
KeyUID: keyUID,
Password: password,
},
}
pms.config2 = &PairingPayloadManagerConfig{
DB: db2,
KeystorePath: keystore2,
KeyUID: keyUID,
Password: password,
DB: db2,
PairingPayloadSourceConfig: PairingPayloadSourceConfig{
KeystorePath: keystore2,
KeyUID: keyUID,
Password: password,
},
}
}

View File

@ -122,7 +122,7 @@ func (s *PairingServer) startSendingAccountData() error {
return s.Start()
}
func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, keystorePath, keyUID, password string) (*PairingServer, error) {
func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, storeConfig PairingPayloadSourceConfig) (*PairingServer, error) {
tlsKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
return nil, err
@ -145,23 +145,21 @@ func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, keystorePath,
}
return NewPairingServer(&Config{
// Things that can be generated
// Things that can be generated, and CANNOT come from the app client (well they could be this is better)
PK: &tlsKey.PublicKey,
EK: AESKey,
Cert: &tlsCert,
Hostname: outboundIP.String(),
// Things that can't be generated, but do come from the client
// Things that can't be generated, but DO come from the app client
Mode: mode,
PairingPayloadManagerConfig: &PairingPayloadManagerConfig{
// Things that can't be generated, but can't come from client
// Things that can't be generated, but DO NOT come from app client
DB: db,
// Things that can't be generated, but do come from the client
KeystorePath: keystorePath,
KeyUID: keyUID,
Password: password,
// Things that can't be generated, but DO come from the app client
PairingPayloadSourceConfig: storeConfig,
},
})
}