From ec500a3ab615a7f733cec4f052a33bc841926da1 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Thu, 4 Oct 2018 09:46:45 +0200 Subject: [PATCH] fix commands to work with both T=0 and T=1 --- globalplatform/commands.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/globalplatform/commands.go b/globalplatform/commands.go index a0e04c2..27403a4 100644 --- a/globalplatform/commands.go +++ b/globalplatform/commands.go @@ -45,19 +45,27 @@ func NewCommandSelect(aid []byte) *apdu.Command { aid, ) - c.SetLe(0x00) + // with T=0 we can both set or not the Le value + // with T=1 it works only without Le + // c.SetLe(0x00) return c } func NewCommandInitializeUpdate(challenge []byte) *apdu.Command { - return apdu.NewCommand( + c := apdu.NewCommand( ClaGp, InsInitializeUpdate, uint8(0x00), uint8(0x00), challenge, ) + + // with T=0 we can both set or not the Le value + // with T=1 it works only if Le is set + c.SetLe(0x00) + + return c } func NewCommandExternalAuthenticate(encKey, cardChallenge, hostChallenge []byte) (*apdu.Command, error) {