amiibo

package
v0.0.0-...-882d3c7 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyFileSize      = 160
	KeyFileMD5       = "45fd53569f5765eef9c337bd5172f937"
	KeyFileSha1      = "bbdbb49a917d14f7a997d327ba40d40c39e606ce"
	MaxMagicByteSize = 16
	MaxSeedSize      = 480
)
View Source
const (
	DeviceWii        DeviceType = 0x10
	DeviceDS         DeviceType = 0x20
	Device3DS        DeviceType = 0x30
	DeviceWiiUSwitch DeviceType = 0x40

	MiiMale   MiiSex = 0
	MiiFemale MiiSex = 1

	RegionNoLock Region = 0
	RegionJapan  Region = 1
	RegionUSA    Region = 2
	RegionEurope Region = 3

	CharsetJapanUsaEurope Charset = 0
	CharsetChina          Charset = 1
	CharsetKorea          Charset = 2
	CharsetTaiwan         Charset = 3

	FavColRed        FavouriteColour = 0
	FavColOrange     FavouriteColour = 1
	FavColYellow     FavouriteColour = 2
	FavColLightGreen FavouriteColour = 3
	FavColDarkGreen  FavouriteColour = 4
	FavColDarkBlue   FavouriteColour = 5
	FavColLightBlue  FavouriteColour = 6
	FavColPink       FavouriteColour = 7
	FavColPurple     FavouriteColour = 8
	FavColBrown      FavouriteColour = 9
	FavColWhite      FavouriteColour = 10
	FavColBlack      FavouriteColour = 11

	SkinLightApricot SkinTone = 0
	SkinChardonnay   SkinTone = 1
	SkinApricot      SkinTone = 2
	SkinSienna       SkinTone = 3
	SkinEspresso     SkinTone = 4
	SkinLightPink    SkinTone = 5
	SkinMediumPink   SkinTone = 6
	SkinRawSienna    SkinTone = 7
	SkinBurntUmber   SkinTone = 8
	SkinBistre       SkinTone = 9
)
View Source
const (
	TypeFigure FigureType = 0x00
	TypeCard   FigureType = 0x01
	TypeYarn   FigureType = 0x02

	SeriesSuperSmashBros        Series = 0x00
	SeriesSuperMario            Series = 0x01
	SeriesChibiRobo             Series = 0x02
	SeriesYoshisWoollyWorld     Series = 0x03
	SeriesSplatoon              Series = 0x04
	SeriesAnimalCrossing        Series = 0x05
	SeriesEightBitMario         Series = 0x06
	SeriesSkylanders            Series = 0x07
	SeriesUnknown1              Series = 0x08
	SeriesTheLegendOfZelda      Series = 0x09
	SeriesShovelKnight          Series = 0x0A
	SeriesUnknown2              Series = 0x0B
	SeriesKirby                 Series = 0x0C
	SeriesPokemon               Series = 0x0D
	SeriesMarioSportsSuperstars Series = 0x0E
	SeriesMonsterHunter         Series = 0x0F
	SeriesBoxBoy                Series = 0x10
	SeriesPikmin                Series = 0x11
	SeriesFireEmblem            Series = 0x12
	SeriesMetroid               Series = 0x13
	SeriesOthers                Series = 0x14
	SeriesMegaMan               Series = 0x15
	SeriesDiablo                Series = 0x16
)
View Source
const (
	// CT stands for Cascade Tag and has a fixed value of 0x88 as defined in ISO/IEC 14443-3 Type A.
	CT = 0x88

	// NTAG215Size defines the maximum amount of bytes for an NTAG215 dump.
	NTAG215Size = 540
)

Variables

View Source
var ErrInvalidSize = fmt.Errorf("amiibo: data must be >= %d and <= %d", AmiiboSize, NTAG215Size)

ErrInvalidSize is the error returned when the data provided is too long or too short.

Functions

func NewDataHmac

func NewDataHmac(dataKey *DerivedKey, amiibo Amiidump, tagHmac []byte) []byte

NewDataHmac generates a new data HMAC from the data DerivedKey using unencrypted data AND the tag HMAC generated by NewTagHmac.

func NewTagHmac

func NewTagHmac(tagKey *DerivedKey, amiibo Amiidump) []byte

NewTagHmac generates a new tag HMAC from the tag DerivedKey using unencrypted data.

func Seed

func Seed(key *MasterKey, amiibo Amiidump) []byte

Seed generates the Seed needed to calculate a DerivedKey using the given MasterKey and data.

func Verify

func Verify(amiibo Amiidump, tagKey, dataKey *DerivedKey) bool

Verify checks if the decrypted data signature matches.

Types

type Amiibo

type Amiibo struct{ NTAG215 }

Amiibo embeds NTAG215 which in turn contains binary amiibo data. Amiibo allows easy amiibo manipulation.

func AmiitoolToAmiibo

func AmiitoolToAmiibo(amiibo *Amiitool) *Amiibo

AmiitoolToAmiibo converts the internal amiitool format to a NTAG215 dump.

func NewAmiibo

func NewAmiibo(data []byte, amiibo *Amiitool) (*Amiibo, error)

NewAmiibo builds a new Amiibo structure based on the given raw NTAG215 data or by converting it from a given Amiitool struct.

func (*Amiibo) DataHMAC

func (a *Amiibo) DataHMAC() []byte

func (*Amiibo) GeneratePassword

func (a *Amiibo) GeneratePassword()

GeneratePassword generates the password based on the tag UID where uid byte 0 is skipped as it's always set to 0x04 on an amiibo tag.

func (*Amiibo) ModelInfo

func (a *Amiibo) ModelInfo() *ModelInfo

func (*Amiibo) ModelInfoRaw

func (a *Amiibo) ModelInfoRaw() []byte

func (*Amiibo) RegisterInfo

func (a *Amiibo) RegisterInfo() *RegisterInfo

func (*Amiibo) RegisterInfoRaw

func (a *Amiibo) RegisterInfoRaw() []byte

func (*Amiibo) Salt

func (a *Amiibo) Salt() []byte

func (*Amiibo) SetDataHMAC

func (a *Amiibo) SetDataHMAC(dHmac []byte)

func (*Amiibo) SetRegisterInfo

func (a *Amiibo) SetRegisterInfo(enc []byte)

func (*Amiibo) SetSettings

func (a *Amiibo) SetSettings(enc []byte)

func (*Amiibo) SetTagHMAC

func (a *Amiibo) SetTagHMAC(tHmac []byte)

func (*Amiibo) Settings

func (a *Amiibo) Settings() *Settings

func (*Amiibo) SettingsRaw

func (a *Amiibo) SettingsRaw() []byte

func (*Amiibo) TagHMAC

func (a *Amiibo) TagHMAC() []byte

func (*Amiibo) Type

func (a *Amiibo) Type() DumpType

func (*Amiibo) Unknown1

func (a *Amiibo) Unknown1() byte

Unknown1 is obviously unknown but always seems to be set to 0xa5 which is done when writing to the amiibo.

func (*Amiibo) Unknown2

func (a *Amiibo) Unknown2() byte

func (*Amiibo) WriteCounter

func (a *Amiibo) WriteCounter() []byte

type Amiidump

type Amiidump interface {
	// DataHMAC returns the HMAC to be verified using a 'data' DerivedKey (using master key
	// unfixed-info.bin).
	DataHMAC() []byte
	// FullUID returns the full UUID including check bytes. All bytes except the last check byte
	// are used in the seed and HMAC calculations.
	FullUID() []byte
	// ModelInfo returns a ModelInfo struct which can be used to extract detailed amiibo info. Since
	// this data is not encrypted, it can be accessed at any time.
	ModelInfo() *ModelInfo
	// ModelInfoRaw returns the raw amiibo model info.
	// The model info is also used in the calculation of the 'tag' HMAC concatenated with the Salt.
	ModelInfoRaw() []byte
	// Raw returns the raw tag data.
	Raw() []byte
	// RegisterInfo returns a RegisterInfo struct which can be used to extract detailed amiibo info.
	// This data is encrypted, so decrypt the amiibo first!
	RegisterInfo() *RegisterInfo
	// RegisterInfoRaw returns the first part of the data needed to generate the 'data' HMAC using the
	// DerivedKey generated from the 'data' master key (usually in a file named unfixed-info.bin).
	RegisterInfoRaw() []byte
	// Salt returns the 32 bytes used as salt in the Seed.
	Salt() []byte
	// SetDataHMAC sets the HMAC to sign the 'data' data.
	SetDataHMAC(dHmac []byte)
	// SetRegisterInfo overwrites the register info with the given data.
	SetRegisterInfo(enc []byte)
	// SetSettings overwrites the settings data with the given data.
	SetSettings(enc []byte)
	// SetTagHMAC sets the HMAC to sign the 'tag' data.
	SetTagHMAC(tHmac []byte)
	// Settings returns the application specific settings and Mii when stored on the amiibo.
	Settings() *Settings
	// SettingsRaw returns the second block of crypto data. En/decryption must be done by
	// prepending RegisterInfoRaw and en/decrypting the entire block in one go.
	// This data is encrypted, so decrypt the amiibo first!
	SettingsRaw() []byte
	// TagHMAC returns the HMAC to be verified using a 'tag' DerivedKey (master key locked-secret.bin).
	TagHMAC() []byte
	// Type returns the dump type: TypeAmiibo or TypeAmiitool.
	Type() DumpType
	// Unknown2 is obviously unknown but is used to generate the data HMAC.
	Unknown2() byte
	// WriteCounter returns the amiibo write counter. This counter is also used as magic bytes to
	// create the crypto Seed.
	WriteCounter() []byte
}

Amiidump defines the interface necessary to encrypt and convert Amiibo and Amiitool structs.

func Crypt

func Crypt(key *DerivedKey, amiibo Amiidump) Amiidump

Crypt encrypts or decrypts the given data using the provided DerivedKey.

func Decrypt

func Decrypt(key *RetailKey, amiibo Amiidump) (Amiidump, error)

Decrypt decrypts the given amiibo. It returns a NEW amiibo struct. The original struct remains unaltered. An error is returned if verification after decryption fails. You WILL receive a decrypted Amiibo struct even if an error occured but beware that it might not contain valid amiibo data.

func Encrypt

func Encrypt(key *RetailKey, amiibo Amiidump) Amiidump

Encrypt signs and encrypts the given amiibo. It returns a NEW amiibo struct. The original struct remains unaltered.

func NewAmiidump

func NewAmiidump(data []byte, typ DumpType) (Amiidump, error)

NewAmiidump creates a new Amiibo or Amiitool struct based on the given type.

type Amiitool

type Amiitool struct {
	// contains filtered or unexported fields
}

Amiitool contains binary amiibo data as structured by the amiitool command (c) 2015-2017 Marcos Del Sol Vives.

func AmiiboToAmiitool

func AmiiboToAmiitool(amiibo *Amiibo) *Amiitool

AmiiboToAmiitool converts a full 540 byte NTAG215 dump to internal amiitool format.

func NewAmiitool

func NewAmiitool(data []byte, amiibo *Amiibo) (*Amiitool, error)

NewAmiitool builds a new Amiitool structure based on the given raw amiitool formatted data or by converting it from a given Amiibo struct.

func (*Amiitool) BCC0

func (a *Amiitool) BCC0() byte

BCC0 returns the first check byte of the serial number. In accordance with ISO/IEC 14443-3 it is calculated as follows: BCC0 = CT ^ UID0 ^ UID1 ^ UID2

func (*Amiitool) BCC1

func (a *Amiitool) BCC1() byte

BCC1 returns the second check byte of the serial number. In accordance with ISO/IEC 14443-3 it is calculated as follows: BCC1 = UID3 ^ UID4 ^ UID5 ^ UID6

func (*Amiitool) CapabilityContainer

func (a *Amiitool) CapabilityContainer() []byte

CapabilityContainer returns the capability container which is programmed during the IC production according to the NFC Forum Type 2 Tag specification. Byte 2 in the capability container defines the available memory size for NDEF (NFC Data Exchange Format) messages which is 496 bytes for NTAG215.

func (*Amiitool) DataHMAC

func (a *Amiitool) DataHMAC() []byte

func (*Amiitool) FullUID

func (a *Amiitool) FullUID() []byte

FullUID returns the 9 byte UID where byte 3 and 8 (the last one) are the check bits.

func (*Amiitool) GeneratePassword

func (a *Amiitool) GeneratePassword()

GeneratePassword generates the password based on the tag UID where uid byte 0 is skipped as it's always set to 0x04 on an amiibo tag.

func (*Amiitool) Int

func (a *Amiitool) Int() byte

Int returns the second byte of page 0x02 and is reserved for internal data.

func (*Amiitool) Lock0

func (a *Amiitool) Lock0() byte

Lock0 returns the first part of the field programmable read-only locking mechanism also referred to as static lock bytes.

func (*Amiitool) Lock1

func (a *Amiitool) Lock1() byte

Lock1 returns the second part of the field programmable read-only locking mechanism also referred to as static lock bytes.

func (*Amiitool) ModelInfo

func (a *Amiitool) ModelInfo() *ModelInfo

func (*Amiitool) ModelInfoRaw

func (a *Amiitool) ModelInfoRaw() []byte

func (*Amiitool) Password

func (a *Amiitool) Password() []byte

Password returns the 32bit password used for memory access protection.

func (*Amiitool) PasswordAcknowledge

func (a *Amiitool) PasswordAcknowledge() []byte

PasswordAcknowledge returns the 16bit password acknowledge used during password verification.

func (*Amiitool) Raw

func (a *Amiitool) Raw() []byte

func (*Amiitool) RegisterInfo

func (a *Amiitool) RegisterInfo() *RegisterInfo

