Skip to content

Commit bc7fadf

Browse files
committed
doc,crypto: add description to the KEM and supports() methods
1 parent ec8c73d commit bc7fadf

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

doc/api/webcrypto.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,9 @@ added: REPLACEME
790790
791791
<!--lint disable maximum-line-length remark-lint-->
792792
793-
* `operation` {string} "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey", "deriveBits", "importKey", "exportKey", "getPublicKey", "wrapKey", or "unwrapKey"
793+
* `operation` {string} "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey", "deriveBits", "importKey", "exportKey", "getPublicKey", "wrapKey", "unwrapKey", "encapsulateBits", "encapsulateKey", "decapsulateBits", or "decapsulateKey"
794794
* `algorithm` {string|Algorithm}
795-
* `lengthOrAdditionalAlgorithm` {null|number|string|Algorithm|undefined} Depending on the operation this is either ignored, the value of the length argument when operation is "deriveBits", the algorithm of key to be derived when operation is "deriveKey", the algorithm of key to be exported before wrapping when operation is "wrapKey", or the algorithm of key to be imported after unwrapping when operation is "unwrapKey". **Default:** `null` when operation is "deriveBits", `undefined` otherwise.
795+
* `lengthOrAdditionalAlgorithm` {null|number|string|Algorithm|undefined} Depending on the operation this is either ignored, the value of the length argument when operation is "deriveBits", the algorithm of key to be derived when operation is "deriveKey", the algorithm of key to be exported before wrapping when operation is "wrapKey", the algorithm of key to be imported after unwrapping when operation is "unwrapKey", or the algorithm of key to be imported after en/decapsulating a key when operation is "encapsulateKey" or "decapsulateKey". **Default:** `null` when operation is "deriveBits", `undefined` otherwise.
796796
* Returns: {boolean} Indicating whether the implementation supports the given operation
797797
798798
<!--lint enable maximum-line-length remark-lint-->
@@ -801,6 +801,8 @@ Allows feature detection in Web Crypto API,
801801
which can be used to detect whether a given algorithm identifier
802802
(including its parameters) is supported for the given operation.
803803
804+
See [Checking for runtime algorithm support][] for an example use of this method.
805+
804806
### `subtle.decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext)`
805807
806808
<!-- YAML
@@ -814,6 +816,10 @@ added: REPLACEME
814816
* `ciphertext` {ArrayBuffer|TypedArray|DataView|Buffer}
815817
* Returns: {Promise} Fulfills with {ArrayBuffer} upon success.
816818
819+
A message recipient uses their asymmetric private key to decrypt an
820+
"encapsulated key" (ciphertext), thereby recovering a temporary symmetric
821+
key (represented as {ArrayBuffer}) which is then used to decrypt a message.
822+
817823
The algorithms currently supported include:
818824
819825
* `'ML-KEM-512'`[^modern-algos]
@@ -836,6 +842,10 @@ added: REPLACEME
836842
* `usages` {string\[]} See [Key usages][].
837843
* Returns: {Promise} Fulfills with {CryptoKey} upon success.
838844
845+
A message recipient uses their asymmetric private key to decrypt an
846+
"encapsulated key" (ciphertext), thereby recovering a temporary symmetric
847+
key (represented as {CryptoKey}) which is then used to decrypt a message.
848+
839849
The algorithms currently supported include:
840850
841851
* `'ML-KEM-512'`[^modern-algos]
@@ -1021,6 +1031,9 @@ added: REPLACEME
10211031
* `encapsulationKey` {CryptoKey}
10221032
* Returns: {Promise} Fulfills with {EncapsulatedBits} upon success.
10231033
1034+
Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
1035+
This encrypted key is the "encapsulated key" represented as {EncapsulatedBits}.
1036+
10241037
The algorithms currently supported include:
10251038
10261039
* `'ML-KEM-512'`[^modern-algos]
@@ -1042,6 +1055,9 @@ added: REPLACEME
10421055
* `usages` {string\[]} See [Key usages][].
10431056
* Returns: {Promise} Fulfills with {EncapsulatedKey} upon success.
10441057
1058+
Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
1059+
This encrypted key is the "encapsulated key" represented as {EncapsulatedKey}.
1060+
10451061
The algorithms currently supported include:
10461062
10471063
* `'ML-KEM-512'`[^modern-algos]
@@ -2023,6 +2039,11 @@ which is equivalent to not providing context at all.
20232039
added: REPLACEME
20242040
-->
20252041
2042+
A temporary symmetric secret key (represented as {ArrayBuffer}) for message encryption
2043+
and the ciphertext (that can be transmitted to the message recipient along with the
2044+
message) encrypted by this shared key. The recipient uses their private key to determine
2045+
what the shared key is which then allows them to decrypt the message.
2046+
20262047
#### `encapsulatedBits.ciphertext`
20272048
20282049
<!-- YAML
@@ -2045,6 +2066,11 @@ added: REPLACEME
20452066
added: REPLACEME
20462067
-->
20472068
2069+
A temporary symmetric secret key (represented as {CryptoKey}) for message encryption
2070+
and the ciphertext (that can be transmitted to the message recipient along with the
2071+
message) encrypted by this shared key. The recipient uses their private key to determine
2072+
what the shared key is which then allows them to decrypt the message.
2073+
20482074
#### `encapsulatedKey.ciphertext`
20492075
20502076
<!-- YAML
@@ -2538,6 +2564,7 @@ The length (in bytes) of the random salt to use.
25382564
25392565
[^openssl35]: Requires OpenSSL >= 3.5
25402566
2567+
[Checking for runtime algorithm support]: #checking-for-runtime-algorithm-support
25412568
[JSON Web Key]: https://tools.ietf.org/html/rfc7517
25422569
[Key usages]: #cryptokeyusages
25432570
[Modern Algorithms in the Web Cryptography API]: #modern-algorithms-in-the-web-cryptography-api

0 commit comments

Comments
 (0)