Поделиться через


BCryptEncapsulate function

Note

Некоторые сведения относятся к предварительному продукту, который может быть существенно изменен до его коммерческого выпуска. Корпорация Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых в отношении информации, предоставленной здесь. Функция, описанная в этом разделе, доступна в предварительной версии Предварительной версии Windows Preview.

The BCryptEncapsulate function performs the Encapsulation operation of a Key Encapsulation Mechanism (KEM). Он создает общий секретный ключ и шифрует его с предоставленным открытым ключом для создания шифра KEM, возвращая как общий секретный ключ, так и зашифрованный текст KEM.

Syntax

NTSTATUS BCryptEncapsulate(
  _In_  BCRYPT_KEY_HANDLE hKey,
  _Out_writes_bytes_to_opt_(cbSecretKey ,*pcbSecretKey)
        PUCHAR            pbSecretKey,
  _In_  ULONG             cbSecretKey,
  _Out_ ULONG             *pcbSecretKey,
  _Out_writes_bytes_to_opt_(cbCipherText ,*pcbCipherText)
        PUCHAR            pbCipherText,
  _In_  ULONG             cbCipherText,
  _Out_ ULONG             *pcbCipherText,
  _In_  ULONG             dwFlags
);

Parameters

hKey[in]

Дескриптор ключа, используемый для операции инкапсуляции. This key must contain a public (encapsulation) key, and the handle would typically be obtained by using BCryptImportKeyPair with a public key BLOB for the KEM algorithm. Также можно использовать дескриптор закрытого ключа для операции инкапсуляции, так как дескриптор закрытого ключа KEM представляет пару ключей.

pbSecretKey[out]

Указатель на буфер, получающий общий секретный ключ. 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]

Указатель на буфер, получающий шифр 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]

Зарезервировано, должно быть равно нулю.

Return value

Возвращает код состояния, указывающий на успешность или сбой функции.

Возможные коды возврата включают в себя, но не ограничиваются следующими.

Return Code Description
STATUS_SUCCESS Функция была успешной.
STATUS_INVALID_PARAMETER One or more required parameters (hKey, pcbSecretKey, pcbCipherText) is NULL, or one of the parameters has an invalid value.
STATUS_INVALID_BUFFER_SIZE A buffer size (cbSecretKey, cbCipherText) does not match the expected size 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.
STATUS_BUFFER_TOO_SMALL An output buffer size (cbSecretKey, cbCipherText) is too small for the result encapsulation operation 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 BCryptEncapsulate with NULLpbSecretKey and pbCipherText. The required sizes will be returned in pcbSecretKey and pcbCipherText, respectively. Этот запрос эффективен и возвращает размер без инкапсуляции. Equivalently, use BCryptGetProperty to query the BCRYPT_KEM_SHARED_SECRET_LENGTH property of the algorithm or key handle, and the BCRYPT_KEM_CIPHERTEXT_LENGTH property of the key handle. Для поддерживаемых в настоящее время алгоритмов KEM (ML-KEM), общая длина секрета является константным размером для заданного алгоритма, а длина шифра KEM — константный размер заданного набора параметров.

Requirements

Requirement Value
Минимальный поддерживаемый клиент Программы предварительной оценки Windows (сборка 27843): Начинается поддержка ML-KEM. [только классические приложения]
минимальный поддерживаемый сервер Программы предварительной оценки Windows (сборка 27843): Начинается поддержка ML-KEM. [только классические приложения]
Library Bcrypt.lib
DLL Bcrypt.dll

See also

BCryptDecapsulate

BCryptGetProperty