Documentation ¶
Index ¶
- Constants
- func AESMAC(key []byte, data []byte) []byte
- func DecryptAES(key []byte, data []byte) []byte
- func DecryptLRP(key []byte, keynum int, counterBytes []byte, data []byte) []byte
- func DiversifyKey(masterKey []byte, application []byte, identifier []byte) []byte
- func LRPMAC(key []byte, keyNum int, msg []byte) []byte
- func ShortAESMAC(key []byte, data []byte) []byte
- type EncryptionMode
- type Key
- type Keyset
- type Meta
- func (meta *Meta) DecryptFileData(data []byte) []byte
- func (meta *Meta) GenerateAESSessionMACKey(originalKey []byte) []byte
- func (meta *Meta) GenerateLRPSessionMACKey(macKey []byte) []byte
- func (meta *Meta) GenerateValidationCode(data []byte) []byte
- func (meta *Meta) ReadCounterBytes() []byte
- func (meta *Meta) UidBytes() []byte
- func (meta *Meta) UidHex() string
Constants ¶
const KEY_NONE = -1
Variables ¶
This section is empty.
Functions ¶
func DecryptAES ¶
func DiversifyKey ¶
func ShortAESMAC ¶
Types ¶
type EncryptionMode ¶
type EncryptionMode int
const ( UNKNOWN EncryptionMode = iota AES EncryptionMode = iota LRP EncryptionMode = iota )
type Key ¶
type Key struct { // KeyData is the bytes of the key (master key if using diversified keys). KeyData []byte // Diversified tells whether this is a straight key or a diversified key. Diversified bool // Application tells the "application data" to use during diversification on diversified keys. Application []byte }
Key is the type used to hold basic key information and generate diversified keys.
func (*Key) GenerateKeyBytes ¶
Generates a key. Diversifies the key if it is set to be a diversified key. If it is not a diversified key, uidBytes can be nil.
type Keyset ¶
type Keyset struct { Mode EncryptionMode Keys []Key MetaReadKey int FileReadKey int AuthenticationKey int }
Keyset maintains information about a set of keys on a chip. DNA chips can support 5 keys. This does not require that the key structure be mimicked, but allows for it.
func (*Keyset) DecodeEncryptedMeta ¶
func (*Keyset) DecodeEncryptedMetaString ¶
DecodeEncryptedMetaString decodes encrypted metadata
func (*Keyset) DecodeEncryptedMetaStringWithAuthenticator ¶
func (keyset *Keyset) DecodeEncryptedMetaStringWithAuthenticator(dataStr string, authenticatorStr string) (meta Meta, validated bool)
DecodeEncryptedMetaStringWithAuthenticator is a convenience function for decoding meta-only messages with meta-only MACs.
type Meta ¶
Meta is the chip metadata (called the PICCData in the docs). UID is an integer representation of the chips ID (convertible to a byte string by calling UidBytes(). ReadCounter is the number of times the chip has been scanned.
func DecodeUnencryptedBytes ¶
func DecryptMetaAES ¶
func DecryptMetaAESString ¶
DecryptMetaAESString decrypts metadata from the given string, assuming the string is encoded in hexadecimal.
func DecryptMetaLRP ¶
DecryptMetaLRP decrypts the data for LRP.
func DecryptMetaLRPString ¶
DecryptMetaLRPString decrypts metadata from the given string, assuming the string is encoded in hexadecimal.
func Deserialize ¶
func (*Meta) DecryptFileData ¶
func (*Meta) GenerateAESSessionMACKey ¶
GenerateAESSessionMACKey generates a session MAC key for AES encryption.
func (*Meta) GenerateLRPSessionMACKey ¶
GenerateLRPSessionMACKey takes the MAC key and generates a session key for MAC-ing using the LRP algorithm.
func (*Meta) GenerateValidationCode ¶
func (*Meta) ReadCounterBytes ¶
ReadCounterBytes retrieves the ReadCounter as a byte array (the way it is stored on the chip)