

# NCryptEnumKeys with Key storage provider (KSP)
<a name="ksp-library-apis-enum-keys"></a>

NCryptEnumKeys function lists the keys stored in the Key Storage Provider (KSP).

## Parameters
<a name="ksp-library-apis-enum-keys-parameters"></a>

 `hProvider` [in]   
The key storage provider handle. Use [`NCryptOpenStorageProvider`](ksp-library-apis-open-provider.md) to get this handle. 

 `pszScope` [in, unused]   
 Set this parameter to NULL.

 `ppKeyName` [out]   
A pointer address to an `NCryptKeyName` structure that stores the key name. To free this memory after use, call `NCryptFreeBuffer`. 

`ppEnumState` [in, out]  
A VOID pointer address that tracks the enumeration progress. The key storage provider uses this information internally to manage the enumeration sequence. To start a new enumeration from the beginning, set this pointer to NULL.  
To free this memory after completing the enumeration, pass this pointer to the `NCryptFreeBuffer`.

`dwFlags` [in]  
Flags to modify the function's behavior. This function has no flags.

## Return Value
<a name="ksp-library-apis-enum-keys-return-value"></a>

The function returns a status code to indicate success or failure.

Common return codes include:


****  

| Return code | Description | 
| --- | --- | 
| ERROR\_SUCCESS | The operation completed successfully. | 
| NTE\_INVALID\_PARAMETER | One or more parameters are not valid. | 
| NTE\_FAIL | The operation couldn't complete. | 
| NTE\_INVALID\_HANDLE | The handle in `hProvider` is not valid. | 
| NTE\_NO\_MORE\_ITEMS | The enumeration has listed all available keys. | 