{"id":13342896,"url":"https://github.com/grafana/xk6-webcrypto","last_synced_at":"2025-10-19T10:31:32.819Z","repository":{"id":62634532,"uuid":"547214235","full_name":"grafana/xk6-webcrypto","owner":"grafana","description":"WIP implementation of the WebCrypto specification for k6","archived":false,"fork":false,"pushed_at":"2024-07-20T14:33:28.000Z","size":449,"stargazers_count":7,"open_issues_count":14,"forks_count":3,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-09-28T15:02:02.105Z","etag":null,"topics":["hacktoberfest","k6","webcrypto","xk6"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-07T10:12:05.000Z","updated_at":"2024-06-27T12:05:06.000Z","dependencies_parsed_at":"2023-01-30T03:46:03.075Z","dependency_job_id":"6be14352-8364-4563-b7ab-1f4c30f53204","html_url":"https://github.com/grafana/xk6-webcrypto","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-webcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-webcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-webcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fxk6-webcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/xk6-webcrypto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869249,"owners_count":16555572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","k6","webcrypto","xk6"],"created_at":"2024-07-29T19:30:06.735Z","updated_at":"2025-10-19T10:31:27.457Z","avatar_url":"https://github.com/grafana.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-webcrypto\n\n\u003e [!WARNING]\n\u003e The `xk6-webcrypto` extension [has been merged](https://github.com/grafana/k6/pull/4188) to the [main k6 repository](https://github.com/grafana/k6). Please contribute and [open issues there](https://github.com/grafana/k6/issues). This repository is no longer maintained.\n\nThis is an implementation of the [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) specification for k6.\n\n## Current state\n\nStarting the version 0.44.0, this implementation is available in k6 as an experimental module. To use it, you need to import it in your script.\n\n```javascript\nimport webcrypto from 'k6/experimental/webcrypto';\n```\n\nWhile we consider it ready for production use, it is still missing some features and is not yet fully compliant with the specification.\n\n### Supported APIs and algorithms\n\n#### Crypto\n\n| API                        | Supported | Notes        |\n| :------------------------- | :-------- | :----------- |\n| `crypto.getRandomValues()` | ✅        | **complete** |\n| `crypto.randomUUID()`      | ✅        | **complete** |\n\n#### SubtleCrypto\n\n\n##### Encryption/Decryption\n\n| API                       | AES-CBC | AES-GCM | AES-CTR | RSA-OAEP |\n| :------------------------ | :------ | :------ | :------ | :------- |\n| `crypto.subtle.encrypt()` | ✅      | ✅      | ✅      | ✅       |\n| `crypto.subtle.decrypt()` | ✅      | ✅      | ✅      | ✅       |\n\n##### Signature\n\n| API                      | HMAC | ECDSA | RSASSA-PKCS1-v1_5 | RSA-PSS |\n| :----------------------- | :--- | :---- | :---------------- | :------ |\n| `crypto.subtle.sign()`   | ✅   | ✅    | ✅                | ✅      |\n| `crypto.subtle.verify()` | ✅   | ✅    | ✅                | ✅      |\n\n##### Key generation, import, and export\n\n| API                           | AES-CBC | AES-GCM | AES-CTR | AES-KW | HMAC | ECDSA | ECDH | RSASSA-PKCS1-v1_5 | RSA-PSS | RSA-OAEP |\n| :---------------------------- | :------ | :------ | :------ | :----- | :--- | :---- | :--- | :---------------- | :------ | :------- |\n| `crypto.subtle.generateKey()` | ✅      | ✅      | ✅      | ❌     | ✅   | ✅    | ✅   | ✅                | ✅      | ✅       |\n| `crypto.subtle.importKey()`   | ✅      | ✅      | ✅      | ❌     | ✅   | ✅    | ✅   | ✅                | ✅      | ✅       |\n| `crypto.subtle.exportKey()`   | ✅      | ✅      | ✅      | ❌     | ✅   | ✅    | ✅   | ✅                | ✅      | ✅       |\n\n\u003e [!WARNING]  \n\u003e Currently, only the `raw` and `jwk` (JSON Web Key) formats are supported for import/export operations for the `AES-*` and `HMAC` algorithms. `ECDH` and `ECDSA` have support for `pkcs8`, `spki`, `raw` and `jwk` formats. RSA algorithms have support for `pkcs8`, `spki`  and `jwk` formats.\n\n##### Key derivation\n\n| API                          | ECDH | HKDF | PBKDF2 |\n| :--------------------------- | :--- | :--- | :----- |\n| `crypto.subtle.deriveKey()`  | ❌   | ❌   | ❌     |\n| `crypto.subtle.deriveBits()` | ✅   | ❌   | ❌     |\n\nNote: `deriveBits` currently doesn't support length parameter non-multiple of 8.\n\n##### Key wrapping\n\n| API                         | AES-CBC | AES-GCM | AES-CTR | AES-KW | RSA-OAEP |\n| :-------------------------- | :------ | :------ | :------ | :----- | :------- |\n| `crypto.subtle.unwrapKey()` | ❌      | ❌      | ❌      | ❌     | ❌       |\n\n### APIs and algorithms with limited support\n\n- **WebCrypto API support**: Even though we implemented the vast majority of the WebCrypto API, there are still some APIs and algorithms that are not yet supported. By looking at the [WebCrypto API Compliant](https://github.com/grafana/xk6-webcrypto/issues?q=is%3Aissue+state%3Aopen+label%3A%22WebCrypto+API+Compliant%22) label, you can see what is missing.\n- **AES-GCM**: Although the algorithm is supported, and can already be used, it is not fully compliant with the specification. The reason for this is that the Go standard library only supports a 12-byte nonce/iv, while the specification allows for a wider range of sizes. We do not expect to address this limitation unless the Go standard library adds support for it.\n- **RSA-PSS**: Since we use Golang SDK under the hood, the RSA-PSS [doesn't support deterministic signatures](https://github.com/golang/go/blob/master/src/crypto/rsa/pss.go#L293-L297). In other words, even if `saltLength` is set to 0, the signature will be different each time.\n\n## Contributing\n\nContributions are welcome! If the module is missing a feature you need, or if you find a bug, please open an issue or a pull request. If you are not sure about something, feel free to open an issue and ask.\n\n### Practices\n\nIn our implementation we rely on [WebCrypto API specification](https://www.w3.org/TR/WebCryptoAPI). Sometimes it feels quite large, and it is not always easy to understand what is going on. To help with that, we have adopted a few practices that we hope will make it easier for contributors to understand the codebase.\n\nFollowing this convention allows us to document why certain operations are made in a certain way, and to track the progress of the implementation. We do not always add them, but we try to do so when it makes sense, and encourage contributors to do the same.\n\n### Web Platform Tests\n\nWe aim to be compliant with the WebCrypto API specification. To ensure that, we test our implementation against the [Web Platform Tests](https://web-platform-tests.org/), this is a part of the CI, and it's expected to implement the missing tests when it's needed. See the [webcrypto/tests/README.md](./webcrypto/tests/README.md) for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-webcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fxk6-webcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fxk6-webcrypto/lists"}