From 91bbfbffb4424d38a45f610eed7cee3a59519d08 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Wed, 13 Mar 2019 13:50:29 +0100 Subject: [PATCH] remove old pairing action --- actions.go | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/actions.go b/actions.go index 9208917..674e2db 100644 --- a/actions.go +++ b/actions.go @@ -3,7 +3,6 @@ package keycard import ( "bytes" "crypto/rand" - "crypto/sha256" "errors" "fmt" @@ -18,48 +17,6 @@ var ( ErrApplicationStatusTemplateNotFound = errors.New("application status template not found") ) -func Pair(c types.Channel, pairingPass string) (*types.PairingInfo, error) { - challenge := make([]byte, 32) - if _, err := rand.Read(challenge); err != nil { - return nil, err - } - - cmd := NewCommandPairFirstStep(challenge) - resp, err := c.Send(cmd) - if err = checkOKResponse(err, resp); err != nil { - return nil, err - } - - cardCryptogram := resp.Data[:32] - cardChallenge := resp.Data[32:] - - secretHash, err := crypto.VerifyCryptogram(challenge, pairingPass, cardCryptogram) - if err != nil { - return nil, err - } - - h := sha256.New() - h.Write(secretHash[:]) - h.Write(cardChallenge) - cmd = NewCommandPairFinalStep(h.Sum(nil)) - resp, err = c.Send(cmd) - if err = checkOKResponse(err, resp); err != nil { - return nil, err - } - - h.Reset() - h.Write(secretHash[:]) - h.Write(resp.Data[1:]) - - pairingKey := h.Sum(nil) - pairingIndex := resp.Data[0] - - return &types.PairingInfo{ - Key: pairingKey, - Index: int(pairingIndex), - }, nil -} - func OpenSecureChannel(c types.Channel, appInfo *types.ApplicationInfo, pairingIndex uint8, pairingKey []byte) (*SecureChannel, error) { sc := NewSecureChannel(c) cmd := NewCommandOpenSecureChannel(pairingIndex, sc.RawPublicKey())