mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-31 00:28:40 +00:00
parse int from KeycardApplicationInfo
This commit is contained in:
parent
c8d0142a16
commit
622a50e950
15
main.go
15
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[:]))
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package signal
|
||||
|
||||
const (
|
||||
// EventSignRequestAdded is triggered when send transaction request is queued
|
||||
EventKeycardConnected = "keycard.connected"
|
||||
)
|
||||
|
||||
|
4
types.go
4
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"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user