UNPKG

6.33 kBMarkdownView Raw
1# @peculiar/webcrypto
2
3[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/PeculiarVentures/webcrypto/master/LICENSE.md)
4![test](https://github.com/PeculiarVentures/webcrypto/workflows/test/badge.svg)
5[![Coverage Status](https://coveralls.io/repos/github/PeculiarVentures/webcrypto/badge.svg?branch=master)](https://coveralls.io/github/PeculiarVentures/webcrypto?branch=master)
6[![npm version](https://badge.fury.io/js/%40peculiar%2Fwebcrypto.svg)](https://badge.fury.io/js/%40peculiar%2Fwebcrypto)
7
8We wanted to be able to write Javascript that used crypto on both the client and the server but we did not want to rely on Javascript implementations of crypto. The only native cryptography available in browser is [Web Crypto](http://caniuse.com/#search=cryptography), this resulted in us creating a `@peculiar/webcrypto`.
9
10## Table Of Contents
11
12* [WARNING](#warning)
13* [Installing](#installing)
14* [Using](#using)
15* [Examples](#examples)
16* [Bug Reporting](#bug-reporting)
17* [Related](#related)
18
19## WARNING
20
21**At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.**
22
23**Module is based on NodeJS v10 Crypto API. It would work only with Node v10 and higher.**
24
25## Installing
26
27```
28npm install @peculiar/webcrypto
29```
30
31## Supported algorithms
32
33| Algorithm name | generateKey | digest | export/import | sign/verify | encrypt/decrypt | wrapKey/unwrapKey | derive |
34|-------------------|-------------|---------|---------------|-------------|-----------------|-------------------|---------|
35| SHA-1 | | X | | | | | |
36| SHA-256 | | X | | | | | |
37| SHA-384 | | X | | | | | |
38| SHA-512 | | X | | | | | |
39| HMAC | X | | X | X | | | |
40| RSASSA-PKCS1-v1_5 | X | | X | X | | | |
41| RSAES-PKCS1-v1_5<sup>2</sup>| X | | X | | X | X | |
42| RSA-PSS | X | | X | X | | | |
43| RSA-OAEP | X | | X | | X | X | |
44| AES-CMAC | X | | X | X | | | |
45| AES-CBC | X | | X | | X | X | |
46| AES-CTR | X | | X | | X | X | |
47| AES-ECB | X | | X | | X | X | |
48| AES-GCM | X | | X | | X | X | |
49| AES-KW | X | | X | | | X | |
50| ECDSA<sup>1</sup> | X | | X | X | | | |
51| ECDH<sup>1</sup> | X | | X | | | | X |
52| EdDSA<sup>2,3</sup> | X | | X | X | | | |
53| ECDH-ES<sup>2,4</sup> | X | | X | | | | X |
54| HKDF | | | X | | | | X |
55| PBKDF2 | | | X | | | | X |
56| DES-CBC<sup>2</sup>| X | | X | | X | X | |
57| DES-EDE3-CBC<sup>2</sup>| X | | X | | X | X | |
58| shake128<sup>2</sup>| | X | | | | | |
59| shake256<sup>2</sup>| | X | | | | | |
60
61<sup>1</sup> Mechanism supports extended list of named curves `P-256`, `P-384`, `P-521`, `K-256`,
62`brainpoolP160r1`, `brainpoolP160t1`, `brainpoolP192r1`, `brainpoolP192t1`, `brainpoolP224r1`, `brainpoolP224t1`, `brainpoolP256r1`, `brainpoolP256t1`, `brainpoolP320r1`, `brainpoolP320t1`, `brainpoolP384r1`, `brainpoolP384t1`, `brainpoolP512r1`, and `brainpoolP512t1`
63
64<sup>2</sup> Mechanism is not defined by the WebCrypto specifications. Use of mechanism in a safe way is hard, it was added for the purpose of enabling interoperability with an existing system. We recommend against its use unless needed for interoperability.
65
66<sup>3</sup> Mechanism supports extended list of named curves `Ed25519`, and `Ed448`
67
68<sup>4</sup> Mechanism supports extended list of named curves `X25519`, and `X448`
69
70## Using
71
72```javascript
73const { Crypto } = require("@peculiar/webcrypto");
74
75const crypto = new Crypto();
76```
77
78## Examples
79
80See [WebCrypto Docs](https://github.com/PeculiarVentures/webcrypto-docs/blob/master/README.md) for examples
81
82## Bug Reporting
83Please report bugs either as pull requests or as issues in the issue tracker. `@peculiar/webcrypto` has a full disclosure vulnerability policy. Please do NOT attempt to report any security vulnerability in this code privately to anybody.
84
85
86## Related
87 - [node-webcrypto-ossl](https://github.com/PeculiarVentures/node-webcrypto-ossl)
88 - [node-webcrypto-p11](https://github.com/PeculiarVentures/node-webcrypto-p11)
89 - [webcrypto-liner](https://github.com/PeculiarVentures/webcrypto-liner)