CardQueryKeySizes function

This function returns the public key sizes that are supported by the card in use.


DWORD WINAPI CardQueryKeySizes(
  _In_    PCARD_DATA      pCardData,
  _In_    DWORD           dwKeySpec,
  _In_    DWORD           dwFlags,
  _Inout_ PCARD_KEY_SIZES pKeySizes


pCardData [in]

Context information for the call. For more information, see CardAcquireContext.

dwKeySpec [in]

The type of key to query. For allowed values see CardCreateContainer.

dwFlags [in]

Reserved. Set to 0.

pKeySizes [in, out]

Pointer to a CARD_KEY_SIZES structure. The supported key sizes for the specified algorithm type are returned.

Return value

Zero on success; otherwise, nonzero.


Key size information is returned in the following structure. For ECC, minimum, default, and maximum are a specific value. Increment is 1.

typedef struct _CARD_KEY_SIZES
    DWORD  dwVersion;         // version should be set by the caller

    DWORD  dwMinimumBitlen;
    DWORD  dwDefaultBitlen;
    DWORD  dwMaximumBitlen;
    DWORD  dwIncrementalBitlen;

If dwKeySpec is undefined, the function should return SCARD_E_INVALID_PARAMETER.

If dwKeySpec is defined but not supported by the card, the function should return SCARD_E_UNSUPPORTED_FEATURE.

A card minidriver that supports read-only cards may support more key types than what the specific read only card has been provisioned with. In this case CardQueryKeySizes should succeed and return a corresponding CARD_KEY_SIZES structure for the supported key spec.


Target platform


Cardmod.h (include Cardmod.h)

See also




Send comments about this topic to Microsoft