Documentation ¶
Index ¶
- Constants
- func CeilDiv(a, b int) int
- func GCMCounterCrypt(out, in []byte, c Block, counter *[GCMBlockSize]byte)
- func IncCtr(b []byte)
- func NewCipher(newCipher func([]byte) (cipher.Block, error)) func([]byte) (cipher.Block, error)
- type Block
- type CTR
- 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 ¶
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.
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 WrapCipher ¶
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.
Click to show internal directories.
Click to hide internal directories.