Source File
xchacha20poly1305.go
Belonging Package
vendor/golang.org/x/crypto/chacha20poly1305
package chacha20poly1305
import (
)
type xchacha20poly1305 struct {
key [KeySize]byte
}
func ( []byte) (cipher.AEAD, error) {
if len() != KeySize {
return nil, errors.New("chacha20poly1305: bad key length")
}
:= new(xchacha20poly1305)
copy(.key[:], )
return , nil
}
func (*xchacha20poly1305) () int {
return NonceSizeX
}
func (*xchacha20poly1305) () int {
return 16
}
func ( *xchacha20poly1305) (, , , []byte) []byte {
if len() != NonceSizeX {
panic("chacha20poly1305: bad nonce length passed to Seal")
}
:= make([]byte, NonceSize)
copy([4:12], [16:24])
return .seal(, [:], , )
}
func ( *xchacha20poly1305) (, , , []byte) ([]byte, error) {
if len() != NonceSizeX {
panic("chacha20poly1305: bad nonce length passed to Open")
}
if len() < 16 {
return nil, errOpen
}
if uint64(len()) > (1<<38)-48 {
panic("chacha20poly1305: ciphertext too large")
}
:= new(chacha20poly1305)
, := chacha20.HChaCha20(.key[:], [0:16])
copy(.key[:], )
![]() |
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. |