Skip to content

Commit fb35ca3

Browse files
sam-githubitaloacasas
authored andcommitted
test: test hmac binding robustness
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 <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c4b9f0a commit fb35ca3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/parallel/test-crypto-hmac.js

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ if (!common.hasCrypto) {
88
}
99
var crypto = require('crypto');
1010

11+
// Test for binding layer robustness
12+
{
13+
const binding = process.binding('crypto');
14+
const h = new binding.Hmac();
15+
// Fail to init the Hmac with an algorithm.
16+
assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/);
17+
}
18+
1119
// Test HMAC
1220
var h1 = crypto.createHmac('sha1', 'Node')
1321
.update('some data')

0 commit comments

Comments
 (0)