requires Lc in GET DATA
This commit is contained in:
parent
6d3737a86e
commit
4a832e606b
|
@ -18,6 +18,7 @@ type Command struct {
|
|||
Data []byte
|
||||
le uint8
|
||||
requiresLe bool
|
||||
requiresLc bool
|
||||
}
|
||||
|
||||
// NewCommand returns a new apdu Command.
|
||||
|
@ -29,6 +30,7 @@ func NewCommand(cla, ins, p1, p2 uint8, data []byte) *Command {
|
|||
P2: p2,
|
||||
Data: data,
|
||||
requiresLe: false,
|
||||
requiresLc: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +40,10 @@ func (c *Command) SetLe(le uint8) {
|
|||
c.le = le
|
||||
}
|
||||
|
||||
func (c *Command) RequiresLc() {
|
||||
c.requiresLc = true
|
||||
}
|
||||
|
||||
// Le returns if Le is set and its value.
|
||||
func (c *Command) Le() (bool, uint8) {
|
||||
return c.requiresLe, c.le
|
||||
|
@ -63,7 +69,7 @@ func (c *Command) Serialize() ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if len(c.Data) > 0 {
|
||||
if (len(c.Data) > 0) || c.requiresLc {
|
||||
if err := binary.Write(buf, binary.BigEndian, uint8(len(c.Data))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -349,6 +349,8 @@ func NewCommandGetData(typ uint8) *apdu.Command {
|
|||
)
|
||||
|
||||
cmd.SetLe(0)
|
||||
cmd.RequiresLc()
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue