Documentation ¶
Index ¶
- Constants
- func GCMCounterCrypt(out, in []byte, c Block, counter *[GCMBlockSize]byte)
- func NewCipherC(newCipher func([]byte) (cipher.Block, error)) func([]byte) (cipher.Block, error)
- func NewKipher(newCipher func([]byte) (cipher.Block, error)) func([]byte) (cipher.Block, error)
- func WrapCipher(b cipher.Block) cipher.Block
- type Block
- type CBCDecAble
- type CBCEncAble
- type CTR
- type CTRAble
- type GCM
- func (g *GCM) Auth(out, ciphertext, additionalData []byte, tagMask *[GCMTagSize]byte)
- func (g *GCM) DeriveCounter(counter *[GCMBlockSize]byte, nonce []byte)
- func (g *GCM) Finish(out []byte, y *GCMFieldElement, ciphertextLen, additionalDataLen int, ...)
- func (g *GCM) Init(cipher Block)
- func (g *GCM) Update(y *GCMFieldElement, blocks []byte)
- type GCMAble
- type GCMFieldElement
Constants ¶
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 ¶
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 ¶
type CBCDecAble ¶
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 ¶
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 CTRAble ¶
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) Update ¶
func (g *GCM) Update(y *GCMFieldElement, blocks []byte)
type GCMAble ¶
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.