Added PairingPayloadSourceConfig to group app client params
This commit is contained in:
parent
32dccf1359
commit
ea3ae8b213
|
@ -27,12 +27,18 @@ type PayloadManager interface {
|
||||||
EncryptPlain(plaintext []byte) ([]byte, error)
|
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
|
// PairingPayloadManagerConfig represents the initialisation parameters required for a PairingPayloadManager
|
||||||
type PairingPayloadManagerConfig struct {
|
type PairingPayloadManagerConfig struct {
|
||||||
DB *multiaccounts.Database
|
DB *multiaccounts.Database
|
||||||
KeystorePath string
|
PairingPayloadSourceConfig
|
||||||
KeyUID string
|
|
||||||
Password string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PairingPayloadManager is responsible for the whole lifecycle of a PairingPayload
|
// PairingPayloadManager is responsible for the whole lifecycle of a PairingPayload
|
||||||
|
|
|
@ -118,16 +118,20 @@ func (pms *PayloadMarshallerSuite) SetupTest() {
|
||||||
|
|
||||||
pms.config1 = &PairingPayloadManagerConfig{
|
pms.config1 = &PairingPayloadManagerConfig{
|
||||||
DB: db1,
|
DB: db1,
|
||||||
|
PairingPayloadSourceConfig: PairingPayloadSourceConfig{
|
||||||
KeystorePath: keystore1,
|
KeystorePath: keystore1,
|
||||||
KeyUID: keyUID,
|
KeyUID: keyUID,
|
||||||
Password: password,
|
Password: password,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pms.config2 = &PairingPayloadManagerConfig{
|
pms.config2 = &PairingPayloadManagerConfig{
|
||||||
DB: db2,
|
DB: db2,
|
||||||
|
PairingPayloadSourceConfig: PairingPayloadSourceConfig{
|
||||||
KeystorePath: keystore2,
|
KeystorePath: keystore2,
|
||||||
KeyUID: keyUID,
|
KeyUID: keyUID,
|
||||||
Password: password,
|
Password: password,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (s *PairingServer) startSendingAccountData() error {
|
||||||
return s.Start()
|
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)
|
tlsKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -145,23 +145,21 @@ func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, keystorePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewPairingServer(&Config{
|
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,
|
PK: &tlsKey.PublicKey,
|
||||||
EK: AESKey,
|
EK: AESKey,
|
||||||
Cert: &tlsCert,
|
Cert: &tlsCert,
|
||||||
Hostname: outboundIP.String(),
|
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,
|
Mode: mode,
|
||||||
|
|
||||||
PairingPayloadManagerConfig: &PairingPayloadManagerConfig{
|
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,
|
DB: db,
|
||||||
|
|
||||||
// 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
|
||||||
KeystorePath: keystorePath,
|
PairingPayloadSourceConfig: storeConfig,
|
||||||
KeyUID: keyUID,
|
|
||||||
Password: password,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue