crypto

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DerivationPurposeEnc defines 2 bytes used when deriving a encoding key.
	DerivationPurposeEnc = []byte{0x01, 0x82}
	// DerivationPurposeMac defines 2 bytes used when deriving a mac key.
	DerivationPurposeMac = []byte{0x01, 0x01}
	// NullBytes8 defined a slice of 8 zero bytes mostrly used as IV in cryptographic functions.
	NullBytes8 = []byte{0, 0, 0, 0, 0, 0, 0, 0}
)

Functions

func AppendDESPadding

func AppendDESPadding(data []byte) []byte

AppendDESPadding appends an 0x80 bytes to data and other zero bytes to make the result length multiple of 8.

func DeriveKey

func DeriveKey(cardKey []byte, seq []byte, purpose []byte) ([]byte, error)

DeriveKey derives a key from the current cardKey using the sequence number receive from the card and the purpose (ENC/MAC).

func EncryptICV

func EncryptICV(macKey, icv []byte) ([]byte, error)

EncryptICV encrypts an ICV with the specified macKey. The ICV is usually the mac of the previous command sent in the current session.

func Mac3DES

func Mac3DES(key, data, iv []byte) ([]byte, error)

Mac3DES generates the triple DES mac of data using the specified key and icv.

func MacFull3DES

func MacFull3DES(key, data, iv []byte) ([]byte, error)

MacFull3DES generates a full triple DES mac.

func VerifyCryptogram

func VerifyCryptogram(encKey, hostChallenge, cardChallenge, cardCryptogram []byte) (bool, error)

VerifyCryptogram verifies the cryptogram sends from the card to ensure that card and client are using the same keys to communicate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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