Socket
Socket
Sign inDemoInstall

sshpk

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sshpk - npm Package Compare versions

Comparing version 1.4.7 to 1.5.0

lib/ed-compat.js

6

lib/algs.js

@@ -17,4 +17,4 @@ // Copyright 2015 Joyent, Inc.

'ed25519': {
parts: ['Q'],
sizePart: 'Q'
parts: ['R'],
sizePart: 'R'
}

@@ -34,3 +34,3 @@ };

'ed25519': {
parts: ['Q', 'd']
parts: ['R', 'r']
}

@@ -37,0 +37,0 @@ };

@@ -13,2 +13,3 @@ // Copyright 2015 Joyent, Inc.

var PrivateKey = require('./private-key');
var edCompat = require('./ed-compat');

@@ -126,2 +127,4 @@ var InvalidAlgorithmError = errs.InvalidAlgorithmError;

hashAlgo = 'sha256';
if (this.type === 'ed25519')
hashAlgo = 'sha512';
if (this.type === 'ecdsa') {

@@ -142,2 +145,7 @@ if (this.size <= 256)

assert.string(hashAlgo, 'hash algorithm');
/* ED25519 is not supported by OpenSSL, use a javascript impl. */
if (this.type === 'ed25519')
return (new edCompat.Verifier(this, hashAlgo));
var v, nm, err;

@@ -144,0 +152,0 @@ try {

@@ -12,2 +12,3 @@ // Copyright 2015 Joyent, Inc.

var util = require('util');
var edCompat = require('./ed-compat');

@@ -81,2 +82,7 @@ var Key = require('./key');

assert.string(hashAlgo, 'hash algorithm');
/* ED25519 is not supported by OpenSSL, use a javascript impl. */
if (this.type === 'ed25519')
return (new edCompat.Signer(this, hashAlgo));
var v, nm, err;

@@ -83,0 +89,0 @@ try {

@@ -42,5 +42,6 @@ // Copyright 2015 Joyent, Inc.

case 'rsa':
case 'ed25519':
if (format === 'ssh') {
buf = new SSHBuffer({});
buf.writeString('ssh-rsa');
buf.writeString('ssh-' + this.type);
buf.writePart(this.part.sig);

@@ -120,3 +121,7 @@ return (buf.toBuffer());

case 'rsa':
return (parseRSA(data, type, format, opts));
return (parseOneNum(data, type, format, opts,
'ssh-rsa'));
case 'ed25519':
return (parseOneNum(data, type, format, opts,
'ssh-ed25519'));

@@ -143,3 +148,3 @@ case 'dsa':

function parseRSA(data, type, format, opts) {
function parseOneNum(data, type, format, opts, headType) {
if (format === 'ssh') {

@@ -152,3 +157,3 @@ try {

}
if (head === 'ssh-rsa') {
if (head === headType) {
var sig = buf.readPart();

@@ -155,0 +160,0 @@ assert.ok(buf.atEnd(), 'extra trailing bytes');

@@ -99,6 +99,3 @@ // Copyright 2015 Joyent, Inc.

function bigintToMpBuf(bigint) {
var hex = bigint.toString(16);
if (hex.length % 2 == 1)
hex = '0' + hex;
var buf = new Buffer(hex, 'hex');
var buf = new Buffer(bigint.toByteArray());
buf = mpNormalize(buf);

@@ -113,26 +110,13 @@ return (buf);

try {
var bigInt = require('big-integer');
var bigInt = require('jsbn');
} catch (e) {
throw (new Error('To load a PKCS#8 format DSA private key, ' +
'the node big-integer library is required.'));
'the node jsbn library is required.'));
}
g = bigInt(g.toString('hex'), 16);
p = bigInt(p.toString('hex'), 16);
x = bigInt(x.toString('hex'), 16);
var y = modexp(g, x, p);
g = new bigInt(g);
p = new bigInt(p);
x = new bigInt(x);
var y = g.modPow(x, p);
var ybuf = bigintToMpBuf(y);
return (ybuf);
/* Bruce Schneier's modular exponentiation algorithm */
function modexp(base, exp, mod) {
var res = bigInt(1);
base = base.mod(mod);
while (exp.gt(0)) {
if (exp.isOdd())
res = res.times(base).mod(mod);
exp = exp.shiftRight(1);
base = base.square().mod(mod);
}
return (res);
}
}

@@ -144,14 +128,14 @@

try {
var bigInt = require('big-integer');
var bigInt = require('jsbn');
} catch (e) {
throw (new Error('To write a PEM private key from ' +
'this source, the node big-integer lib is required.'));
'this source, the node jsbn lib is required.'));
}
var d = bigInt(key.part.d.data.toString('hex'), 16);
var d = new bigInt(key.part.d.data);
var buf;
if (!key.part.dmodp) {
var p = bigInt(key.part.p.data.toString('hex'), 16);
var dmodp = d.mod(p.minus(1));
var p = new bigInt(key.part.p.data);
var dmodp = d.mod(p.subtract(1));

@@ -163,4 +147,4 @@ buf = bigintToMpBuf(dmodp);

if (!key.part.dmodq) {
var q = bigInt(key.part.q.data.toString('hex'), 16);
var dmodq = d.mod(q.minus(1));
var q = new bigInt(key.part.q.data);
var dmodq = d.mod(q.subtract(1));

@@ -167,0 +151,0 @@ buf = bigintToMpBuf(dmodq);

{
"name": "sshpk",
"version": "1.4.7",
"version": "1.5.0",
"description": "A library for finding and using SSH public keys",

@@ -33,3 +33,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=0.8.0"
"node": ">=0.10.0"
},

@@ -47,3 +47,4 @@ "directories": {

"optionalDependencies": {
"big-integer": ">=1.6.0 <2.0.0"
"jsbn": ">=0.0.0 <1.0.0",
"jodid25519": ">=1.0.0 <2.0.0"
},

@@ -50,0 +51,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc