经过Agile Encryption加密后的Office07文档不再是一个zip包,而是一个复合文档。其复合文档结构类似这样:
注:图片里绿色的是storage 白色的是stream
EncryptInfoStream The EncryptionInfo stream contains detailed information about the cryptography used to encrypt the EncryptedPackage stream when agile encryption is used
以上是[MS-OFFCRYPTO]里的原文,其实这个流主要就是一个xml,类似于这样
<encryption xmlns="http://schemas.microsoft.com/office/2006/encryption"xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password">
<keyData saltSize="16" blockSize="16" keyBits="128" hashSize="20" cipherAlgorithm="AES" cipherChaining="ChainingModeCBC"hashAlgorithm="SHA1" saltValue="Q7OE8gKnfX/bm7uMJ752ag=="/>
<dataIntegrity encryptedHmacKey="pTQH/zG6UxAs8zcV3MylFmxZdwJzVOSUpQiJg5hK9Oc="encryptedHmacValue="ZCx7AOc/p8I/FZpZRCgaOrLoAx3GZXGYthp2Kr65bPA="/>
</encryption>
EncryptedPackageStream:由一个8bytes的StreamSize字段加一个EncryptedData数据段组成,EncryptedData就是整个Office07文档加密后的数据。StreamSize标识的长度可能要比EncryptedData的长度要短,因为加密数据时需按照BlockSize的倍数补齐。
另外几个stream的结构是这样的
DataSpaceMap
Version Stream
StrongEncryptionDataSpace
0x06Primary