crypto

package
v0.0.0-...-f2fe5c7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2017 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicKeySize represents the size of a public key in bytes.
	PublicKeySize = 32

	// SecretKeySize represents the size of a secret key in bytes.
	SecretKeySize = 32

	// SharedKeySize represents the size of a shared key in bytes.
	SharedKeySize = 32

	// NonceSize represents the size of a nonce in bytes.
	NonceSize = 24
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encryptedData []byte, sharedKey *[SharedKeySize]byte, nonce *[NonceSize]byte) ([]byte, error)

Decrypt uses a crypto_box_open_afternm-equivalent function to decrypt the given data.

func Encrypt

func Encrypt(data []byte, sharedKey *[SharedKeySize]byte) ([]byte, *[NonceSize]byte, error)

Encrypt uses a crypto_box_afternm-equivalent function to encrypt the given data.

func GenerateKeyPair

func GenerateKeyPair() (*[PublicKeySize]byte, *[SecretKeySize]byte, error)

GenerateKeyPair generates a new curve25519 keypair.

func GenerateNonce

func GenerateNonce() (*[NonceSize]byte, error)

GenerateNonce generates a random nonce.

func GeneratePingID

func GeneratePingID() (uint64, error)

GeneratePingID generates a new random ping ID.

func PrecomputeKey

func PrecomputeKey(publicKey *[PublicKeySize]byte, secretKey *[SecretKeySize]byte) *[SharedKeySize]byte

PrecomputeKey calculates the shared key between the peer's publicKey and our own secret key.

func Zero

func Zero(buffer []byte)

Zero replaces all values in the given buffer with zeros. This might give a false sense of security. There is no guarantee that the system hasn't swapped a piece of RAM to disk that contains this buffer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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