rename APDUWrapper to SCP02Wrapper

This commit is contained in:
Andrea Franz 2019-03-05 12:00:23 +01:00
parent 33b1afaba3
commit 2b0ff91b13
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
3 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -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)

View File

@ -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()),
}
}