kipher

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GCMBlockSize         = 16
	GCMTagSize           = 16
	GCMMinimumTagSize    = 12 // NIST SP 800-38D recommends tags with 12 or more bytes.
	GCMStandardNonceSize = 12
)

Variables

This section is empty.

Functions

func GCMCounterCrypt

func GCMCounterCrypt(out, in []byte, c Block, counter *[GCMBlockSize]byte)

counterCrypt crypts in to out using g.cipher in counter mode.

func NewCipherC

func NewCipherC(newCipher func([]byte) (cipher.Block, error)) func([]byte) (cipher.Block, error)

func NewKipher

func NewKipher(newCipher func([]byte) (cipher.Block, error)) func([]byte) (cipher.Block, error)

func WrapCipher

func WrapCipher(b cipher.Block) cipher.Block

Types

type Block

type Block interface {
	cipher.Block

	Encrypt4(dst, src []byte)
	Decrypt4(dst, src []byte)

	Encrypt8(dst, src []byte)
	Decrypt8(dst, src []byte)
}

func WrapKipher

func WrapKipher(b cipher.Block) Block

type CBCDecAble

type CBCDecAble interface {
	NewCBCDecrypter(iv []byte) cipher.BlockMode
}

cbcDecAble is an interface implemented by ciphers that have a specific optimized implementation of CBC decryption, like crypto/aes. NewCBCDecrypter will check for this interface and return the specific BlockMode if found.

type CBCEncAble

type CBCEncAble interface {
	NewCBCEncrypter(iv []byte) cipher.BlockMode
}

cbcEncAble is an interface implemented by ciphers that have a specific optimized implementation of CBC encryption, like crypto/aes. NewCBCEncrypter will check for this interface and return the specific BlockMode if found.

type CTR

type CTR struct {
	Out []byte
	// contains filtered or unexported fields
}

func (*CTR) CopyCTR

func (x *CTR) CopyCTR(b []byte)

func (*CTR) Init

func (x *CTR) Init(b Block, iv []byte, ctrSize int)

func (*CTR) Refill

func (x *CTR) Refill(blocks int)

func (*CTR) Xor

func (x *CTR) Xor(out, in []byte)

type CTRAble

type CTRAble interface {
	NewCTR(iv []byte) cipher.Stream
}

ctrAble is an interface implemented by ciphers that have a specific optimized implementation of CTR, like crypto/aes. NewCTR will check for this interface and return the specific Stream if found.

type GCM

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

GCM represents a Galois Counter Mode with a specific key. See https://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/GCM/GCM-revised-spec.pdf

func (*GCM) Auth

func (g *GCM) Auth(out, ciphertext, additionalData []byte, tagMask *[GCMTagSize]byte)

func (*GCM) DeriveCounter

func (g *GCM) DeriveCounter(counter *[GCMBlockSize]byte, nonce []byte)

func (*GCM) Finish

func (g *GCM) Finish(out []byte, y *GCMFieldElement, ciphertextLen, additionalDataLen int, tagMask *[GCMTagSize]byte)

func (*GCM) Init

func (g *GCM) Init(cipher Block)

func (*GCM) Update

func (g *GCM) Update(y *GCMFieldElement, blocks []byte)

type GCMAble

type GCMAble interface {
	NewGCM(nonceSize, tagSize int) (cipher.AEAD, error)
}

gcmAble is an interface implemented by ciphers that have a specific optimized implementation of GCM, like crypto/aes. NewGCM will check for this interface and return the specific AEAD if found.

type GCMFieldElement

type GCMFieldElement struct {
	Low, High uint64
}

GCMFieldElement represents a value in GF(2¹²⁸). In order to reflect the GCM standard and make binary.BigEndian suitable for marshaling these values, the bits are stored in big endian order. For example:

the coefficient of x⁰ can be obtained by v.low >> 63.
the coefficient of x⁶³ can be obtained by v.low & 1.
the coefficient of x⁶⁴ can be obtained by v.high >> 63.
the coefficient of x¹²⁷ can be obtained by v.high & 1.

Jump to

Keyboard shortcuts

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