func (*Amiitool) RegisterInfoRaw

func (a *Amiitool) RegisterInfoRaw() []byte

func (*Amiitool) ResetSecurity

func (a *Amiitool) ResetSecurity()

ResetSecurity writes the default amiibo security to the tag. Existing data will be lost beyond recovery.

func (*Amiitool) Salt

func (a *Amiitool) Salt() []byte

func (*Amiitool) SetDataHMAC

func (a *Amiitool) SetDataHMAC(dHmac []byte)

func (*Amiitool) SetPassword

func (a *Amiitool) SetPassword(pwd [4]byte)

SetPassword writes the given password to the NFC tag.

func (*Amiitool) SetPasswordAcknowledge

func (a *Amiitool) SetPasswordAcknowledge(pack [2]byte)

SetPasswordAcknowledge writes the given password acknowledge to the NFC tag.

func (*Amiitool) SetRegisterInfo

func (a *Amiitool) SetRegisterInfo(enc []byte)

func (*Amiitool) SetSettings

func (a *Amiitool) SetSettings(enc []byte)

func (*Amiitool) SetTagHMAC

func (a *Amiitool) SetTagHMAC(tHmac []byte)

func (*Amiitool) Settings

func (a *Amiitool) Settings() *Settings

func (*Amiitool) SettingsRaw

func (a *Amiitool) SettingsRaw() []byte

func (*Amiitool) StaticLockBytes

func (a *Amiitool) StaticLockBytes() []byte

StaticLockBytes returns the static lock bytes. The three least significant bits of lock byte 0 are the block-locking bits. Bit 2 is for pages 0x0a to 0x0f, bit 1 for pages 0x04 to 0x09 and bit 0 deals with page 0x03 which is the capacity container. A bit value of 1 represents a lock.

func (*Amiitool) TagHMAC

func (a *Amiitool) TagHMAC() []byte

func (*Amiitool) Type

func (a *Amiitool) Type() DumpType

func (*Amiitool) UID

func (a *Amiitool) UID() []byte

UID returns the 7 byte UID or serial number.

func (*Amiitool) UID0

func (a *Amiitool) UID0() byte

UID0 returns the first byte of the seven byte serial number or UID.

func (*Amiitool) UID1

func (a *Amiitool) UID1() byte

UID1 returns the second byte of the seven byte serial number or UID.

func (*Amiitool) UID2

func (a *Amiitool) UID2() byte

UID2 returns the third byte of the seven byte serial number or UID.

func (*Amiitool) UID3

func (a *Amiitool) UID3() byte

UID3 returns the fourth byte of the seven byte serial number or UID.

func (*Amiitool) UID4

func (a *Amiitool) UID4() byte

UID4 returns the fifth byte of the seven byte serial number or UID.

func (*Amiitool) UID5

func (a *Amiitool) UID5() byte

UID5 returns the sixth byte of the seven byte serial number or UID.

func (*Amiitool) UID6

func (a *Amiitool) UID6() byte

UID6 returns the seventh byte of the seven byte serial number or UID.

func (*Amiitool) Unknown1

func (a *Amiitool) Unknown1() byte

Unknown1 is obviously unknown but always seems to be set to 0xa5 which is done when writing to the amiibo.

func (*Amiitool) Unknown2

func (a *Amiitool) Unknown2() byte

func (*Amiitool) WriteCounter

func (a *Amiitool) WriteCounter() []byte

type Charset

type Charset int

type DerivedKey

type DerivedKey struct {
	AesKey  [16]byte
	AesIV   [16]byte
	HmacKey [16]byte
}

DerivedKey holds a derived key for a given amiibo figure.

func NewDerivedKey

func NewDerivedKey(key *MasterKey, amiibo Amiidump) *DerivedKey

NewDerivedKey is in essence a Deterministic Random Bit Generator that will generate a derived key from the given data.

type DeviceType

type DeviceType int

type DumpType

type DumpType byte
const (
	TypeAmiibo   DumpType = 1
	TypeAmiitool DumpType = 2

	// AmiiboSize defines the minimum amount of bytes for an (incomplete) amiibo dump;
	AmiiboSize = 520
)

type FavouriteColour

type FavouriteColour int

type FigureType

type FigureType int

type MasterKey

type MasterKey struct {
	HmacKey        [16]byte
	Type           [14]byte
	Rfu            byte
	MagicBytesSize byte
	MagicBytes     [MaxMagicByteSize]byte
	XorPad         [32]byte
}

MasterKey describes the structure of the info and secret keyfiles needed for amiibo crypto actions.

func (*MasterKey) TypeAsString

func (mk *MasterKey) TypeAsString() string

TypeAsString returns the master key type as null terminated string.

