Skip to content

Commit

Permalink
fixed bug with hash shorter then q
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Metcalf committed Jan 10, 2015
1 parent 18b953c commit 222dc8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions algos.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ exports.DSA = exports['DSA-SHA1'] = exports['DSA-SHA'] = {
hash: 'sha1',
id: new Buffer('', 'hex')
};
exports['DSA-SHA224'] = {
exports['DSA-SHA224'] = exports['DSA-WITH-SHA224'] = {
sign: 'dsa',
hash: 'sha224',
id: new Buffer('', 'hex')
};
exports['DSA-SHA256'] = {
exports['DSA-SHA256'] = exports['DSA-WITH-SHA256'] = {
sign: 'dsa',
hash: 'sha256',
id: new Buffer('', 'hex')
};
exports['DSA-SHA384'] = {
exports['DSA-SHA384'] = exports['DSA-WITH-SHA384'] = {
sign: 'dsa',
hash: 'sha384',
id: new Buffer('', 'hex')
};
exports['DSA-SHA512'] = {
exports['DSA-SHA512'] = exports['DSA-WITH-SHA512'] = {
sign: 'dsa',
hash: 'sha512',
id: new Buffer('', 'hex')
Expand Down
8 changes: 7 additions & 1 deletion sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ function bits2int(obits, q) {
function bits2octets (bits, q) {
bits = bits2int(bits, q);
bits = bits.mod(q);
return new Buffer(bits.toArray());
var out = new Buffer(bits.toArray());
if (out.length < q.byteLength()) {
var zeros = new Buffer(q.byteLength() - out.length);
zeros.fill(0);
out = Buffer.concat([zeros, out]);
}
return out;
}
module.exports.makeKey = makeKey;
function makeKey(q, kv, algo, crypto) {
Expand Down

0 comments on commit 222dc8e

Please sign in to comment.