diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 6 | ||||
-rw-r--r-- | openbsd-compat/timingsafe_bcmp.c | 34 |
2 files changed, 39 insertions, 1 deletions
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index e15d2bd96..77c5ed2b1 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.50 2010/08/16 03:15:23 dtucker Exp $ */ | 1 | /* $Id: openbsd-compat.h,v 1.51 2010/10/07 10:25:29 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
@@ -213,6 +213,10 @@ char *user_from_uid(uid_t, int); | |||
213 | char *group_from_gid(gid_t, int); | 213 | char *group_from_gid(gid_t, int); |
214 | #endif | 214 | #endif |
215 | 215 | ||
216 | #ifndef HAVE_TIMINGSAFE_BCMP | ||
217 | int timingsafe_bcmp(const void *, const void *, size_t); | ||
218 | #endif | ||
219 | |||
216 | void *xmmap(size_t size); | 220 | void *xmmap(size_t size); |
217 | char *xcrypt(const char *password, const char *salt); | 221 | char *xcrypt(const char *password, const char *salt); |
218 | char *shadow_pw(struct passwd *pw); | 222 | char *shadow_pw(struct passwd *pw); |
diff --git a/openbsd-compat/timingsafe_bcmp.c b/openbsd-compat/timingsafe_bcmp.c new file mode 100644 index 000000000..7e28c0e2a --- /dev/null +++ b/openbsd-compat/timingsafe_bcmp.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* $OpenBSD: timingsafe_bcmp.c,v 1.1 2010/09/24 13:33:00 matthew Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2010 Damien Miller. All rights reserved. | ||
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 | |||
18 | /* OPENBSD ORIGINAL: lib/libc/string/timingsafe_bcmp.c */ | ||
19 | |||
20 | #include "includes.h" | ||
21 | #ifndef HAVE_TIMINGSAFE_BCMP | ||
22 | |||
23 | int | ||
24 | timingsafe_bcmp(const void *b1, const void *b2, size_t n) | ||
25 | { | ||
26 | const unsigned char *p1 = b1, *p2 = b2; | ||
27 | int ret = 0; | ||
28 | |||
29 | for (; n > 0; n--) | ||
30 | ret |= *p1++ ^ *p2++; | ||
31 | return (ret != 0); | ||
32 | } | ||
33 | |||
34 | #endif /* TIMINGSAFE_BCMP */ | ||