ECSignature: avoid multiple push/unshift operations

This commit is contained in:
Daniel Cousens 2014-07-10 14:22:07 +10:00
parent dcc9ddff08
commit 656de37fc0

View file

@ -98,16 +98,17 @@ ECSignature.prototype.toDER = function() {
var sBa = this.s.toDERInteger() var sBa = this.s.toDERInteger()
var sequence = [] var sequence = []
sequence.push(0x02) // INTEGER
sequence.push(rBa.length) // INTEGER
sequence.push(0x02, rBa.length)
sequence = sequence.concat(rBa) sequence = sequence.concat(rBa)
sequence.push(0x02) // INTEGER // INTEGER
sequence.push(sBa.length) sequence.push(0x02, sBa.length)
sequence = sequence.concat(sBa) sequence = sequence.concat(sBa)
sequence.unshift(sequence.length) // SEQUENCE
sequence.unshift(0x30) // SEQUENCE sequence.unshift(0x30, sequence.length)
return new Buffer(sequence) return new Buffer(sequence)
} }