Source File
aes_gcm.go
Belonging Package
crypto/aes
package aes
import (
subtleoverlap
)
func ( *[256]byte, , *[16]byte, , uint64)
const (
gcmBlockSize = 16
gcmTagSize = 16
gcmMinimumTagSize = 12 // NIST SP 800-38D recommends tags with 12 or more bytes.
gcmStandardNonceSize = 12
)
var errOpen = errors.New("cipher: message authentication failed")
type aesCipherGCM struct {
aesCipherAsm
}
var _ gcmAble = (*aesCipherGCM)(nil)
func ( *aesCipherGCM) (, int) (cipher.AEAD, error) {
:= &gcmAsm{ks: .enc, nonceSize: , tagSize: }
gcmAesInit(&.productTable, .ks)
return , nil
}
copy([:], )
[gcmBlockSize-1] = 1
gcmAesData(&.productTable, , &)
gcmAesFinish(&.productTable, &, &, uint64(len()), uint64(0))
}
encryptBlockAsm(len(.ks)/4-1, &.ks[0], &[0], &[0])
var [gcmTagSize]byte
gcmAesData(&.productTable, , &)
, := sliceForAppend(, len()+.tagSize)
if subtleoverlap.InexactOverlap([:len()], ) {
panic("crypto/cipher: invalid buffer overlap")
}
if len() > 0 {
gcmAesEnc(&.productTable, , , &, &, .ks)
}
gcmAesFinish(&.productTable, &, &, uint64(len()), uint64(len()))
copy([len():], [:])
return
}
var , [gcmBlockSize]byte
copy([:], )
[gcmBlockSize-1] = 1
gcmAesData(&.productTable, , &)
gcmAesFinish(&.productTable, &, &, uint64(len()), uint64(0))
}
encryptBlockAsm(len(.ks)/4-1, &.ks[0], &[0], &[0])
var [gcmTagSize]byte
gcmAesData(&.productTable, , &)
, := sliceForAppend(, len())
if subtleoverlap.InexactOverlap(, ) {
panic("crypto/cipher: invalid buffer overlap")
}
if len() > 0 {
gcmAesDec(&.productTable, , , &, &, .ks)
}
gcmAesFinish(&.productTable, &, &, uint64(len()), uint64(len()))
if subtle.ConstantTimeCompare([:.tagSize], ) != 1 {
for := range {
[] = 0
}
return nil, errOpen
}
return , nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |