-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcard.go
46 lines (38 loc) · 1.03 KB
/
card.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
package to handle the communication of smartcard devices under the PCSC implementation
projects on which it is based:
https://github.com/LudovicRousseau/PCSC
https://github.com/ebfe/scard
*/
package smartcard
import (
"errors"
)
// ICard Interface
type ICard interface {
Apdu(apdu []byte) ([]byte, error)
ATR() ([]byte, error)
GetData(byte) ([]byte, error)
UID() ([]byte, error)
ATS() ([]byte, error)
SAK() byte
DisconnectCard() error
DisconnectResetCard() error
DisconnectUnpowerCard() error
DisconnectEjectCard() error
EndTransactionResetCard() error
}
var ErrComm = Error(errors.New("error communication"))
var ErrSecurity = Error(errors.New("error security"))
var ErrNoSmartcard = Error(errors.New("error no smartcard"))
var ErrTransmit = Error(errors.New("error transmit"))
var ErrSharingViolation = Error(errors.New("error sharing violation"))
type SmartcardError struct {
Err error
}
func Error(e error) error {
return &SmartcardError{Err: e}
}
func (e *SmartcardError) Error() string {
return e.Err.Error()
}