-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto: validate RSA-PSS saltLength in subtle.sign and subtle.verify #52262
crypto: validate RSA-PSS saltLength in subtle.sign and subtle.verify #52262
Conversation
Review requested:
|
validateInt32(saltLength, 'algorithm.saltLength', -2); | ||
} | ||
|
||
async function rsaSignVerify(key, data, { saltLength }, signature) { | ||
const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify; | ||
const type = mode === kSignJobModeSign ? 'private' : 'public'; | ||
|
||
if (key.type !== type) | ||
throw lazyDOMException(`Key must be a ${type} key`, 'InvalidAccessError'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is not sync anymore. Does this make this semver-major change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not. The entire API surface of webcrypto is async functions.
case 'SHA-1': return 20; | ||
case 'SHA-256': return 32; | ||
case 'SHA-384': return 48; | ||
case 'SHA-512': return 64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a default with unreachable (like throw error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's done the same way as the method above. I don't feel it's necessary. Used hashes are verified far before this is ever invoked.
Landed in 2241e8c |
fixes: #52188 PR-URL: #52262 Fixes: #52188 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
fixes: #52188 PR-URL: #52262 Fixes: #52188 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
Resolves a TODO from @jasnell to validate RSA-PSS saltLength in SubtleCrypto.sign and SubtleCrypto.verify
fixes: #52188