From: Arne Schwabe <arne@...1227...>
To: Gert Doering <gert@...1296...>, Steffan Karger <steffan@...1856...>
Cc: openvpn-devel@lists.sourceforge.net
Subject: Re: [Openvpn-devel] [PATCH v2 1/3] Use crypto library functions for const time memcmp when possible
Date: Mon, 27 Apr 2020 00:38:32 +0200 [thread overview]
Message-ID: <094fe6d0-c6f5-e8e8-56ed-b7a18567634d@...1227...> (raw)
In-Reply-To: <20200426093431.GX1431@...1296...>
[-- Attachment #1.1: Type: text/plain, Size: 1982 bytes --]
Am 26.04.20 um 11:34 schrieb Gert Doering:
> Hi,
>
> On Sun, Apr 26, 2020 at 11:25:49AM +0200, Steffan Karger wrote:
>>>> well, sometimes to adhere to the codestyle, you have to re-arrange code :)
>>>
>>> "rearrange" and "rewrite in a not easy to understand way" (which looks
>>> a bit overthought to me, TBH - unlike "secure memzero" I cannot see an
>>> obvious reason why all that volatile would be relevant).
>>
>> This secure memcmp is relevant to avoid timing side channels in e.g.
>> authentication tag compare. Think about the HMAC in our tls-auth/crypt
>> and the HMAC of (non-AEAD) data channel packets.
>
> I do understand why it has to be constant *time*, in regards to "do the
> compared buffers differ or not".
>
> I do not see how all this "volatile" and "copy from pointer to variables
> to other stuff" handwaving is going to make any difference wrt constant
> time comparison.
>
> And it hurts my eyes.
Yeah the goal is basically do what the crypto library is doing. And if
you play with godbolt. So we don't need to go down this path of having
to come up with our own version.
And if you care about speed then we should definitively go for OpenSSL's
memcmp function. Since it is implemented in assembler it does not try to
breaks the compiler compilation optimisation with volatile that might
trigger more memory loads than necessary but can be a small fast
constant time function.
If you play a bit with godbolt.org (https://godbolt.org/z/gXgcC9) you
will see that the code that is generated from our current version is not
yet optimised to non constant versions but especially the clang compiler
is getting close. It completely optimises away the function for compile
strings (main2 just becomes return 95), builds a version optimised for
one fixed string and vectorises the generic version. So I am not sure if
these variants still have their constant with modern processes and
speculative execution.
Arne
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-04-26 22:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-16 11:39 [Openvpn-devel] [PATCH v2 1/3] Use crypto library functions for const time memcmp when possible Arne Schwabe
2020-04-16 11:39 ` [Openvpn-devel] [PATCH v2 2/3] Minor style change to improve code style Arne Schwabe
2020-04-17 14:56 ` Antonio Quartulli
2020-04-19 10:32 ` [Openvpn-devel] [PATCH applied] " Gert Doering
2020-04-16 11:39 ` [Openvpn-devel] [PATCH v2 3/3] After the last big formatting patch a number of changes have been commited that do not conform with our style/uncrustify config. This has lead to the problem that running uncrustify on before sending PR some of the changes made by uncrustify need to be backed out again Arne Schwabe
2020-04-17 15:01 ` Antonio Quartulli
2020-04-19 10:27 ` Gert Doering
2020-04-19 12:22 ` Antonio Quartulli
2020-04-19 15:46 ` Gert Doering
2020-04-19 10:40 ` [Openvpn-devel] [PATCH applied] " Gert Doering
2020-04-16 14:10 ` [Openvpn-devel] [PATCH v2 1/3] Use crypto library functions for const time memcmp when possible Antonio Quartulli
2020-04-17 7:53 ` Arne Schwabe
2020-04-17 8:51 ` Gert Doering
2020-04-17 13:42 ` Antonio Quartulli
2020-04-17 15:36 ` Gert Doering
2020-04-26 9:25 ` Steffan Karger
2020-04-26 9:34 ` Gert Doering
2020-04-26 9:49 ` Steffan Karger
2020-04-26 22:38 ` Arne Schwabe [this message]
2020-05-07 13:21 ` [Openvpn-devel] [PATCH applied] " Gert Doering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=094fe6d0-c6f5-e8e8-56ed-b7a18567634d@...1227... \
--to=openvpn-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.