Skip to content

Commit 20373fc

Browse files
committed
formats aliases
1 parent 4cc4e09 commit 20373fc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/NodeRSA.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ module.exports = (function () {
168168
throw Error("Empty key given");
169169
}
170170

171+
if (format) {
172+
format = EXPORT_FORMAT_ALIASES[format] || format;
173+
}
174+
171175
if(!formats.detectAndImport(this.keyPair, keyData, format) && format === undefined) {
172176
throw Error("Key format must be specified");
173177
}

test/tests.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ describe("NodeRSA", function(){
232232
'pkcs1-public-der': {public: true, der: true, file: 'public_pkcs1.der'},
233233
'pkcs1-public-pem': {public: true, der: false, file: 'public_pkcs1.pem'},
234234
'pkcs8-public-der': {public: true, der: true, file: 'public_pkcs8.der'},
235-
'pkcs8-public-pem': {public: true, der: false, file: 'public_pkcs8.pem'}
235+
'pkcs8-public-pem': {public: true, der: false, file: 'public_pkcs8.pem'},
236+
237+
'private': {public: false, der: false, file: 'private_pkcs1.pem'},
238+
'public': {public: true, der: false, file: 'public_pkcs8.pem'}
236239
};
237240

238241
describe("Good cases", function () {
@@ -291,7 +294,7 @@ describe("NodeRSA", function(){
291294
}
292295
});
293296

294-
it("should export to " + format + " format", function () {
297+
it("should export to \"" + format + "\" format", function () {
295298
var keyData = fs.readFileSync(keysFolder + options.file);
296299
var exported = sampleKey.exportKey(format);
297300

0 commit comments

Comments
 (0)