pub fn decrypt(
private_key: &str,
data: &[u8],
) -> Result<Vec<u8>, Box<dyn Error>>Expand description
Decrypts data that was encrypted with the hybrid RSA + AES-GCM approach.
Takes a PEM-encoded RSA private key and encrypted data, then:
- Deserializes the encrypted message structure
- Decrypts the AES key using the RSA private key
- Uses the decrypted AES key to decrypt the actual data
§Arguments
private_key- A PEM-encoded RSA private keydata- The encrypted data to decrypt (as serialized byencrypt)
§Returns
The decrypted plaintext data
§Errors
Returns an error if:
- The private key is invalid or cannot be parsed
- The encrypted data cannot be deserialized
- The RSA decryption of the AES key fails
- The AES decryption of the data fails