Export (0) Print
Expand All

NCryptSecretAgreement function

The NCryptSecretAgreement function creates a secret agreement value from a private and a public key.

Syntax


SECURITY_STATUS WINAPI NCryptSecretAgreement(
  _In_   NCRYPT_KEY_HANDLE hPrivKey,
  _In_   NCRYPT_KEY_HANDLE hPubKey,
  _Out_  NCRYPT_SECRET_HANDLE *phSecret,
  _In_   DWORD dwFlags
);

Parameters

hPrivKey [in]

The handle of the private key to use to create the secret agreement value. This key and the hPubKey key must come from the same key storage provider.

hPubKey [in]

The handle of the public key to use to create the secret agreement value. This key and the hPrivKey key must come from the same key storage provider.

phSecret [out]

A pointer to an NCRYPT_SECRET_HANDLE variable that receives a handle that represents the secret agreement value. When this handle is no longer needed, release it by passing it to the NCryptFreeObject function.

dwFlags [in]

Flags that modify function behavior. This can be zero or a combination of one or more of the following values. The set of valid flags is specific to each key storage provider. The following flag applies to all providers.

ValueMeaning
NCRYPT_SILENT_FLAG

Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error.

 

Return value

Returns a status code that indicates the success or failure of the function.

Possible return codes include, but are not limited to, the following.

Return codeDescription
ERROR_SUCCESS

The function was successful.

NTE_INVALID_HANDLE

The hPrivKey or the hPubKey parameter is not valid.

NTE_INVALID_PARAMETER

One or more parameters are not valid.

NTE_NO_MEMORY

A memory allocation failure occurred.

 

Remarks

A service must not call this function from its StartService Function. If a service calls this function from its StartService function, a deadlock can occur, and the service may stop responding.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Ncrypt.h

Library

Ncrypt.lib

DLL

Ncrypt.dll

See also

NCryptFreeObject

 

 

Community Additions

ADD
Show:
© 2014 Microsoft