From 2b0ff91b130c784909beed2bae1d65726ce5a358 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Tue, 5 Mar 2019 12:00:23 +0100 Subject: [PATCH] rename APDUWrapper to SCP02Wrapper --- globalplatform/{apdu_wrapper.go => scp02_wrapper.go} | 12 ++++++------ .../{apdu_wrapper_test.go => scp02_wrapper_test.go} | 4 ++-- globalplatform/secure_channel.go | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) rename globalplatform/{apdu_wrapper.go => scp02_wrapper.go} (81%) rename globalplatform/{apdu_wrapper_test.go => scp02_wrapper_test.go} (94%) diff --git a/globalplatform/apdu_wrapper.go b/globalplatform/scp02_wrapper.go similarity index 81% rename from globalplatform/apdu_wrapper.go rename to globalplatform/scp02_wrapper.go index 9d687b8..b4687d2 100644 --- a/globalplatform/apdu_wrapper.go +++ b/globalplatform/scp02_wrapper.go @@ -8,15 +8,15 @@ import ( "github.com/status-im/keycard-go/globalplatform/crypto" ) -// APDUWrapper is a wrapper for apdu commands inside a global platform secure channel. -type APDUWrapper struct { +// SCP02Wrapper is a wrapper for apdu commands inside a global platform secure channel. +type SCP02Wrapper struct { macKey []byte icv []byte } -// NewAPDUWrapper returns a new APDUWrapper using the specified key for MAC generation. -func NewAPDUWrapper(macKey []byte) *APDUWrapper { - return &APDUWrapper{ +// NewSCP02Wrapper returns a new SCP02Wrapper using the specified key for MAC generation. +func NewSCP02Wrapper(macKey []byte) *SCP02Wrapper { + return &SCP02Wrapper{ macKey: macKey, icv: crypto.NullBytes8, } @@ -24,7 +24,7 @@ func NewAPDUWrapper(macKey []byte) *APDUWrapper { // Wrap wraps the apdu command adding the MAC to the end of the command. // Future implementations will encrypt the message when needed. -func (w *APDUWrapper) Wrap(cmd *apdu.Command) (*apdu.Command, error) { +func (w *SCP02Wrapper) Wrap(cmd *apdu.Command) (*apdu.Command, error) { macData := new(bytes.Buffer) cla := cmd.Cla | 0x04 diff --git a/globalplatform/apdu_wrapper_test.go b/globalplatform/scp02_wrapper_test.go similarity index 94% rename from globalplatform/apdu_wrapper_test.go rename to globalplatform/scp02_wrapper_test.go index 2c44267..64dd227 100644 --- a/globalplatform/apdu_wrapper_test.go +++ b/globalplatform/scp02_wrapper_test.go @@ -9,9 +9,9 @@ import ( "github.com/stretchr/testify/assert" ) -func TestAPDUWrapper_Wrap(t *testing.T) { +func TestSCP02Wrapper_Wrap(t *testing.T) { macKey := hexutils.HexToBytes("2983BA77D709C2DAA1E6000ABCCAC951") - w := NewAPDUWrapper(macKey) + w := NewSCP02Wrapper(macKey) data := hexutils.HexToBytes("1d4de92eaf7a2c9f") cmd := apdu.NewCommand(uint8(0x80), uint8(0x82), uint8(0x01), uint8(0x00), data) diff --git a/globalplatform/secure_channel.go b/globalplatform/secure_channel.go index 4a7a995..050e235 100644 --- a/globalplatform/secure_channel.go +++ b/globalplatform/secure_channel.go @@ -5,11 +5,11 @@ import ( "github.com/status-im/keycard-go/hexutils" ) -// SecureChannel wraps another channel and sends wrapped commands using APDUWrapper. +// SecureChannel wraps another channel and sends wrapped commands using SCP02Wrapper. type SecureChannel struct { session *Session c Channel - w *APDUWrapper + w *SCP02Wrapper } // NewSecureChannel returns a new SecureChannel based on a session and wrapping a Channel c. @@ -17,7 +17,7 @@ func NewSecureChannel(session *Session, c Channel) *SecureChannel { return &SecureChannel{ session: session, c: c, - w: NewAPDUWrapper(session.KeyProvider().Mac()), + w: NewSCP02Wrapper(session.KeyProvider().Mac()), } }