Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
[Windows Media Format 11 SDK bu sayfayla ilişkilendirilmiş özellik eski bir özelliktir. Kaynak Okuyucu ve Havuz Yazıcısıtarafından değiştirildi. Kaynak Okuyucu ve Havuz Yazıcısı Windows 10 ve Windows 11 için iyileştirilmiştir. Microsoft, yeni kodun mümkün olduğunda Windows Media Format 11 SDKyerine Kaynak Okuyucu ve Havuz Yazıcı kullanmasını kesinlikle önerir. Microsoft, mümkünse yeni API'leri kullanmak için eski API'leri kullanan mevcut kodun yeniden yazılmasını önerir.]
İçerik anahtarı, Windows Media DRM İçeri Aktarma için medya örneklerini şifrelemek için kullanılır. Aşağıdaki kod örneği, bir içerik anahtarı yapısının nasıl oluşturulacağını ve başlatacağını gösterir.
HRESULT CreateContentKey( WMDRM_IMPORT_CONTENT_KEY **ppContentKey, DWORD *pcbContentKey)
{
// TODO: Set this value to the desired number of bytes for the content key data.
const DWORD IV_DATA_SIZE = 16;
HRESULT hr = S_OK;
WMDRM_IMPORT_CONTENT_KEY *pContentKey = NULL;
// The content key.
const BYTE rgbContentKey[] = {
0x67, 0x39, 0x83, 0xb9,
0x52, 0xa8, 0xe3
};
const DWORD CONTENT_KEY_DATA_SIZE = sizeof(rgbContentKey);
// Compute the total size of the content key structure
DWORD cbContentKey = sizeof( WMDRM_IMPORT_CONTENT_KEY ) +
IV_DATA_SIZE + CONTENT_KEY_DATA_SIZE;
// Make sure we have a valid
if( NULL == ppContentKey )
{
hr = E_POINTER;
goto EXIT;
}
// Allocate the content key, locally first
pContentKey = (WMDRM_IMPORT_CONTENT_KEY *)new BYTE[ cbContentKey ];
// Check the allocation was successful
if( NULL == pContentKey )
{
hr = E_OUTOFMEMORY;
goto EXIT;
}
// Ininitalize the key
ZeroMemory( pContentKey, cbContentKey );
pContentKey->dwVersion = 0;
pContentKey->cbStructSize = cbContentKey;
// Set the initialization vector key type
pContentKey->dwIVKeyType = WMDRM_KEYTYPE_RC4;
pContentKey->cbIVKey = IV_DATA_SIZE;
// Generate a random initialization vector. Note that this random number
// generator is not very good. It is only intended to be demonstrative
// and it is not recommended for use in commercial strength code.
srand((unsigned int)time(NULL));
BYTE* pKeyData = pContentKey->rgbKeyData;
for (size_t i = 0; i < IV_DATA_SIZE; ++i)
{
*pKeyData++ = (BYTE)(rand() & 0xFF);
}
// Set the content key type.
pContentKey->dwContentKeyType = WMDRM_KEYTYPE_COCKTAIL;
pContentKey->cbContentKey = CONTENT_KEY_DATA_SIZE;
// Fill out the content key.
for (size_t i = 0; i < CONTENT_KEY_DATA_SIZE; ++i)
{
*pKeyData++ = rgbContentKey[i];
}
// If all has been successful, set the parameters
*ppContentKey = pContentKey;
pContentKey = NULL;
*pcbContentKey = cbContentKey;
EXIT:
SAFE_ARRAY_DELETE( pContentKey );
return hr;
}
İlgili konular