type Mii

type Mii struct {
	// contains filtered or unexported fields
}

Mii represents the mii data structure in the amiibo dump. Note that not all settings are supported by the Switch! The data is primarily little endian.

func (*Mii) Author

func (m *Mii) Author() string

func (*Mii) BeardColour

func (m *Mii) BeardColour() int

func (*Mii) BeardStyle

func (m *Mii) BeardStyle() int

func (*Mii) BirthdayDay

func (m *Mii) BirthdayDay() int

func (*Mii) BirthdayMonth

func (m *Mii) BirthdayMonth() int

func (*Mii) CanCopy

func (m *Mii) CanCopy() bool

func (*Mii) Charset

func (m *Mii) Charset() Charset

func (*Mii) CreatedOn

func (m *Mii) CreatedOn() time.Time

TODO: fix this conversion, it's off by several years so what's wrong? Switch has a different

offset? Or Switch doesn't store it like birthday day and month?

func (*Mii) CreatorMac

func (m *Mii) CreatorMac() []byte

func (*Mii) Device

func (m *Mii) Device() DeviceType

func (*Mii) EyeColour

func (m *Mii) EyeColour() int

func (*Mii) EyeRotation

func (m *Mii) EyeRotation() int

func (*Mii) EyeScale

func (m *Mii) EyeScale() int

func (*Mii) EyeStyle

func (m *Mii) EyeStyle() int

func (*Mii) EyeXSpacing

func (m *Mii) EyeXSpacing() int

func (*Mii) EyeYPosition

func (m *Mii) EyeYPosition() int

func (*Mii) EyeYScale

func (m *Mii) EyeYScale() int

func (*Mii) Eyebrow

func (m *Mii) Eyebrow() uint32

Eyebrow data holds:

bit 0-4: eyebrow style
bit 5-7: eyebrow colour
bit 8-11: eyebrow scale
bit 12-14: eyebrow y scale
bit 16-19: eyebrow rotation
bit 21-24: eyebrow x spacing
bit 25-29: eyebrow y position

func (*Mii) EyebrowColour

func (m *Mii) EyebrowColour() int

func (*Mii) EyebrowRotation

func (m *Mii) EyebrowRotation() int

func (*Mii) EyebrowScale

func (m *Mii) EyebrowScale() int

func (*Mii) EyebrowStyle

func (m *Mii) EyebrowStyle() int

func (*Mii) EyebrowXSpacing

func (m *Mii) EyebrowXSpacing() int

func (*Mii) EyebrowYScale

func (m *Mii) EyebrowYScale() int

func (*Mii) EyebrowYSpacing

func (m *Mii) EyebrowYSpacing() int

func (*Mii) Eyes

func (m *Mii) Eyes() uint32

Eyes data holds:

bit 0-5: eye style
bit 6-8: eye colour
bit 9-12: eye scale
bit 13-15: eye y scale
bit 16-20: eye rotation
bit 21-24: eye x spacing
bit 25-29: eye y position

func (*Mii) Face

func (m *Mii) Face() int

Face data holds:

bit 0-3: wrinkles
bit 4-7: makeup

func (*Mii) FavouriteColour

func (m *Mii) FavouriteColour() FavouriteColour

func (*Mii) Glasses

func (m *Mii) Glasses() uint16

Glasses data holds:

bit 0-3: glasses style
bit 4-6: glasses colour
bit 7-10: glasses scale
bit 11-15: glasses y position

func (*Mii) GlassesColour

func (m *Mii) GlassesColour() int

func (*Mii) GlassesScale

func (m *Mii) GlassesScale() int

func (*Mii) GlassesStyle

func (m *Mii) GlassesStyle() int

func (*Mii) GlassesYPosition

func (m *Mii) GlassesYPosition() int

func (*Mii) HairColour

func (m *Mii) HairColour() int

func (*Mii) HairStyle

func (m *Mii) HairStyle() int

func (*Mii) HasMole

func (m *Mii) HasMole() bool

func (*Mii) Head

func (m *Mii) Head() int

Head data holds:

bit 0: disable sharing
bit 1-4: face shape
bit 5-7: skin colour

func (*Mii) HeadShape

func (m *Mii) HeadShape() int

func (*Mii) Height

func (m *Mii) Height() int

func (*Mii) ID

func (m *Mii) ID() uint32

ID holds the creation date in bytes 0-27.

func (*Mii) IsFavourite

func (m *Mii) IsFavourite() bool

func (*Mii) Makeup

func (m *Mii) Makeup() int

func (*Mii) MayShare

func (m *Mii) MayShare() bool

func (*Mii) Mole

func (m *Mii) Mole() uint16

Mole data holds:

