Documentation ¶
Index ¶
- Constants
- Variables
- func NewCommandDelete(aid []byte, p2 uint8) *apdu.Command
- func NewCommandExternalAuthenticate(encKey, cardChallenge, hostChallenge []byte) (*apdu.Command, error)
- func NewCommandGetResponse(length uint8) *apdu.Command
- func NewCommandGetStatus(aid []byte, p1 uint8) *apdu.Command
- func NewCommandInitializeUpdate(challenge []byte) *apdu.Command
- func NewCommandInstallForInstall(pkgAID, appletAID, instanceAID, params []byte) *apdu.Command
- func NewCommandInstallForLoad(aid, sdaid []byte) *apdu.Command
- func NewCommandSelect(aid []byte) *apdu.Command
- type CommandSet
- func (cs *CommandSet) Channel() types.Channel
- func (cs *CommandSet) Delete(aid []byte, p2 uint8) error
- func (cs *CommandSet) DeleteKeycardInstancesAndPackage() error
- func (cs *CommandSet) DeleteObject(aid []byte) error
- func (cs *CommandSet) DeleteObjectAndRelatedObject(aid []byte) error
- func (cs *CommandSet) GetStatus() (*types.CardStatus, error)
- func (cs *CommandSet) InstallCashApplet() error
- func (cs *CommandSet) InstallForInstall(packageAID, appletAID, instanceAID, params []byte) error
- func (cs *CommandSet) InstallKeycardApplet() error
- func (cs *CommandSet) InstallNDEFApplet(ndefRecord []byte) error
- func (cs *CommandSet) LoadKeycardPackage(capFile *os.File, callback LoadingCallback) error
- func (cs *CommandSet) LoadPackage(capFile *os.File, pkgAID []byte, callback LoadingCallback) error
- func (cs *CommandSet) OpenSecureChannel() error
- func (cs *CommandSet) SecureChannel() *SecureChannel
- func (cs *CommandSet) Select() error
- func (cs *CommandSet) SelectAID(aid []byte) error
- type LoadCommandStream
- type LoadingCallback
- type SCP02Keys
- type SCP02Wrapper
- type SecureChannel
- type Session
Constants ¶
const ( ClaISO7816 = 0x00 ClaGp = 0x80 ClaMac = 0x84 InsSelect = 0xA4 InsInitializeUpdate = 0x50 InsExternalAuthenticate = 0x82 InsGetResponse = 0xC0 InsDelete = 0xE4 InsLoad = 0xE8 InsInstall = 0xE6 InsGetStatus = 0xF2 P1ExternalAuthenticateCMAC = 0x01 P1InstallForLoad = 0x02 P1InstallForInstall = 0x04 P1InstallForMakeSelectable = 0x08 P1LoadMoreBlocks = 0x00 P1LoadLastBlock = 0x80 P1GetStatusIssuerSecurityDomain = 0x80 P1GetStatusApplications = 0x40 P1GetStatusExecLoadFiles = 0x20 P1GetStatusExecLoadFilesAndModules = 0x10 P2GetStatusTLVData = 0x02 P2DeleteObject = 0x00 P2DeleteObjectAndRelatedObject = 0x80 Sw1ResponseDataIncomplete = 0x61 SwOK = 0x9000 SwFileNotFound = 0x6A82 SwReferencedDataNotFound = 0x6A88 SwSecurityConditionNotSatisfied = 0x6982 SwAuthenticationMethodBlocked = 0x6983 )
Constants used in apdu commands and responses as defined by iso7816 and globalplatform.
Variables ¶
var ErrSecureChannelNotOpen = errors.New("secure channel not open")
Functions ¶
func NewCommandDelete ¶
NewCommandDelete returns a Delete command as defined in the globalplatform specifications.
func NewCommandExternalAuthenticate ¶
func NewCommandExternalAuthenticate(encKey, cardChallenge, hostChallenge []byte) (*apdu.Command, error)
NewCommandExternalAuthenticate returns an External Authenticate command as defined in the globalplatform specifications.
func NewCommandGetResponse ¶
NewCommandGetResponse returns a Get Response command as defined in the globalplatform specifications.
func NewCommandGetStatus ¶
NewCommandGetStatus returns a Get Status command as defined in the globalplatform specifications.
func NewCommandInitializeUpdate ¶
NewCommandInitializeUpdate returns an Initialize Update command as defined in the globalplatform specifications.
func NewCommandInstallForInstall ¶
NewCommandInstallForInstall returns an Install command with the install-for-instalp parameter as defined in the globalplatform specifications.
func NewCommandInstallForLoad ¶
NewCommandInstallForLoad returns an Install command with the install-for-load parameter as defined in the globalplatform specifications.
func NewCommandSelect ¶
NewCommandSelect returns a Select command as defined in the globalplatform specifications.
Types ¶
type CommandSet ¶
type CommandSet struct {
// contains filtered or unexported fields
}
func NewCommandSet ¶
func NewCommandSet(c types.Channel) *CommandSet
func (*CommandSet) Channel ¶
func (cs *CommandSet) Channel() types.Channel
func (*CommandSet) DeleteKeycardInstancesAndPackage ¶
func (cs *CommandSet) DeleteKeycardInstancesAndPackage() error
func (*CommandSet) DeleteObject ¶
func (cs *CommandSet) DeleteObject(aid []byte) error
func (*CommandSet) DeleteObjectAndRelatedObject ¶
func (cs *CommandSet) DeleteObjectAndRelatedObject(aid []byte) error
func (*CommandSet) GetStatus ¶
func (cs *CommandSet) GetStatus() (*types.CardStatus, error)
func (*CommandSet) InstallCashApplet ¶
func (cs *CommandSet) InstallCashApplet() error
func (*CommandSet) InstallForInstall ¶
func (cs *CommandSet) InstallForInstall(packageAID, appletAID, instanceAID, params []byte) error
func (*CommandSet) InstallKeycardApplet ¶
func (cs *CommandSet) InstallKeycardApplet() error
func (*CommandSet) InstallNDEFApplet ¶
func (cs *CommandSet) InstallNDEFApplet(ndefRecord []byte) error
func (*CommandSet) LoadKeycardPackage ¶
func (cs *CommandSet) LoadKeycardPackage(capFile *os.File, callback LoadingCallback) error
func (*CommandSet) LoadPackage ¶
func (cs *CommandSet) LoadPackage(capFile *os.File, pkgAID []byte, callback LoadingCallback) error
func (*CommandSet) OpenSecureChannel ¶
func (cs *CommandSet) OpenSecureChannel() error
func (*CommandSet) SecureChannel ¶
func (cs *CommandSet) SecureChannel() *SecureChannel
func (*CommandSet) Select ¶
func (cs *CommandSet) Select() error
func (*CommandSet) SelectAID ¶
func (cs *CommandSet) SelectAID(aid []byte) error
type LoadCommandStream ¶
type LoadCommandStream struct {
// contains filtered or unexported fields
}
LoadCommandStream implement a struct that generates multiple Load commands used to load files to smartcards.
func NewLoadCommandStream ¶
func NewLoadCommandStream(file *os.File) (*LoadCommandStream, error)
NewLoadCommandStream returns a new LoadCommandStream to load the specified file.
func (*LoadCommandStream) BlocksCount ¶
func (lcs *LoadCommandStream) BlocksCount() int
BlocksCount returns the total number of blocks based on data length and blockSize
func (*LoadCommandStream) GetCommand ¶
func (lcs *LoadCommandStream) GetCommand() *apdu.Command
GetCommand returns the current apdu command.
func (*LoadCommandStream) Index ¶
func (lcs *LoadCommandStream) Index() uint8
Index returns the command index.
func (*LoadCommandStream) Next ¶
func (lcs *LoadCommandStream) Next() bool
Next returns initialize the data for the next Load command. TODO:@gravityblast update blockSize when using encrypted data
type LoadingCallback ¶
type LoadingCallback = func(loadingBlock, totalBlocks int)
type SCP02Keys ¶
type SCP02Keys struct {
// contains filtered or unexported fields
}
SCP02Keys is a struct that contains encoding and MAC keys used to communicate with smartcards.
func NewSCP02Keys ¶
NewSCP02Keys returns a new SCP02Keys with the specified ENC and MAC keys.
type SCP02Wrapper ¶
type SCP02Wrapper struct {
// contains filtered or unexported fields
}
SCP02Wrapper is a wrapper for apdu commands inside a global platform secure channel.
func NewSCP02Wrapper ¶
func NewSCP02Wrapper(macKey []byte) *SCP02Wrapper
NewSCP02Wrapper returns a new SCP02Wrapper using the specified key for MAC generation.
type SecureChannel ¶
type SecureChannel struct {
// contains filtered or unexported fields
}
SecureChannel wraps another channel and sends wrapped commands using SCP02Wrapper.
func NewSecureChannel ¶
func NewSecureChannel(session *Session, c types.Channel) *SecureChannel
NewSecureChannel returns a new SecureChannel based on a session and wrapping a Channel c.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a struct containing the keys and challenges used in the current communication with a card.
func NewSession ¶
NewSession returns a new session after validating the cryptogram received from the card.
func (*Session) CardChallenge ¶
CardChallenge returns the current card challenge.
func (*Session) HostChallenge ¶
HostChallenge returns the current host challenge.