swtag

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package swtag provides a CommandDriver implementation which acts as a binary interface to software-based NFC Type 4 Tags which implement the tags.Tag interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Tag tags.Tag
}

Driver implements a CommandDriver to interface with a software tag (something that implements the Tag interface from the tags module).

This means that this driver provides the binary channel to those tags.

Among its applications, is the easily test that a software Tag conforms to the NFC Type 4 Tag specification, by attaching this driver to a `nfctype4.Device` with, and performing the Device operations on the Tag.

The second application is to simulate a NFC Type 4 with a hardware NFC reader. Libnfc, for example, allows to initialize NFC Readers in Target mode, where the Libnfc device behaves like a tag rather than a reader. This driver makes it trivial to provide a libnfc device in Target mode with full-fledged Type 4 Tag behaviour.

An example of how this is done can be seen visiting the following snippet: https://gitlab.com/snippets/18718

func (*Driver) Close

func (driver *Driver) Close()

Close does nothing.

func (*Driver) Initialize

func (driver *Driver) Initialize() error

Initialize does nothing because software Tags don't need initialization.

func (*Driver) String

func (driver *Driver) String() string

String returns information about this driver.

func (*Driver) TransceiveBytes

func (driver *Driver) TransceiveBytes(tx []byte, rxLen int) ([]byte, error)

TransceiveBytes parses the tx bytes to a Command APDU and uses the Tag to process the APDU and provide a Response APDU, which is in turn serialized and returned.

It returns an error if the Tag field has not been set, if the APDUs cannot be serialized or deserialized, or if the response size is bigger than the expected size.

Jump to

Keyboard shortcuts

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