Platform SDK: Certificate Enrollment Control |
The EnumAlgs method enumerates the IDs of cryptographic algorithms supported by the current cryptographic service provider (CSP).
[Visual Basic] objEnroll.EnumAlgs( _ dwIndex As Long, _ algClass As Long ) As Long [C++] HRESULT EnumAlgs( DWORD dwIndex, DWORD algClass, DWORD* pdwAlgID );
[Visual Basic] Upon successful completion, value representing a cryptographic algorithm (as defined in wincrypt.h) which is supported by the current CSP. For example, this value could be CALG_MD2. When there are no more algorithms to enumerate, the value ERROR_NO_MORE_ITEMS is returned.
[C++] The return value is an HRESULT. A value of S_OK indicates success, and *pdwAlgID will be the value of the enumerated algorithm ID. When there are no more algorithms to enumerate, the value ERROR_NO_MORE_ITEMS is returned.
Use this method to enumerate the algorithms supported by the current CSP for a given algorithm class.
DWORD dwAlgID; DWORD dwIndex; BSTR bstrAlgName = NULL; HRESULT hr, hr2; // Loop through the AlgIDs. dwIndex = 0; while ( TRUE ) { // Enumerate the alg IDs for a specific class. hr = pEnroll->EnumAlgs(dwIndex, ALG_CLASS_SIGNATURE, &dwAlgID); if ( S_OK != hr ) { break; } // Do something with the AlgID. // For example, retrieve the corresponding name. hr2 = pEnroll->GetAlgName( dwAlgID, &bstrAlgName); if ( FAILED( hr2 ) ) printf("Failed GetAlgName [%x]\n", hr); else printf("AlgID: %d Name: %S\n", dwAlgID, bstrAlgName ); // Reuse the BSTR variable in next iteration. if ( NULL != bstrAlgName ) { SysFreeString( bstrAlgName ); bstrAlgName = NULL; } // Increment the index. dwIndex++; }
' Constants representing algorithm classes. Const ALG_CLASS_SIGNATURE = &H2000 ' (1 << 13) in wincrypt.h Const ALG_CLASS_MSG_ENCRYPT = &H4000 ' (2 << 13) in wincrypt.h Const ALG_CLASS_DATA_ENCRYPT = &H6000 ' (3 << 13) in wincrypt.h Const ALG_CLASS_HASH = &H8000 ' (4 << 13) in wincrypt.h Const ALG_CLASS_KEY_EXCHANGE = &HA000 ' (5 << 13) in wincrypt.h ' Variables for algID and index Dim AlgID As Long, Index As Long ' Set the index to the first item. Index = 0 On Error GoTo Err1 ' Loop through the algorithm IDs for a specific class. Do ' objXen is a previously instantiated ICEnroll3 object. AlgID = objXen.EnumAlgs(Index, ALG_CLASS_DATA_ENCRYPT) ' Do something with the algID. MsgBox (objXen.GetAlgName(AlgID)) ' Increment to next index. Index = Index + 1 Loop Err1: MsgBox ("Number of algorithm ID(s): " & Index)
Windows NT/2000: Requires Windows 2000.
Header: Declared in Xenroll.h.
Library: Use Uuid.lib.