Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70844 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74823 invoked from network); 23 Dec 2013 01:26:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2013 01:26:09 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.182 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.128.182 mail-ve0-f182.google.com Received: from [209.85.128.182] ([209.85.128.182:48679] helo=mail-ve0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/00-08405-03197B25 for ; Sun, 22 Dec 2013 20:26:08 -0500 Received: by mail-ve0-f182.google.com with SMTP id jy13so2692155veb.13 for ; Sun, 22 Dec 2013 17:26:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Vm5knUhEETtHlPGryGtxavibQ34sdFpiQJKMMN9okFE=; b=eKTNm9vyZVwuGHBKCcbARJNVqbNOcDmy4ZoUOs3quMq5BXZ00eJzzok587Z1U3IGz8 zfVmeJ/WJ8i+0HQ7KgnCMUJgdoYv34mtDBJttCZQxdXZBeuXgNlTS7o+4yakP++6ynhL 8AnOX3rMByAg8LLfdW2S8VqDfs5oMduQJQJiLEBAl1QXTW6+CFRm4fVxfaGifNeOce8d RlZrH5paAEfUfbbPJbHBDIgbXKhtSGR44qJye9OLgAYOkigwNpGgIHmInrQ4AyeeRVFO O5vGJzhlg7SQigptRjoJHVgzj8PmOYRSSi7FJQz8aJUwXirsA4I9NinT/8tkbaf7I1b7 oU9w== MIME-Version: 1.0 X-Received: by 10.221.7.132 with SMTP id oo4mr451185vcb.31.1387761965917; Sun, 22 Dec 2013 17:26:05 -0800 (PST) Received: by 10.58.128.33 with HTTP; Sun, 22 Dec 2013 17:26:05 -0800 (PST) In-Reply-To: <3014595E-B155-47F6-AC7B-71083D89525D@rouvenwessling.de> References: <3014595E-B155-47F6-AC7B-71083D89525D@rouvenwessling.de> Date: Mon, 23 Dec 2013 09:26:05 +0800 Message-ID: To: =?ISO-8859-1?Q?Rouven_We=DFling?= Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0115f90202e9a704ee298323 Subject: Re: [PHP-DEV] [RFC] Timing attack safe string comparison function From: tjerk.meesters@gmail.com (Tjerk Meesters) --089e0115f90202e9a704ee298323 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, On Mon, Dec 23, 2013 at 1:08 AM, Rouven We=DFling wro= te: > Hi internals, > > I'd like to propose this RFC to introduce a time-constant string > comparison function: https://wiki.php.net/rfc/timing_attack > > On the whole it looks okay. The special branch for `known_len =3D=3D 0 && user_len !=3D 0` can be avoid= ed by doing something like this: mod_len =3D max(known_len, 1); And then use `j % mod_len` instead of `j % known_len` to avoid a division by zero; since `x mod 1` always yields `0` you will always be comparing against the null byte of the known string. I will not open the voting before January 7 to account for holidays. > > Best regards > Rouven > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 -- Tjerk --089e0115f90202e9a704ee298323--