Skip to content

Commit

Permalink
feat: added versionRaw for simpler comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Jan 20, 2025
1 parent ce293c7 commit 65a2c97
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/keycard_context_v2_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
WaitingForReader State = "waiting-for-reader"
WaitingForCard State = "waiting-for-card"
ConnectingCard State = "connecting-card"
ConnectionError State = "connection-error" // NOTE: Perhaps a good place for retry
ConnectionError State = "connection-error"
NotKeycard State = "not-keycard"
EmptyKeycard State = "empty-keycard"
NoAvailablePairingSlots State = "no-available-pairing-slots"
Expand Down Expand Up @@ -43,3 +43,7 @@ func (s *Status) Reset(newState State) {
s.AppStatus = nil
s.Metadata = nil
}

func (s *Status) KeycardSupportsExtendedKeys() bool {
return s.AppInfo != nil && s.AppInfo.versionRaw >= 0x0310
}
1 change: 1 addition & 0 deletions internal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ApplicationInfoV2 struct {
Installed bool `json:"installed"`
Initialized bool `json:"initialized"`
InstanceUID utils.HexString `json:"instanceUID"`
versionRaw int `json:"-"`
Version string `json:"version"`
AvailableSlots int `json:"availableSlots"`
// KeyUID is the sha256 of the master public key on the card.
Expand Down
1 change: 1 addition & 0 deletions internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func ToAppInfoV2(r *ktypes.ApplicationInfo) *ApplicationInfoV2 {
Installed: r.Installed,
Initialized: r.Initialized,
InstanceUID: r.InstanceUID,
versionRaw: BytesToInt(r.Version),
Version: ParseVersion(r.Version),
AvailableSlots: BytesToInt(r.AvailableSlots),
KeyUID: r.KeyUID,
Expand Down

0 comments on commit 65a2c97

Please sign in to comment.