Files
craft-libs/crates/offcrypto
dependabot[bot] cc60eb3898 chore(deps): bump the cargo-dependencies group across 1 directory with 30 updates
Bumps the cargo-dependencies group with 30 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [acadrust](https://github.com/hakanaktt/acadrust) | `0.6.6` | `0.6.8` |
| [log](https://github.com/rust-lang/log) | `0.4.34` | `0.4.35` |
| [miniz_oxide](https://github.com/Frommi/miniz_oxide) | `0.8.9` | `0.9.1` |
| [weezl](https://github.com/image-rs/weezl) | `0.1.12` | `0.2.1` |
| [skrifa](https://github.com/googlefonts/fontations) | `0.44.0` | `0.48.0` |
| [jixel](https://github.com/awxkee/jixel) | `0.3.4` | `0.5.7` |
| [encoding_rs](https://github.com/hsivonen/encoding_rs) | `0.8.42` | `0.8.44` |
| [crc32fast](https://github.com/srijs/rust-crc32fast) | `1.5.2` | `1.5.5` |
| [flate2](https://github.com/rust-lang/flate2-rs) | `1.1.10` | `1.1.11` |
| [rustix](https://github.com/bytecodealliance/rustix) | `1.1.5` | `1.1.6` |
| [moxcms](https://github.com/awxkee/moxcms) | `0.8.1` | `0.9.2` |
| [zip](https://github.com/zip-rs/zip2) | `9.1.3` | `9.5.1` |
| [rfd](https://github.com/PolyMeilex/rfd) | `0.17.2` | `0.18.0` |
| [sha1](https://github.com/RustCrypto/hashes) | `0.10.7` | `0.11.0` |
| [cfb](https://github.com/mdsteele/rust-cfb) | `0.15.0` | `0.16.0` |
| [quick-xml](https://github.com/tafia/quick-xml) | `0.41.0` | `0.42.0` |
| [harfrust](https://github.com/harfbuzz/harfrust) | `0.13.3` | `0.16.0` |
| [fontique](https://github.com/linebender/parley) | `0.11.1` | `0.13.0` |
| [windows-registry](https://github.com/microsoft/windows-rs) | `0.6.1` | `0.100.0` |
| [write-fonts](https://github.com/googlefonts/fontations) | `0.54.1` | `0.56.0` |
| [ureq](https://github.com/algesten/ureq) | `3.5.0` | `3.5.2` |
| [skera](https://github.com/googlefonts/fontations) | `0.8.0` | `0.10.0` |
| [icu_locale_core](https://github.com/unicode-org/icu4x) | `2.3.0` | `2.4.0` |
| [icu_provider](https://github.com/unicode-org/icu4x) | `2.3.1` | `2.4.0` |
| [icu_provider_blob](https://github.com/unicode-org/icu4x) | `2.3.0` | `2.4.0` |
| [jpeg-encoder](https://github.com/vstroebel/jpeg-encoder) | `0.6.1` | `0.7.1` |
| [hayro-jpeg2000](https://github.com/LaurenzV/hayro) | `0.3.5` | `0.5.0` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.53.2` | `1.54.1` |
| [getrandom](https://github.com/rust-random/getrandom) | `0.3.4` | `0.4.3` |
| [pgp](https://github.com/rpgp/rpgp) | `0.21.0` | `0.21.1` |



Updates `acadrust` from 0.6.6 to 0.6.8
- [Release notes](https://github.com/hakanaktt/acadrust/releases)
- [Changelog](https://github.com/hakanaktt/acadrust/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hakanaktt/acadrust/compare/v0.6.6...v0.6.8)

Updates `log` from 0.4.34 to 0.4.35
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.34...v0.4.35)

Updates `miniz_oxide` from 0.8.9 to 0.9.1
- [Changelog](https://github.com/Frommi/miniz_oxide/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Frommi/miniz_oxide/commits)

Updates `weezl` from 0.1.12 to 0.2.1
- [Changelog](https://github.com/image-rs/weezl/blob/master/Changes.md)
- [Commits](https://github.com/image-rs/weezl/compare/v0.1.12...v0.2.1)

Updates `skrifa` from 0.44.0 to 0.48.0
- [Release notes](https://github.com/googlefonts/fontations/releases)
- [Changelog](https://github.com/googlefonts/fontations/blob/main/docs/RELEASE.md)
- [Commits](https://github.com/googlefonts/fontations/compare/skrifa-v0.44.0...skrifa-v0.48.0)

Updates `jixel` from 0.3.4 to 0.5.7
- [Release notes](https://github.com/awxkee/jixel/releases)
- [Commits](https://github.com/awxkee/jixel/compare/0.3.4...0.5.7)

Updates `encoding_rs` from 0.8.42 to 0.8.44
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.42...v0.8.44)

Updates `crc32fast` from 1.5.2 to 1.5.5
- [Commits](https://github.com/srijs/rust-crc32fast/compare/v1.5.2...v1.5.5)

Updates `flate2` from 1.1.10 to 1.1.11
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Changelog](https://github.com/rust-lang/flate2-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.1.10...v1.1.11)

Updates `rustix` from 1.1.5 to 1.1.6
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Changelog](https://github.com/bytecodealliance/rustix/blob/main/CHANGES.md)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v1.1.5...v1.1.6)

Updates `moxcms` from 0.8.1 to 0.9.2
- [Release notes](https://github.com/awxkee/moxcms/releases)
- [Commits](https://github.com/awxkee/moxcms/compare/0.8.1...0.9.2)

Updates `zip` from 9.1.3 to 9.5.1
- [Release notes](https://github.com/zip-rs/zip2/releases)
- [Changelog](https://github.com/zip-rs/zip2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zip-rs/zip2/compare/v9.1.3...v9.5.1)

Updates `rfd` from 0.17.2 to 0.18.0
- [Release notes](https://github.com/PolyMeilex/rfd/releases)
- [Changelog](https://github.com/PolyMeilex/rfd/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PolyMeilex/rfd/compare/0.17.2...0.18.0)

Updates `sha1` from 0.10.7 to 0.11.0
- [Commits](https://github.com/RustCrypto/hashes/compare/sha1-v0.10.7...sha1-v0.11.0)

Updates `cfb` from 0.15.0 to 0.16.0
- [Commits](https://github.com/mdsteele/rust-cfb/compare/v0.15.0...v0.16.0)

Updates `quick-xml` from 0.41.0 to 0.42.0
- [Release notes](https://github.com/tafia/quick-xml/releases)
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md)
- [Commits](https://github.com/tafia/quick-xml/compare/v0.41.0...v0.42.0)

Updates `harfrust` from 0.13.3 to 0.16.0
- [Release notes](https://github.com/harfbuzz/harfrust/releases)
- [Changelog](https://github.com/harfbuzz/harfrust/blob/main/CHANGELOG.md)
- [Commits](https://github.com/harfbuzz/harfrust/compare/0.13.3...0.16.0)

Updates `fontique` from 0.11.1 to 0.13.0
- [Release notes](https://github.com/linebender/parley/releases)
- [Changelog](https://github.com/linebender/parley/blob/main/CHANGELOG.md)
- [Commits](https://github.com/linebender/parley/compare/v0.11.1...v0.13.0)

Updates `windows-registry` from 0.6.1 to 0.100.0
- [Release notes](https://github.com/microsoft/windows-rs/releases)
- [Commits](https://github.com/microsoft/windows-rs/commits)

Updates `write-fonts` from 0.54.1 to 0.56.0
- [Release notes](https://github.com/googlefonts/fontations/releases)
- [Changelog](https://github.com/googlefonts/fontations/blob/main/docs/RELEASE.md)
- [Commits](https://github.com/googlefonts/fontations/compare/write-fonts-v0.54.1...write-fonts-v0.56.0)

Updates `ureq` from 3.5.0 to 3.5.2
- [Changelog](https://github.com/algesten/ureq/blob/main/CHANGELOG.md)
- [Commits](https://github.com/algesten/ureq/compare/3.5.0...3.5.2)

Updates `skera` from 0.8.0 to 0.10.0
- [Release notes](https://github.com/googlefonts/fontations/releases)
- [Changelog](https://github.com/googlefonts/fontations/blob/main/docs/RELEASE.md)
- [Commits](https://github.com/googlefonts/fontations/compare/skera-v0.8.0...skera-v0.10.0)

Updates `icu_locale_core` from 2.3.0 to 2.4.0
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/compare/icu@2.3.0...icu@2.4.0)

Updates `icu_provider` from 2.3.1 to 2.4.0
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/compare/icu@2.3.1...icu@2.4.0)

Updates `icu_provider_blob` from 2.3.0 to 2.4.0
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/compare/icu@2.3.0...icu@2.4.0)

Updates `jpeg-encoder` from 0.6.1 to 0.7.1
- [Release notes](https://github.com/vstroebel/jpeg-encoder/releases)
- [Commits](https://github.com/vstroebel/jpeg-encoder/compare/v0.6.1...v0.7.1)

Updates `hayro-jpeg2000` from 0.3.5 to 0.5.0
- [Release notes](https://github.com/LaurenzV/hayro/releases)
- [Commits](https://github.com/LaurenzV/hayro/compare/hayro-jpeg2000-v0.3.5...hayro-jpeg2000-v0.5.0)

Updates `tokio` from 1.53.2 to 1.54.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.53.2...tokio-1.54.1)

Updates `getrandom` from 0.3.4 to 0.4.3
- [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/getrandom/compare/v0.3.4...v0.4.3)

Updates `pgp` from 0.21.0 to 0.21.1
- [Release notes](https://github.com/rpgp/rpgp/releases)
- [Changelog](https://github.com/rpgp/rpgp/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rpgp/rpgp/compare/v0.21.0...v0.21.1)

---
updated-dependencies:
- dependency-name: acadrust
  dependency-version: 0.6.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: cfb
  dependency-version: 0.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: crc32fast
  dependency-version: 1.5.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: encoding_rs
  dependency-version: 0.8.44
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: flate2
  dependency-version: 1.1.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: fontique
  dependency-version: 0.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: getrandom
  dependency-version: 0.4.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: harfrust
  dependency-version: 0.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: hayro-jpeg2000
  dependency-version: 0.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: icu_locale_core
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: icu_provider
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: icu_provider_blob
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: jixel
  dependency-version: 0.5.7
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: jpeg-encoder
  dependency-version: 0.7.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: log
  dependency-version: 0.4.35
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: miniz_oxide
  dependency-version: 0.9.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: moxcms
  dependency-version: 0.9.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: pgp
  dependency-version: 0.21.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: quick-xml
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: rfd
  dependency-version: 0.18.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: rustix
  dependency-version: 1.1.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: sha1
  dependency-version: 0.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: skera
  dependency-version: 0.10.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: skrifa
  dependency-version: 0.48.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: tokio
  dependency-version: 1.54.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: ureq
  dependency-version: 3.5.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: weezl
  dependency-version: 0.2.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: windows-registry
  dependency-version: 0.100.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: write-fonts
  dependency-version: 0.56.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: zip
  dependency-version: 9.5.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-16 07:01:44 +00:00
..

craft-offcrypto

Clean-room Office document cryptography: password-encrypted OOXML packages and the password hashes of document and sheet protection. No unsafe. No third-party implementation was consulted; some expected keys in the tests were computed with msoffcrypto-tool and Python's hashlib as independent checks.

Document Used for
[MS-OFFCRYPTO] Office Document Cryptography Structure (Microsoft Open Specifications) §2.1 data spaces; §2.3.2, §2.3.3, §2.3.4.5-§2.3.4.9 standard encryption; §2.3.4.10-§2.3.4.15 agile encryption; §2.4.2.4 the ISO write-protection hash
ECMA-376 Part 1 §17.15.1.29, §18.2.29; Part 4 §14.8.1 where protection hashes are stored; the legacy 32-bit password key
[MS-CFB] the compound file, through craft-cfb

Encrypted packages

A password-protected .docx, .xlsx or .pptx is a compound file with an EncryptionInfo stream and an EncryptedPackage stream. The crate turns that file into the zip package and back. It does not look inside the package: craft-opc reads what decrypt returns.

if craft_offcrypto::is_encrypted(&bytes) {
    craft_offcrypto::check(&bytes)?;                       // Unsupported("RC4"), ... before asking
    let package = craft_offcrypto::decrypt(&bytes, Some(password))?;   // WrongPassword, Malformed
}
let file = craft_offcrypto::encrypt(&package, password)?;
Read Written
Agile (Office 2010 and later): AES-128/192/256 CBC in 4096-byte segments, SHA-1/256/384/512 yes; the HMAC over the encrypted stream is required and checked AES-256, SHA-512, 100,000 spins, with the data-spaces streams Office expects
Standard (Office 2007): AES-128/192/256 ECB, SHA-1, 50,000 spins yes for tests only (encrypt_standard)
RC4, extensible, certificate-only, rights management refused by name (Error::Unsupported) no

decrypt(bytes, None) returns Error::PasswordRequired once it knows the file is one it can decrypt; check is that question on its own.

Protection passwords

protection::hash_password makes the algorithmName / hashValue / saltValue / spinCount values of a new protection password; protection::check_password_hash and check_legacy_password_hash (the cryptAlgorithmSid form, through legacy_key) check a password against stored values. Which attributes hold them is the format's business. A hash that cannot be checked is PasswordCheck::Unsupported, never a match.

Hostile input

Stream reads are capped (EncryptionInfo at 1 MiB, the package at the file's size), the XML descriptor is parsed with craft-xml under the same cap, every length is checked before slicing, a stated package size larger than the data is damage and never drives an allocation, and spin counts above 10,000,000 are refused. Verifier and integrity values are compared without stopping at the first difference. Passwords, keys and derived hashes are wiped when dropped (zeroize).

Origin

Moved from WordCraft's crates/docx/src/crypt.rs (at 07f97737), the fullest of three copies: it reads both schemes, writes agile encryption and has the protection hashes. From GridCraft's crates/xlsx/src/crypto.rs (at 5cf52c5f) come check, the naming of unsupported schemes (Error::Unsupported), rights-managed files, choosing the password key encryptor by its URI, and the independent key vectors in the tests. DeckCraft's crates/pptx/src/cfb.rs only detected encrypted files, which is_encrypted does.