diff --git a/main.go b/main.go index f24c79e..400f4e3 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main // #cgo LDFLAGS: -shared import "C" import ( + "encoding/binary" "encoding/json" "fmt" "time" @@ -103,8 +104,8 @@ func Select() *C.char { Initialized: info.Initialized, InstanceUID: info.InstanceUID, SecureChannelPublicKey: info.SecureChannelPublicKey, - Version: info.Version, - AvailableSlots: info.AvailableSlots, + Version: bytesToInt(info.Version), + AvailableSlots: bytesToInt(info.AvailableSlots), KeyUID: info.KeyUID, Capabilities: Capability(info.Capabilities), }) @@ -411,3 +412,13 @@ func ChangePairingPassword(jsonParams *C.char) *C.char { func SetSignalEventCallback(cb unsafe.Pointer) { signal.SetSignalEventCallback(cb) } + +func bytesToInt(s []byte) int { + if len(s) > 4 { + return 0 + } + + var b [4]byte + copy(b[4-len(s):], s) + return int(binary.BigEndian.Uint32(b[:])) +} diff --git a/signal/events_keycard.go b/signal/events_keycard.go index 3127046..c4dc70a 100644 --- a/signal/events_keycard.go +++ b/signal/events_keycard.go @@ -1,7 +1,6 @@ package signal const ( - // EventSignRequestAdded is triggered when send transaction request is queued EventKeycardConnected = "keycard.connected" ) diff --git a/types.go b/types.go index cfd69f0..1a49eee 100644 --- a/types.go +++ b/types.go @@ -93,8 +93,8 @@ type ApplicationInfo struct { Initialized bool `json:"initialized"` InstanceUID hexString `json:"instanceUID"` SecureChannelPublicKey hexString `json:"secureChannelPublicKey"` - Version hexString `json:"version"` - AvailableSlots hexString `json:"availableSlots"` + Version int `json:"version"` + AvailableSlots int `json:"availableSlots"` // KeyUID is the sha256 of of the master public key on the card. // It's empty if the card doesn't contain any key. KeyUID hexString `json:"keyUID"`