Table of Contents

Class EncryptedOfficePackage

Namespace
DocWright.Cryptography
Assembly
DocWright.Cryptography.dll

An encrypted Office document: a Compound File Binary container holding an EncryptionInfo descriptor and an EncryptedPackage stream whose plaintext is an ordinary OOXML zip.

This is what a password-protected .docx actually is on disk. It carries no zip signature, which is why a reader that sniffs for PK\x03\x04 declines it and the caller ends up with a puzzling "not a valid package" error instead of "supply a password".

public sealed class EncryptedOfficePackage : IDisposable
Inheritance
EncryptedOfficePackage
Implements
Inherited Members

Fields

EncryptedPackageStreamName

The CFB stream name holding the encrypted payload.

EncryptionInfoStreamName

The CFB stream name holding the encryption descriptor.

Properties

Descriptor

Gets the parsed encryption descriptor.

Scheme

Gets the scheme the descriptor declares.

Methods

Dispose()
IsEncryptedPackage(Stream)

Determines whether a stream is an encrypted Office package: a compound file carrying both the EncryptionInfo and EncryptedPackage streams.

Requiring both is what keeps this from claiming an encrypted legacy .doc, which is also a compound file but stores its content in WordDocument and has no EncryptedPackage at all.

LooksLikeCompoundFile(Stream)

Returns whether the bytes begin with the Compound File Binary magic number. This is the cheap half of the sniff: eight bytes, no parsing.

Open(Stream, Stream?)

Opens an encrypted Office package and parses its descriptor. Does not decrypt and needs no password.

OpenEncryptedPackageStream()

Opens the raw EncryptedPackage stream: an eight-byte little-endian plaintext length followed by the ciphertext.

ThrowUnopenable(bool)

Throws the exception that describes why this package cannot be opened without help: either no password was supplied, or the scheme is one DocWright does not decrypt.