References: <68d50540-ec71-5564-99a7-7bb24ae05d17@...1856...> <1480371252-3880-1-git-send-email-steffan@...1856...> <331bcfe6-0373-1542-cdfc-50f360b7ceaa@...1435...> <2ebb29c2-6cbf-e770-2f31-5e08fa2f0e9f@...1227...> <20161129101812.GE1013@...1296...> From: Arne Schwabe Message-ID: <769188a1-74c7-a6f9-443c-6bfd8103921c@...1227...> Date: Tue, 29 Nov 2016 11:28:57 +0100 MIME-Version: 1.0 In-Reply-To: <20161129101812.GE1013@...1296...> Content-Type: multipart/alternative; boundary="------------D8F8A83E56D1B0D4B3CF5F7F" Subject: Re: [Openvpn-devel] [PATCH v2] Introduce and use secure_memzero() to erase secrets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gert Doering Cc: openvpn-devel@lists.sourceforge.net This is a multi-part message in MIME format. --------------D8F8A83E56D1B0D4B3CF5F7F Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Am 29.11.16 um 11:18 schrieb Gert Doering: > Hi, > > On Tue, Nov 29, 2016 at 11:07:12AM +0100, Arne Schwabe wrote: >> I think we should prefer memset_s if available since it is a C11 standard. > Since we're currently compiling against C99, we can't rely on it being > there (in my OS Zoo, only MacOS seems to have it, at least "have a manpage > for it" - not even FreeBSD 11 or "gentoo current") - but then, configure > could check that for us... I wouldn't add a configure test for that. According to http://en.cppreference.com/w/c/string/byte/memset: As all bounds-checked functions, |memset_s| is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including |string.h|. so preprocessor magic can check that. > > Shall we merge the current patch anyway, as the memory barrier does the > job on all current compilers, and add a memset_s() variant "whenever > one of us finds time to add and test this"? > Yes. Go ahead. I might --------------D8F8A83E56D1B0D4B3CF5F7F Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: quoted-printable



Am 29.11.16 um 11:18 schrieb Gert Doering:
Hi,

On Tue, Nov 29, 2016 at 11:07:12AM +0100, Arne Schwabe wrote:
I think we should prefer memset_s if available since=
 it is a C11 standard.
Since we're currently compiling against C99, we can't rely on it being
there (in my OS Zoo, only MacOS seems to have it, at least "have a manpage
for it" - not even FreeBSD 11 or "gentoo current") - but then, configure=20
could check that for us...
I wouldn't add a configure test for that. According to http://en.cppreference.com/w/c/string/byte/memset:

As all bounds-checked functions,=A0memset_s=A0is only guaranteed to be available if=A0__STDC_LIB_EXT1__=A0is defined by the implementation and if the user defines=A0__STDC_WANT_LIB_EXT1__=A0to the integer constant=A01=A0before including=A0string.h.

so preprocessor magic can check that.

Shall we merge the current patch anyway, as the memory barrier does the
job on all current compilers, and add a memset_s() variant "whenever=20
one of us finds time to add and test this"?

Yes. Go ahead. I might
--------------D8F8A83E56D1B0D4B3CF5F7F--