old-keypairs.js/README.md

107 lines
2.9 KiB
Markdown
Raw Normal View History

2018-11-11 06:59:59 +00:00
This is being ported from code from rsa-compat.js, greenlock.html (bacme.js), and others.
2018-12-03 07:57:41 +00:00
This was intended to be just a weekend project, but it's grown a bit.
2018-11-12 18:50:49 +00:00
* 2018-10-10 (Saturday) work has begun
* 2018-10-11 (Sunday) W00T! got a CSR generated for RSA with VanillaJS ArrayBuffer
* 2018-10-12 (Monday) Figuring out ECDSA CSRs right now
2018-11-16 08:40:07 +00:00
* 2018-10-15 (Thursday) ECDSA is a trixy hobbit... but I think I've got it...
2018-12-03 07:57:41 +00:00
* 2018-12-02 (Sunday) Been mostly done for a while, individually, slowly merging everything together
* [Rasha.js](https://git.coolaj86.com/coolaj86/rasha.js) (RSA utils)
* [Eckles.js](https://git.coolaj86.com/coolaj86/eckles.js) (EC utils)
2018-11-11 06:59:59 +00:00
<!--
2018-05-10 21:19:09 +00:00
Keypairs&trade; for node.js
===========================
JavaScript RSA and ECDSA utils that work on Windows, Mac, and Linux with or without C compiler.
There are many different RSA and ECDSA libraries for node and it seems like they're
all incompatible in different ways. This isn't [yet another library](https://xkcd.com/927/),
but rather [one to rule them all and bind them](https://en.wikipedia.org/wiki/One_Ring).
Features
========
* [x] RSA
2018-11-10 22:29:39 +00:00
* [ ] ECDSA (in-progress)
2018-05-10 21:19:09 +00:00
* [x] generate keypair
* [x] export to JWK
* [x] import from JWK
* [x] export to PEM
* [x] import from PEM
* [x] sign JWS
* [x] generate CSR (DER as PEM or base64url)
API
===
* `Keypairs.generate(options)`
* options example `{ type: 'RSA' || 'ECDSA', bitlength: 2048 || 256 }`
* `Keypairs.import(options)`
* options example `{ pem: '...', crv: 'P-256' || 'ECC', bitlength: 2048 || 256 }`
* `Keypairs.export(options)`
* options example `{ private: true || false, pem: true || false }`
* `Keypairs.jws.sign(options)`
* options example `{ keypair, header, protected, payload }`
* `Keypairs.csr.generate(options)`
* options example `{ keypair, [ 'example.com' ] }`
`keypair` can be any object with
any of these keys `publicKeyPem, privateKeyPem, publicKeyJwk, privateKeyJwk`.
Examples
========
These are quick examples of how to use the library.
If you have a specific question, please open an issue.
Keypairs.generate(options)
-------------------
Simple RSA
```js
return Keypairs.generate({
type: 'RSA'
, bitlength: 2048
}).then(function (keypair) {
// we won't bother describing this object
// because it's only useful once exported
});
```
Advanced RSA
```js
return Keypairs.generate({
type: 'RSA'
, bitlength: 2048 // or 4096
, exponent: 65537 // don't change this
, public: true // pre-cache public key
, pem: true // pre-export the PEM
, internal: true // pre-cache internal representations
}).then(function (keypair) {
// we won't bother describing this object
// because it's only useful once exported
});
```
Keypairs.export(options)
-------------------
Keypairs.import(options)
-------------------
Keypairs.jws.sign(options)
-------------------
Keypairs.csr.generate(options)
-------------------
2018-11-11 06:59:59 +00:00
-->