다음을 통해 공유


BCryptEncapsulate function

Note

일부 정보는 상용 출시되기 전에 실질적으로 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다. 이 항목에 설명된 기능은 Windows Insider 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]

예약됨, 0이어야 합니다.

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