Skip to content

Commit bbb7d27

Browse files
committed
fixup! lib: refactor internal webidl converters
1 parent 996606f commit bbb7d27

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/internal/crypto/webidl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ converters.Argon2Params = createDictionaryConverter(
594594
validator: (V, dict) => {
595595
if (V === 0 || V > MathPow(2, 24) - 1) {
596596
throw lazyDOMException(
597-
'parallelism must be > 0 and < 16777215',
597+
'parallelism must be > 0 and <= 16777215',
598598
'OperationError');
599599
}
600600
},

test/parallel/test-webcrypto-webidl.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,25 @@ function assertJsonWebKey(actual, expected) {
585585
assertIdlDictionary(converters.ContextParams({ ...good, filtered: 'out' }, opts), good);
586586
}
587587
}
588+
589+
// Argon2Params
590+
{
591+
const maxParallelism = 2 ** 24 - 1;
592+
const good = {
593+
name: 'Argon2id',
594+
nonce: Buffer.alloc(8),
595+
parallelism: maxParallelism,
596+
memory: 8 * maxParallelism,
597+
passes: 1,
598+
};
599+
assertIdlDictionary(converters.Argon2Params({ ...good, filtered: 'out' }, opts), good);
600+
601+
assert.throws(() => converters.Argon2Params({
602+
...good,
603+
parallelism: maxParallelism + 1,
604+
memory: 8 * (maxParallelism + 1),
605+
}, opts), {
606+
name: 'OperationError',
607+
message: 'parallelism must be > 0 and <= 16777215',
608+
});
609+
}

0 commit comments

Comments
 (0)