Documentation
¶
Overview ¶
Package crypt opens the encryption of the binary Office formats ([MS-OFFCRYPTO] 2.3): XOR obfuscation, the RC4 encryption of Office 97, and RC4 with a key made by the CryptoAPI. A password is verified against what the file keeps for that before anything is decrypted with it.
These schemes are weak, and are read here because documents kept in them still exist; nothing is written with them.
Index ¶
Constants ¶
const ( XOR = "XOR obfuscation" RC4 = "RC4" CryptoAPI = "RC4 CryptoAPI" )
The schemes.
const DefaultPassword = "VelvetSweatshop"
DefaultPassword is the password Excel encrypts a workbook with when its structure is protected and no password to open it was set ([MS-XLS] 2.2.10).
Variables ¶
var ErrHeader = errors.New("crypt: the encryption header cannot be read")
ErrHeader is returned for a header of encryption that cannot be read, or that names an algorithm other than RC4.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct {
Scheme string
// XOR obfuscation: the key and the verifier made of the password.
Key, Hash uint16
// RC4: the salt, and the verifier and its hash, both encrypted.
Salt, Verifier, VerifierHash []byte
// KeyBits is the length of a CryptoAPI key.
KeyBits int
}
Header is what a file keeps of its encryption: the scheme, and what a password is verified against.
func Parse ¶
Parse reads the header of an RC4 encryption, which begins with its version: 1.1 for the encryption of Office 97, and 2.2 to 4.2 for the CryptoAPI ([MS-OFFCRYPTO] 2.3.6.1, 2.3.5.1).
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key decrypts what a file encrypted.
func (*Key) Block ¶
Block decrypts in place data that is encrypted on its own with the key of one block, as an object of a presentation is with the key of its number. It returns the cipher, for what follows the data in the same run.
func (*Key) Stream ¶
Stream decrypts a stream in place whose blocks of the given size are each encrypted with the key of their number, from the start of the stream: 512 bytes in a Word document, 1024 in a workbook.
func (*Key) XorDocument ¶
XorDocument decrypts in place a part of a stream of a Word document that is obfuscated, which begins at the given place of the stream. A byte that is zero, or that would become zero, is as it is.
func (*Key) XorWorkbook ¶
XorWorkbook decrypts in place the data of a record of a workbook that is obfuscated ([MS-XLS] 2.2.10): the place in the key is that of the data in the stream, plus the size of the record.