Skip to main content

decrypt_bytes

Function decrypt_bytes 

Source
pub fn decrypt_bytes(
    encrypted: &[u8],
    passphrase: &str,
) -> Result<Vec<u8>, AgentError>
Expand description

Decrypts data using a tagged encryption format and a user-provided passphrase.

Supports three tag formats:

  • Tag 1 (AES-GCM) / Tag 2 (ChaCha20): Legacy HKDF path [tag][salt:16][nonce:12][ciphertext]
  • Tag 3 (Argon2id): [0x03][salt:16][m_cost:4 LE][t_cost:4 LE][p_cost:4 LE][algo_tag:1][nonce:12][ciphertext]

If decryption fails (e.g. due to wrong passphrase), returns AgentError::IncorrectPassphrase.