CSecureChannelClient::MACFinal (deprecated)
This is preliminary documentation and subject to change.
This topic documents a feature of the Windows Media Device Manager SDK. We recommend that you migrate your application to use the Windows Portable Devices API. For more information, see the Windows Portable Devices SDK.
The MACFinal method releases the message authentication code (MAC) channel and retrieves a final MAC value.
Syntax
HRESULT MACFinal(
HMAC hMAC,
BYTE abData[WMDM_MAC_LEN]
);
Parameters
hMAC
[in] Handle for the MAC for the current parameter data. This handle is created by calling the MACInit method. This datatype is declared in the SDK file ...\inc\Sac.h. After this method is called, the handle passed in is no longer valid.
abData
[out] Array of bytes to receive the final MAC value for the current parameter data.
Return Values
The method returns an HRESULT. All the interface methods in Windows Media Device Manager can return any of the following classes of error codes:
- Standard COM error codes
- Windows error codes converted to HRESULT values
- Windows Media Device Manager error codes
For an extenstive list of possible error codes, see Error Codes.
Possible values include, but are not limited to, those in the following table.
Return code | Description |
S_OK | The method succeeded. |
E_INVALIDARG | A parameter is invalid. |
E_FAIL | An unspecified error occurred. |
Remarks
This method completes creating a MAC key. For information about MAC creation, see
Example Code
The following example code checks the MAC received by a call to IWMDMStorage::GetRights to verify that the data has not been tampered with.
HRESULT hr;
CSecureChannelClient *pSPClient = NULL;
hr = m_pStorage->GetRights(ppRights, pnRightsCount, abTempMAC);
if (SUCCEEDED(hr))
{
// Verify MAC returned by GetRights on the service provider.
pSPClient->MACInit(&hMAC);
pSPClient->MACUpdate(hMAC, (BYTE*)(*ppRights),
sizeof(WMDMRIGHTS) * (*pnRightsCount));
pSPClient->MACUpdate(hMAC, (BYTE*)(pnRightsCount),
sizeof(*pnRightsCount));
pSPClient->MACFinal(hMAC, abMACVerify);
if (memcmp(abMACVerify, abTempMAC, WMDM_MAC_LENGTH) != 0)
{
hr = WMDM_E_MAC_CHECK_FAILED;
goto exit;
}
}
Requirements
Header: Include scclient.h.
Library: mssachlp.lib
See Also