Documentation
¶
Overview ¶
Package crypto implements cryptographic functions for gonacl.
Index ¶
- Constants
- Variables
- func Decrypt(cyphertext []byte, privatekey *[PrivateKeySize]byte) (cleartest []byte, err error)
- func Encrypt(publicKey *[PublicKeySize]byte, cleartext []byte) (encrypted *[CyphertextSize]byte, err error)
- func GenerateKeys() (publicKey *[PublicKeySize]byte, privatekey *[PrivateKeySize]byte, err error)
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.
Click to show internal directories.
Click to hide internal directories.