CSecureChannelServer::EncryptParam

banner art

The EncryptParam method uses the session key of the secure authenticated channel to encrypt the data contained in a parameter.

Syntax

HRESULT EncryptParam(
  BYTE*  pbData,
  DWORD  dwDataLen
);

Parameters

  pbData

Pointer to the first byte of a data buffer containing the parameter that is to be encrypted.

  dwDataLen

Pointer to a DWORD specifying the length of the buffer to which pbData points.

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
  • 8Windows 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 A parameter is invalid or is a NULL pointer.
E_FAIL An unspecified error occurred.

Remarks

Certain parameters, listed in the tables under Secure Authenticated Channel Interface, must be included in the message authentication code (MAC) and must be encrypted before the call for data transfer in both directions. Call EncryptParam to encrypt the specified parameters. Do not encrypt any parameters that do not require it.

Example Code

// Calculate MAC to hand to operation.
g_pAppSCServer = new CSecureChannelServer();
g_pAppSCServer->MACInit(&hMAC);
g_pAppSCServer->MACUpdate(hMAC, (BYTE*)(pData), dwBytes);
g_pAppSCServer->MACUpdate(hMAC, (BYTE*)(&dwBytes), sizeof(dwBytes));
g_pAppSCServer->MACFinal(hMAC, abMAC);

// Encrypt the data parameter.
g_pAppSCServer->EncryptParam(pData, dwBytes);
pOperation->TransferObjectData(pData, &dwBytes, abMAC);

Requirements

Header: Include scserver.h.

Library: mssachlp.lib

See Also