bit 0: enable mole
bit 1-4: mole scale
bit 5-9: mole x position
bit 10-14: mole y position

func (*Mii) MoleScale

func (m *Mii) MoleScale() int

func (*Mii) MoleXPosition

func (m *Mii) MoleXPosition() int

func (*Mii) MoleYPosition

func (m *Mii) MoleYPosition() int

func (*Mii) Moustache

func (m *Mii) Moustache() int

func (*Mii) MoustacheScale

func (m *Mii) MoustacheScale() int

func (*Mii) MoustacheYPosition

func (m *Mii) MoustacheYPosition() int

func (*Mii) Mouth1

func (m *Mii) Mouth1() uint16

Mouth1 data holds:

bit 0-5: mouth style
bit 6-8: mouth colour
bit 9-12: mouth scale
bit 13-15: mouth yscale

func (*Mii) Mouth2

func (m *Mii) Mouth2() uint16

Mouth2 data holds:

bit 0-4: mouth y position
bit 5-7: mustach style

func (*Mii) Mouth3

func (m *Mii) Mouth3() uint16

Mouth3 data holds:

bit 0-2: beard style
bit 3-5: beard colour
bit 6-9: mustache scale
bit 10-14:mustache y position

func (*Mii) MouthColour

func (m *Mii) MouthColour() int

func (*Mii) MouthScale

func (m *Mii) MouthScale() int

func (*Mii) MouthStyle

func (m *Mii) MouthStyle() int

func (*Mii) MouthYPosition

func (m *Mii) MouthYPosition() int

func (*Mii) MouthYScale

func (m *Mii) MouthYScale() int

func (*Mii) Name

func (m *Mii) Name() string

func (*Mii) Nose

func (m *Mii) Nose() uint16

Nose data holds:

bit 0-4: nose style
bit 5-8: nose scale
bit 9-13: nose y position

func (*Mii) NoseScale

func (m *Mii) NoseScale() int

func (*Mii) NoseStyle

func (m *Mii) NoseStyle() int

func (*Mii) NoseYPosition

func (m *Mii) NoseYPosition() int

func (*Mii) Padding1

func (m *Mii) Padding1() []byte

func (*Mii) Padding2

func (m *Mii) Padding2() []byte

func (*Mii) Personal

func (m *Mii) Personal() uint16

Personal data holds:

bit 0: sex (0 if male, 1 if female)
bit 1-4: birthday month
bit 5-9: birthday day
bit 10-13: favorite colour
bit 14: is favourite (1 is true)

func (*Mii) Position

func (m *Mii) Position() int

Position is the position shown on the selection screen, will always be 0.

func (*Mii) Profanity

func (m *Mii) Profanity() bool

func (*Mii) Raw

func (m *Mii) Raw() []byte

func (*Mii) Region

func (m *Mii) Region() int

Region holds:

bit 0: allow copying
bit 1: profanity flag (whether in Mii name or creator name does not matter)
bit 2-3: region lock (0=no lock, 1=JPN, 2=USA, 3=EUR)
bit 4-5:character set(0=JPN+USA+EUR, 1=CHN, 2=KOR, 3=TWN)

func (*Mii) RegionLock

func (m *Mii) RegionLock() Region

func (*Mii) Sex

func (m *Mii) Sex() MiiSex

func (*Mii) SkinTone

func (m *Mii) SkinTone() SkinTone

func (*Mii) SystemID

func (m *Mii) SystemID() []byte

func (*Mii) Version

func (m *Mii) Version() int

func (*Mii) Width

func (m *Mii) Width() int

func (*Mii) Wrinkles

func (m *Mii) Wrinkles() int

type MiiSex

type MiiSex int

type ModelInfo

type ModelInfo struct {
	// contains filtered or unexported fields
}

func (*ModelInfo) CharacterID

func (mi *ModelInfo) CharacterID() int

CharacterID returns the amiibo character ID which is extracted from the full ID: the last 6 bits of the first two bytes of the full amiibo ID.

func (*ModelInfo) CharacterVariant

func (mi *ModelInfo) CharacterVariant() int

CharacterVariant returns the amiibo character variant.

func (*ModelInfo) FigureType

func (mi *ModelInfo) FigureType() FigureType

FigureType returns the type of figure: TypeFigure, TypeCard or TypeYarn.

func (*ModelInfo) GameID

func (mi *ModelInfo) GameID() int

GameID returns the amiibo game ID which is extracted from the full ID: the first 10 bits of the first two bytes of the full amiibo ID.

func (*ModelInfo) ID

func (mi *ModelInfo) ID() []byte

ID returns the full amiibo ID.

func (*ModelInfo) ModelNumber

