-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* webcrypto: RSA support * webcrypto: mentioning RsaHashedImportParams --------- Co-authored-by: Joan López de la Franca Beltran <[email protected]>
- Loading branch information
1 parent
4c77b19
commit 27a5d99
Showing
12 changed files
with
114 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...urces/k6/next/javascript-api/k6-experimental/webcrypto/rsahashedimportparams.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: 'RsaHashedImportParams' | ||
description: 'RsaHashedImportParams represents the object that should be passed as the algorithm parameter into the importKey operation, when using the RSA algorithm.' | ||
weight: 12 | ||
--- | ||
|
||
# RsaHashedImportParams | ||
|
||
The `RsaHashedImportParams` represents the object that should be passed as the algorithm parameter into [`importKey`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/importkey/) when using the RSA algorithm. | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| :------- | :------- | :------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| name | `string` | This should be set to `RSASSA-PKCS1-v1_5`, `RSA-PSS` or `RSA-OAEP`. | | ||
| hash | `string` | `object` | The name or an object with a `name` property of the digest function to use. Possible values are `SHA-1`, `SHA-256`, `SHA-384` and `SHA-512`. | |
41 changes: 41 additions & 0 deletions
41
...urces/k6/next/javascript-api/k6-experimental/webcrypto/rsahashedkeygenparams.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: 'RSAHashedKeyGenParams' | ||
description: 'RSAHashedKeyGenParams represents the object that should be passed as the algorithm parameter into the generateKey operation, when generating an RSA key pair.' | ||
weight: 12 | ||
--- | ||
|
||
# RSAHashedKeyGenParams | ||
|
||
The `RSAHashedKeyGenParams` object represents the object that should be passed as the algorithm parameter into the [generateKey](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/generatekey) operation when generating an RSA key pair. | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| :------------- | :----------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| name | `string` | This should be set to `RSASSA-PKCS1-v1_5`, `RSA-PSS` or `RSA-OAEP`. | | ||
| modulusLength | `number` | The length in bits of the RSA modulus. This should be at least 2048. Some organizations are now recommending that it should be 4096. | | ||
| publicExponent | `Uint8Array` | The public exponent. Unless you have a good reason to use something else, specify `65537` here, which represented as a `Uint8Array` is `new Uint8Array([1, 0, 1])` | | ||
| hash | `string` | `object` | The name or an object with a `name` property of the digest function to use. Possible values are `SHA-1`, `SHA-256`, `SHA-384` and `SHA-512`. | | ||
|
||
## Example | ||
|
||
{{< code >}} | ||
|
||
```javascript | ||
import { crypto } from 'k6/experimental/webcrypto'; | ||
|
||
export default async function () { | ||
const keyPair = await crypto.subtle.generateKey( | ||
{ | ||
name: 'RSA-PSS', | ||
modulusLength: 2048, | ||
publicExponent: new Uint8Array([1, 0, 1]), | ||
hash: { name: 'SHA-256' }, | ||
}, | ||
true, | ||
['sign', 'verify'] | ||
); | ||
} | ||
``` | ||
|
||
{{< /code >}} |
19 changes: 19 additions & 0 deletions
19
docs/sources/k6/next/javascript-api/k6-experimental/webcrypto/rsaoaepparams.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: 'RsaOaepParams' | ||
description: 'RsaOaepParams represents the object that should be passed as the algorithm parameter into the encrypt and decrypt operation when using the RSA-OAEP algorithm.' | ||
weight: 06 | ||
--- | ||
|
||
# RsaOaepParams | ||
|
||
The `RsaOaepParams` object represents the object that should be passed as the algorithm parameter into the [encrypt](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/encrypt) and [decrypt](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/decrypt) operation when using the RSA-OAEP algorithm. | ||
|
||
For more details, head to the [MDN Web Crypto API documentation on RSA-OAEP](https://developer.mozilla.org/en-US/docs/Web/API/RsaOaepParams). | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| :--------------- | :----------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| name | `string` | Should be set to `RSA-OAEP`. | | ||
| label (optional) | `ArrayBuffer`, `TypedArray`, or `DataView` | It's an array of bytes that does not itself need to be encrypted but which should be bound to the ciphertext. A digest of the label is part of the input to the encryption operation. Unless your application calls for a label, you can just omit this argument, and it will not affect the security of the encryption operation. | | ||
| | |
22 changes: 22 additions & 0 deletions
22
docs/sources/k6/next/javascript-api/k6-experimental/webcrypto/rsapssparams.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: 'RsaPssParams' | ||
description: 'RsaPssParams is a parameter used for sign or verify operations.' | ||
weight: 11 | ||
--- | ||
|
||
# RsaPssParams | ||
|
||
The `RsaPssParams` represents the object that should be passed as the algorithm parameter into [`sign`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/sign/) or [`verify`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/webcrypto/subtlecrypto/verify/) when using the RSA-PSS algorithm. | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| :--------- | :------- | :-------------------------------------------------------------------------- | | ||
| name | `string` | An algorithm name. Should be `RSA-PSS`. | | ||
| saltLength | `number` | A long integer representing the length of the random salt to use, in bytes. | | ||
|
||
{{< admonition type="caution" >}} | ||
|
||
Since under the hood we use Golang's SDK the salt length 0 is not supported. In that case the maximum possible salt length will be used. | ||
|
||
{{< /admonition >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.