2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream

When RC4 CryptoAPI encryption is used, an encrypted summary stream MAY<23> be created. The name of the stream MUST be specified by the application. If the encrypted summary stream is present, the \0x05DocumentSummaryInformation stream MUST be present, MUST conform to the details as specified in [MS-OSHARED] section 2.3.3.2, and MUST contain no properties. The \0x05SummaryInformation stream MUST NOT be present.

For details about the contents of the \0x05SummaryInformation and \0x05DocumentSummaryInformation streams, see [MS-OSHARED] section 2.3.3.2.1 and [MS-OSHARED] section 2.3.3.2.2.

For brevity, this section refers to the RC4 CryptoAPI Encrypted Summary stream as the encrypted summary stream.

The stream MUST have the format that is shown in the following diagram.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

StreamDescriptorArrayOffset

StreamDescriptorArraySize

EncryptedStreamData (variable)

...

EncryptedStreamDescriptorCount

EncryptedStreamDescriptorArray (variable)

...

StreamDescriptorArrayOffset (4 bytes): An unsigned integer that specifies the offset within the encrypted summary stream where the EncryptedStreamDescriptorCount structure is found.

StreamDescriptorArraySize (4 bytes): An unsigned integer that specifies the number of bytes used by the EncryptedStreamDescriptorArray structure.

EncryptedStreamData (variable): One or more encrypted streams stored within the encrypted summary stream.

EncryptedStreamDescriptorCount (4 bytes): An encrypted unsigned integer specifying the count of EncryptedStreamDescriptor structures (section 2.3.5.3).

EncryptedStreamDescriptorArray (variable): One or more EncryptedStreamDescriptor structures that specify the offsets and names of the encrypted streams and storages contained within the encrypted summary stream.

The encrypted summary stream MUST be written as specified in the following steps:

  1. Seek forward from the start of the encrypted summary stream by 8 bytes to provide space for the StreamDescriptorArrayOffset and StreamDescriptorArraySize fields, which will be written in step 8. Let BlockNumber initially be 0x00000000.

  2. If additional streams or storages are provided by the application, for each stream or storage the following steps MUST be performed:

    1. If the data is contained within a stream, retrieve the contents of the stream. Initialize the encryption key as specified in section 2.3.5.2, using a block number of 0x00000000, and encrypt the stream data. Write the encrypted bytes into the encrypted summary stream.

    2. If the data is contained within a storage, convert the storage into a file as specified in [MS-CFB]. Initialize the encryption key as specified in section 2.3.5.2, using a block number of BlockNumber, and encrypt the storage data as a stream of bytes. Write the encrypted bytes into the encrypted summary stream.

    3. Set the fields within the associated EncryptedStreamDescriptor for the stream or storage. Do not write it to the encrypted summary stream yet.

    4. Increment BlockNumber.

  3. Generate or retrieve the entire contents of the \0x05SummaryInformation stream. Initialize the encryption key as specified in section 2.3.5.2, using a block number of BlockNumber, and encrypt the \0x05SummaryInformationStream data. Write the encrypted bytes into the encrypted summary stream. Increment BlockNumber.

  4. Set the fields within the associated EncryptedStreamDescriptor for the \0x05SummaryInformation stream. Do not write it to the encrypted summary stream yet.

  5. Generate or retrieve data contained within the \0x05DocumentSummaryInformation stream. Initialize the encryption key as specified in section 2.3.5.2, using a block number of BlockNumber, and encrypt the \0x05DocumentSummaryInformationStream data. Write the encrypted bytes into the encrypted summary stream immediately following the data written in step 2.

  6. Set the fields within the associated EncryptedStreamDescriptor for the \0x05DocumentSummaryInformation stream. Do not write it to the encrypted summary stream yet.

  7. Write the EncryptedStreamDescriptorCount and EncryptedStreamDescriptorArray by initializing the encryption key as specified in section 2.3.5.2, using a block number of 0x00000000. Concatenate and encrypt the EncryptedStreamDescriptorCount and the EncryptedStreamDescriptor. Write the encrypted bytes into the encrypted summary stream.

  8. Initialize the StreamDescriptorArrayOffset and StreamDescriptorArraySize fields to specify the encrypted location of the EncryptedStreamDescriptorCount and size of the EncryptedStreamDescriptorCount and EncryptedStreamDescriptorArray within the encrypted summary stream. Initialize the encryption key as specified in section 2.3.5.2, using a block number of 0x00000000.