The NCryptSetProperty function sets the value for a named property for a CNG key storage object.
Syntax
SECURITY_STATUS WINAPI NCryptSetProperty(
__in NCRYPT_HANDLE hObject,
__in LPCWSTR pszProperty,
__in PBYTE pbInput,
__in DWORD cbInput,
__in DWORD dwFlags
);
Parameters
- hObject [in]
-
The handle of the key storage object to set the property for.
- pszProperty [in]
-
A pointer to a null-terminated Unicode string that contains the name of the property to set. This can be one of the predefined Key Storage Property Identifiers or a custom property identifier.
- pbInput [in]
-
The address of a buffer that contains the new property value. The cbInput parameter contains the size of this buffer.
- cbInput [in]
-
The size, in bytes, of the pbInput buffer.
- dwFlags [in]
-
A set of flags that modify the behavior of this function. This can be zero or a combination of one or more of the following values.
| Value | Meaning |
- NCRYPT_PERSIST_FLAG
| The property should be stored in key storage along with the key material. This flag can only be used when the hObject parameter is the handle of a persisted key. The maximum size of the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes.
|
- NCRYPT_PERSIST_ONLY_FLAG
| Do not overwrite any built-in values for this property and only set the user-persisted properties of the key. The maximum size of the data for any persisted property is NCRYPT_MAX_PROPERTY_DATA bytes. This flag cannot be used with the NCRYPT_SECURITY_DESCR_PROPERTY property.
|
For the NCRYPT_SECURITY_DESCR_PROPERTY property, this parameter must also contain one of the following values, which identifies the part of the security descriptor to set.
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 code | Description |
- ERROR_SUCCESS
| The function was successful.
|
- NTE_BAD_FLAGS
| The dwFlags parameter contains a value that is not valid.
|
- NTE_INVALID_HANDLE
| The hObject parameter is not valid.
|
- NTE_INVALID_PARAMETER
| One or more parameters are not valid.
|
- NTE_NO_MEMORY
| A memory allocation failure occurred.
|
- NTE_NOT_SUPPORTED
| The specified property is not supported for the object.
|
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 |
| Minimum supported server | Windows Server 2008 |
| Header | Ncrypt.h |
| Library | Ncrypt.lib |
| DLL | Ncrypt.dll |
Send comments about this topic to Microsoft
Build date: 11/19/2009