remove old pairing action

This commit is contained in:
Andrea Franz 2019-03-13 13:50:29 +01:00
parent 165bc34b82
commit 91bbfbffb4
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 0 additions and 43 deletions

View File

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