Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Note
Beberapa informasi berkaitan dengan produk prarilis yang mungkin dimodifikasi secara substansial sebelum dirilis secara komersial. Microsoft tidak memberikan jaminan, tersurat maupun tersirat, sehubungan dengan informasi yang diberikan di sini. Fitur yang dijelaskan dalam topik ini tersedia dalam versi pra-rilis Windows Insider Preview.
The NCryptEncapsulate function performs the Encapsulation operation of a Key Encapsulation Mechanism (KEM). Ini menghasilkan kunci rahasia bersama dan mengenkripsinya dengan kunci umum yang disediakan untuk menghasilkan ciphertext KEM, mengembalikan kunci rahasia bersama dan ciphertext 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]
Handel kunci yang akan digunakan untuk operasi enkapulasi.
pbSecretKey[out]
Penunjuk ke buffer yang menerima kunci rahasia bersama. 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]
Pointer ke buffer yang menerima ciphertext 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]
Dicadangkan, harus nol.
Return value
Mengembalikan kode status yang menunjukkan keberhasilan atau kegagalan fungsi.
Kemungkinan kode pengembalian termasuk, tetapi tidak terbatas pada, berikut ini.
| Return Code | Description |
|---|---|
ERROR_SUCCESS |
Fungsi berhasil. |
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. Kueri ini efisien dan mengembalikan ukuran tanpa melakukan enkapulasi.
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.
Untuk algoritma KEM yang saat ini didukung (ML-KEM), panjang rahasia bersama adalah ukuran konstan untuk algoritma tertentu dan panjang ciphertext KEM adalah ukuran konstan untuk set parameter tertentu.
Requirements
| Requirement | Value |
|---|---|
| Klien minimum yang didukung | Windows Insider (build 27843): Dukungan untuk ML-KEM dimulai. [hanya aplikasi desktop] |
| Server minimum yang didukung | Windows Insider (build 27843): Dukungan untuk ML-KEM dimulai. [hanya aplikasi desktop] |
| Library | Ncrypt.lib |
| DLL | Ncrypt.dll |