Documentation
¶
Index ¶
- func Decrypt(hash hash.Hash, random io.Reader, k int, priv *p11.PrivateKey, ...) ([]byte, error)
- func Encrypt(hash hash.Hash, random io.Reader, pub *rsa.PublicKey, plaintext []byte, ...) ([]byte, error)
- func GetKey(session p11.Session, keyLabel string) (pub *rsa.PublicKey, priv *p11.PrivateKey, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
func Decrypt(hash hash.Hash, random io.Reader, k int, priv *p11.PrivateKey, ciphertext []byte, label []byte) ([]byte, error)
Decrypt decrypts ciphertext using RSA-OAEP.
OAEP is parameterised by a hash function that is used as a random oracle. Encryption and decryption of a given message must use the same hash function and sha256.New() is a reasonable choice.
The label parameter must match the value given when encrypting. See Encrypt for details.
func Encrypt ¶
func Encrypt(hash hash.Hash, random io.Reader, pub *rsa.PublicKey, plaintext []byte, label []byte) ([]byte, error)
Encrypt encrypts the given message with RSA-OAEP.
OAEP is parameterised by a hash function that is used as a random oracle. Encryption and decryption of a given message must use the same hash function and sha256.New() is a reasonable choice.
The random parameter is used as a source of entropy to ensure that encrypting the same message twice doesn't result in the same ciphertext.
The label parameter may contain arbitrary data that will not be encrypted, but which gives important context to the message. For example, if a given public key is used to decrypt two types of messages then distinct label values could be used to ensure that a ciphertext for one purpose cannot be used for another by an attacker. If not required it can be empty.
The message must be no longer than the length of the public modulus minus twice the hash length, minus a further 2.
NB this is compatible with Go 1.15 rsa.EncryptOAEP (which you can use).
but its here to maintain the symmetry of the operations.
Types ¶
This section is empty.