func (mi *ModelInfo) ModelNumber() int

ModelNumber returns the amiibo model number.

func (*ModelInfo) Series

func (mi *ModelInfo) Series() Series

Series returns the series the amiibo is part of such as SeriesMegaMan, SeriesPokemon, SeriesAnimalCrossing, etc.

func (*ModelInfo) Unknown

func (mi *ModelInfo) Unknown() int

Unknown but seems to always be 0x02.

type NTAG215

type NTAG215 struct {
	// contains filtered or unexported fields
}

NTAG215 implements the NTAG215 part of the NXP Semiconductors NTAG213/215/216 specification publicly available on the NXP website: https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf

func NewNTAG215

func NewNTAG215(data [540]byte) *NTAG215

func (*NTAG215) BCC0

func (n *NTAG215) BCC0() byte

BCC0 returns the first check byte of the serial number. In accordance with ISO/IEC 14443-3 it is calculated as follows: BCC0 = CT ^ UID0 ^ UID1 ^ UID2

func (*NTAG215) BCC1

func (n *NTAG215) BCC1() byte

BCC1 returns the second check byte of the serial number. In accordance with ISO/IEC 14443-3 it is calculated as follows: BCC1 = UID3 ^ UID4 ^ UID5 ^ UID6

func (*NTAG215) CFG0

func (n *NTAG215) CFG0() []byte

CFG0 returns the NTAG215 first configuration page. This page is used to set the ASCII mirror feature. For an Amiibo this should always match 0x00 0x00 0x00 0x04.

func (*NTAG215) CFG1

func (n *NTAG215) CFG1() []byte

CFG1 returns the NTAG215 second configuration page. This page is used to configute memory access restrictions. For an Amiibo this should always match 0x5f 0x00 0x00 0x00.

func (*NTAG215) CapabilityContainer

func (n *NTAG215) CapabilityContainer() []byte

CapabilityContainer returns the capability container which is programmed during the IC production according to the NFC Forum Type 2 Tag specification. Byte 2 in the capability container defines the available memory size for NDEF (NFC Data Exchange Format) messages which is 496 bytes for NTAG215.

func (*NTAG215) DLock0

func (n *NTAG215) DLock0() byte

DLock0 returns the first part of the dynamic lock bytes.

func (*NTAG215) DLock1

func (n *NTAG215) DLock1() byte

DLock1 returns the second part of the dynamic lock bytes.

func (*NTAG215) DLock2

func (n *NTAG215) DLock2() byte

DLock2 returns the third part of the dynamic lock bytes.

func (*NTAG215) DynamicLockBytes

func (n *NTAG215) DynamicLockBytes() []byte

DynamicLockBytes returns the dynamic lock bytes used for locking pages starting at page 0x10 and upwards which spans a memory area of 456 bytes. For an Amiibo figure, this should always be 0x01 0x00 0x0f.

func (*NTAG215) FullUID

func (n *NTAG215) FullUID() []byte

FullUID returns the 9 byte UID where byte 3 and 8 (the last one) are the check bits.

func (*NTAG215) Int

func (n *NTAG215) Int() byte

Int returns the second byte of page 0x02 and is reserved for internal data.

func (*NTAG215) Lock0

func (n *NTAG215) Lock0() byte

Lock0 returns the first part of the field programmable read-only locking mechanism also referred to as static lock bytes.

func (*NTAG215) Lock1

func (n *NTAG215) Lock1() byte

Lock1 returns the second part of the field programmable read-only locking mechanism also referred to as static lock bytes.

func (*NTAG215) Password

func (n *NTAG215) Password() []byte

Password returns the 32bit password used for memory access protection.

func (*NTAG215) PasswordAcknowledge

func (n *NTAG215) PasswordAcknowledge() []byte

PasswordAcknowledge returns the 16bit password acknowledge used during password verification.

func (*NTAG215) RFUI

func (n *NTAG215) RFUI() []byte

RFUI stands for Reserved for future use - implemented. These should all be set to 0x00.

func (*NTAG215) RandomiseUid

func (n *NTAG215) RandomiseUid(uid0 byte) error

RandomiseUid randomises the tag's UID or serial number so that it adheres to ISO/IEC 14443-3 standards. uid0 can be passed in to set byte 0 of the uid. All amiibo seem to have 0x04 set as byte 0 of the UID.

func (*NTAG215) Raw

func (n *NTAG215) Raw() []byte

Raw returns the raw tag data.

func (*NTAG215) ResetSecurity

func (n *NTAG215) ResetSecurity()

ResetSecurity writes the default amiibo security to the tag. Existing data will be lost beyond recovery.

func (*NTAG215) SetPassword

func (n *NTAG215) SetPassword(pwd [4]byte)

