Platform SDK: Certificate Enrollment Control

ICEnroll3::GetKeyLen [C++]

CEnroll.GetKeyLen [Visual Basic]

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
);

Parameters

[Visual Basic] objEnroll
Object expression that resolves to a CEnroll object.
[Visual Basic,C++] fMin
Boolean value representing whether the minimum or maximum length of the key is being queried. If the value is TRUE, the minimum length of the key will be retrieved. If the value is FALSE, the maximum length of the key will be retrieved.
[Visual Basic,C++] fExchange
Boolean value representing whether the exchange or signature key is being queried. If the value is TRUE, the value retrieved will apply to the exchange key. If the value is FALSE, the value retrieved will apply to the signature key.
[C++] pdwKeySize
Upon successful completion, pointer to value representing the length (in bits) for the key's minimum or maximum length.

Return Values

[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.

Remarks

Call this method to determine the minimum and maximum key lengths. If a CSP doesn't support this method, an error is returned.

Example Code [C++]

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 );

Example Code [Visual Basic]

' 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

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Xenroll.h.
  Library: Use Uuid.lib.

See Also

ICEnroll3