Compare commits
2 Commits
03f4700554
...
d3b459aaf5
Author | SHA1 | Date | |
---|---|---|---|
d3b459aaf5 | |||
57edc8641b |
@ -17,6 +17,10 @@ This project is fully functional and tested (and the code is pretty clean).
|
|||||||
|
|
||||||
It is considered to be complete, but if you find a bug please open an issue.
|
It is considered to be complete, but if you find a bug please open an issue.
|
||||||
|
|
||||||
|
## Looking for ECDSA as well?
|
||||||
|
|
||||||
|
Check out [Eckles.js](https://git.coolaj86.com/coolaj86/eckles.js)
|
||||||
|
|
||||||
## PEM-to-JWK
|
## PEM-to-JWK
|
||||||
|
|
||||||
* [x] PKCS#1 (traditional)
|
* [x] PKCS#1 (traditional)
|
||||||
|
20
lib/rasha.js
20
lib/rasha.js
@ -7,8 +7,7 @@ var x509 = require('./x509.js');
|
|||||||
var ASN1 = require('./asn1.js');
|
var ASN1 = require('./asn1.js');
|
||||||
|
|
||||||
/*global Promise*/
|
/*global Promise*/
|
||||||
RSA.parse = function parseRsa(opts) {
|
RSA.importSync = function (opts) {
|
||||||
return Promise.resolve().then(function () {
|
|
||||||
if (!opts || !opts.pem || 'string' !== typeof opts.pem) {
|
if (!opts || !opts.pem || 'string' !== typeof opts.pem) {
|
||||||
throw new Error("must pass { pem: pem } as a string");
|
throw new Error("must pass { pem: pem } as a string");
|
||||||
}
|
}
|
||||||
@ -34,6 +33,13 @@ RSA.parse = function parseRsa(opts) {
|
|||||||
jwk = RSA.nueter(jwk);
|
jwk = RSA.nueter(jwk);
|
||||||
}
|
}
|
||||||
return jwk;
|
return jwk;
|
||||||
|
};
|
||||||
|
RSA.parse = function parseRsa(opts) {
|
||||||
|
// wrapped in a promise for API compatibility
|
||||||
|
// with the forthcoming browser version
|
||||||
|
// (and potential future native node capability)
|
||||||
|
return Promise.resolve().then(function () {
|
||||||
|
return RSA.importSync(opts);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
RSA.toJwk = RSA.import = RSA.parse;
|
RSA.toJwk = RSA.import = RSA.parse;
|
||||||
@ -53,8 +59,7 @@ RSAPrivateKey ::= SEQUENCE {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RSA.pack = function (opts) {
|
RSA.exportSync = function (opts) {
|
||||||
return Promise.resolve().then(function () {
|
|
||||||
if (!opts || !opts.jwk || 'object' !== typeof opts.jwk) {
|
if (!opts || !opts.jwk || 'object' !== typeof opts.jwk) {
|
||||||
throw new Error("must pass { jwk: jwk }");
|
throw new Error("must pass { jwk: jwk }");
|
||||||
}
|
}
|
||||||
@ -104,6 +109,13 @@ RSA.pack = function (opts) {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("Sanity Error: reached unreachable code block with format: " + format);
|
throw new Error("Sanity Error: reached unreachable code block with format: " + format);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
RSA.pack = function (opts) {
|
||||||
|
// wrapped in a promise for API compatibility
|
||||||
|
// with the forthcoming browser version
|
||||||
|
// (and potential future native node capability)
|
||||||
|
return Promise.resolve().then(function () {
|
||||||
|
return RSA.exportSync(opts);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
RSA.toPem = RSA.export = RSA.pack;
|
RSA.toPem = RSA.export = RSA.pack;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rasha",
|
"name": "rasha",
|
||||||
"version": "1.0.1",
|
"version": "1.0.3",
|
||||||
"description": "💯 PEM-to-JWK and JWK-to-PEM for RSA keys in a lightweight, zero-dependency library focused on perfect universal compatibility.",
|
"description": "💯 PEM-to-JWK and JWK-to-PEM for RSA keys in a lightweight, zero-dependency library focused on perfect universal compatibility.",
|
||||||
"homepage": "https://git.coolaj86.com/coolaj86/rasha.js",
|
"homepage": "https://git.coolaj86.com/coolaj86/rasha.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user