Throw OperationError if PBKDF2 iterations is zero#29
Conversation
Node.js accepts an iteration count of zero, but WebCrypto requires an OperationError.
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM FWIW. Would you say it's a good idea to make it an error in Node.js core too? I can't think of a single legitimate reason why you would want to perform zero iterations and plenty of why an input of 0 is probably an accident.
|
@bnoordhuis I think it would be a breaking change. But I tend to agree, and I considered going one step further and suggesting the change to OpenSSL. According to RFC 2898, zero is not a valid parameter, but I am not so sure about NIST SP 800-132. The latter does not seem to explicitely forbid setting iterations to zero. |
|
I just looked at OpenSSL, and the implementation in OpenSSL 1.1.1 seems to treat values <= 1 as 1. OpenSSL master, however, appears to forbid such inputs. Experimentally confirmed: Setting the iteration count to zero in Node.js results in the same output as setting it to one. I probably should have looked at the documentation first: "Any iter less than 1 is treated as a single iteration." |
RFC 2898 does not permit an iteration count of zero, and OpenSSL 1.1.1 will treat it as one iteration internally. Future OpenSSL versions will reject such inputs (already on master branch), but until that happens, Node.js should manually reject them. Refs: nodejs/webcrypto#29
RFC 2898 does not permit an iteration count of zero, and OpenSSL 1.1.1 will treat it as one iteration internally. Future OpenSSL versions will reject such inputs (already on master branch), but until that happens, Node.js should manually reject them. Refs: nodejs/webcrypto#29 PR-URL: #30578 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Node.js accepts an iteration count of zero, but WebCrypto requires an
OperationError. This fixes 468 WPTs.