Skip to main content

Module crypt

Module crypt 

Source
Expand description

Encryption and decryption support for password-protected Excel files.

Excel files can be encrypted using either Standard Encryption (Office 2007, AES-128-ECB) or Agile Encryption (Office 2010+, AES-256-CBC). Encrypted files are stored in an OLE/CFB compound file container rather than a plain ZIP archive.

This module provides:

  • CFB container reading and writing
  • EncryptionInfo parsing (both Standard and Agile formats)
  • Standard Encryption decryption (read-only)
  • Agile Encryption decryption and encryption (read/write)

Modules§

block_keys
Block key constants used in Agile Encryption key derivation.

Structs§

AgileEncryptionInfo
Parsed Agile EncryptionInfo from the XML portion of the EncryptionInfo stream.
CryptLimits
Finite limits for one encrypted-container operation.
DataIntegrity
Data integrity values (encrypted HMAC key and value).
KeyData
Key data parameters.
KeyEncryptor
Password-based key encryptor parameters.
StandardEncryptionHeader
Parsed header from a Standard Encryption EncryptionInfo stream.
StandardEncryptionVerifier
Parsed verifier from a Standard Encryption EncryptionInfo stream.

Enums§

ContainerFormat
Determines the container format of a file from its leading bytes.
EncryptionInfo
Parsed encryption information from the EncryptionInfo stream.
EncryptionType
Encryption type detected from the EncryptionInfo stream.

Functions§

decrypt_xlsx
Read the EncryptionInfo and EncryptedPackage streams from a CFB container, verify the password, decrypt the package, and return the raw ZIP bytes.
decrypt_xlsx_with_limits
Decrypt an encrypted Office container using explicit finite limits.
detect_container_format
Identifies the container format by inspecting magic bytes.
encrypt_package_agile
Encrypt ZIP data using Agile Encryption and return (encrypted_package_with_size_prefix, info).
encrypt_package_agile_with_limits
Encrypt package bytes using explicit finite KDF limits.
encrypt_xlsx
Encrypt a ZIP buffer with a password and write it as a CFB container. Returns the CFB container bytes.
encrypt_xlsx_with_limits
Encrypt ZIP bytes into an Office container using explicit finite limits.
verify_password_agile
Verify a password against Agile Encryption encryptor data. Returns the decrypted secret key, sized for the password encryptor’s keyBits, on success. Packages whose keyData uses a different AES key size are handled by crate::crypt::decrypt_xlsx.
verify_password_agile_with_limits
Verify an Agile password using explicit finite KDF limits.