Class DocumentProtectionHash
- Namespace
- DocWright.Cryptography
- Assembly
- DocWright.Cryptography.dll
Computes and checks the password hashes on w:documentProtection and
w:writeProtection.
These hashes are not a security boundary and DocWright does not treat them as one. Protection settings are a user-interface convenience: Word asks for the password before letting a person edit, and any program that ignores the setting edits anyway — including DocWright, which reports protection and never enforces it. What this class provides is the ability to answer "is this the password the document records?", and to record a new one.
public static class DocumentProtectionHash
- Inheritance
-
DocumentProtectionHash
- Inherited Members
Fields
- DefaultSaltSize
The salt length Word writes.
- DefaultSpinCount
The spin count Word writes. Used when a caller does not choose one.
Methods
- AlgorithmAttributeName(OfficeHashAlgorithmKind)
Returns the
w:algorithmNamespelling of an algorithm.
- AlgorithmFromSid(int?)
Maps a
w:cryptAlgorithmSidvalue onto an algorithm.
- Compute(string, OfficeHashAlgorithmKind, byte[], int, ResourceLimits?)
Computes a protection hash.
- ComputeOffice2007(string, OfficeHashAlgorithmKind, byte[], int, ResourceLimits?)
Computes the hash Word records for a password in the Office 2007 spelling (
w:hash): the iteration of Compute(string, OfficeHashAlgorithmKind, byte[], int, ResourceLimits?), over the password's legacy key written as eight hexadecimal digits in place of the password itself (Phase 157, WQ-0130). Only a password's first fifteen characters count.
- SetDocumentProtectionPassword(DocumentProtection, string, ProtectionHashKind, OfficeHashAlgorithmKind, int, IRandomSource?)
Records a document-protection password on the settings, replacing any existing hash.
- SetWriteProtectionPassword(DocumentProtection, string, OfficeHashAlgorithmKind, int, IRandomSource?)
Records a write-protection password on the settings.
- SidFromAlgorithm(OfficeHashAlgorithmKind)
Maps an algorithm onto its
w:cryptAlgorithmSidvalue.
- StartEnforcing(DocumentProtection, DocumentEditRestriction, string?, IRandomSource?)
Starts enforcing protection as Word's Restrict Editing does (Phase 157, WQ-0130): the restriction with
w:enforcement="1"and, for a password, what Word writes for one (the Office 2007 spelling, SHA-512, DefaultSpinCount iterations, a fresh salt). Whatever password material the settings held is replaced or, without a password, removed; a formatting restriction and the write-protection recommendation are left as they are.
- StopEnforcing(DocumentProtection)
Stops protection as Word's Stop Protection does (Phase 157, WQ-0130): nothing of
w:documentProtectionis left, the password material included. The write-protection recommendation is left as it is. Whether the caller may stop it is the caller's to decide: VerifyDocumentProtection(DocumentProtection, string, ResourceLimits?) checks a password.
- VerifyDocumentProtection(DocumentProtection, string, ResourceLimits?)
Checks a password against the document-protection hash a document records.
- VerifyWriteProtection(DocumentProtection, string, ResourceLimits?)
Checks a password against the write-protection hash a document records.