Skip to content

Commit 4d5792a

Browse files
authored
doc,crypto: add description to the KEM and supports() methods
PR-URL: #59644 Reviewed-By: James M Snell <[email protected]>
1 parent a3cd430 commit 4d5792a

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
@@ -801,9 +801,9 @@ added: v24.7.0
801801
802802
<!--lint disable maximum-line-length remark-lint-->
803803
804-
* `operation` {string} "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey", "deriveBits", "importKey", "exportKey", "getPublicKey", "wrapKey", or "unwrapKey"
804+
* `operation` {string} "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey", "deriveBits", "importKey", "exportKey", "getPublicKey", "wrapKey", "unwrapKey", "encapsulateBits", "encapsulateKey", "decapsulateBits", or "decapsulateKey"
805805
* `algorithm` {string|Algorithm}
806-
* `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.
806+
* `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.
807807
* Returns: {boolean} Indicating whether the implementation supports the given operation
808808
809809
<!--lint enable maximum-line-length remark-lint-->
@@ -812,6 +812,8 @@ Allows feature detection in Web Crypto API,
812812
which can be used to detect whether a given algorithm identifier
813813
(including its parameters) is supported for the given operation.
814814
815+
See [Checking for runtime algorithm support][] for an example use of this method.
816+
815817
### `subtle.decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext)`
816818
817819
<!-- YAML
@@ -825,6 +827,10 @@ added: v24.7.0
825827
* `ciphertext` {ArrayBuffer|TypedArray|DataView|Buffer}
826828
* Returns: {Promise} Fulfills with {ArrayBuffer} upon success.
827829
830+
A message recipient uses their asymmetric private key to decrypt an
831+
"encapsulated key" (ciphertext), thereby recovering a temporary symmetric
832+
key (represented as {ArrayBuffer}) which is then used to decrypt a message.
833+
828834
The algorithms currently supported include:
829835
830836
* `'ML-KEM-512'`[^modern-algos]
@@ -847,6 +853,10 @@ added: v24.7.0
847853
* `usages` {string\[]} See [Key usages][].
848854
* Returns: {Promise} Fulfills with {CryptoKey} upon success.
849855
856+
A message recipient uses their asymmetric private key to decrypt an
857+
"encapsulated key" (ciphertext), thereby recovering a temporary symmetric
858+
key (represented as {CryptoKey}) which is then used to decrypt a message.
859+
850860
The algorithms currently supported include:
851861
852862
* `'ML-KEM-512'`[^modern-algos]
@@ -1032,6 +1042,9 @@ added: v24.7.0
10321042
* `encapsulationKey` {CryptoKey}
10331043
* Returns: {Promise} Fulfills with {EncapsulatedBits} upon success.
10341044
1045+
Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
1046+
This encrypted key is the "encapsulated key" represented as {EncapsulatedBits}.
1047+
10351048
The algorithms currently supported include:
10361049
10371050
* `'ML-KEM-512'`[^modern-algos]
@@ -1053,6 +1066,9 @@ added: v24.7.0
10531066
* `usages` {string\[]} See [Key usages][].
10541067
* Returns: {Promise} Fulfills with {EncapsulatedKey} upon success.
10551068
1069+
Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.
1070+
This encrypted key is the "encapsulated key" represented as {EncapsulatedKey}.
1071+
10561072
The algorithms currently supported include:
10571073
10581074
* `'ML-KEM-512'`[^modern-algos]
@@ -2033,6 +2049,11 @@ added: v15.0.0
20332049
added: v24.7.0
20342050
-->
20352051
2052+
A temporary symmetric secret key (represented as {ArrayBuffer}) for message encryption
2053+
and the ciphertext (that can be transmitted to the message recipient along with the
2054+
message) encrypted by this shared key. The recipient uses their private key to determine
2055+
what the shared key is which then allows them to decrypt the message.
2056+
20362057
#### `encapsulatedBits.ciphertext`
20372058
20382059
<!-- YAML
@@ -2055,6 +2076,11 @@ added: v24.7.0
20552076
added: v24.7.0
20562077
-->
20572078
2079+
A temporary symmetric secret key (represented as {CryptoKey}) for message encryption
2080+
and the ciphertext (that can be transmitted to the message recipient along with the
2081+
message) encrypted by this shared key. The recipient uses their private key to determine
2082+
what the shared key is which then allows them to decrypt the message.
2083+
20582084
#### `encapsulatedKey.ciphertext`
20592085
20602086
<!-- YAML
@@ -2657,6 +2683,7 @@ The length (in bytes) of the random salt to use.
26572683
26582684
[^openssl35]: Requires OpenSSL >= 3.5
26592685
2686+
[Checking for runtime algorithm support]: #checking-for-runtime-algorithm-support
26602687
[JSON Web Key]: https://tools.ietf.org/html/rfc7517
26612688
[Key usages]: #cryptokeyusages
26622689
[Modern Algorithms in the Web Cryptography API]: #modern-algorithms-in-the-web-cryptography-api

0 commit comments

Comments
 (0)