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§
- Agile
Encryption Info - Parsed Agile EncryptionInfo from the XML portion of the EncryptionInfo stream.
- Crypt
Limits - Finite limits for one encrypted-container operation.
- Data
Integrity - Data integrity values (encrypted HMAC key and value).
- KeyData
- Key data parameters.
- KeyEncryptor
- Password-based key encryptor parameters.
- Standard
Encryption Header - Parsed header from a Standard Encryption EncryptionInfo stream.
- Standard
Encryption Verifier - Parsed verifier from a Standard Encryption EncryptionInfo stream.
Enums§
- Container
Format - Determines the container format of a file from its leading bytes.
- Encryption
Info - Parsed encryption information from the EncryptionInfo stream.
- Encryption
Type - 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 whosekeyDatauses a different AES key size are handled bycrate::crypt::decrypt_xlsx. - verify_
password_ agile_ with_ limits - Verify an Agile password using explicit finite KDF limits.