Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59006 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57370 invoked from network); 18 Mar 2012 15:59:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2012 15:59:33 -0000 Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:64282] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/33-41178-466066F4 for ; Sun, 18 Mar 2012 10:59:32 -0500 Received: by wibhr14 with SMTP id hr14so2586398wib.11 for ; Sun, 18 Mar 2012 08:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=3SaOam4ES5GJsaJq9nL8LtPasfK5OgfMOJwKWHG2ydA=; b=u6KzgXXaRlNvvPFaC7XiUkyzvaNVh5/8DTPFHSJIkm8JwOzpOLqlnsdhk2uwH/Ou8U mULcs0F07nI2fW0CRX11Crdjtu6zSBulakJcklepUURiGNjacU4Uhd7LbEi6h41BgdJX EiQP/bBZ9qTjL1EB07OS4WxsPHH6oBKEztsCWkP/UPQM/ocBXCR/Ctd9yH02P0j4ZJrW 4GgtZZ2J7XCG8YephEib+ToF3UpZfv/YDwK9b8xc0OuBKtTD92Ky0EZ+M16rlmO5kJAQ wWmQunPllu9FdEmPxN+Pt6+rL9RjaXBpRvRlJVM2sDctcgLm5XlsjMOI9l66e1MiL5jJ yShw== Received: by 10.180.100.196 with SMTP id fa4mr22463722wib.0.1332086369474; Sun, 18 Mar 2012 08:59:29 -0700 (PDT) Received: from [192.168.1.26] (208.Red-83-49-115.dynamicIP.rima-tde.net. [83.49.115.208]) by mx.google.com with ESMTPS id p10sm23537452wic.0.2012.03.18.08.59.26 (version=SSLv3 cipher=OTHER); Sun, 18 Mar 2012 08:59:28 -0700 (PDT) Message-ID: <4F66078E.1080100@gmail.com> Date: Sun, 18 Mar 2012 17:04:30 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Tjerk Anne Meesters CC: Stas Malyshev , Sam , "internals@lists.php.net" References: <4F65267D.3040005@googlemail.com> <4F652868.7070901@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Randomize hash-function in php From: keisial@gmail.com (=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=) On 18/03/12 06:56, Tjerk Anne Meesters wrote: > On Sun, Mar 18, 2012 at 8:12 AM, Stas Malyshev wrote: >> Obvious solution would be to use a salt for the hash, which prevents blind >> pre-computing of hash collisions. However, due to the fact that PHP hash >> values can be reused in different processes by bytecode caches, implementing >> it properly is not trivial. > What if php uses salts for specific hashes only, such as GPC (or all > hashes whose lifetime is limited to the current reuqest), and use a > zero-value salt for all others? We'll need to have at least two kind of hashes, at that point, I think it makes sense to place the salt as a member of the HashTable struct. Bytecode caches would just store the salt with the hash. We can also mt_rand() the salt of each hash, for further randomization.