encryption

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package encryption is used to encrypt and decrypt data using asymmetric algorithms. We expose methods to encrypt long messages (>256 bits) and shorts messages (<256 bits).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCouldNotDecrypt is returned when the message decryption has failed for crypto reasons.
	ErrCouldNotDecrypt = errors.New("could not decrypt the message")

	// ErrNotImplemented is returned when trying to use an algo that does not handle encryption.
	ErrNotImplemented = errors.New("Unhandled encryption algorithm")
)

Functions

func Decrypt

func Decrypt(secretKey, data []byte) ([]byte, error)

Decrypt decrypts a long message with the private key. Only RSA keys are supported for now. The ciphertext is actually composed of: - a RSA-OAEP encrypted AES key - an AES-256-GCM encrypted message Returns the bytes of the plaintext.

func DecryptShort

func DecryptShort(secretKey, data []byte) ([]byte, error)

DecryptShort decrypt a short message. for 2048-bit RSA keys, the max message size is 214 bytes. Only RSA keys are supported for now. The message is directly RSA-OAEP decrypted. Returns the bytes of the plaintext.

func Encrypt

func Encrypt(publicKey, data []byte) ([]byte, error)

Encrypt encrypt a long message with the private key. Only RSA keys are supported for now. The message is first encrypted with AES-256-GCM with a random key. The we encrypt the AES key with the public key. Returns the bytes of the ciphertext.

func EncryptShort

func EncryptShort(publicKey, data []byte) ([]byte, error)

EncryptShort encrypts a short message. for 2048-bit RSA keys, the max message size is 214 bytes. Only RSA keys are supported for now. The message is directly RSA-OAEP encrypted. Returns the bytes of the ciphertext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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