]>
Commit | Line | Data |
---|---|---|
fc5ea90f A |
1 | .\" $OpenBSD: timingsafe_bcmp.3,v 1.2 2014/06/21 20:22:15 tedu Exp $ |
2 | .\" | |
3 | .\" Copyright (c) 2014 Google Inc. | |
4 | .\" | |
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. | |
8 | .\" | |
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. | |
16 | .\" | |
17 | .\" $FreeBSD$ | |
18 | .Dd August 15, 2016 | |
19 | .Dt TIMINGSAFE_BCMP 3 | |
20 | .Os | |
21 | .Sh NAME | |
22 | .Nm timingsafe_bcmp | |
23 | .Nd timing-safe byte sequence comparisons | |
24 | .Sh SYNOPSIS | |
25 | .In string.h | |
26 | .Ft int | |
27 | .Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len" | |
28 | .Sh DESCRIPTION | |
29 | The | |
30 | .Fn timingsafe_bcmp | |
31 | function compares the first | |
32 | .Fa len | |
33 | bytes pointed to by | |
34 | .Fa b1 | |
35 | and | |
36 | .Fa b2 . | |
37 | .Pp | |
38 | Additionally, the running time is independent of the byte sequences compared, | |
39 | making it safe to use for comparing secret values such as cryptographic MACs. | |
40 | In contrast, | |
41 | .Xr bcmp 3 | |
42 | and | |
43 | .Xr memcmp 3 | |
44 | may short-circuit after finding the first differing byte. | |
45 | .Sh RETURN VALUES | |
46 | The | |
47 | .Fn timingsafe_bcmp | |
48 | function returns 0 or not zero if the byte sequence pointed to by | |
49 | .Fa b1 | |
50 | compares equal to or not equal to (respectively) | |
51 | the byte sequence pointed to by | |
52 | .Fa b2 . | |
53 | .Sh SEE ALSO | |
54 | .Xr bcmp 3 | |
55 | .Sh STANDARDS | |
56 | The | |
57 | .Fn timingsafe_bcmp | |
58 | function is a non-standard extension. | |
59 | .Sh HISTORY | |
60 | The | |
61 | .Fn timingsafe_bcmp | |
62 | function first appeared in | |
63 | .Ox 4.9 , | |
64 | .Fx 12.0 , | |
65 | and macOS 10.12.1. |