Platform SDK: Certificate Enrollment Control

ICEnroll3::GetSupportedKeySpec [C++]

CEnroll.GetSupportedKeySpec [Visual Basic]

The GetSupportedKeySpec method retrieves information regarding the current cryptographic service provider (CSP) support for signature and/or exchange operations. The values retrieved by this method are dependent upon the current CSP.

[Visual Basic]
objEnroll.GetSupportedKeySpec() As Long
[C++]
HRESULT GetSupportedKeySpec(
  DWORD* pdwKeySpec
);

Parameters

[Visual Basic] objEnroll
Object expression that resolves to a CEnroll object.
[C++] pdwKeySpec
Pointer to a DWORD value. Upon success, this value will be a bit flag specifying whether the current CSP supports exchange and/or signature keys. The value can be bitwise compared to AT_KEYEXCHANGE and AT_SIGNATURE. AT_KEYEXCHANGE is defined as 1 and AT_SIGNATURE is defined as 2 in wincrypt.h.

Return Values

[Visual Basic] Represents the value specifying whether the current CSP supports exchange and/or signature keys. The value can be bitwise compared to AT_KEYEXCHANGE and AT_SIGNATURE. AT_KEYEXCHANGE is defined as 1 and AT_SIGNATURE is defined as 2 in wincrypt.h. If a CSP doesn't support this method, an error is returned.

[C++] The return value is an HRESULT. A value of S_OK indicates success, and *pdwKeySpec represents the value for the support provided by the current CSP. If a CSP doesn't support this method, an error is returned.

Remarks

Call this method to determine if the current CSP supports exchange keys, signature keys, or both.

Example Code [C++]

DWORD dwKeySpec;

// Determine the supported key specifications.
// hr is HRESULT variable.
hr = pEnroll->GetSupportedKeySpec( &dwKeySpec );
if ( FAILED( hr ) )    
    printf("Failed GetSupportedKeySpec [%x]\n", hr);
else
{
    printf("Exchange keys are %s. Signature keys are %s.\n",
           dwKeySpec & AT_KEYEXCHANGE ? "supported" : "not supported",
           dwKeySpec & AT_SIGNATURE ? "supported" : "not supported" );
}

Example Code [Visual Basic]

' Constants (from wincrypt.h).
Const AT_KEYEXCHANGE = 1
Const AT_SIGNATURE = 2

' Variable for the CEnroll object.
Dim objXen As Object

' Instantiate the object.
Set objXen = CreateObject("CEnroll.CEnroll.1")

Dim KeySpec As Long

' Retrieve the value for key support
KeySpec = objXen.GetSupportedKeySpec()

' Create a string based on the result.
Dim strText As String

strText = "Exchange keys are"
If (KeySpec And AT_KEYEXCHANGE) Then
    strText = strText & " supported."
Else
    strText = strText & " unsupported."
End If
strText = strText & vbNewLine
strText = strText & "Signature keys are"
If (KeySpec And AT_SIGNATURE) Then
    strText = strText & " supported."
Else
    strText = strText & " unsupported."
End If

' Output the key support.
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