Skip to content

Commit

Permalink
#35 #32 broke node <5.x by using Buffer.from
Browse files Browse the repository at this point in the history
Reviewed by: Tim Kordas <tim.kordas@joyent.com>
  • Loading branch information
Alex Wilson committed Aug 19, 2017
1 parent 0d6852f commit 760b71c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/formats/dnssec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function readRFC3110(keyString) {
if (!supportedAlgosById[algorithm])
throw (new Error('Unsupported algorithm: ' + algorithm));
var base64key = elems.slice(6, elems.length).join();
var keyBuffer = Buffer.from(base64key, 'base64');
var keyBuffer = new Buffer(base64key, 'base64');
if (supportedAlgosById[algorithm].match(/^RSA-/)) {
// join the rest of the body into a single base64-blob
var publicExponentLen = keyBuffer.readUInt8(0);
Expand Down Expand Up @@ -101,7 +101,7 @@ function readRFC3110(keyString) {
curve: curve,
size: size,
parts: [
{name: 'curve', data: Buffer.from(curve) },
{name: 'curve', data: new Buffer(curve) },
{name: 'Q', data: utils.ecNormalize(keyBuffer) }
]
};
Expand All @@ -112,7 +112,7 @@ function readRFC3110(keyString) {
}

function elementToBuf(e) {
return (Buffer.from(e.split(' ')[1], 'base64'));
return (new Buffer(e.split(' ')[1], 'base64'));
}

function readDNSSECRSAPrivateKey(elements) {
Expand Down Expand Up @@ -161,7 +161,7 @@ function readDNSSECPrivateKey(alg, elements) {
}
if (supportedAlgosById[alg] === 'ECDSA-P384-SHA384' ||
supportedAlgosById[alg] === 'ECDSA-P256-SHA256') {
var d = Buffer.from(elements[0].split(' ')[1], 'base64');
var d = new Buffer(elements[0].split(' ')[1], 'base64');
var curve = 'nistp384';
var size = 384;
if (supportedAlgosById[alg] === 'ECDSA-P256-SHA256') {
Expand All @@ -176,7 +176,7 @@ function readDNSSECPrivateKey(alg, elements) {
curve: curve,
size: size,
parts: [
{name: 'curve', data: Buffer.from(curve) },
{name: 'curve', data: new Buffer(curve) },
{name: 'd', data: d },
{name: 'Q', data: Q }
]
Expand Down Expand Up @@ -237,7 +237,7 @@ function writeRSA(key, options) {
out += 'Created: ' + dnssecTimestamp(timestamp) + '\n';
out += 'Publish: ' + dnssecTimestamp(timestamp) + '\n';
out += 'Activate: ' + dnssecTimestamp(timestamp) + '\n';
return (Buffer.from(out, 'ascii'));
return (new Buffer(out, 'ascii'));
}

function writeECDSA(key, options) {
Expand All @@ -260,7 +260,7 @@ function writeECDSA(key, options) {
out += 'Publish: ' + dnssecTimestamp(timestamp) + '\n';
out += 'Activate: ' + dnssecTimestamp(timestamp) + '\n';

return (Buffer.from(out, 'ascii'));
return (new Buffer(out, 'ascii'));
}

function write(key, options) {
Expand Down

0 comments on commit 760b71c

Please sign in to comment.