Skip to content

Commit

Permalink
lib: pass pers to drbg from ec.sign
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Jan 22, 2016
1 parent b465fea commit b77b7a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/elliptic/ec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
var drbg = new elliptic.hmacDRBG({
hash: this.hash,
entropy: bkey,
nonce: nonce
nonce: nonce,
pers: options.pers,
persEnc: options.persEnc
});

// Number of bytes to generate
Expand Down
7 changes: 7 additions & 0 deletions test/ecdsa-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ describe('ECDSA', function() {
assert(ecdsa.verify(msg, sign, keys), 'custom-k verify');
});

it('should have another signature with pers', function () {
var sign1 = keys.sign(msg);
var sign2 = keys.sign(msg, {pers: '1234', persEnc: 'hex'});
assert.notEqual(sign1.r.toArray().concat(sign1.s.toArray()),
sign2.r.toArray().concat(sign2.s.toArray()));
});

it('should load public key from compact hex value', function() {
var pub = keys.getPublic(true, 'hex');
var copy = ecdsa.keyFromPublic(pub, 'hex');
Expand Down

0 comments on commit b77b7a5

Please sign in to comment.