GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
TIMINGSAFE_BCMP(3) FreeBSD Library Functions Manual TIMINGSAFE_BCMP(3)

timingsafe_bcmp, timingsafe_memcmp
timing-safe byte sequence comparisons

#include <string.h>

int
timingsafe_bcmp(const void *b1, const void *b2, size_t len);

int
timingsafe_memcmp(const void *b1, const void *b2, size_t len);

The timingsafe_bcmp() and timingsafe_memcmp() functions lexicographically compare the first len bytes (each interpreted as an unsigned char) pointed to by b1 and b2.

Additionally, their running times are independent of the byte sequences compared, making them safe to use for comparing secret values such as cryptographic MACs. In contrast, bcmp(3) and memcmp(3) may short-circuit after finding the first differing byte.

The timingsafe_bcmp() function returns 0 or not zero if the byte sequence pointed to by b1 compares equal to or not equal to (respectively) the byte sequence pointed to by b2.

The timingsafe_memcmp() function returns a negative value, 0, or positive value if the byte sequence pointed to by b1 compares less than, equal to, or greater than (respectively) the byte sequence pointed to by b2.

bcmp(3), memcmp(3)

The timingsafe_bcmp() and timingsafe_memcmp() functions are FreeBSD extensions.

The timingsafe_bcmp() function first appeared in OpenBSD 4.9.

The timingsafe_memcmp() function first appeared in OpenBSD 5.6.

Both functions first appeared in FreeBSD 12.0.

August 15, 2016 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.