7.1. Public Key Encryption (PKE)¶
Data Types:
- PKEEncKey
The RSA public key for public-key encryption with RSA.
- PKEDecKey
The RSA private key, used for RSA decryption.
Functions:
-
PKEKeyGen
() (PKEEncKey, PKEDecKey, error)¶ Generate a 2048-bit RSA key pair for public-key encryption.
- Return type
PKEEncKey, PKEDecKey, error
-
PKEEnc
(ek PKEEncKey, plaintext []byte) ([]byte, error)¶ Use the RSA public key to encrypt a message.
- Parameters
ek (PKEEncKey) – RSA encryption (public) key
plaintext ([]byte) – Message to encrypt, no longer than 126 bytes
- Return type
[]byte, error
-
PKEDec
(dk PKEDecKey, ciphertext []byte) ([]byte, error)¶ Use the RSA private key to decrypt a ciphertext.
- Parameters
ek (PKEDecKey) – RSA encryption (private) key
ciphertext ([]byte) – Message to decrypt
- Return type
[]byte, error
Warning
PKEEnc does not support very long plaintext.