lrp

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LrpCipher

type LrpCipher struct {
	Multi       *LrpMultiCipher
	Key         []byte
	Counter     uint64
	CounterSize int
	Encrypting  bool
}

func (*LrpCipher) BlockSize

func (lrp *LrpCipher) BlockSize() int

Number of bytes in a block

func (*LrpCipher) CounterPieces

func (lrp *LrpCipher) CounterPieces() []int

Breaks the block counter into nibbles for the EvalLRP primitive

func (*LrpCipher) CryptBlocks

func (lrp *LrpCipher) CryptBlocks(dst, src []byte)

Standard BlockMode interface functions

func (*LrpCipher) Decrypt

func (lrp *LrpCipher) Decrypt(dst, src []byte)

Decrypt a single block

func (*LrpCipher) DecryptAll

func (lrp *LrpCipher) DecryptAll(src []byte, removePadding bool) []byte

Decrypt the entire message. removePadding tells whether or not it was originally padded, and, therefore, whether to remove the padding before it is returned.

func (*LrpCipher) DecryptBlocks

func (lrp *LrpCipher) DecryptBlocks(dst, src []byte)

Decrypt the given blocks in src to dst. Requires full blocks.

func (*LrpCipher) Decrypter

func (lrp *LrpCipher) Decrypter() *LrpCipher

Generates a decrypting cipher, compatible with cipher.BlockMode

func (*LrpCipher) Encrypt

func (lrp *LrpCipher) Encrypt(dst, src []byte)

Encrypt a single block

func (*LrpCipher) EncryptAll

func (lrp *LrpCipher) EncryptAll(src []byte, padEvenBlocks bool) []byte

Encrypt the entire message. All non-even blocks are padded. Setting padEvenBlocks to true will give you padded blocks no matter what. This is normally what you want, but NXP has a few cases of non-padded encryption.

func (*LrpCipher) EncryptBlocks

func (lrp *LrpCipher) EncryptBlocks(dst, src []byte)

Encrypts the given blocks from src to dst. Based on the smaller of src/dst. Requires that src is only full blocks.

func (*LrpCipher) Encrypter

func (lrp *LrpCipher) Encrypter() *LrpCipher

Generates a encrypting cipher, compatible with cipher.BlockMode

func (*LrpCipher) EvalLRP

func (lrp *LrpCipher) EvalLRP(x []int, final bool) []byte

This is the fundamental primitive used for encryption/decryption

type LrpForMAC

type LrpForMAC struct {
	LrpCipher
}

func (*LrpForMAC) CMAC

func (lrp *LrpForMAC) CMAC(msg []byte) []byte

Convenience function for doing a CMAC

func (*LrpForMAC) Encrypt

func (lrp *LrpForMAC) Encrypt(dst, src []byte)

This overrides the Encrypt method on LrpCipher to only run the EvalLRP

func (*LrpForMAC) ShortCMAC

func (lrp *LrpForMAC) ShortCMAC(msg []byte) []byte

Convenience function for doing an NXP-style short CMAC

type LrpMultiCipher

type LrpMultiCipher struct {
	MainKey []byte
	M       int      // Nibble Size
	P       [][]byte // Plaintexts
}

func NewMultiCipher

func NewMultiCipher(key []byte, nibbleSize int) *LrpMultiCipher

Creates a new multi-cipher with a given nibble size

func NewStandardMultiCipher

func NewStandardMultiCipher(key []byte) *LrpMultiCipher

Create a multi-cipher with the standard nibble size

func (LrpMultiCipher) Cipher

func (lrp LrpMultiCipher) Cipher(idx int) *LrpCipher

Generates a cipher with the specific key number from the multi-cypher.

func (LrpMultiCipher) CipherForMAC

func (lrp LrpMultiCipher) CipherForMAC(idx int) *LrpForMAC

Generates a cipher specifically for use for MAC-ing (uses the LRP primitive rather than the encryption). Note that the “Encrypt” function doesn't actually encrypt/decrypt, but MAC processes utilize that interface.

func (*LrpMultiCipher) Reset

func (lrp *LrpMultiCipher) Reset()

Recalculates all of the shared plaintexts of the multi-cipher

Jump to

Keyboard shortcuts

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