Shanks0224 opened a new pull request, #22239: URL: https://github.com/apache/nuttx/pull/22239
timingsafe_bcmp() only tells whether two buffers are equal. Code that compares MACs, tags, hashes or nonces without revealing where the buffers first differ may also need to know which one is greater, so add the ordering form next to timingsafe_bcmp(). The difference of two bytes is tested on the bit just above the value range of unsigned char, so unlike the OpenBSD original no negative value is shifted right. The function is also added to libc.csv. *Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Add `timingsafe_memcmp()`, the ordering form of `timingsafe_bcmp()`, for code that compares MACs, tags or hashes without revealing where the buffers differ. It is also added to libc.csv. Split from #22177. ## Impact New function only. No impact on the build system, documentation or hardware. ## Testing Build host: Linux x86_64. - `sim:nsh` builds with no warning. - 20000 random pairs of 64-byte buffers (with and without a difference): the sign of `timingsafe_memcmp()` matches `memcmp()` in every case. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
