Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Publish explicit_memset and consttime_memequal in userland l...
details: https://anonhg.NetBSD.org/src/rev/372cf2779575
branches: trunk
changeset: 789629:372cf2779575
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Aug 28 17:47:07 2013 +0000
description:
Publish explicit_memset and consttime_memequal in userland libc.
Remove the double-underscore from the userland versions, and do the
weak alias dance instead, now that these are public parts of libc.
As discussed on tech-userlevel:
https://mail-index.netbsd.org/tech-userlevel/2013/06/24/msg007843.html
(option 3)
diffstat:
common/lib/libc/string/consttime_memequal.c | 7 +++++--
common/lib/libc/string/explicit_memset.c | 7 +++++--
crypto/external/bsd/libsaslc/dist/src/dict.c | 6 +++---
crypto/external/bsd/openssh/dist/dns.c | 6 +++---
include/string.h | 6 +++---
lib/libc/include/namespace.h | 4 +++-
lib/libcrypt/bcrypt.c | 6 +++---
lib/libcrypt/crypt-sha1.c | 6 +++---
lib/libcrypt/md5crypt.c | 6 +++---
9 files changed, 31 insertions(+), 23 deletions(-)
diffs (213 lines):
diff -r 7e0d4d142486 -r 372cf2779575 common/lib/libc/string/consttime_memequal.c
--- a/common/lib/libc/string/consttime_memequal.c Wed Aug 28 16:20:38 2013 +0000
+++ b/common/lib/libc/string/consttime_memequal.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,8 +1,11 @@
-/* $NetBSD: consttime_memequal.c,v 1.2 2013/08/28 15:24:41 riastradh Exp $ */
+/* $NetBSD: consttime_memequal.c,v 1.3 2013/08/28 17:47:07 riastradh Exp $ */
#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include "namespace.h"
#include <string.h>
-#define consttime_memequal __consttime_memequal
+#ifdef __weak_alias
+__weak_alias(consttime_memequal,_consttime_memequal)
+#endif
#else
#include <lib/libkern/libkern.h>
#endif
diff -r 7e0d4d142486 -r 372cf2779575 common/lib/libc/string/explicit_memset.c
--- a/common/lib/libc/string/explicit_memset.c Wed Aug 28 16:20:38 2013 +0000
+++ b/common/lib/libc/string/explicit_memset.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,8 +1,11 @@
-/* $NetBSD: explicit_memset.c,v 1.2 2013/08/28 15:46:23 riastradh Exp $ */
+/* $NetBSD: explicit_memset.c,v 1.3 2013/08/28 17:47:07 riastradh Exp $ */
#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include "namespace.h"
#include <string.h>
-#define explicit_memset __explicit_memset
+#ifdef __weak_alias
+__weak_alias(explicit_memset,_explicit_memset)
+#endif
#define explicit_memset_impl __explicit_memset_impl
#else
#include <lib/libkern/libkern.h>
diff -r 7e0d4d142486 -r 372cf2779575 crypto/external/bsd/libsaslc/dist/src/dict.c
--- a/crypto/external/bsd/libsaslc/dist/src/dict.c Wed Aug 28 16:20:38 2013 +0000
+++ b/crypto/external/bsd/libsaslc/dist/src/dict.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dict.c,v 1.8 2013/06/24 04:21:19 riastradh Exp $ */
+/* $NetBSD: dict.c,v 1.9 2013/08/28 17:47:07 riastradh Exp $ */
/* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -35,7 +35,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: dict.c,v 1.8 2013/06/24 04:21:19 riastradh Exp $");
+__RCSID("$NetBSD: dict.c,v 1.9 2013/08/28 17:47:07 riastradh Exp $");
#include <sys/queue.h>
@@ -136,7 +136,7 @@
free(node->key);
/* zero value, it may contain sensitive data */
- __explicit_memset(node->value, 0, node->value_len);
+ explicit_memset(node->value, 0, node->value_len);
free(node->value);
LIST_REMOVE(node, nodes);
free(node);
diff -r 7e0d4d142486 -r 372cf2779575 crypto/external/bsd/openssh/dist/dns.c
--- a/crypto/external/bsd/openssh/dist/dns.c Wed Aug 28 16:20:38 2013 +0000
+++ b/crypto/external/bsd/openssh/dist/dns.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dns.c,v 1.7 2013/08/28 15:24:41 riastradh Exp $ */
+/* $NetBSD: dns.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $ */
/* $OpenBSD: dns.c,v 1.28 2012/05/23 03:28:28 djm Exp $ */
/*
@@ -27,7 +27,7 @@
*/
#include "includes.h"
-__RCSID("$NetBSD: dns.c,v 1.7 2013/08/28 15:24:41 riastradh Exp $");
+__RCSID("$NetBSD: dns.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -278,7 +278,7 @@
if (hostkey_algorithm == dnskey_algorithm &&
hostkey_digest_type == dnskey_digest_type) {
if (hostkey_digest_len == dnskey_digest_len &&
- __consttime_memequal(hostkey_digest, dnskey_digest,
+ consttime_memequal(hostkey_digest, dnskey_digest,
hostkey_digest_len))
*flags |= DNS_VERIFY_MATCH;
}
diff -r 7e0d4d142486 -r 372cf2779575 include/string.h
--- a/include/string.h Wed Aug 28 16:20:38 2013 +0000
+++ b/include/string.h Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: string.h,v 1.47 2013/08/28 15:46:23 riastradh Exp $ */
+/* $NetBSD: string.h,v 1.48 2013/08/28 17:47:07 riastradh Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -103,8 +103,8 @@
char *stresep(char **, const char *, int);
char *strndup(const char *, size_t);
void *memrchr(const void *, int, size_t);
-void *__explicit_memset(void *, int, size_t);
-int __consttime_memequal(const void *, const void *, size_t);
+void *explicit_memset(void *, int, size_t);
+int consttime_memequal(const void *, const void *, size_t);
__END_DECLS
#endif
diff -r 7e0d4d142486 -r 372cf2779575 lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Wed Aug 28 16:20:38 2013 +0000
+++ b/lib/libc/include/namespace.h Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.168 2013/08/19 13:03:12 joerg Exp $ */
+/* $NetBSD: namespace.h,v 1.169 2013/08/28 17:47:07 riastradh Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -233,6 +233,7 @@
#define closelog _closelog
#define closelog_r _closelog_r
#define confstr _confstr
+#define consttime_memequal _consttime_memequal
#define csetexpandtc _csetexpandtc
#define ctermid _ctermid
#define ctime_r _ctime_r
@@ -272,6 +273,7 @@
#define execlp _execlp
#define execv _execv
#define execvp _execvp
+#define explicit_memset _explicit_memset
#define fdopen _fdopen
#define fgetln _fgetln
#define fgetwln _fgetwln
diff -r 7e0d4d142486 -r 372cf2779575 lib/libcrypt/bcrypt.c
--- a/lib/libcrypt/bcrypt.c Wed Aug 28 16:20:38 2013 +0000
+++ b/lib/libcrypt/bcrypt.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcrypt.c,v 1.18 2013/06/24 04:21:20 riastradh Exp $ */
+/* $NetBSD: bcrypt.c,v 1.19 2013/08/28 17:47:07 riastradh Exp $ */
/* $OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $ */
/*
@@ -46,7 +46,7 @@
*
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bcrypt.c,v 1.18 2013/06/24 04:21:20 riastradh Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.19 2013/08/28 17:47:07 riastradh Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -314,7 +314,7 @@
encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT);
encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext,
4 * BCRYPT_BLOCKS - 1);
- __explicit_memset(&state, 0, sizeof(state));
+ explicit_memset(&state, 0, sizeof(state));
return encrypted;
}
diff -r 7e0d4d142486 -r 372cf2779575 lib/libcrypt/crypt-sha1.c
--- a/lib/libcrypt/crypt-sha1.c Wed Aug 28 16:20:38 2013 +0000
+++ b/lib/libcrypt/crypt-sha1.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crypt-sha1.c,v 1.7 2013/08/10 18:42:29 dholland Exp $ */
+/* $NetBSD: crypt-sha1.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $ */
/*
* Copyright (c) 2004, Juniper Networks, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: crypt-sha1.c,v 1.7 2013/08/10 18:42:29 dholland Exp $");
+__RCSID("$NetBSD: crypt-sha1.c,v 1.8 2013/08/28 17:47:07 riastradh Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -192,7 +192,7 @@
*ep = '\0';
/* Don't leave anything around in vm they could use. */
- __explicit_memset(hmac_buf, 0, sizeof hmac_buf);
+ explicit_memset(hmac_buf, 0, sizeof hmac_buf);
return passwd;
}
diff -r 7e0d4d142486 -r 372cf2779575 lib/libcrypt/md5crypt.c
--- a/lib/libcrypt/md5crypt.c Wed Aug 28 16:20:38 2013 +0000
+++ b/lib/libcrypt/md5crypt.c Wed Aug 28 17:47:07 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md5crypt.c,v 1.13 2013/06/24 04:21:20 riastradh Exp $ */
+/* $NetBSD: md5crypt.c,v 1.14 2013/08/28 17:47:07 riastradh Exp $ */
/*
* ----------------------------------------------------------------------------
@@ -15,7 +15,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: md5crypt.c,v 1.13 2013/06/24 04:21:20 riastradh Exp $");
+__RCSID("$NetBSD: md5crypt.c,v 1.14 2013/08/28 17:47:07 riastradh Exp $");
#endif /* not lint */
#include <unistd.h>
@@ -143,6 +143,6 @@
*p = '\0';
/* Don't leave anything around in vm they could use. */
- __explicit_memset(final, 0, sizeof(final));
+ explicit_memset(final, 0, sizeof(final));
return (passwd);
}
Home |
Main Index |
Thread Index |
Old Index