diff options
author | matthew <> | 2010-09-24 13:33:00 +0000 |
---|---|---|
committer | matthew <> | 2010-09-24 13:33:00 +0000 |
commit | ca3efbcfa52175f6883523a4782ce280dd592054 (patch) | |
tree | a85c16e95e9d9e32e4eb2a44cfd664f4e6320458 /src/lib/libc/string/bcmp.3 | |
parent | a94c2f0834fa88251427636d1ca7fb8d29c15712 (diff) | |
download | openbsd-ca3efbcfa52175f6883523a4782ce280dd592054.tar.gz openbsd-ca3efbcfa52175f6883523a4782ce280dd592054.tar.bz2 openbsd-ca3efbcfa52175f6883523a4782ce280dd592054.zip |
Add timingsafe_bcmp(3) to libc, mention that it's already in the
kernel in kern(9), and remove it from OpenSSH.
ok deraadt@, djm@
Diffstat (limited to 'src/lib/libc/string/bcmp.3')
-rw-r--r-- | src/lib/libc/string/bcmp.3 | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3 index 57e1a0fade..1a77750627 100644 --- a/src/lib/libc/string/bcmp.3 +++ b/src/lib/libc/string/bcmp.3 | |||
@@ -27,18 +27,21 @@ | |||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. |
29 | .\" | 29 | .\" |
30 | .\" $OpenBSD: bcmp.3,v 1.7 2007/05/31 19:19:32 jmc Exp $ | 30 | .\" $OpenBSD: bcmp.3,v 1.8 2010/09/24 13:33:00 matthew Exp $ |
31 | .\" | 31 | .\" |
32 | .Dd $Mdocdate: May 31 2007 $ | 32 | .Dd $Mdocdate: September 24 2010 $ |
33 | .Dt BCMP 3 | 33 | .Dt BCMP 3 |
34 | .Os | 34 | .Os |
35 | .Sh NAME | 35 | .Sh NAME |
36 | .Nm bcmp | 36 | .Nm bcmp , |
37 | .Nm timingsafe_bcmp | ||
37 | .Nd compare byte string | 38 | .Nd compare byte string |
38 | .Sh SYNOPSIS | 39 | .Sh SYNOPSIS |
39 | .Fd #include <string.h> | 40 | .Fd #include <string.h> |
40 | .Ft int | 41 | .Ft int |
41 | .Fn bcmp "const void *b1" "const void *b2" "size_t len" | 42 | .Fn bcmp "const void *b1" "const void *b2" "size_t len" |
43 | .Ft int | ||
44 | .Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len" | ||
42 | .Sh DESCRIPTION | 45 | .Sh DESCRIPTION |
43 | The | 46 | The |
44 | .Fn bcmp | 47 | .Fn bcmp |
@@ -53,6 +56,20 @@ bytes long. | |||
53 | Zero-length strings are always identical. | 56 | Zero-length strings are always identical. |
54 | .Pp | 57 | .Pp |
55 | The strings may overlap. | 58 | The strings may overlap. |
59 | .Pp | ||
60 | The | ||
61 | .Fn timingsafe_bcmp | ||
62 | function has the same semantics as | ||
63 | .Fn bcmp , | ||
64 | but its running time is independent of the contents of | ||
65 | .Fa b1 | ||
66 | and | ||
67 | .Fa b2 , | ||
68 | making it safe to use for comparing secret values such as cryptographic MACs. | ||
69 | In contrast, | ||
70 | .Fn bcmp | ||
71 | returns after finding the first differing byte, | ||
72 | making it vulnerable to timing attacks. | ||
56 | .Sh SEE ALSO | 73 | .Sh SEE ALSO |
57 | .Xr memcmp 3 , | 74 | .Xr memcmp 3 , |
58 | .Xr strcasecmp 3 , | 75 | .Xr strcasecmp 3 , |
@@ -64,3 +81,8 @@ A | |||
64 | .Fn bcmp | 81 | .Fn bcmp |
65 | function first appeared in | 82 | function first appeared in |
66 | .Bx 4.2 . | 83 | .Bx 4.2 . |
84 | .Pp | ||
85 | The | ||
86 | .Fn timingsafe_bcmp | ||
87 | function first appeared in | ||
88 | .Ox 4.9 . | ||