Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110492 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39514 invoked from network); 11 Jun 2020 22:57:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Jun 2020 22:57:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F30BD1804F8 for ; Thu, 11 Jun 2020 14:42:06 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 11 Jun 2020 14:42:06 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id c12so4342532lfc.10 for ; Thu, 11 Jun 2020 14:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NDsKZ20Hq+LmDaQvukh/hz21eyYfEdOqcUTwqEHxbq0=; b=sf5P+vn3p/+UpiFWce/RyG8K0p9OZbF0GPjk6Otcg+QdG6WtYKOKbEWFytwocyz2bw E6w4IcQHfdImk5fVDKNeWN2SkkAhTtYqsAW8soJnQJ8GsijaLDnq8iPzRwfllcZViebq /G3SIlyFanKa9QVEKyZo06M+jte3veRjMsSd/sfq96pcbbE3bmhKhwG/puR+vq6i+pSq OzktlDSsa8wngXR4i4mBo3Np1XPR025DHP6kUUa98dH6CqcD6v6nnpwKiIFIhcyWsnpn T5NP0vZWpHeot6fejpE6qgshZI7Tvq1QRyLMMRzHQQYEqf/ecD/AlCUaZikwLqRlchnI Cfcg== X-Gm-Message-State: AOAM533X9moaA1TdG8QAe6hNOMw9kDiioHjY1VtRLaX9PoHmFM7xcM00 kzw2kqw6JC5Bd6a/DtexsnHOogoSOVT9PmZrFSABzA== X-Google-Smtp-Source: ABdhPJzcFov5uJKxRtt17/BuNH2+r/0iaPPtzbhARH9EOyqclccSLQet6KsGI1PGhJ6BDJBkRqJWyRlPDsQjjj1Kfn4= X-Received: by 2002:a19:8ac3:: with SMTP id m186mr5267804lfd.131.1591911722475; Thu, 11 Jun 2020 14:42:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 11 Jun 2020 16:41:51 -0500 Message-ID: To: Eddie Kohler Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , PHP Internals Content-Type: multipart/alternative; boundary="000000000000bb7bc405a7d5d4ac" Subject: Re: [PHP-DEV] New functions `hash_serialize` and `hash_unserialize`? From: pollita@php.net (Sara Golemon) --000000000000bb7bc405a7d5d4ac Content-Type: text/plain; charset="UTF-8" On Thu, Jun 11, 2020 at 11:59 AM Eddie Kohler wrote: > Thanks for this suggestion. I've updated the implementation to make > HashContext implement Serializable. > > I'd still be grateful for more feedback, or perhaps I should just create > an RFC? > > Be careful what you ask for. :) Overall +1 on the concept with a few notes: 1. Please put this on a branch and make it a PR so we can comment on it directly. 2. Consider using zend_parse_parameters_throws() and family so that the exception which is thrown contains the type error information rather than the generic RETURN_THROWS() macros. 3. Consider using hex or base64 to serialize the contexts. This will reduce various transport/storage issues. 4. It's great that you've thought about endianness, but the current implementation simply bails on endian mismatch. It'd be a nice-to-have for the user if these serializations were portable. I know this represents a lot of work for sort of an edge case so I won't hold it against you if you say 'no' and/or save this for later work if demand surfaces. 5. Storing $key makes me nervous. I don't have a good solution to this since the deserialization doesn't actually give us a chance to specify it in the deserialization process. I wish I'd made $key/hmac an option to hash_final rather than hash_init. Maybe we can think about allowing that to be specified at either end. Let's expand on this topic while you work on your RFC. 6. Yeah... I think you need an RFC because of #5. Sorry. 7. TABS v SPACES indentation issues. -Sara --000000000000bb7bc405a7d5d4ac--