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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.