const ( KeySize = 16 // For Ascon128 and Ascon128a. KeySize80pq = 20 // Only for Ascon80pq. NonceSize = 16 TagSize = 16 )
var ( ErrKeySize = errors.New("ascon: bad key size") ErrNonceSize = errors.New("ascon: bad nonce size") ErrDecryption = errors.New("ascon: invalid ciphertext") ErrMode = errors.New("ascon: invalid cipher mode") )
type Cipher struct {
// contains filtered or unexported fields
}
func New(key []byte, m Mode) (*Cipher, error)
New returns a Cipher struct implementing the crypto/cipher.AEAD interface. The key must be Mode.KeySize() bytes long, and the mode is one of Ascon128, Ascon128a or Ascon80pq.
func (a *Cipher) NonceSize() int
NonceSize returns the size of the nonce that must be passed to Seal and Open.
func (a *Cipher) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error)
Open decrypts and authenticates ciphertext, authenticates the additional data and, if successful, appends the resulting plaintext to dst, returning the updated slice. The nonce must be NonceSize() bytes long and both it and the additional data must match the value passed to Seal.
To reuse ciphertext's storage for the decrypted output, use ciphertext[:0] as dst. Otherwise, the remaining capacity of dst must not overlap plaintext.
Even if the function fails, the contents of dst, up to its capacity, may be overwritten.
func (a *Cipher) Overhead() int
Overhead returns the maximum difference between the lengths of a plaintext and its ciphertext.
func (a *Cipher) Seal(dst, nonce, plaintext, additionalData []byte) []byte
Seal encrypts and authenticates plaintext, authenticates the additional data and appends the result to dst, returning the updated slice. The nonce must be NonceSize() bytes long and unique for all time, for a given key.
To reuse plaintext's storage for the encrypted output, use plaintext[:0] as dst. Otherwise, the remaining capacity of dst must not overlap plaintext.
type Mode int
const ( Ascon128 Mode = 1 Ascon128a Mode = 2 Ascon80pq Mode = -1 )
func (m Mode) KeySize() int
KeySize is 16 for Ascon128 and Ascon128a, or 20 for Ascon80pq.
func (m Mode) String() string