Documentation
¶
Overview ¶
Go bindings for the libopenkey. These bindings use the libfreefare bindings from package github.com/clausecker/freefare. Please notice that these bindings ship their own copy of the libopenkey.
Index ¶
- Constants
- func Kdf(masterKey []byte, aid uint32, keyNo byte, data, derivedKey []byte) error
- func Pbkdf(masterKey []byte, aid uint32, keyNo byte, data, pw []byte, iterations int, ...) error
- type Context
- func (c Context) AddRole(role int, privateBasePath string) error
- func (c Context) AuthenticateCard(tag freefare.DESFireTag, pw []byte) (cardId string, err error)
- func (c Context) BootstrapManager(preferredSlot int) (bool, error)
- func (c Context) BootstrapProducer() (bool, error)
- func (c Context) Close() error
- func (c Context) IsManagerBootstrapped() bool
- func (c Context) IsProducerBootstrapped() bool
- func (c Context) ManagerOwnCard(tag freefare.DESFireTag, slot int, keyFile string, pw []byte) error
- func (c Context) PrepareAuthenticator() bool
- func (c Context) ProducerCardCreate(tag freefare.DESFireTag, cardName string) error
- func (c Context) ProducerCardRecreate(tag freefare.DESFireTag, cardName, oldId string) error
- type Error
Constants ¶
const ( CardProducer = iota LockManager CardAuthenticator )
Roles
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
An openkey context. This type wraps openkey_context_t. Allocate an object of this type using the New() function.
func New ¶
func New() Context
Create a new openkey context. This function wraps openkey_context_init(). If initialization of the context fails, this function panics. A context allocated with New() must be released after use with Close().
func (Context) AddRole ¶
Add a role to an openkey context. For a description of the possible errors, have a look at libopenkey.c. There is no documentation but you can possibly figure out where your error came from if you look long enough.
func (Context) AuthenticateCard ¶
Use a card for authentication. This function fails if no authenticator role has been added to the context. This function wraps openkey_authenticator_authenticate_pw(). To get the functionality of openkey_authenticator_authenticate(), pass nil for pw. This function may either return an Error object or any of the error objects freefare.Tag.TranslateError() may return; the wrapper automatically translates error codes to a freefare.Error if it finds that the error was produced by the libfreefare.
func (Context) BootstrapManager ¶
Bootstrap a manager role. This function returns true if the producer role of c had already been bootstrapped before.
func (Context) BootstrapProducer ¶
Bootstrap a producer role. This function returns true if the producer role of c had already been bootstrapped before.
func (Context) Close ¶
Release an openkey context. This function wraps openkey_context_fini(). This function fails with an error iff the context has already been closed. It is save to ignore any errors coming from this function.
Usage of a context after Close() results in an error.
func (Context) IsManagerBootstrapped ¶
Has a manager role been bootstrapped? This function also returns false if c has already been closed.
func (Context) IsProducerBootstrapped ¶
Has a producer role been bootstrapped? This function also returns false if c has already been closed.
func (Context) ManagerOwnCard ¶
Own a card. This function wraps openkey_manager_card_own_pw(). To own a card without a password (as with openkey_manager_card_own()), pass nil for pw. This function may either return an Error object or any of the error objects freefare.Tag.TranslateError() may return; the wrapper automatically translates error codes to a freefare.Error if it finds that the error was produced by the libfreefare.
func (Context) PrepareAuthenticator ¶
Figure out if a card has an authenticator role added. This function also returns false if c has already been closed. The name of this function is a bit strange and has been taken verbatim from the C code.
func (Context) ProducerCardCreate ¶
func (c Context) ProducerCardCreate(tag freefare.DESFireTag, cardName string) error
Create an openkey card. This function may either return an Error object or any of the error objects freefare.Tag.TranslateError() may return; the wrapper automatically translates error codes to a freefare.Error if it finds that the error was produced by the libfreefare.
func (Context) ProducerCardRecreate ¶
func (c Context) ProducerCardRecreate(tag freefare.DESFireTag, cardName, oldId string) error
Recreate an openkey card. This function may either return an Error object or any of the error objects freefare.Tag.TranslateError() may return; the wrapper automatically translates error codes for this function. Notice that since the implementation of openkey_producer_card_recreate() does not distinguish between different errors, the translation is a little bit inexact. Specifically, the translation routine looks for errno and translates the error code if errno is set. Since versions of the libfreefare up to 0.4.0 do not set errno on authentication failure, error reporting might be wrong.