Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97492 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63514 invoked from network); 30 Dec 2016 02:32:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Dec 2016 02:32:25 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:36330] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/78-04761-737C5685 for ; Thu, 29 Dec 2016 21:32:24 -0500 Received: by mail-oi0-f41.google.com with SMTP id v84so413109962oie.3 for ; Thu, 29 Dec 2016 18:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=TIw4p4p2pf8gKwbqsvyGNzbjLj58BGydX+JwiP+M69M=; b=gGJ+1BaBjGsI2l0O4NczDtBOmDTaWIrL9y35k916isU2ZQiKwYXXWsAk/wgp/6lMgv +o9oOE2vrwhBgxewFd0d4mWx8fcc2RTGu+os+RenYX6WOK29Q4DeF0Z2XBabX4jL73ai qtzOFYF8d9ogIbHM+5psffmR6v+6Ks0O+jHtrkqY8OUKDuevSvoiJ0YIHC67whZJotXM jXrd4OpNYWc8bMwdyCfiRjwh6Ai5OtknZxubCJAUuq/kS3en7WiHqHtqECO6FanlJpa6 C0YwbVyLkgC9hsJIrFFU0AxdlIWxrBr9i2+j/DZ6Z+QwNzIa3MCdhpMciW1erAmWGUYJ v9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=TIw4p4p2pf8gKwbqsvyGNzbjLj58BGydX+JwiP+M69M=; b=VR8Yac9WKAlQVmvYJW5h/1WnQe5mDAp2P0t7RiuiXFJwoWRSsFhGmEWHlBf5OnjPjc ZYxzc4Bp2WmMP8dE5+6dFOzvzYu35ft6nK/S3y6saeqipswdRWgSjSufgAsV9r+vPEiu N9V/j8aPUv74ehjMbQI4jSngwiFKtf6HX7W0+0Wq1pOojoh8hUtfIsjLeoKW1nTGhsg6 94rfGGOh1IuDNZFA6kEUOfdelHGdUoHDTZ6NCD9XMxk2VnFfu/m/S4+xqcVUJHQv2z1z I9ZIPrynU3vhKoBLRkGVW1YZQXxtWRBU/iuC7vX0TZFiIy6JpqLVmQZ98XJVYM0In0Fk TIng== X-Gm-Message-State: AIkVDXLBR/yBy7Lu0Jwi97ZSr8iQhomOUiebFN3dvDui861Sr81EaAvsYrkbELekkMwovXOvvv01+eJZL7uc9w== X-Received: by 10.202.244.22 with SMTP id s22mr17854265oih.190.1483065140666; Thu, 29 Dec 2016 18:32:20 -0800 (PST) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.157.34.233 with HTTP; Thu, 29 Dec 2016 18:32:20 -0800 (PST) X-Originating-IP: [107.198.91.68] In-Reply-To: References: Date: Thu, 29 Dec 2016 18:32:20 -0800 X-Google-Sender-Auth: sQJPrPWyJo5c60W9cmD95fnp0AY Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Fwd: [RFC] HashContext as Object From: pollita@php.net (Sara Golemon) On Mon, Dec 26, 2016 at 7:35 PM, Sara Golemon wrote: > I was trawling through Pull Requests and found #660 which I think is a > nice idea and deserves some attention. It involves minor BC however, > so I've updated the patch and presented it for your discussing > pleasure. > Specifically, I should say I'm eager to hear thoughts on the item listed as an Open Issue. That is: Currently hash_final() destroys the existing HashContext resource immediately. No hope of continuing or even just reissuing the result. I'm quite tempted atm, to go the "copy the context, finalize to get a digest, then restoring to the saved context state". For most use cases of this API this is a slight overhead add since the context is being duplicated then shortly thereafter discarded. (Bear in mind though, that the hash_init->hash_update->hash_final API is the edge case already compared to the all-in-one hash() and hash_hmac() functions). What doing this does offer, however, is a pathway to reasonable APIs for streaming hash functions (see SHA3/Keccak Sponge Functions). As a minor side benefit, we also get an idempotent hash_final(). So even though there's a VERY minor BC break involved, I think it's the right thing to do. If others agree, I'll update the diff to reflect. -Sara