rsa-compat
Advanced tools
Comparing version 1.6.1 to 1.9.1
{ | ||
"name": "rsa-compat", | ||
"version": "1.6.1", | ||
"version": "1.9.1", | ||
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler", | ||
"main": "node.js", | ||
"main": "index.js", | ||
"bin": { | ||
@@ -10,7 +10,8 @@ "rsa-keygen-js": "bin/rsa-keygen.js" | ||
"scripts": { | ||
"test": "node tests" | ||
"postinstall": "node lib/telemetry.js event:install", | ||
"test": "bash test.sh" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://git.coolaj86.com/coolaj86/rsa-compat.js.git" | ||
"url": "https://git.coolaj86.com/coolaj86/rsa-compat.js.git" | ||
}, | ||
@@ -31,3 +32,3 @@ "keywords": [ | ||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)", | ||
"license": "(MIT OR Apache-2.0)", | ||
"license": "MPL-2.0", | ||
"bugs": { | ||
@@ -41,3 +42,3 @@ "url": "https://git.coolaj86.com/coolaj86/rsa-compat.js/issues" | ||
"optionalDependencies": { | ||
"ursa-optional": "^0.9.6" | ||
"ursa-optional": "^0.9.10" | ||
}, | ||
@@ -44,0 +45,0 @@ "trulyOptionalDependencies": { |
112
README.md
@@ -6,15 +6,16 @@ # rsa-compat.js | ||
| Sponsored by [ppl](https://ppl.family). | ||
| A [Root](https://therootcompany.com) Project. | ||
JavaScript RSA utils that work on Windows, Mac, and Linux with or without C compiler | ||
In order to provide a module that "just works" everywhere, we mix and match methods | ||
from `node.js` core, `ursa`, `forge`, and others. | ||
This now uses node-native RSA key generation and lightweight, zero-dependency solutions for key conversion. | ||
However, it also optionally depends on `ursa` and `forge` for backwards compatibility with older node versions. | ||
This is useful for **certbot** and **letsencrypt**. | ||
This was built for the [ACME.js](https://git.coolaj86.com/coolaj86/acme.js) and | ||
[Greenlock.js](https://git.coolaj86.com/coolaj86/greenlock.js) **Let's Encrypt** clients | ||
and is particularly suitable for building **certbot**-like clients. | ||
(in the future we'd like to provide the same API to the browser) | ||
(if you're looking for similar tools in the browser, consider [Bluecrypt](https://www.npmjs.com/search?q=bluecrypt)) | ||
Install | ||
======= | ||
# Install | ||
@@ -27,15 +28,2 @@ node.js | ||
For **more efficient** RSA key generation: | ||
<small>(I dropped `ursa` as an "optional dependency" because the non-fatal error messages on unsupported platforms and node versions were confusing people, but I still recommend installing it)</small> | ||
```bash | ||
npm install --save ursa | ||
``` | ||
**Node < v6** support: | ||
```bash | ||
npm install --save buffer-v6-polyfill | ||
``` | ||
### CLI | ||
@@ -47,4 +35,3 @@ | ||
Usage | ||
===== | ||
# Usage | ||
@@ -111,24 +98,4 @@ CLI | ||
Security and Compatibility | ||
------ | ||
# API Summary | ||
**TL;DR**: Use the default values 2048 and 65537 unless you have a really, really good reason to do otherwise. | ||
Various platforms *require* these values. | ||
Most security experts agree that 4096-bit is no more "secure" than 2048-bit - | ||
a fundamental vulnerability in the RSA algorithm which causes 2048 to be broken | ||
will most likely also cause 4096 to be broken | ||
(i.e. if someone can prove mathematically prove P=NP or a way to predict prime numbers). | ||
Also, many platforms | ||
only support 2048 bit keys due to the insecurity of 1024-bit keys (which are not 1/2 secure | ||
but rather 1/(2^1028) less secure) and the excess computational | ||
cost of 4096-bit keys (it's not a 2x increase, it's more like a 2^2048 increase). | ||
As to why 65537 is even optional as a prime exponent or why it matters... no idea, | ||
but it does matter. | ||
API | ||
--- | ||
* `RSA.generateKeypair(options, cb)` | ||
@@ -255,6 +222,63 @@ * (deprecated `RSA.generateKeypair(bitlen, exp, options, cb)`) | ||
ChangeLog: | ||
# Old Node Versions | ||
In recent versions of node >= v10.12 native RSA key generation is fairly quick for 2048-bit keys | ||
(though it may still be too slow for some applications with 4096-bit keys). | ||
In old versions, however, and especially on ARM and/or MIPS procesors, RSA key generation can be | ||
very, very slow. | ||
In old node versions `ursa` can provide faster key generation, but it must be compiled. | ||
`ursa` will not compile for new node versions, but they already include the same openssl bindings anyawy. | ||
```bash | ||
npm install --save ursa | ||
``` | ||
Also, if you need **Node < v6** support: | ||
```bash | ||
npm install --save buffer-v6-polyfill | ||
``` | ||
## Security and Compatibility | ||
**TL;DR**: Use the default values 2048 and 65537 unless you have a really, really good reason to do otherwise. | ||
Various platforms *require* these values. | ||
Most security experts agree that 4096-bit is no more "secure" than 2048-bit - | ||
a fundamental vulnerability in the RSA algorithm which causes 2048 to be broken | ||
will most likely also cause 4096 to be broken | ||
(i.e. if someone can prove mathematically prove P=NP or a way to predict prime numbers). | ||
Also, many platforms | ||
only support 2048 bit keys due to the insecurity of 1024-bit keys (which are not 1/2 secure | ||
but rather 1/(2^1028) less secure) and the excess computational | ||
cost of 4096-bit keys (it's not a 2x increase, it's more like a 2^2048 increase). | ||
As to why 65537 is even optional as a prime exponent or why it matters... no idea, | ||
but it does matter. | ||
# ChangeLog: | ||
* v1.9.0 | ||
* consistently handle key generation across node crypto, ursa, and forge | ||
* move all other operations to rasha.js and rsa-csr.js | ||
* v1.4.0 | ||
* remove ursa as dependency (just causes confusion), but note in docs | ||
* drop node < v6 support | ||
# Legal | ||
rsa-compat.js directly includes code from | ||
[Rasha.js](https://git.coolaj86.com/coolaj86/rasha.js) | ||
and | ||
[RSA-CSR.js](https://git.coolaj86.com/coolaj86/rsa-csr.js) | ||
(also [Root](https://therootcompany.com) projects), | ||
retrofitted for rsa-compat. | ||
[rsa-compat.js](https://git.coolaj86.com/coolaj86/rsa-compat.js) | | ||
MPL-2.0 | | ||
[Terms of Use](https://therootcompany.com/legal/#terms) | | ||
[Privacy Policy](https://therootcompany.com/legal/#privacy) |
@@ -10,14 +10,2 @@ 'use strict'; | ||
if ( | ||
keys.publicKeyJwk | ||
|| keys.privateKeyPem | ||
|| keys.publicKeyPem | ||
|| keys.thumbprint | ||
|| keys._ursa | ||
|| keys._forge | ||
) { | ||
console.error(Object.keys(keys)); | ||
throw new Error("Got unexpected keys"); | ||
} | ||
var options = { | ||
@@ -38,3 +26,2 @@ public: true // export public keys | ||
//|| !keys.thumbprint | ||
|| !(keys._ursa || keys._forge) | ||
) { | ||
@@ -41,0 +28,0 @@ console.error(Object.keys(keys)); |
@@ -10,14 +10,2 @@ 'use strict'; | ||
if ( | ||
keys.publicKeyJwk | ||
|| keys.privateKeyPem | ||
|| keys.publicKeyPem | ||
|| keys.thumbprint | ||
|| keys._ursa | ||
|| keys._forge | ||
) { | ||
console.error(Object.keys(keys)); | ||
throw new Error("Got unexpected keys"); | ||
} | ||
var options = { | ||
@@ -36,3 +24,2 @@ public: true // export public keys | ||
//|| !keys.thumbprint | ||
|| !(keys._ursa || keys._forge) | ||
) { | ||
@@ -39,0 +26,0 @@ console.error(Object.keys(keys)); |
@@ -8,10 +8,10 @@ 'use strict'; | ||
"kty": "RSA", | ||
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK/Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY+2UPUS/GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK_Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY-2UPUS_GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"e": "AQAB", | ||
"d": "HT8DCrv69G3n9uFNovE4yMEMqW7lX0m75eJkMze3Jj5xNOa/4qlrc+4IuuA2uuyfY72IVQRxqqqXOuvS8ZForZZk+kWSd6z45hrpbNAAHH2Rf7XwnwHY8VJrOQF3UtbktTWqHX36ITZb9Hmf18hWsIeEp8Ng7Ru9h7hNuVxKMjk=", | ||
"p": "AONjOvZVAvhCM2JnLGWJG3+5Boar3MB5P4ezfExDmuyGET/w0C+PS60jbjB8TivQsSdEcGo7GOaOlmAX6EQtAec=", | ||
"q": "ANrllgJsy4rTMfa3mQ50kMIcNahiEOearhAcJ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
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK/Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY+2UPUS/GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK_Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY-2UPUS_GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"e": "AQAB" | ||
@@ -40,3 +40,3 @@ } | ||
"kty": "RSA", | ||
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK/Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY+2UPUS/GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"n": "AMJubTfOtAarnJytLE8fhNsEI8wnpjRvBXGK_Kp0675J10ORzxyMLqzIZF3tcrUkKBrtdc79u4X0GocDUgukpfkY-2UPUS_GxehUYbYrJYWOLkoJWzxn7wfoo9X1JgvBMY6wHQnTKvnzZdkom2FMhGxkLaEUGDSfsNznTTZNBBg9", | ||
"e": "AQAB" | ||
@@ -43,0 +43,0 @@ } |
@@ -48,3 +48,3 @@ 'use strict'; | ||
imported = RSA.import({ privateKeyPem: privkeyPemRef }); | ||
refs.privPem2 = RSA.exportPrivatePem({ _forge: imported._forge }); | ||
refs.privPem2 = RSA.exportPrivatePem(imported); | ||
} | ||
@@ -77,3 +77,3 @@ if (privkeyPemRef !== refs.privPem2) { | ||
imported = RSA.import({ privateKeyJwk: privkeyJwkRef }); | ||
refs.privJwk2 = RSA.exportPrivateJwk({ _forge: imported._forge }); | ||
refs.privJwk2 = RSA.exportPrivateJwk(imported); | ||
console.log('JWK -> _ -> JWK ?', privkeyJwkRef.n === refs.privJwk2.n); | ||
@@ -80,0 +80,0 @@ if (privkeyJwkRef.n !== refs.privJwk2.n) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
126979
55
2059
280
1
4
4