Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (p === false)
return false;
var q = readString(info.hostkey, info.hostkey._pos, self, callback);
if (q === false)
return false;
var g = readString(info.hostkey, info.hostkey._pos, self, callback);
if (g === false)
return false;
var y = readString(info.hostkey, info.hostkey._pos, self, callback);
if (y === false)
return false;
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1');
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
if (rawsig.length <= 40) {
// change bare signature r and s values to ASN.1 DER values for OpenSSL
var asnSigWriter = new Ber.Writer();
asnSigWriter.startSequence();
asnSigWriter.writeBuffer(rawsig.slice(0, 20), Ber.Integer);
asnSigWriter.writeBuffer(rawsig.slice(20), Ber.Integer);
function genOpenSSLDSAPub(p, q, g, y) {
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa
// algorithm parameters
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
return makePEM('PUBLIC', asnWriter.buffer);
}
asnWriter.writeByte(0x00);
asnWriter.startSequence();
asnWriter.writeBuffer(n, Ber.Integer);
asnWriter.writeBuffer(e, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
} else {
var p = Parser.readString(info.hostkey, info.hostkey._pos),
q = Parser.readString(info.hostkey, info.hostkey._pos),
g = Parser.readString(info.hostkey, info.hostkey._pos),
y = Parser.readString(info.hostkey, info.hostkey._pos);
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1');
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
if (rawsig.length <= 40) {
// change bare signature r and s values to ASN.1 DER values for OpenSSL
var asnSigWriter = new Ber.Writer();
asnSigWriter.startSequence();
asnSigWriter.writeBuffer(rawsig.slice(0, 20), Ber.Integer);
asnSigWriter.writeBuffer(rawsig.slice(20), Ber.Integer);
return false;
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.113549.1.1.1'); // rsaEncryption
// algorithm parameters (RSA has none)
asnWriter.writeNull();
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.startSequence();
asnWriter.writeBuffer(n, Ber.Integer);
asnWriter.writeBuffer(e, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
asnWriter.endSequence();
return asnWriter.buffer;
}
var q = readString(info.hostkey, info.hostkey._pos, self, callback);
if (q === false)
return false;
var g = readString(info.hostkey, info.hostkey._pos, self, callback);
if (g === false)
return false;
var y = readString(info.hostkey, info.hostkey._pos, self, callback);
if (y === false)
return false;
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1');
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
if (rawsig.length <= 40) {
// change bare signature r and s values to ASN.1 DER values for OpenSSL
var asnSigWriter = new Ber.Writer();
asnSigWriter.startSequence();
asnSigWriter.writeBuffer(rawsig.slice(0, 20), Ber.Integer);
asnSigWriter.writeBuffer(rawsig.slice(20), Ber.Integer);
asnSigWriter.endSequence();
rawsig = asnSigWriter.buffer;
var g = readString(key, key._pos, self, callback);
if (g === false)
return false;
var y = readString(key, key._pos, self, callback);
if (y === false)
return false;
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
// algorithm
asnWriter.startSequence();
asnWriter.writeOID('1.2.840.10040.4.1'); // id-dsa
// algorithm parameters
asnWriter.startSequence();
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
// subjectPublicKey
asnWriter.startSequence(Ber.BitString);
asnWriter.writeByte(0x00);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.endSequence();
asnWriter.endSequence();
return asnWriter.buffer;
}
function genOpenSSLDSAPriv(p, q, g, y, x) {
var asnWriter = new Ber.Writer();
asnWriter.startSequence();
asnWriter.writeInt(0x00, Ber.Integer);
asnWriter.writeBuffer(p, Ber.Integer);
asnWriter.writeBuffer(q, Ber.Integer);
asnWriter.writeBuffer(g, Ber.Integer);
asnWriter.writeBuffer(y, Ber.Integer);
asnWriter.writeBuffer(x, Ber.Integer);
asnWriter.endSequence();
return makePEM('DSA PRIVATE', asnWriter.buffer);
}
}
if (typeof (v) !== 'number' || v % 1 !== 0)
throw new TypeError('value is of incompatible type');
if (v < MIN_INT32 || v > MAX_INT32) {
throw new RangeError('value ' + v +
' out of range for ' + self._typename);
}
self._value = v >> 0;
});
if (value !== undefined)
this.value = value;
}
util.inherits(SnmpInteger, SnmpData);
SnmpInteger.prototype._tag = ASN1.Integer;
SnmpInteger.prototype._typename = 'Integer';
SnmpInteger.prototype.encode = function _integer_encode(writer) {
writer.writeInt(this._value, this._tag);
};
function
SnmpOctetString(value)
{
var self = this;
SnmpData.call(this);
this.__defineSetter__('value', function (v) {
if (typeof (v) === 'object' && (v instanceof ASN1.Reader)) {
var b;
asnWriter.endSequence();
return asnWriter.buffer;
case 'ecdsa-sha2-nistp256':
case 'ecdsa-sha2-nistp384':
case 'ecdsa-sha2-nistp521':
var r = readString(sig, 0, self, callback);
if (r === false)
return false;
var s = readString(sig, sig._pos, self, callback);
if (s === false)
return false;
asnWriter = new Ber.Writer();
asnWriter.startSequence();
asnWriter.writeBuffer(r, Ber.Integer);
asnWriter.writeBuffer(s, Ber.Integer);
asnWriter.endSequence();
return asnWriter.buffer;
default:
return sig;
}
}
asnWriter.writeBuffer(s, Ber.Integer);
asnWriter.endSequence();
return asnWriter.buffer;
case 'ecdsa-sha2-nistp256':
case 'ecdsa-sha2-nistp384':
case 'ecdsa-sha2-nistp521':
var r = readString(sig, 0, self, callback);
if (r === false)
return false;
var s = readString(sig, sig._pos, self, callback);
if (s === false)
return false;
asnWriter = new Ber.Writer();
asnWriter.startSequence();
asnWriter.writeBuffer(r, Ber.Integer);
asnWriter.writeBuffer(s, Ber.Integer);
asnWriter.endSequence();
return asnWriter.buffer;
default:
return sig;
}
}