package gcm
import (
)
func ( *GCM, , , , []byte) {
if uint64(len()) > uint64((1<<32)-2)*gcmBlockSize {
panic("crypto/cipher: message too large for GCM")
}
if len() != gcmStandardNonceSize {
panic("crypto/cipher: incorrect nonce length given to GCMWithRandomNonce")
}
if len() != len()+gcmTagSize {
panic("crypto/cipher: incorrect output length given to GCMWithRandomNonce")
}
if alias.InexactOverlap(, ) {
panic("crypto/cipher: invalid buffer overlap of output and input")
}
if alias.AnyOverlap(, ) {
panic("crypto/cipher: invalid buffer overlap of output and additional data")
}
fips140.RecordApproved()
drbg.Read()
seal(, , , , )
}
func ( *aes.Block) (*GCMWithCounterNonce, error) {
, := newGCM(&GCM{}, , gcmStandardNonceSize, gcmTagSize)
if != nil {
return nil,
}
return &GCMWithCounterNonce{g: *}, nil
}
type GCMWithCounterNonce struct {
g GCM
ready bool
fixedName uint32
start uint64
next uint64
}
func ( *GCMWithCounterNonce) () int { return gcmStandardNonceSize }
func ( *GCMWithCounterNonce) () int { return gcmTagSize }
func ( *GCMWithCounterNonce) (, , , []byte) []byte {
if len() != gcmStandardNonceSize {
panic("crypto/cipher: incorrect nonce length given to GCM")
}
:= byteorder.BEUint64([len()-8:])
if !.ready {
.ready = true
.start =
.fixedName = byteorder.BEUint32([:4])
}
if .fixedName != byteorder.BEUint32([:4]) {
panic("crypto/cipher: incorrect module name given to GCMWithCounterNonce")
}
-= .start
if == math.MaxUint64 {
panic("crypto/cipher: counter wrapped")
}
if < .next {
panic("crypto/cipher: counter decreased")
}
.next = + 1
fips140.RecordApproved()
return .g.sealAfterIndicator(, , , )
}
func ( *GCMWithCounterNonce) (, , , []byte) ([]byte, error) {
fips140.RecordApproved()
return .g.Open(, , , )
}
func ( *aes.Block) (*GCMForTLS12, error) {
, := newGCM(&GCM{}, , gcmStandardNonceSize, gcmTagSize)
if != nil {
return nil,
}
return &GCMForTLS12{g: *}, nil
}
type GCMForTLS12 struct {
g GCM
next uint64
}
func ( *GCMForTLS12) () int { return gcmStandardNonceSize }
func ( *GCMForTLS12) () int { return gcmTagSize }
func ( *GCMForTLS12) (, , , []byte) []byte {
if len() != gcmStandardNonceSize {
panic("crypto/cipher: incorrect nonce length given to GCM")
}
:= byteorder.BEUint64([len()-8:])
if == math.MaxUint64 {
panic("crypto/cipher: counter wrapped")
}
if < .next {
panic("crypto/cipher: counter decreased")
}
.next = + 1
fips140.RecordApproved()
return .g.sealAfterIndicator(, , , )
}
func ( *GCMForTLS12) (, , , []byte) ([]byte, error) {
fips140.RecordApproved()
return .g.Open(, , , )
}
func ( *aes.Block) (*GCMForTLS13, error) {
, := newGCM(&GCM{}, , gcmStandardNonceSize, gcmTagSize)
if != nil {
return nil,
}
return &GCMForTLS13{g: *}, nil
}
type GCMForTLS13 struct {
g GCM
ready bool
mask uint64
next uint64
}
func ( *GCMForTLS13) () int { return gcmStandardNonceSize }
func ( *GCMForTLS13) () int { return gcmTagSize }
func ( *GCMForTLS13) (, , , []byte) []byte {
if len() != gcmStandardNonceSize {
panic("crypto/cipher: incorrect nonce length given to GCM")
}
:= byteorder.BEUint64([len()-8:])
if !.ready {
.ready = true
.mask =
}
^= .mask
if == math.MaxUint64 {
panic("crypto/cipher: counter wrapped")
}
if < .next {
panic("crypto/cipher: counter decreased")
}
.next = + 1
fips140.RecordApproved()
return .g.sealAfterIndicator(, , , )
}
func ( *GCMForTLS13) (, , , []byte) ([]byte, error) {
fips140.RecordApproved()
return .g.Open(, , , )
}
func ( *aes.Block) (*GCMForSSH, error) {
, := newGCM(&GCM{}, , gcmStandardNonceSize, gcmTagSize)
if != nil {
return nil,
}
return &GCMForSSH{g: *}, nil
}
type GCMForSSH struct {
g GCM
ready bool
start uint64
next uint64
}
func ( *GCMForSSH) () int { return gcmStandardNonceSize }
func ( *GCMForSSH) () int { return gcmTagSize }
func ( *GCMForSSH) (, , , []byte) []byte {
if len() != gcmStandardNonceSize {
panic("crypto/cipher: incorrect nonce length given to GCM")
}
:= byteorder.BEUint64([len()-8:])
if !.ready {
.ready = true
.start =
}
-= .start
if == math.MaxUint64 {
panic("crypto/cipher: counter wrapped")
}
if < .next {
panic("crypto/cipher: counter decreased")
}
.next = + 1
fips140.RecordApproved()
return .g.sealAfterIndicator(, , , )
}
func ( *GCMForSSH) (, , , []byte) ([]byte, error) {
fips140.RecordApproved()
return .g.Open(, , , )
}