Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Chan Ngo <chan.ngo2203@gmail.com>
Cc: "Milan Stanojević" <milanst@gmail.com>,
	"Anton Bachin" <antronbachin@gmail.com>,
	"Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Constant-time function
Date: Mon, 22 Feb 2016 22:25:59 +0100	[thread overview]
Message-ID: <1456176359.12030.22.camel@e130.lan.sumadev.de> (raw)
In-Reply-To: <E778B379-DE81-4812-936B-668E40BC50EF@gmail.com>

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

Am Montag, den 22.02.2016, 15:16 -0500 schrieb Chan Ngo:
> 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.

You can define an operator that behaves like this:

let ( &&& ) p q = p && q

There might be other functions whose run time varies with the input.
E.g. (string) equality comes to my mind.

Gerd

> 
> 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)
> > 
> > 
> > 
> 
> 

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

      parent reply	other threads:[~2016-02-22 21:26 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ć
2016-02-22 21:25             ` Gerd Stolpmann [this message]

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=1456176359.12030.22.camel@e130.lan.sumadev.de \
    --to=info@gerd-stolpmann.de \
    --cc=antronbachin@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=chan.ngo2203@gmail.com \
    --cc=milanst@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