summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2020-02-25 18:10:17 +0000
committerflorian <florian@openbsd.org>2020-02-25 18:10:17 +0000
commitd7fbd970f87653f4e19938d3b964ff8a5d13c00a (patch)
tree7e941f97d28322d9f992294ecc2f0832e40abfc4
parentuse freezero() rather that explicit_bzero() when free() is immediately (diff)
downloadwireguard-openbsd-d7fbd970f87653f4e19938d3b964ff8a5d13c00a.tar.xz
wireguard-openbsd-d7fbd970f87653f4e19938d3b964ff8a5d13c00a.zip
use timingsafe_bcmp and get rid of now unused safe.c
-rw-r--r--usr.bin/dig/dighost.c5
-rw-r--r--usr.bin/dig/lib/dns/dst_api.c5
-rw-r--r--usr.bin/dig/lib/dns/hmac_link.c3
-rw-r--r--usr.bin/dig/lib/isc/Makefile.inc4
-rw-r--r--usr.bin/dig/lib/isc/hmacsha.c17
-rw-r--r--usr.bin/dig/lib/isc/include/isc/safe.h35
-rw-r--r--usr.bin/dig/lib/isc/safe.c35
7 files changed, 15 insertions, 89 deletions
diff --git a/usr.bin/dig/dighost.c b/usr.bin/dig/dighost.c
index fc1902676ff..c7366abd88b 100644
--- a/usr.bin/dig/dighost.c
+++ b/usr.bin/dig/dighost.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.24 2020/02/25 17:01:56 deraadt Exp $ */
+/* $Id: dighost.c,v 1.25 2020/02/25 18:10:17 florian Exp $ */
/*! \file
* \note
@@ -58,7 +58,6 @@
#include <isc/netaddr.h>
#include <isc/parseint.h>
#include <isc/result.h>
-#include <isc/safe.h>
#include <isc/serial.h>
#include <isc/sockaddr.h>
#include <isc/task.h>
@@ -3188,7 +3187,7 @@ process_sit(dig_lookup_t *l, dns_message_t *msg,
INSIST(msg->sitok == 0 && msg->sitbad == 0);
if (optlen >= len && optlen >= 8U) {
- if (isc_safe_memequal(isc_buffer_current(optbuf), sit, 8)) {
+ if (timingsafe_bcmp(isc_buffer_current(optbuf), sit, 8) == 0) {
msg->sitok = 1;
} else {
printf(";; Warning: SIT client cookie mismatch\n");
diff --git a/usr.bin/dig/lib/dns/dst_api.c b/usr.bin/dig/lib/dns/dst_api.c
index be9154041d0..fcce2293afd 100644
--- a/usr.bin/dig/lib/dns/dst_api.c
+++ b/usr.bin/dig/lib/dns/dst_api.c
@@ -33,16 +33,15 @@
/*
* Principal Author: Brian Wellington
- * $Id: dst_api.c,v 1.14 2020/02/25 17:06:08 deraadt Exp $
+ * $Id: dst_api.c,v 1.15 2020/02/25 18:10:17 florian Exp $
*/
/*! \file */
#include <stdlib.h>
+#include <string.h>
#include <isc/buffer.h>
#include <isc/refcount.h>
-#include <isc/safe.h>
-#include <string.h>
#include <isc/util.h>
#include <dns/keyvalues.h>
diff --git a/usr.bin/dig/lib/dns/hmac_link.c b/usr.bin/dig/lib/dns/hmac_link.c
index 76ef776957a..56c886b9e2f 100644
--- a/usr.bin/dig/lib/dns/hmac_link.c
+++ b/usr.bin/dig/lib/dns/hmac_link.c
@@ -33,7 +33,7 @@
/*
* Principal Author: Brian Wellington
- * $Id: hmac_link.c,v 1.8 2020/02/25 17:06:08 deraadt Exp $
+ * $Id: hmac_link.c,v 1.9 2020/02/25 18:10:17 florian Exp $
*/
#include <string.h>
@@ -41,7 +41,6 @@
#include <isc/buffer.h>
#include <isc/hmacsha.h>
#include <isc/sha1.h>
-#include <isc/safe.h>
#include <isc/util.h>
#include <dst/result.h>
diff --git a/usr.bin/dig/lib/isc/Makefile.inc b/usr.bin/dig/lib/isc/Makefile.inc
index f2c78e7ce26..41240e1a80d 100644
--- a/usr.bin/dig/lib/isc/Makefile.inc
+++ b/usr.bin/dig/lib/isc/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.5 2020/02/24 15:09:14 jsg Exp $
+# $OpenBSD: Makefile.inc,v 1.6 2020/02/25 18:10:17 florian Exp $
.PATH: ${.CURDIR}/lib/isc
@@ -6,6 +6,6 @@ SRCS+= assertions.c base32.c base64.c netaddr.c buffer.c bufferlist.c
SRCS+= error.c event.c hash.c heap.c hex.c hmacsha.c
SRCS+= lex.c log.c regex.c sockaddr.c
SRCS+= task.c result.c parseint.c refcount.c timer.c
-SRCS+= safe.c serial.c sha1.c sha2.c symtab.c
+SRCS+= serial.c sha1.c sha2.c symtab.c
diff --git a/usr.bin/dig/lib/isc/hmacsha.c b/usr.bin/dig/lib/isc/hmacsha.c
index 2548675b7e6..0229c4d2278 100644
--- a/usr.bin/dig/lib/isc/hmacsha.c
+++ b/usr.bin/dig/lib/isc/hmacsha.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hmacsha.c,v 1.5 2020/02/25 16:54:24 deraadt Exp $ */
+/* $Id: hmacsha.c,v 1.6 2020/02/25 18:10:17 florian Exp $ */
/*
* This code implements the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384
@@ -22,12 +22,11 @@
* draft-ietf-dnsext-tsig-sha-01.txt.
*/
-#include <isc/hmacsha.h>
+#include <string.h>
-#include <isc/safe.h>
+#include <isc/hmacsha.h>
#include <isc/sha1.h>
#include <isc/sha2.h>
-#include <string.h>
#include <isc/util.h>
void
@@ -230,7 +229,7 @@ isc_hmacsha1_verify(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
isc_hmacsha1_sign(ctx, newdigest, ISC_SHA1_DIGESTLENGTH);
- return (isc_safe_memequal(digest, newdigest, len));
+ return (ISC_TF(timingsafe_bcmp(digest, newdigest, len) == 0));
}
/*
@@ -243,7 +242,7 @@ isc_hmacsha224_verify(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len)
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
isc_hmacsha224_sign(ctx, newdigest, ISC_SHA224_DIGESTLENGTH);
- return (isc_safe_memequal(digest, newdigest, len));
+ return (ISC_TF(timingsafe_bcmp(digest, newdigest, len) == 0));
}
/*
@@ -256,7 +255,7 @@ isc_hmacsha256_verify(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len)
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
isc_hmacsha256_sign(ctx, newdigest, ISC_SHA256_DIGESTLENGTH);
- return (isc_safe_memequal(digest, newdigest, len));
+ return (ISC_TF(timingsafe_bcmp(digest, newdigest, len) == 0));
}
/*
@@ -269,7 +268,7 @@ isc_hmacsha384_verify(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len)
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
isc_hmacsha384_sign(ctx, newdigest, ISC_SHA384_DIGESTLENGTH);
- return (isc_safe_memequal(digest, newdigest, len));
+ return (ISC_TF(timingsafe_bcmp(digest, newdigest, len) == 0));
}
/*
@@ -282,5 +281,5 @@ isc_hmacsha512_verify(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len)
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
isc_hmacsha512_sign(ctx, newdigest, ISC_SHA512_DIGESTLENGTH);
- return (isc_safe_memequal(digest, newdigest, len));
+ return (ISC_TF(timingsafe_bcmp(digest, newdigest, len) == 0));
}
diff --git a/usr.bin/dig/lib/isc/include/isc/safe.h b/usr.bin/dig/lib/isc/include/isc/safe.h
deleted file mode 100644
index 516036d22d3..00000000000
--- a/usr.bin/dig/lib/isc/include/isc/safe.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* $Id: safe.h,v 1.4 2020/02/25 16:54:24 deraadt Exp $ */
-
-#ifndef ISC_SAFE_H
-#define ISC_SAFE_H 1
-
-/*! \file isc/safe.h */
-
-#include <isc/types.h>
-#include <stdlib.h>
-
-isc_boolean_t
-isc_safe_memequal(const void *s1, const void *s2, size_t n);
-/*%<
- * Returns ISC_TRUE iff. two blocks of memory are equal, otherwise
- * ISC_FALSE.
- *
- */
-
-#endif /* ISC_SAFE_H */
diff --git a/usr.bin/dig/lib/isc/safe.c b/usr.bin/dig/lib/isc/safe.c
deleted file mode 100644
index 496d1fa496d..00000000000
--- a/usr.bin/dig/lib/isc/safe.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*! \file */
-
-#include <string.h>
-
-#include <isc/safe.h>
-
-isc_boolean_t
-isc_safe_memequal(const void *s1, const void *s2, size_t n) {
- uint8_t acc = 0;
-
- if (n != 0U) {
- const uint8_t *p1 = s1, *p2 = s2;
-
- do {
- acc |= *p1++ ^ *p2++;
- } while (--n != 0U);
- }
- return (ISC_TF(acc == 0));
-}