Encrypting and Importing Media Samples
[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
For each media sample that you encrypt using Windows Media DRM, you must generate a salt value that is strictly bigger than the previous one (monotonically increasing). Use the new salt value to create a transitory encryption key by applying the SHA-1 encryption algorithm to the initialization vector concatenated with the salt value.
Next, encrypt the sample according to the RC4 algorithm using the generated transitory key. Before the sample is passed to the SDK, your application must associate the salt value with the sample by setting an extension attribute.
Here are the steps for encrypting media samples:
- Call the QueryInterface method of the sample object to get the INSSBuffer3 interface.
- Increment the salt value.
- Encrypt the sample using an RC1 encryption algorithm. For the encryption you create a key by concatenating the initialization vector and the salt value.
- Provide the salt value to the SDK by calling INSSBuffer::SetProperty.
Related topics