card

package
v0.0.0-...-15d4781 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2019 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

package card provides interfaces for accdssing smartcards

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLoginRequired

func IsLoginRequired(e error) bool

IsLoginRequred checks if an error is a CardError representing a login required error

func IsStatus

func IsStatus(e error, sw uint16) bool

IsStatus checks if the error is a card error and, if so, the status word matches sw

func PinAttempts

func PinAttempts(e error) int

PinAttempts returns the number of PIN attempts remaining from an error. If this is not a PIN attempts remaining error, returns -1

Types

type Card

type Card struct {
	C transport.Card
}

Card represents a single card Card wraps a transport.Card providing higher level operations

func (*Card) Command

func (c *Card) Command(cla, ins, p1, p2 byte, data []byte, le uint) ([]byte, error)

Command is an easy interface for building APDUs

func (*Card) GetDataObject

func (c *Card) GetDataObject(name uint32) ([]byte, error)

func (*Card) GetFileData

func (c *Card) GetFileData(name FileID, body []byte) ([]byte, error)

GetFileData returns the data contained in the specified file, including the specified request

func (*Card) Lock

func (c *Card) Lock() error

func (*Card) PutDataObject

func (c *Card) PutDataObject(name uint32, buf []byte) error

func (*Card) PutFileData

func (c *Card) PutFileData(name FileID, body []byte) error

PutFileData puts data in the specified file

func (*Card) SelectDF

func (c *Card) SelectDF(name []byte) ([]byte, error)

SelectDF selects a Dedicated File

func (*Card) Transact

func (c *Card) Transact(req ReqAPDU) (RespAPDU, error)

Transact sends a request to the card and gets a response Unlike the raw Transport implementation, this one will fragment and reassemble large APDUs

func (*Card) Unlock

func (c *Card) Unlock() error

func (*Card) Verify

func (c *Card) Verify(id byte, pin []byte) error

type CardError

type CardError struct {
	SW uint16
}

func ErrorFromAPDU

func ErrorFromAPDU(apdu RespAPDU) CardError

ErrorFromAPDU constructs a CardError from a response APDU

func (CardError) Error

func (e CardError) Error() string

Error returns a textual description of an error

type FileID

type FileID uint16

FileID references a 16-bit smartcard file ID

const (
	MF        FileID = 0x3F00
	CurrentEF FileID = 0x0000
	CurrentDF FileID = 0x3FFF
)

type ReqAPDU

type ReqAPDU = transport.ReqAPDU

type RespAPDU

type RespAPDU = transport.RespAPDU

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL