Partager via


NCryptEncapsulate function

Note

Certaines informations concernent un produit de préversion qui peut être sensiblement modifié avant sa publication commerciale. Microsoft n’offre aucune garantie, expresse ou implicite, en ce qui concerne les informations fournies ici. La fonctionnalité décrite dans cette rubrique est disponible dans les versions préliminaires du Windows Insider Preview.

The NCryptEncapsulate function performs the Encapsulation operation of a Key Encapsulation Mechanism (KEM). Il génère une clé secrète partagée et le chiffre avec la clé publique fournie pour produire un texte chiffré KEM, en retournant à la fois la clé secrète partagée et le texte chiffré KEM.

Syntax

NTSTATUS NCryptEncapsulate (
    [in]    NCRYPT_KEY_HANDLE hKey
    [out]   PBYTE             pbSecretKey,
    [in]    ULONG             cbSecretKey,
    [out]   ULONG             *pcbSecretKey,
    [out]   PBYTE             pbCipherText,
    [in]    ULONG             cbCipherText,
    [out]   ULONG             *pcbCipherText,
    [in]    ULONG             dwFlags
);

Parameters

hKey[in]

Handle de la clé à utiliser pour l’opération d’encapsulation.

pbSecretKey[out]

Pointeur vers une mémoire tampon qui reçoit la clé secrète partagée. See remarks for more information.

cbSecretKey[in]

The size, in bytes, of the pbSecretKey buffer.

pcbSecretKey[out]

A pointer to a ULONG variable that the receives the number of bytes written to pbSecretKey buffer.

If pbSecretKey is NULL, this receives the size, in bytes, required for the shared secret key. See remarks for more information.

pbCipherText[out]

Pointeur vers une mémoire tampon qui reçoit le texte chiffré KEM. See remarks for more information.

cbCipherText[in]

The size, in bytes, of the pbCipherText buffer.

pcbCipherText[out]

A pointer to a ULONG variable that the receives the number of bytes written to pbCipherText buffer.

If pbCipherText is NULL, this receives the size, in bytes, required for the KEM ciphertext. See remarks for more information.

dwFlags[in]

Réservée, doit être zéro.

Return value

Retourne un code d’état qui indique la réussite ou l’échec de la fonction.

Les codes de retour possibles incluent, mais ne sont pas limités à, les éléments suivants.

Return Code Description
ERROR_SUCCESS La fonction a réussi.
NTE_BAD_FLAGS The dwFlags parameter contains a value that is not valid.
NTE_INVALID_PARAMETER One or more required parameters (hKey, pcbSecretKey, pcbCipherText) is NULL, or one of the parameters has an invalid value.
NTE_BUFFER_TOO_SMALL An output buffer size (cbSecretKey, cbCipherText) is too small for the result of the encapsulation for the KEM parameters associated with the encapsulation key. pcbSecretKey receives the number of bytes required for pbSecretKey, pcbCipherText receives the number of bytes required for pbCipherText.

Remarks

To query the required sizes of the pbSecretKey and pbCipherText buffers, callers may call NCryptEncapsulate with NULL values in pbSecretKey and pbCipherText. The required size will be returned in pcbSecretKey and pcbCipherText, respectively. Cette requête est efficace et retourne la taille sans effectuer l’encapsulation. Equivalently, use NCryptGetProperty to query the NCRYPT_KEM_SHARED_SECRET_LENGTH_PROPERTY property of the algorithm or key handle, and the NCRYPT_KEM_CIPHERTEXT_LENGTH_PROPERTY property of the key handle. Pour les algorithmes KEM actuellement pris en charge (ML-KEM), la longueur du secret partagé est une taille constante pour un algorithme donné et la longueur du texte chiffré KEM est une taille constante pour un jeu de paramètres donné.

Requirements

Requirement Value
Client minimum requis Windows Insiders (build 27843) : La prise en charge de ML-KEM commence. [Applications de bureau uniquement]
Serveur minimal pris en charge Windows Insiders (build 27843) : La prise en charge de ML-KEM commence. [Applications de bureau uniquement]
Library Ncrypt.lib
DLL Ncrypt.dll

See also

NCryptDecapsulate

NCryptGetProperty

BCryptEncapsulate

BCryptDecapsulate