Skip to content

Commit

Permalink
test: test hmac binding robustness
Browse files Browse the repository at this point in the history
The Hmac binding layer is not documented as part of the API, and is not
intended to be used, but it should be robust to misuse, and contains
defensive checks for misuse. This test checks that updates without init
throw (as opposed to abort or misbehave in some other way).

PR-URL: #10923
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
sam-github authored and italoacasas committed Jan 30, 2017
1 parent c4b9f0a commit fb35ca3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/parallel/test-crypto-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ if (!common.hasCrypto) {
}
var crypto = require('crypto');

// Test for binding layer robustness
{
const binding = process.binding('crypto');
const h = new binding.Hmac();
// Fail to init the Hmac with an algorithm.
assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/);
}

// Test HMAC
var h1 = crypto.createHmac('sha1', 'Node')
.update('some data')
Expand Down

0 comments on commit fb35ca3

Please sign in to comment.