Platform SDK: Certificate Enrollment Control |
The GetKeyLen method is used to retrieve the minimum and maximum key lengths for the signature and exchange keys. The values retrieved by this method are dependent upon the current cryptographic service provider.
[Visual Basic] objEnroll.GetKeyLen( _ fMin As Boolean, _ fExchange As Boolean ) As Long [C++] HRESULT GetKeyLen( BOOL fMin, BOOL fExchange, DWORD* pdwKeySize );
[Visual Basic] Value representing the length (in bits) for the key's minimum or maximum length.
[C++] The return value is an HRESULT. A value of S_OK indicates success, and *pdwKeySize will be the value representing the length (in bits) for the key's minimum or maximum length.
Call this method to determine the minimum and maximum key lengths. If a CSP doesn't support this method, an error is returned.
DWORD dwExchMin, dwExchMax, dwSignMin, dwSignMax; // Determine the minimum and maximum key length values. // hr is HRESULT variable. hr = pEnroll->GetKeyLen( TRUE, TRUE, &dwExchMin ); if ( FAILED( hr ) ) printf("Failed GetKeyLen for Exchange Minimum [%x]\n", hr); else printf("Exchange key Min: %d\n", dwExchMin); hr = pEnroll->GetKeyLen( FALSE, TRUE, &dwExchMax ); if ( FAILED( hr ) ) printf("Failed GetKeyLen for Exchange Maximum [%x]\n", hr); else printf("Exchange key Max: %d\n", dwExchMax ); hr = pEnroll->GetKeyLen( TRUE, FALSE, &dwSignMin ); if ( FAILED( hr ) ) printf("Failed GetKeyLen for Signature Minimum [%x]\n", hr); else printf("Signature key Min: %d\n", dwSignMin ); hr = pEnroll->GetKeyLen( FALSE, FALSE, &dwSignMax ); if ( FAILED( hr ) ) printf("Failed GetKeyLen for Signature Maximum [%x]\n", hr); else printf("Signature key Max: %d\n", dwSignMax );
' Variable for the CEnroll object. Dim objXen As Object ' Instantiate the object. Set objXen = CreateObject("CEnroll.CEnroll.1") ' Variables to contain key min/max values. Dim nMinExch As Long Dim nMaxExch As Long Dim nMinSign As Long Dim nMaxSign As Long ' Retrieve the minimum and maximum key lengths. nMinExch = objXen.GetKeyLen(True, True) nMaxExch = objXen.GetKeyLen(False, True) nMinSign = objXen.GetKeyLen(True, False) nMaxSign = objXen.GetKeyLen(False, False) ' Display the results. Dim strText As String strText = "Exchange key Min: " & nMinExch & " Max: " & nMaxExch strText = strText & vbNewLine & _ "Signature key Min: " & nMinSign & " Max: " & nMaxSign MsgBox (strText) ' Free object resource. Set objXen = Nothing
Windows NT/2000: Requires Windows 2000.
Header: Declared in Xenroll.h.
Library: Use Uuid.lib.