caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Milan Stanojević" <milanst@gmail.com>
To: Chan Ngo <chan.ngo2203@gmail.com>
Cc: Caml List <caml-list@inria.fr>, Anton Bachin <antronbachin@gmail.com>
Subject: Re: [Caml-list] Constant-time function
Date: Mon, 22 Feb 2016 15:28:14 -0500	[thread overview]
Message-ID: <CAKR7PS8VmmxqfX7db1y8nVZ6wtBZ1=Ck+Cxnpawbbm7i8FgfNg@mail.gmail.com> (raw)
In-Reply-To: <E778B379-DE81-4812-936B-668E40BC50EF@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]

Oh, that's tricky then.
I mean, it's not hard to make this particular function behave how you want,
but in general ocaml compiler might optimize some constructs such that time
behavior of your code changes slightly (and in some cases a lot). For
example allocation can increase or decrease with small changes which will
affect your program's running time.
Now, I don't know much about crypto so I don't know how much you care about
this.
On Feb 22, 2016 15:16, "Chan Ngo" <chan.ngo2203@gmail.com> wrote:

> Hi Milan,
>
> thanks, I see what you mentioned with the “&&” operator. In fact, one case
> the behavior as I wanted is in crypto primitive (we need constant-time
> function to avoid time side-channel attack, for example, give any input for
> comparing with the secret hash value with fixed size, the time execution of
> comparing is constant.
>
> Best,
> Chan
>
> On Feb 22, 2016, at 3:12 PM, Milan Stanojević <milanst@gmail.com> wrote:
>
> Compiler short circuits && operator so your loop runs only til the first
> element that differs. If you swap the arguments to && you should get the
> behavior of visiting all elements (which is of course undesirable in
> practice)
>
>
>

[-- Attachment #2: Type: text/html, Size: 1937 bytes --]

  reply	other threads:[~2016-02-22 20:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22  9:48 [Caml-list] [ANN] bigstring 0.1 Simon Cruanes
2016-02-22 19:45 ` [Caml-list] Constant-time function Chan Ngo
2016-02-22 19:51   ` Anton Bachin
2016-02-22 19:54     ` Anton Bachin
2016-02-22 19:57     ` Chan Ngo
2016-02-22 20:02       ` Anton Bachin
2016-02-22 20:12         ` Milan Stanojević
2016-02-22 20:16           ` Chan Ngo
2016-02-22 20:28             ` Milan Stanojević [this message]
2016-02-22 21:25             ` Gerd Stolpmann

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='CAKR7PS8VmmxqfX7db1y8nVZ6wtBZ1=Ck+Cxnpawbbm7i8FgfNg@mail.gmail.com' \
    --to=milanst@gmail.com \
    --cc=antronbachin@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=chan.ngo2203@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).