From 656de37fc049a71fb6ff28402e51476200b6b401 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 10 Jul 2014 14:22:07 +1000 Subject: [PATCH] ECSignature: avoid multiple push/unshift operations --- src/ecsignature.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ecsignature.js b/src/ecsignature.js index cbae925..bcd59d5 100644 --- a/src/ecsignature.js +++ b/src/ecsignature.js @@ -98,16 +98,17 @@ ECSignature.prototype.toDER = function() { var sBa = this.s.toDERInteger() var sequence = [] - sequence.push(0x02) // INTEGER - sequence.push(rBa.length) + + // INTEGER + sequence.push(0x02, rBa.length) sequence = sequence.concat(rBa) - sequence.push(0x02) // INTEGER - sequence.push(sBa.length) + // INTEGER + sequence.push(0x02, sBa.length) sequence = sequence.concat(sBa) - sequence.unshift(sequence.length) - sequence.unshift(0x30) // SEQUENCE + // SEQUENCE + sequence.unshift(0x30, sequence.length) return new Buffer(sequence) }