Partilhar via


Enumerando protocolos suportados

Os protocolos suportados e os conjuntos de cifras podem ser listados por chamadas para CryptGetProvParam com PP_ENUMALGS ou PP_ENUMALGS_EX. O valor PP_ENUMALGS_EX funciona como PP_ENUMALGS mas retorna uma estrutura PROV_ENUMALGS_EX que contém informações mais extensas sobre os algoritmos suportados pelo provedor.

Para obter mais informações sobre sinalizadores de protocolo definidos e seus valores, consulte Protocol Flags.

Dado que o membro hCryptProv é o identificador de um contexto criptográfico aberto adquirido usando CryptAcquireContext com o seu parâmetro dwProvType definido como PROV_RSA_SCHANNEL, o seguinte exemplo lista os nomes de todos os algoritmos disponíveis no CSP.

PROV_ENUMALGS_EX EnumAlgs;     //   Structure to hold information on 
                               //   a supported algorithm
DWORD dFlag = CRYPT_FIRST;     //   Flag indicating that the first
                               //   supported algorithm is to be
                               //   enumerated. Changed to 0 after the
                               //   first call to the function.
cbData = sizeof(PROV_ENUMALGS_EX);

while( CryptGetProvParam(
    hCryptProv,          // handle to an open cryptographic provider
    PP_ENUMALGS_EX, 
    (BYTE *)&EnumAlgs,  // information on the next algorithm
    &cbData,            // number of bytes in the PROV_ENUMALGS_EX
    dFlag))             // flag to indicate whether this is a first or
                        // subsequent algorithm supported by the
                        // CSP.
{
    printf("Supported Algorithm name %s\n", EnumAlgs.szName);
    dFlag = CRYPT_NEXT;          // Set to CRYPT_NEXT after the first call,
} //  end of while loop. When all of the supported algorithms have
  //  been enumerated, the function returns FALSE.

A tabela a seguir lista alguns algoritmos retornados por um CSP de PROV_RSA_SCHANNEL doméstico típico. Observe que nem os MACs SHA SSL2 nem a criptografia DES SSL2 são suportados pelo CSP neste exemplo.

Identificador do algoritmo Comprimento mínimo da chave Comprimento máximo da chave Protocolos Nome do algoritmo
CALG_RSA_KEYX 512 2048 0x0007 "RSA_KEYX"
CALG_MD5 128 128 0x0007 MD5
CALG_SHA 160 160 0x0005 "SHA"
CALG_RC4 40 128 0x0007 "RC4"
CALG_DES 56 56 0x0005 "DES"

 

Para se preparar para enviar mensagens ClientHello ou ServerHello, o mecanismo de protocoloSchannel enumera os algoritmos e tamanhos de chave suportados pelo CSP e cria uma lista interna de pacotes de codificação suportados.