-
Notifications
You must be signed in to change notification settings - Fork 63
fix: eval in portableTimingSafeEqual #227
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
Changes from 1 commit
1859e9c
be142b9
f4a6e41
fb3de3a
97eb7fb
c430da0
42f251b
7e919b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,14 +82,19 @@ const timingSafeEqual: (a: Uint8Array, b: Uint8Array) => boolean = (function () | |
/* https://codahale.com/a-lesson-in-timing-attacks/ */ | ||
function portableTimingSafeEqual (a: Uint8Array, b: Uint8Array) { | ||
/* It is *possible* that a runtime could optimize this constant time function. | ||
* Adding `eval` should prevent the optimization, but this is no grantee. | ||
* If you copy this function for your own use, make sure to educate yourself. | ||
* Side channel attacks are pernicious and subtle. | ||
*/ | ||
eval('') // eslint-disable-line no-eval | ||
* Adding `eval` could prevent the optimization, but this is no grantee. | ||
* The eval below is commented out, | ||
seebees marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* because if a browser is using a Content Security Policy with `'unsafe-eval'` | ||
* it would fail on this eval. | ||
* The value in attempting to ensure this function is not optimized, | ||
seebees marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* is not worth the cost of making customers to alow `'unsafe-eval'`. | ||
seebees marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* If you copy this function for your own use, make sure to educate yourself. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a reference for such a person to read up on? Just saying "educate yourself" comes across as dismissive, and I know that was not your intent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good point. https://codahale.com/a-lesson-in-timing-attacks/ is linked above. Perhaps adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe "please review the above link before use"? |
||
* Side channel attacks are pernicious and subtle. | ||
*/ | ||
// eval('') // eslint-disable-line no-eval | ||
/* Check for early return (Postcondition) UNTESTED: Size is well-know information. | ||
seebees marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* and does not leak information about contents. | ||
*/ | ||
* and does not leak information about contents. | ||
*/ | ||
if (a.byteLength !== b.byteLength) return false | ||
|
||
let diff = 0 | ||
|
Uh oh!
There was an error while loading. Please reload this page.