Skip to content

Commit 2efa5c1

Browse files
committed
minor code fixes
1 parent 314ad98 commit 2efa5c1

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/NodeRSA.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ module.exports = (function() {
7272
if (/^\s*-----BEGIN RSA PRIVATE KEY-----\s*([A-Za-z0-9+/=]+\s*)+-----END RSA PRIVATE KEY-----\s*$/g.test(pem)) {
7373
this.$loadFromPrivatePEM(pem, 'base64');
7474
} else if (/^\s*-----BEGIN PUBLIC KEY-----\s*([A-Za-z0-9+/=]+\s*)+-----END PUBLIC KEY-----\s*$/g.test(pem)) {
75-
this.$loadFromPublicPEM(pem, 'base64');
75+
this.$loadFromPublicPKCS8(pem, 'base64');
7676
} else
77-
throw Error('Invalid PEM format');
77+
throw Error('Invalid key format');
7878

7979
this.$recalculateCache();
8080
};
@@ -111,7 +111,7 @@ module.exports = (function() {
111111
*
112112
* @param publicPEM {string}
113113
*/
114-
NodeRSA.prototype.$loadFromPublicPEM = function(publicPEM, encoding) {
114+
NodeRSA.prototype.$loadFromPublicPKCS8 = function(publicPEM, encoding) {
115115
var pem = publicPEM
116116
.replace('-----BEGIN PUBLIC KEY-----','')
117117
.replace('-----END PUBLIC KEY-----','')

src/libs/rsa.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ var utils = require('../utils.js');
4545
var _ = require('lodash');
4646

4747
var SIGNINFOHEAD = {
48-
sha1: new Buffer('3021300906052b0e03021a05000414','hex'),
49-
sha256: new Buffer('3031300d060960864801650304020105000420','hex'),
50-
md5: new Buffer('3020300c06082a864886f70d020505000410','hex')
48+
sha1: new Buffer('3021300906052b0e03021a05000414', 'hex'),
49+
sha256: new Buffer('3031300d060960864801650304020105000420', 'hex'),
50+
md5: new Buffer('3020300c06082a864886f70d020505000410', 'hex')
5151
};
5252

5353
exports.BigInteger = BigInteger;
@@ -351,9 +351,7 @@ module.exports.Key = (function() {
351351
filled[0] = 1;
352352
filled[filled.length - 1] = 0;
353353

354-
var res = Buffer.concat([filled, data]);
355-
356-
return res;
354+
return Buffer.concat([filled, data]);
357355
};
358356

359357
/**

0 commit comments

Comments
 (0)