crypto

package
v0.0.0-...-a5c0453 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package crypto implements cryptographic functions for gonacl.

Index

Constants

View Source
const (
	// PublicKeySize is the size of a public key.
	PublicKeySize = 32
	// PrivateKeySize is the size of a private key.
	PrivateKeySize = 32
	// MaximumCleartextSize is the number of bytes a cleartext may contain AT MOST.
	MaximumCleartextSize = 500
	// NonceSize is the size of nonces.
	NonceSize = 24

	// CyphertextSize is the fixed length of any binary cyphertext.
	CyphertextSize = messageHeaderSize + paddingLengthFieldSize + MaximumCleartextSize + box.Overhead
)

Variables

View Source
var (
	// ErrMaximumMessageSize is returned if a given message is too long.
	ErrMaximumMessageSize = errors.New("gonacl/crypto: Maximum message size exceeded")
	// ErrMessageLength is returned whenever a message slice is encountered that has an unexpected length.
	ErrMessageLength = errors.New("gonacl/crypto: Unexpected message length")
	// ErrDecryptionFailed is returned if a message cannot be decrypted.
	ErrDecryptionFailed = errors.New("gonacal/crypto: Decryption failed")
)

Functions

func Decrypt

func Decrypt(cyphertext []byte, privatekey *[PrivateKeySize]byte) (cleartest []byte, err error)

Decrypt a cyphertext with a private key.

func Encrypt

func Encrypt(publicKey *[PublicKeySize]byte, cleartext []byte) (encrypted *[CyphertextSize]byte, err error)

Encrypt the given cleartext to the public key. Message is always padded to 500 byte.

func GenerateKeys

func GenerateKeys() (publicKey *[PublicKeySize]byte, privatekey *[PrivateKeySize]byte, err error)

GenerateKeys returns a keypair for curve25519.

Types

This section is empty.

Jump to

Keyboard shortcuts

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