mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-09 10:33:53 +00:00
work around GET DATA transmission over T=1
This commit is contained in:
parent
4a832e606b
commit
5e261398ed
@ -18,7 +18,6 @@ type Command struct {
|
|||||||
Data []byte
|
Data []byte
|
||||||
le uint8
|
le uint8
|
||||||
requiresLe bool
|
requiresLe bool
|
||||||
requiresLc bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCommand returns a new apdu Command.
|
// NewCommand returns a new apdu Command.
|
||||||
@ -30,7 +29,6 @@ func NewCommand(cla, ins, p1, p2 uint8, data []byte) *Command {
|
|||||||
P2: p2,
|
P2: p2,
|
||||||
Data: data,
|
Data: data,
|
||||||
requiresLe: false,
|
requiresLe: false,
|
||||||
requiresLc: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +38,6 @@ func (c *Command) SetLe(le uint8) {
|
|||||||
c.le = le
|
c.le = le
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) RequiresLc() {
|
|
||||||
c.requiresLc = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Le returns if Le is set and its value.
|
// Le returns if Le is set and its value.
|
||||||
func (c *Command) Le() (bool, uint8) {
|
func (c *Command) Le() (bool, uint8) {
|
||||||
return c.requiresLe, c.le
|
return c.requiresLe, c.le
|
||||||
@ -69,7 +63,7 @@ func (c *Command) Serialize() ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len(c.Data) > 0) || c.requiresLc {
|
if len(c.Data) > 0 {
|
||||||
if err := binary.Write(buf, binary.BigEndian, uint8(len(c.Data))); err != nil {
|
if err := binary.Write(buf, binary.BigEndian, uint8(len(c.Data))); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -340,18 +340,13 @@ func NewCommandSign(data []byte, p1 uint8, pathStr string) (*apdu.Command, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewCommandGetData(typ uint8) *apdu.Command {
|
func NewCommandGetData(typ uint8) *apdu.Command {
|
||||||
cmd := apdu.NewCommand(
|
return apdu.NewCommand(
|
||||||
globalplatform.ClaGp,
|
globalplatform.ClaGp,
|
||||||
InsGetData,
|
InsGetData,
|
||||||
typ,
|
typ,
|
||||||
0,
|
0,
|
||||||
[]byte{},
|
[]byte{0xCA},
|
||||||
)
|
)
|
||||||
|
|
||||||
cmd.SetLe(0)
|
|
||||||
cmd.RequiresLc()
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommandStoreData(typ uint8, data []byte) *apdu.Command {
|
func NewCommandStoreData(typ uint8, data []byte) *apdu.Command {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user