Share via


CSecureChannelServer::MACInit

banner art

The MACInit method acquires a message authentication code (MAC) channel for use in calls to the MACUpdate and MACFinal methods.

Syntax

HRESULT MACInit(
  HMAC*  phMAC
);

Parameters

  phMAC

[out] Pointer to a MAC handle.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager and service provider 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 a complete 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 The phMAC parameter is invalid or is a NULL pointer.
E_FAIL An unspecified error occurred.

Remarks

The MACInit method begins a message authentication code (MAC) session. This method must be called every time a (MAC) is required. MACUpdate and MACFinal must be called sequentially after MACInit. After MACFinal, MACInit must be called again to acquire a new handle.

Example Code

g_pAppSCServer = new CsecureChannelServer();
if( dwRead )
{
    // MAC the parameters.
    HMAC hMAC;
    
    g_pAppSCServer->MACInit(&hMAC);
    g_pAppSCServer->MACUpdate(hMAC, (BYTE*)(pTmpData), dwRead);
    g_pAppSCServer->MACUpdate(hMAC, (BYTE*)(pdwSize), sizeof(DWORD));
    g_pAppSCServer->MACFinal(hMAC, abMac);
    
    g_pAppSCServer->EncryptParam(pTmpData, dwRead);
    
    memcpy(pData, pTmpData, dwRead);
    }

Requirements

Header: Include scserver.h.

Library: mssachlp.lib

See Also