Crates.io | ms-offcrypto-writer |
lib.rs | ms-offcrypto-writer |
version | 1.0.1 |
source | src |
created_at | 2024-06-18 02:42:23.780207 |
updated_at | 2024-06-19 18:44:47.374694 |
description | Encrypting ECMA376/OOXML files with agile encryption as described in MS-OFFCRYPTO |
homepage | |
repository | https://github.com/42triangles/ms-offcrypto-writer |
max_upload_size | |
id | 1275086 |
size | 44,500 |
ms-offcrypto-writer
This crate allows encrypting ECMA376/OOXML (so newer MS-Office files such as XLSX) using the agile encryption method as described in MS-OFFCRYPTO.
Use the Ecma376AgileWriter
wrapper around a File
or Cursor
(or whatever writer you're using) for other crates such as simple-xlsx-writer
.
If you find any security flaws beyond the lack of zeroing out data structures, please send me an email at 42triangles@tutanota.com. I will try to answer within two days.
The created files are NOT byte-equivalent to the ones created by the used reference implementation of "Microsoft Excel für Microsoft 365 MSO (16.0.13001.20508) 64-Bit", but the streams embedded in the CFB files are, and the CFB metadata beyond access dates (specifically the CFB version, and per storage & stream the state bits & CLSID) are equivalent as well.
This does also include one deviation from the standard, which specifies that the HMAC key should have a length equal to the salt length in <keyData>
. However, the reference implementation uses an HMAC key length of 64.
The used values are:
<keyData>
and <p:encryptedKey>
<keyData>
and <p:encryptedKey>
: AES256 with CBC, and its derived values<keyData>
and <p:encryptedKey>
: SHA512, and its derived values100_000
PRs are open; this is specifically aims to be a very simple and easy to audit implementation. A more complete implementation that includes reading as well, plus a lot more features & configurability, is in the works though - if you're interested in working on that instead, please send me an email at 42triangles@tutanota.com!
src/encryption_info.xml
fileIf you need to edit this, you may want to do it in a binary editor. It includes both binary data in the beginning, uses CRLF and should NOT include a trailing newline.
cfb
crate or the write!
usage directly into the stream is a likely culprit if things aren't, but nothing has been verified or even tested regarding performance.The following things are NOT the goal of this crate, and will only be found in the more complete crate: