Re: help me about encrypting WMV file with WMFSDK

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Nick Haddad (nick_at_haddads.net)
Date: 06/22/04


Date: Tue, 22 Jun 2004 16:09:55 -0400
To: remove in use <"cw97(remove in use)"@tsinghua.org.cn>

I'm having the exact same problem. Have you found a solution to the
problem yet.

Thanks,
-Nick

Welchan wrote:
> I pasted the source code which set attributes of DRMWriter as below. Could
> you help me to figure out the erroneous configurations?
>
> Thanks you very much.
>
> HRESULT hr = S_OK;
>
> BOOL bUseDRM = TRUE;
>
> WORD wStreamNumber = 0;
>
> //
> // Set the DRMAttribute of the DRMwriter, Notify the Writer to use DRM
> //
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMUse_Advanced_DRM,
> WMT_TYPE_BOOL,
> (BYTE *)&bUseDRM,
> sizeof(BOOL) );
>
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> //
> // generate key related values
> //
> WCHAR* pwszKeyID;
> WCHAR* pwszKeySeed;
> WCHAR* pwszPrivKey;
> WCHAR* pwszPubKey;
> WCHAR* pwszAcqLicURL;
> WCHAR* pwszAcqV1LicURL;
> WCHAR* pwszLASignatureRootCert;
> WCHAR* pwszLASignatureCert;
> WCHAR* pwszLASignatureLicSrvCert;
> WCHAR* pwszLASignaturePrivKey;
> DWORD pcwchLength;
> /*
> hr = m_pDRMWriter->GenerateKeyID( NULL,
> &pcwchLength );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> pwszKeyID = new WCHAR[pcwchLength];
> ZeroMemory(pwszKeyID, sizeof(WCHAR)*pcwchLength);
>
> hr = m_pDRMWriter->GenerateKeyID( pwszKeyID,
> &pcwchLength );
>
> if( FAILED( hr ) )
> {
> return( hr );
> }
> */
>
> pwszKeyID = L"BuRds416pw==";
> pwszKeySeed = L"HOPMvii0xZtOZrIdQkiw3Bbr1YADHzamc9RyhqH7";
> pwszPubKey = L"9YEcGkR3YHr78bgssVFGkKdmcmjNJPb!El2KvtMG7idFgKLY5T!rCQ==";
> pwszPrivKey = L"4NRd8IkalKUR3wIZ!1LOBTgG6CI=";
> pwszAcqLicURL = L"http://10.10.16.101/wmrm9/simple.asp";
> pwszAcqV1LicURL = L"";
> pwszLASignatureRootCert =
> L"AAEAADgAAAA5pDm2NlEjjZ68R69eNG5k5Pk*Z6O4QexIm1WZeOty5lakJMsLmykOJfETPkcKJz
> dt8oL5YXnx8NARtiAMhSdBhcWk4UtcmoC2K2Z8VkpHOhQGAwEAAAAKAAAAAQAAAAE=";
> pwszLASignatureCert =
> L"AAEAADgAAABGIa*vKXZ2ijaBEjLCY5GQkXM6GjsYz7btHlw4UTZgNHGCdeJMV!AcCH9PlMFgLs
> mh05JbuX5VzN16CxU77CtTwbDsEC9WanwRvZ1UNDsjbhQFBgEAAGMBAACcMQAAnDE=";
> pwszLASignatureLicSrvCert =
> L"AAEAADgAAACU5nxfUDZjSeDvFr0RdTVMvdgSGIkyEFPWLidpO4X1wNqXKMK5f7Je8bFDcBxiAk
> VQLkSjgral7OVRAHbHX5RznOC3FG9YFrXdGQhHXXDcUBQFBgEAAGMBAAAAAgAAnDE=";
> pwszLASignaturePrivKey = L"kZU6IzMFYY9UiY7*lVNpIPrTakQ=";
>
> //
> // Set the DRMAttribute of DRM Header attributes and properties
> //
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_LASignatureRootCert,
> WMT_TYPE_STRING,
> (BYTE *)pwszLASignatureRootCert,
> (wcslen( pwszLASignatureRootCert ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_LASignatureCert,
> WMT_TYPE_STRING,
> (BYTE *)pwszLASignatureCert,
> (wcslen( pwszLASignatureCert ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_LASignatureLicSrvCert,
> WMT_TYPE_STRING,
> (BYTE *)pwszLASignatureLicSrvCert,
> (wcslen( pwszLASignatureLicSrvCert ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_LASignaturePrivKey,
> WMT_TYPE_STRING,
> (BYTE *)pwszLASignaturePrivKey,
> (wcslen( pwszLASignaturePrivKey ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_HeaderSignPrivKey,
> WMT_TYPE_STRING,
> (BYTE *)pwszPrivKey,
> (wcslen( pwszPrivKey ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_KeySeed,
> WMT_TYPE_STRING,
> (BYTE *)pwszKeySeed,
> (wcslen( pwszKeySeed ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_DRMHeader_KeyID,
> WMT_TYPE_STRING,
> (BYTE *)pwszKeyID,
> (wcslen( pwszKeyID ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_DRMHeader_LicenseAcqURL,
> WMT_TYPE_STRING,
> (BYTE *)pwszAcqLicURL,
> (wcslen( pwszAcqLicURL ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> hr = m_pDRMWriter->SetDRMAttribute( wStreamNumber,
> g_wszWMDRM_V1LicenseAcqURL,
> WMT_TYPE_STRING,
> (BYTE *)pwszAcqV1LicURL,
> (wcslen( pwszAcqV1LicURL ) + 1)*sizeof(WCHAR) );
> if( FAILED( hr ) )
> {
> return( hr );
> }
>
> return hr;
>
>
> "Geoff Dunbar [MSFT]" <geoffdu@online.microsoft.com> 写入邮件
> news:O2ULyFMTEHA.2416@TK2MSFTNGP12.phx.gbl...
>
>>That error could also be returned if you have configured any of the values
>>incorrectly, even if they have been set. Carefully check all of the values
>>that you've set.
>>
>>It could also be returned if you neglected to call BeginWriting, but that
>>seems unlikely.
>>
>>Thanks,
>>Geoff
>>
>>--
>>This posting is provided "AS IS" with no warranties, and confers no
>
> rights.
>
>>"Welchan" <cw97(remove in use)@tsinghua.org.cn> wrote in message
>>news:OW7onbDTEHA.1472@TK2MSFTNGP09.phx.gbl...
>>
>>>发件人: "Welchan" <cw97(remove in use)@tsinghua.org.cn>
>>>主题: how to use WMFSDK DRM appendum to package WMV file
>>>日期: 2004年6月3日 18:38
>>>
>>>I have followed the instructions described on WMFSDK docs as follows:
>>>
>>>1. Link to WMStubDRM.lib and, if necessary, unlink wmvcore.lib.
>>>2. Call the WMCreateWriter function to create the DRM writer. The first
>>>argument is reserved and must be set to NULL.
>>>3. Set a profile for the writer to use by calling IWMWriter::SetProfile
>
> or
>
>>>IWMWriter::SetProfileByID. You must set a profile in the writer before
>>>setting any DRM attributes. DRM is supported only for profiles that use
>>
>>the
>>
>>>Windows Media Audio or Windows Media Video codecs
>>>4. Obtain the writer object's IWMDRMWriter interface.
>>>5. Call IWMDRMWriter::SetDRMAttribute and set Use_Advanced_DRM to TRUE.
>>>6. If necessary, obtain the values to populate the DRM header's digital
>>>signature object. If you do not have a working version of Windows Media
>>>Rights Manager installed on your system, you must configure the ASF file
>>>header's digital signature object by specifying the following four
>>>attributes, which all must be obtained from Microsoft:
>>>DRM_LASignatureRootCert
>>>DRM_LASignatureCert
>>>DRM_LASignatureLicSrvCert
>>>DRM_LASignaturePrivKey
>>>7. Call IWMDRMWriter::SetDRMAttribute as many times as necessary to set
>>
>>the
>>
>>>required DRM header attributes and run-time properties. These properties
>>>persist for the lifetime of the writer object or until they are reset
>
> with
>
>>a
>>
>>>new value. They do not need to be reset for each new file you create.
>>>The following properties are required:
>>>DRM_HeaderSignPrivKey
>>>DRM_KeySeed
>>>DRM_V1LicenseAcqURL
>>>DRM_DRMHeader_KeyID
>>>DRM_DRMHeader_LicenseAcqURL
>>>The following properties are optional:
>>>DRM_DRMHeader_ContentID
>>>DRM_DRMHeader_IndividualizedVersion
>>>DRM_DRMHeader_ContentDistributor
>>>DRM_DRMHeader_SubscriptionContentID
>>>8. Write the file using the IWMWriter interface methods as described
>>>elsewhere in this documentation. To create a "live DRM" stream, simply
>>
>>write
>>
>>>to a network sink. You can also write to a push sink.
>>>
>>>But the HRESULT return value of IWMWriter::BeginWrite() is 0xC00D2764.
>
> It
>
>>>means "NS_E_DRM_NOT_CONFIGURED 0xC00D2764Not all of the necessary
>>
>>properties
>>
>>>for DRM have been set."
>>>
>>>Do I neglect some necessary steps or options setup? Any hint will be
>>
>>highly
>>
>>>appreciated.
>>>
>>>
>>>
>>
>>
>
>
>