crypto

package
v0.0.0-...-9721c62 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: GPL-3.0 Imports: 4 Imported by: 19

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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