Documentation ¶
Index ¶
- Constants
- Variables
- func NewCommandChangePIN(pin string) *apdu.Command
- func NewCommandChangePUK(puk string) *apdu.Command
- func NewCommandChangePairingSecret(secret []byte) *apdu.Command
- func NewCommandDeriveKey(pathStr string) (*apdu.Command, error)
- func NewCommandExportCert() *apdu.Command
- func NewCommandExportData(page uint8) *apdu.Command
- func NewCommandExportKey(p1 uint8, p2 uint8, pathStr string) (*apdu.Command, error)
- func NewCommandExportSeed() *apdu.Command
- func NewCommandGenerateKey() *apdu.Command
- func NewCommandGetStatus(p1 uint8) *apdu.Command
- func NewCommandIdentifyCard(hash []byte) *apdu.Command
- func NewCommandInit(data []byte) *apdu.Command
- func NewCommandLoadSeed(seed []byte) *apdu.Command
- func NewCommandMutuallyAuthenticate(data []byte) *apdu.Command
- func NewCommandOpenSecureChannel(pairingIndex uint8, pubKey []byte) *apdu.Command
- func NewCommandPairFinalStep(cryptogramHash []byte) *apdu.Command
- func NewCommandPairFirstStep(challenge []byte) *apdu.Command
- func NewCommandRemoveKey() *apdu.Command
- func NewCommandSetPinlessPath(pathStr string) (*apdu.Command, error)
- func NewCommandSign(data []byte, p1 uint8, pathStr string) (*apdu.Command, error)
- func NewCommandUnpair(index uint8) *apdu.Command
- func NewCommandVerifyPIN(pin string) *apdu.Command
- type CashCommandSet
- type CommandSet
- func (cs *CommandSet) ChangePIN(pin string) error
- func (cs *CommandSet) ChangePUK(puk string) error
- func (cs *CommandSet) ChangePairingSecret(password string) error
- func (cs *CommandSet) DeriveKey(path string) error
- func (cs *CommandSet) ExportCert() ([]byte, error)
- func (cs *CommandSet) ExportData() ([]byte, error)
- func (cs *CommandSet) ExportKey(derive bool, makeCurrent bool, onlyPublic bool, path string) ([]byte, error)
- func (cs *CommandSet) ExportSeed() ([]byte, error)
- func (cs *CommandSet) GenerateKey() ([]byte, error)
- func (cs *CommandSet) GetStatus(info uint8) (*types.ApplicationStatus, error)
- func (cs *CommandSet) GetStatusApplication() (*types.ApplicationStatus, error)
- func (cs *CommandSet) GetStatusKeyPath() (*types.ApplicationStatus, error)
- func (cs *CommandSet) IdentifyCard(hash []byte) ([]byte, error)
- func (cs *CommandSet) Init(secrets *Secrets) error
- func (cs *CommandSet) LoadSeed(seed []byte) ([]byte, error)
- func (cs *CommandSet) OpenSecureChannel() error
- func (cs *CommandSet) Pair() error
- func (cs *CommandSet) RemoveKey() error
- func (cs *CommandSet) Select() error
- func (cs *CommandSet) SetPairingInfo(key []byte, index int)
- func (cs *CommandSet) SetPinlessPath(path string) error
- func (cs *CommandSet) Sign(data []byte) (*types.Signature, error)
- func (cs *CommandSet) SignPinless(data []byte) (*types.Signature, error)
- func (cs *CommandSet) SignWithPath(data []byte, path string) (*types.Signature, error)
- func (cs *CommandSet) Unpair(index uint8) error
- func (cs *CommandSet) VerifyPIN(pin string) error
- type Secrets
- type SecureChannel
- func (sc *SecureChannel) GenerateSecret(cardPubKeyData []byte) error
- func (sc *SecureChannel) Init(iv, encKey, macKey []byte)
- func (sc *SecureChannel) OneShotEncrypt(secrets *Secrets) ([]byte, error)
- func (sc *SecureChannel) PublicKey() *ecdsa.PublicKey
- func (sc *SecureChannel) RawPublicKey() []byte
- func (sc *SecureChannel) Reset()
- func (sc *SecureChannel) Secret() []byte
- func (sc *SecureChannel) Send(cmd *apdu.Command) (*apdu.Response, error)
Constants ¶
View Source
const ( InsInit = 0xFE InsOpenSecureChannel = 0x10 InsMutuallyAuthenticate = 0x11 InsPair = 0x12 InsUnpair = 0x13 InsGetStatus = 0xF2 InsGenerateKey = 0xD4 InsRemoveKey = 0xD3 InsVerifyPIN = 0x20 InsChangePIN = 0x21 InsDeriveKey = 0xD1 InsExportKey = 0xC2 InsExportSeed = 0xC3 InsSign = 0xC0 InsSetPinlessPath = 0xC1 InsExportData = 0xC5 InsLoadKey = 0xD0 InsIdentifyCard = 0x14 InsExportCert = 0x16 P1PairingFirstStep = 0x00 P1PairingFinalStep = 0x01 P1GetStatusApplication = 0x00 P1GetStatusKeyPath = 0x01 P1DeriveKeyFromMaster = 0x00 P1DeriveKeyFromParent = 0x40 P1DeriveKeyFromCurrent = 0x80 P1ChangePinPIN = 0x00 P1ChangePinPUK = 0x01 P1ChangePinPairingSecret = 0x02 P1SignCurrentKey = 0x00 P1SignDerive = 0x01 P1SignDeriveAndMakeCurrent = 0x02 P1SignPinless = 0x03 P1ExportKeyCurrent = 0x00 P1ExportKeyDerive = 0x01 P1ExportKeyDeriveAndMakeCurrent = 0x02 P2ExportKeyPrivateAndPublic = 0x00 P2ExportKeyPublicOnly = 0x01 P1LoadKeySeed = 0x03 SwNoAvailablePairingSlots = 0x6A84 )
Variables ¶
View Source
var ErrCertInvalid = errors.New("pairing detected invalid certificate")
View Source
var ErrInvalidResponseMAC = errors.New("invalid response MAC")
View Source
var ErrNoAvailablePairingSlots = errors.New("no available pairing slots")
Functions ¶
func NewCommandChangePIN ¶
func NewCommandChangePUK ¶
func NewCommandExportCert ¶
func NewCommandExportData ¶
func NewCommandExportKey ¶
Export a key
@param {p1} 0x00: current key - returns the key that is currently loaded and ready for signing. Does not use derivation path 0x01: derive - returns derived key 0x02: derive and make current - returns derived key and also sets it to the current key @param {p2} 0x00: return public and private key pair 0x01: return only the public key @param {pathStr} Derivation path of format "m/x/x/x/x/x", e.g. "m/44'/0'/0'/0/0"
func NewCommandExportSeed ¶
func NewCommandGenerateKey ¶
func NewCommandGetStatus ¶
func NewCommandIdentifyCard ¶
func NewCommandInit ¶
func NewCommandLoadSeed ¶
func NewCommandPairFinalStep ¶
func NewCommandPairFirstStep ¶
func NewCommandRemoveKey ¶
func NewCommandSign ¶
func NewCommandUnpair ¶
func NewCommandVerifyPIN ¶
Types ¶
type CashCommandSet ¶
type CashCommandSet struct { CashApplicationInfo *types.CashApplicationInfo // contains filtered or unexported fields }
func NewCashCommandSet ¶
func NewCashCommandSet(c types.Channel) *CashCommandSet
func (*CashCommandSet) Select ¶
func (cs *CashCommandSet) Select() error
type CommandSet ¶
type CommandSet struct { ApplicationInfo *types.ApplicationInfo PairingInfo *types.PairingInfo // contains filtered or unexported fields }
func NewCommandSet ¶
func NewCommandSet(c types.Channel) *CommandSet
func (*CommandSet) ChangePIN ¶
func (cs *CommandSet) ChangePIN(pin string) error
func (*CommandSet) ChangePUK ¶
func (cs *CommandSet) ChangePUK(puk string) error
func (*CommandSet) ChangePairingSecret ¶
func (cs *CommandSet) ChangePairingSecret(password string) error
func (*CommandSet) DeriveKey ¶
func (cs *CommandSet) DeriveKey(path string) error
func (*CommandSet) ExportCert ¶
func (cs *CommandSet) ExportCert() ([]byte, error)
func (*CommandSet) ExportData ¶
func (cs *CommandSet) ExportData() ([]byte, error)
Supported by SafeCard applet v2.3 and above
func (*CommandSet) ExportSeed ¶
func (cs *CommandSet) ExportSeed() ([]byte, error)
func (*CommandSet) GenerateKey ¶
func (cs *CommandSet) GenerateKey() ([]byte, error)
func (*CommandSet) GetStatus ¶
func (cs *CommandSet) GetStatus(info uint8) (*types.ApplicationStatus, error)
func (*CommandSet) GetStatusApplication ¶
func (cs *CommandSet) GetStatusApplication() (*types.ApplicationStatus, error)
func (*CommandSet) GetStatusKeyPath ¶
func (cs *CommandSet) GetStatusKeyPath() (*types.ApplicationStatus, error)
func (*CommandSet) IdentifyCard ¶
func (cs *CommandSet) IdentifyCard(hash []byte) ([]byte, error)
func (*CommandSet) Init ¶
func (cs *CommandSet) Init(secrets *Secrets) error
func (*CommandSet) OpenSecureChannel ¶
func (cs *CommandSet) OpenSecureChannel() error
func (*CommandSet) Pair ¶
func (cs *CommandSet) Pair() error
func (*CommandSet) RemoveKey ¶
func (cs *CommandSet) RemoveKey() error
func (*CommandSet) Select ¶
func (cs *CommandSet) Select() error
func (*CommandSet) SetPairingInfo ¶
func (cs *CommandSet) SetPairingInfo(key []byte, index int)
func (*CommandSet) SetPinlessPath ¶
func (cs *CommandSet) SetPinlessPath(path string) error
func (*CommandSet) SignPinless ¶
func (cs *CommandSet) SignPinless(data []byte) (*types.Signature, error)
func (*CommandSet) SignWithPath ¶
func (*CommandSet) Unpair ¶
func (cs *CommandSet) Unpair(index uint8) error
func (*CommandSet) VerifyPIN ¶
func (cs *CommandSet) VerifyPIN(pin string) error
type Secrets ¶
type Secrets struct {
// contains filtered or unexported fields
}
Secrets contains the secret data needed to pair a client with a card.
func GenerateSecrets ¶
GenerateSecrets generate a new Secrets with random puk and pairing password.
func NewSecrets ¶
func (*Secrets) PairingPass ¶
PairingPass returns the pairing password string.
func (*Secrets) PairingToken ¶
PairingToken returns the pairing token generated from the random pairing password.
type SecureChannel ¶
type SecureChannel struct {
// contains filtered or unexported fields
}
func NewSecureChannel ¶
func NewSecureChannel(c types.Channel) *SecureChannel
func (*SecureChannel) GenerateSecret ¶
func (sc *SecureChannel) GenerateSecret(cardPubKeyData []byte) error
func (*SecureChannel) Init ¶
func (sc *SecureChannel) Init(iv, encKey, macKey []byte)
func (*SecureChannel) OneShotEncrypt ¶
func (sc *SecureChannel) OneShotEncrypt(secrets *Secrets) ([]byte, error)
func (*SecureChannel) PublicKey ¶
func (sc *SecureChannel) PublicKey() *ecdsa.PublicKey
func (*SecureChannel) RawPublicKey ¶
func (sc *SecureChannel) RawPublicKey() []byte
func (*SecureChannel) Reset ¶
func (sc *SecureChannel) Reset()
func (*SecureChannel) Secret ¶
func (sc *SecureChannel) Secret() []byte
Source Files ¶
Click to show internal directories.
Click to hide internal directories.