chacha20poly1305

package
v0.0.0-...-dd73372 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2017 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

Package chacha20poly1305 contains the libsodium bindings for ChaCha20-Poly1305.

Index

Constants

View Source
const (
	KeyBytes   int = C.crypto_aead_chacha20poly1305_KEYBYTES  // Size of a secret key in bytes
	NSecBytes  int = C.crypto_aead_chacha20poly1305_NSECBYTES // Size of a secret nonce in bytes
	NonceBytes int = C.crypto_aead_chacha20poly1305_NPUBBYTES // Size of a nonce in bytes
	ABytes     int = C.crypto_aead_chacha20poly1305_ABYTES    // Size of an authentication tag in bytes
)

Sizes of nonces, key and mac.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(c, ad []byte, nonce *[NonceBytes]byte, k *[KeyBytes]byte) (m []byte, err error)

Decrypt and verify a ciphertext `c` using additional data `ad`, nonce `npub` and secret key `k`. Returns the decrypted message and verification status.

func DecryptDetached

func DecryptDetached(c, mac, ad []byte, nonce *[NonceBytes]byte, k *[KeyBytes]byte) (m []byte, err error)

DecryptDetached decrypts and verifies a ciphertext `c` with authentication tag `mac` using additional data `ad`, nonce `npub` and secret key `k`. Returns the decrypted message and verification status.

func Encrypt

func Encrypt(m, ad []byte, nonce *[NonceBytes]byte, k *[KeyBytes]byte) (c []byte)

Encrypt a message `m` with additional data `ad` using a nonce `npub` and a secret key `k`. A ciphertext (including authentication tag) and encryption status are returned.

func EncryptDetached

func EncryptDetached(m, ad []byte, nonce *[NonceBytes]byte, k *[KeyBytes]byte) (c, mac []byte)

EncryptDetached encrypts a message `m` with additional data `ad` using a nonce `npub` and a secret key `k`. A ciphertext, authentication tag and encryption status are returned.

func GenerateKey

func GenerateKey() *[KeyBytes]byte

GenerateKey generates a secret key

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL