mirror of
https://github.com/status-im/keycard-go.git
synced 2025-02-09 02:26:28 +00:00
rename APDUWrapper to SCP02Wrapper
This commit is contained in:
parent
33b1afaba3
commit
2b0ff91b13
@ -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
|
@ -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)
|
@ -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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user