Skip to content

Commit 824ca8c

Browse files
♻️ Fix WebAuthn SHA256 returndatasize check (#1224)
Co-authored-by: rholterhus <rileyholterhus@gmail.com>
1 parent 4fb8763 commit 824ca8c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/utils/WebAuthn.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ library WebAuthn {
132132
// 19. Compute `sha256(clientDataJSON)`.
133133
// 20. Compute `sha256(authenticatorData ‖ sha256(clientDataJSON))`.
134134
// forgefmt: disable-next-item
135-
messageHash := mload(staticcall(gas(), 2, p, add(l, 0x20),
136-
staticcall(gas(), 2, o, n, e, 0x20), 0x20))
135+
messageHash := mload(staticcall(gas(),
136+
shl(1, staticcall(gas(), 2, o, n, e, 0x20)), p, add(l, 0x20), 0x01, 0x20))
137137
mstore(e, w) // Restore the word after `authenticatorData`, in case of reuse.
138138
// `returndatasize()` is `0x20` on `sha256` success, and `0x00` otherwise.
139139
if iszero(returndatasize()) { invalid() }

src/utils/g/WebAuthn.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ library WebAuthn {
136136
// 19. Compute `sha256(clientDataJSON)`.
137137
// 20. Compute `sha256(authenticatorData ‖ sha256(clientDataJSON))`.
138138
// forgefmt: disable-next-item
139-
messageHash := mload(staticcall(gas(), 2, p, add(l, 0x20),
140-
staticcall(gas(), 2, o, n, e, 0x20), 0x20))
139+
messageHash := mload(staticcall(gas(),
140+
shl(1, staticcall(gas(), 2, o, n, e, 0x20)), p, add(l, 0x20), 0x01, 0x20))
141141
mstore(e, w) // Restore the word after `authenticatorData`, in case of reuse.
142142
// `returndatasize()` is `0x20` on `sha256` success, and `0x00` otherwise.
143143
if iszero(returndatasize()) { invalid() }

0 commit comments

Comments
 (0)