Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21640 invoked from network); 23 Dec 2013 11:26:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2013 11:26:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.174 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.174 mail-qc0-f174.google.com Received: from [209.85.216.174] ([209.85.216.174:41814] helo=mail-qc0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/38-08405-7CD18B25 for ; Mon, 23 Dec 2013 06:25:59 -0500 Received: by mail-qc0-f174.google.com with SMTP id n7so4746209qcx.33 for ; Mon, 23 Dec 2013 03:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=u7vNqcjAfM3bASjQD/G+ELDyt7s/TY3LqEEuX+itd+g=; b=UMCAQs+QzaBijHWBRYIbMWJYw54LjtDPu78sHRzPAmOZiVkQVOr+jKdDwQtUfzhRvs 8sHgZdjEQHNzA75a6Kh1D3uZ9BnkCidCD6Cp2lfi86Om0Ixy+ZsNP4C8EZzxku/hVaaV abtOvBGP8pI6oRXpQzc+Y2PvOcwyL9AgYWzCHdHXlt6537JO9WuvQdEgWLGewkO9MtzY neWEcjviE2ilvysp5fT+5FNL4fnsQ8SQ4N9OlPq/ViaTUVwqmcIso1jXoG740soy/tr8 UnQPvzudm6Kb9/98JIOejHlSSx5LzOqIM6xZIlGlNbO7rlZDI1Xr2o5iXAVoyX8MN0+U lzVg== X-Received: by 10.49.74.138 with SMTP id t10mr41174601qev.21.1387797955674; Mon, 23 Dec 2013 03:25:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.85.149 with HTTP; Mon, 23 Dec 2013 03:25:35 -0800 (PST) In-Reply-To: <52B81B9F.6040609@php.net> References: <3014595E-B155-47F6-AC7B-71083D89525D@rouvenwessling.de> <52B80C5B.2050208@sugarcrm.com> <6C0AE2F4-26DA-4081-914A-F6D18C46911C@rouvenwessling.de> <52B81559.8080409@php.net> <52B81B9F.6040609@php.net> Date: Mon, 23 Dec 2013 12:25:35 +0100 Message-ID: To: Joe Watkins Cc: PHP Internals List Content-Type: multipart/alternative; boundary=047d7bdc13fe2b0b2304ee31e439 Subject: Re: [PHP-DEV] [RFC] Timing attack safe string comparison function From: ocramius@gmail.com (Marco Pivetta) --047d7bdc13fe2b0b2304ee31e439 Content-Type: text/plain; charset=UTF-8 On 23 December 2013 12:16, Joe Watkins wrote: > > 291 /* We're using this method instead of == in order to provide > 292 * resistence towards timing attacks. This is a constant time > 293 * equality check that will always check every byte of both > 294 * values. */ > 295 for (i = 0; i < hash_len; i++) { > 296 status |= (ret[i] ^ hash[i]); > 297 } > > So that puts in perspective the what if it borks argument, and the > complication argument too, since the new function and old can share a > static inline implementation of the same logic ... do you really want me to > explain why static inline c is better than PHP, or is that obvious at this > point ?? > The performance question is irrelevant to me - I don't think I'd ever code a performance-sensitive API with this sort of function, but maybe someone has a real world example for that. Slower is probably even better here :P Let me re-state: "performance is not a problem here". > I would love it if at some point in the future you could point at bits of > PHP and say "that's a good implementation", That's admirable, but the userland implementation seems ok for me as well. > Anyone who doesn't see that, is barking mad, barking, mad ... > > I'm always barking mad :-) Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --047d7bdc13fe2b0b2304ee31e439--