Gathering detailed insights and metrics for rasha
Gathering detailed insights and metrics for rasha
Gathering detailed insights and metrics for rasha
Gathering detailed insights and metrics for rasha
@types/rasha
TypeScript definitions for rasha
test-rasha-library
A library of React components created using `create-react-app`. ## Installation Run the following command: `npm install simple-component-library`
jhipster-rasha-core
JHipster's own domain language and core objects
generator-rasha-jhipster
Spring Boot + Angular in one handy generator
npm install rasha
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
A Root Project. Built for ACME.js and Greenlock.js
| ~550 lines of code | 3kb gzipped | 10kb minified | 18kb with comments |
RSA tools. Lightweight. Zero Dependencies. Universal compatibility.
Achieves the fastest possible key generation using node's native RSA bindings to OpenSSL, then converts to JWK for ease-of-use.
Rasha.generate({ format: 'jwk' }).then(function (keypair) {
console.log(keypair.private);
console.log(keypair.public);
});
options
format
defaults to 'jwk'
'pkcs1'
(traditional)'pkcs8'
modulusLength
defaults to 2048 (must not be lower)
advanced options
These options are provided for debugging and should not be used.
publicExponent
defaults to 65537 (0x10001
)1var Rasha = require('rasha'); 2var pem = require('fs') 3 .readFileSync('./node_modles/rasha/fixtures/privkey-rsa-2048.pkcs1.pem', 'ascii'); 4 5Rasha.import({ pem: pem }).then(function (jwk) { 6 console.log(jwk); 7});
1{ 2 "kty": "RSA", 3 "n": "m2ttVBxPlWw06ZmGBWVDl...QlEz7UNNj9RGps_50-CNw", 4 "e": "AQAB", 5 "d": "Cpfo7Mm9Nu8YMC_xrZ54W...Our1IdDzJ_YfHPt9sHMQQ", 6 "p": "ynG-t9HwKCN3MWRYFdnFz...E9S4DsGcAarIuOT2TsTCE", 7 "q": "xIkAjgUzB1zaUzJtW2Zgv...38ahSrBFEVnxjpnPh1Q1c", 8 "dp": "tzDGjECFOU0ehqtuqhcu...dVGAXJoGOdv5VpaZ7B1QE", 9 "dq": "kh5dyDk7YCz7sUFbpsmu...aX9PKa12HFlny6K1daL48", 10 "qi": "AlHWbx1gp6Z9pbw_1hlS...lhmIOgRApS0t9VoXtHhFU" 11}
1var Rasha = require('rasha'); 2var jwk = require('rasha/fixtures/privkey-rsa-2048.jwk.json'); 3 4Rasha.export({ jwk: jwk }).then(function (pem) { 5 // PEM in PKCS1 (traditional) format 6 console.log(pem); 7});
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAm2ttVBxPlWw06ZmGBWVDlfjkPAJ4DgnY0TrDwtCohHzLxGhD
NzUJefLukC+xu0LBKylYojT5vTkxaOhxeSYo31syu4WhxbkTBLICOFcCGMob6pSQ
38P8LdAIlb0pqDHxEJ9adWomjuFf.....5cCBahfsiNtNR6WV1/iCSuINYs6uPdA
Jlw7hm9m8TAmFWWyfL0s7wiRvAYkQvpxetorTwHJVLabBDJ+WBOAY2enOLHIRQv+
atAvHrLXjkUdzF96o0icyF6n7QzGfUPmeWGYg6BEClLS31Whe0eEVQ==
-----END RSA PRIVATE KEY-----
format: 'pkcs8'
:
The default output format pkcs1
(RSA-specific format) is used for private keys.
Use format: 'pkcs8'
to output in PKCS#8 format instead.
1Rasha.export({ jwk: jwk, format: 'pkcs8' }).then(function (pem) { 2 // PEM in PKCS#8 format 3 console.log(pem); 4});
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCba21UHE+VbDTp
mYYFZUOV+OQ8AngOCdjROsPC0KiEfMvEaEM3NQl58u6QL7G7QsErKViiNPm9OTFo
6HF5JijfWzK7haHFuRMEsgI4VwIY.....LorV1ovjwKBgAJR1m8dYKemfaW8P9YZ
Uux7lwIFqF+yI201HpZXX+IJK4g1izq490AmXDuGb2bxMCYVZbJ8vSzvCJG8BiRC
+nF62itPAclUtpsEMn5YE4BjZ6c4schFC/5q0C8esteORR3MX3qjSJzIXqftDMZ9
Q+Z5YZiDoEQKUtLfVaF7R4RV
-----END PRIVATE KEY-----
format: 'ssh'
:
Although SSH uses PKCS#1 for private keys, it uses ts own special non-ASN1 format (affectionately known as rfc4716) for public keys. I got curious and then decided to add this format as well.
To get the same format as you
would get with ssh-keygen
, pass ssh
as the format option:
1Rasha.export({ jwk: jwk, format: 'ssh' }).then(function (pub) { 2 // Special SSH2 Public Key format (RFC 4716) 3 console.log(pub); 4});
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCba21UHE.....Q02P1Eamz/nT4I3 rsa@localhost
public: 'true'
:
If a private key is used as input, a private key will be output.
If you'd like to output a public key instead you can pass public: true
.
or format: 'spki'
.
1Rasha.export({ jwk: jwk, public: true }).then(function (pem) { 2 // PEM in SPKI/PKIX format 3 console.log(pem); 4});
-----BEGIN PUBLIC KEY-----
MIIBCgKCAQEAm2ttVBxPlWw06ZmGBWVDlfjkPAJ4DgnY0TrDwtCohHzLxGhDNzUJ
efLukC+xu0LBKylYojT5vTkxaOhx.....TmzCh2ikrwTMja7mUdBJf2bK3By5AB0
Qi49OykUCfNZeQlEz7UNNj9RGps/50+CNwIDAQAB
-----END PUBLIC KEY-----
1Rasha.thumbprint({ jwk: jwk }).then(function (thumbprint) { 2 console.log(thumbprint); 3});
All cases are tested in test.sh
.
You can compare these keys to the ones that you get from OpenSSL, OpenSSH/ssh-keygen, and WebCrypto:
1# Generate 2048-bit RSA Keypair 2openssl genrsa -out privkey-rsa-2048.pkcs1.pem 2048 3 4# Convert PKCS1 (traditional) RSA Keypair to PKCS8 format 5openssl rsa -in privkey-rsa-2048.pkcs1.pem -pubout -out pub-rsa-2048.spki.pem 6 7# Export Public-only RSA Key in PKCS1 (traditional) format 8openssl pkcs8 -topk8 -nocrypt -in privkey-rsa-2048.pkcs1.pem -out privkey-rsa-2048.pkcs8.pem 9 10# Convert PKCS1 (traditional) RSA Public Key to SPKI/PKIX format 11openssl rsa -in pub-rsa-2048.spki.pem -pubin -RSAPublicKey_out -out pub-rsa-2048.pkcs1.pem 12 13# Convert RSA public key to SSH format 14ssh-keygen -f ./pub-rsa-2048.spki.pem -i -mPKCS8 > ./pub-rsa-2048.ssh.pub
Rasha.js | MPL-2.0 | Terms of Use | Privacy Policy
No vulnerabilities found.
No security vulnerabilities found.