SetPassword writes the given password to the NFC tag.

func (*NTAG215) SetPasswordAcknowledge

func (n *NTAG215) SetPasswordAcknowledge(pack [2]byte)

SetPasswordAcknowledge writes the given password acknowledge to the NFC tag.

func (*NTAG215) SetUID

func (n *NTAG215) SetUID(uid [9]byte) error

SetUID sets the given UID.

func (*NTAG215) SetUserData

func (n *NTAG215) SetUserData(d [504]byte)

SetUserData updates the entire user memory to the given byte array.

func (*NTAG215) StaticLockBytes

func (n *NTAG215) StaticLockBytes() []byte

StaticLockBytes returns the static lock bytes. The three least significant bits of lock byte 0 are the block-locking bits. Bit 2 is for pages 0x0a to 0x0f, bit 1 for pages 0x04 to 0x09 and bit 0 deals with page 0x03 which is the capacity container. A bit value of 1 represents a lock.

func (*NTAG215) UID

func (n *NTAG215) UID() []byte

UID returns the 7 byte UID or serial number.

func (*NTAG215) UID0

func (n *NTAG215) UID0() byte

UID0 returns the first byte of the seven byte serial number or UID.

func (*NTAG215) UID1

func (n *NTAG215) UID1() byte

UID1 returns the second byte of the seven byte serial number or UID.

func (*NTAG215) UID2

func (n *NTAG215) UID2() byte

UID2 returns the third byte of the seven byte serial number or UID.

func (*NTAG215) UID3

func (n *NTAG215) UID3() byte

UID3 returns the fourth byte of the seven byte serial number or UID.

func (*NTAG215) UID4

func (n *NTAG215) UID4() byte

UID4 returns the fifth byte of the seven byte serial number or UID.

func (*NTAG215) UID5

func (n *NTAG215) UID5() byte

UID5 returns the sixth byte of the seven byte serial number or UID.

func (*NTAG215) UID6

func (n *NTAG215) UID6() byte

UID6 returns the seventh byte of the seven byte serial number or UID.

func (*NTAG215) UserData

func (n *NTAG215) UserData() []byte

UserData returns the read/write memory of the NFC215 tag.

func (*NTAG215) ValidateUID

func (n *NTAG215) ValidateUID() bool

ValidateUID validates the tag's UID or serial number in accordance with ISO/IEC 14443-3.

type Region

type Region int

type RegisterInfo

type RegisterInfo struct {
	// contains filtered or unexported fields
}

func (*RegisterInfo) CRC

func (ri *RegisterInfo) CRC() []byte

func (*RegisterInfo) CRCCounter

func (ri *RegisterInfo) CRCCounter() uint16

func (*RegisterInfo) CountryCode

func (ri *RegisterInfo) CountryCode() int

func (*RegisterInfo) Flags

func (ri *RegisterInfo) Flags() int

func (*RegisterInfo) LastWriteDate

func (ri *RegisterInfo) LastWriteDate() uint16

func (*RegisterInfo) LastWriteDateAsString

func (ri *RegisterInfo) LastWriteDateAsString() string

func (*RegisterInfo) Nickname

func (ri *RegisterInfo) Nickname() string

Nickname returns the nickname as configured for the amiibo. When an empty nickname is returned this could mean the nickname could not be read!

func (*RegisterInfo) SetupDate

func (ri *RegisterInfo) SetupDate() uint16

func (*RegisterInfo) SetupDateAsString

func (ri *RegisterInfo) SetupDateAsString() string

type RetailKey

type RetailKey struct {
	// Data holds the key usually named unfixed-info.bin
	Data MasterKey
	// Tag holds the key usually named locked-secret.bin
	Tag MasterKey
}

RetailKey describes the structure of the concatenated info and secret files.

func NewRetailKey

func NewRetailKey(file string) (*RetailKey, error)

NewRetailKey loads the key data from the given file and returns a new populated RetailKey struct.

type Series

type Series int

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

func (*Settings) ApplicationData

func (s *Settings) ApplicationData() []byte

func (*Settings) ApplicationID

func (s *Settings) ApplicationID() []byte

func (*Settings) Mii

func (s *Settings) Mii() *Mii

Mii returns the Mii struct allowing you to explore the Mii data stored in the amiibo.

func (*Settings) TitleID

func (s *Settings) TitleID() []byte

func (*Settings) Unknown1

func (s *Settings) Unknown1() []byte

func (*Settings) Unknown2

func (s *Settings) Unknown2() []byte

func (*Settings) WriteCounter

func (s *Settings) WriteCounter() uint16

type SkinTone

type SkinTone int

Jump to

Keyboard shortcuts

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