pub fn raw_encrypt(
public_key: &RsaPublicKey,
data: &[u8],
) -> Result<Vec<u8>, Box<dyn Error>>Expand description
Encrypts data using a hybrid RSA + AES-GCM approach with a pre-parsed RSA public key.
This is similar to encrypt but takes an already parsed RsaPublicKey object
rather than a PEM-encoded string.
§Arguments
public_key- The RSA public key objectdata- The plaintext data to encrypt
§Returns
A serialized EncryptedMessage containing the encrypted data
§Errors
Returns an error if:
- The AES encryption fails
- The RSA encryption of the AES key fails
- Serialization fails