PeerIdentityGetCryptKey function (p2p.h)

The PeerIdentityGetCryptKey function retrieves a handle to a cryptographic service provider (CSP).

Syntax

NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerIdentityGetCryptKey(
  [in]  PCWSTR     pwzIdentity,
  [out] HCRYPTPROV *phCryptProv
);

Parameters

[in] pwzIdentity

Specifies the peer identity to retrieve the key pair for.

[out] phCryptProv

Receives a pointer to the handle of the cryptographic service provider (CSP) that contains an AT_KEYEXCHANGE RSA key pair.

Return value

If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.

Return code Description
E_INVALIDARG
One of the parameters is not valid.
E_OUTOFMEMORY
There is not enough memory to perform the specified operation.
PEER_E_NO_KEY_ACCESS
Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the folder that contains the user or computer keys. This can happen when the ACL has been manually reset.
PEER_E_NOT_FOUND
An identity that matches the specified name cannot be found.

Remarks

The key can be retrieved by calling CryptGetUserKey.

When the handle is not required anymore, the application is responsible for releasing the handle by using CryptReleaseContext.

Requirements

Requirement Value
Minimum supported client Windows XP with SP2 [desktop apps only],Windows XP with SP1 with the Advanced Networking Pack for Windows XP
Minimum supported server None supported
Target Platform Windows
Header p2p.h
Library P2P.lib
DLL P2P.dll

See also

CryptGetUserKey

CryptReleaseContext