2021-10-15 10:34:19 +02:00
|
|
|
package statuskeycardgo
|
2021-09-13 13:09:23 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
|
|
|
type hexString []byte
|
|
|
|
|
|
|
|
// MarshalJSON serializes hexString to hex
|
|
|
|
func (s hexString) MarshalJSON() ([]byte, error) {
|
2021-10-18 14:50:56 +03:00
|
|
|
bytes, err := json.Marshal(tox(s))
|
2021-09-13 13:09:23 +02:00
|
|
|
return bytes, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON deserializes hexString to hex
|
|
|
|
func (s *hexString) UnmarshalJSON(data []byte) error {
|
|
|
|
var x string
|
|
|
|
err := json.Unmarshal(data, &x)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
str, err := hex.DecodeString(x)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*s = hexString([]byte(str))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type openSecureChannelParams struct {
|
|
|
|
Index int `json:"index"`
|
|
|
|
Key hexString `json:"key"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type verifyPinParams struct {
|
|
|
|
Pin string `json:"pin"`
|
|
|
|
}
|
2021-09-14 18:31:02 +02:00
|
|
|
|
|
|
|
type deriveKeyParams struct {
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type signWithPathParams struct {
|
|
|
|
Data hexString `json:"data"`
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type exportKeyParams struct {
|
|
|
|
Derive bool `json:"derive"`
|
|
|
|
MakeCurrent bool `json:"makeCurrent"`
|
|
|
|
OnlyPublic bool `json:"onlyPublic"`
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type loadSeedParams struct {
|
|
|
|
Seed hexString `json:"seed"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type pairParams struct {
|
|
|
|
PairingPassword string `json:"pairingPassword"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type initSeedParams struct {
|
|
|
|
Pin string `json:"pin"`
|
|
|
|
Puk string `json:"puk"`
|
|
|
|
PairingPassword string `json:"pairingPassword"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type changeSecretsParams struct {
|
|
|
|
Pin string `json:"pin"`
|
|
|
|
Puk string `json:"puk"`
|
|
|
|
PairingPassword string `json:"pairingPassword"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type unpairParams struct {
|
|
|
|
Index uint8 `json:"index"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Signature struct {
|
|
|
|
PublicKey hexString `json:"publicKey"`
|
|
|
|
R hexString `json:"r"`
|
|
|
|
S hexString `json:"s"`
|
|
|
|
V byte `json:"v"`
|
|
|
|
}
|
|
|
|
|
2021-09-28 11:26:45 +02:00
|
|
|
type Capability uint8
|
|
|
|
|
|
|
|
type ApplicationInfo struct {
|
2021-10-18 14:50:56 +03:00
|
|
|
Initialized bool `json:"initialized"`
|
|
|
|
InstanceUID hexString `json:"instanceUID"`
|
|
|
|
Version int `json:"version"`
|
|
|
|
AvailableSlots int `json:"availableSlots"`
|
2021-09-28 11:26:45 +02:00
|
|
|
// KeyUID is the sha256 of of the master public key on the card.
|
|
|
|
// It's empty if the card doesn't contain any key.
|
2021-10-18 14:50:56 +03:00
|
|
|
KeyUID hexString `json:"keyUID"`
|
2021-09-28 11:26:45 +02:00
|
|
|
}
|
|
|
|
|
2021-09-14 18:31:02 +02:00
|
|
|
type PairingInfo struct {
|
|
|
|
Key hexString `json:"key"`
|
|
|
|
Index int `json:"index"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ApplicationStatus struct {
|
|
|
|
PinRetryCount int `json:"pinRetryCount"`
|
|
|
|
PUKRetryCount int `json:"pukRetryCount"`
|
|
|
|
KeyInitialized bool `json:"keyInitialized"`
|
|
|
|
Path string `json:"path"`
|
|
|
|
}
|
2021-10-21 08:48:51 +03:00
|
|
|
|
|
|
|
type KeyPair struct {
|
|
|
|
Address string `json:"address"`
|
|
|
|
PublicKey hexString `json:"publicKey"`
|
2021-10-21 09:09:20 +03:00
|
|
|
PrivateKey hexString `json:"privateKey,omitempty"`
|
2021-10-21 08:48:51 +03:00
|
|
|
}
|