mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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: https://github.com/nodejs/node/pull/10923 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
106d09ab7a
commit
b4b37e8dc9
1 file changed
+8
@@ -8,6 +8,14 @@ if (!common.hasCrypto) {
|
||||
}
|
||||
const 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
|
||||
const h1 = crypto.createHmac('sha1', 'Node')
|
||||
.update('some data')
|
||||
|
||||
Reference in new issue
Block a user