1 .\" $OpenBSD: timingsafe_bcmp.3,v 1.2 2014/06/21 20:22:15 tedu Exp $
3 .\" Copyright (c) 2014 Google Inc.
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 .Nd timing-safe byte sequence comparisons
28 .Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len"
30 .Fn timingsafe_memcmp "const void *b1" "const void *b2" "size_t len"
36 functions lexicographically compare the first
38 bytes (each interpreted as an
45 Additionally, their running times are independent of the byte sequences compared,
46 making them safe to use for comparing secret values such as cryptographic MACs.
51 may short-circuit after finding the first differing byte.
55 function returns 0 or not zero if the byte sequence pointed to by
57 compares equal to or not equal to (respectively)
58 the byte sequence pointed to by
63 function returns a negative value, 0, or positive value if the byte sequence
66 compares less than, equal to, or greater than (respectively)
67 the byte sequence pointed to by
83 function first appeared in
88 function first appeared in
91 Both functions first appeared in