Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122200 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82542 invoked from network); 19 Jan 2024 20:43:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jan 2024 20:43:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1705697024; bh=fhT4iTTAAOe9Y6qaSSPCWoTbcljrzPL30OI8UkTTMMk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gzkUKArYw3ZEEq/ticPx3UuXXiSVIX/SLVrB6GLEwTjT7XT5j7YxKg529mfBF8nC3 Sa0WtYDb2yst40A38F3p8sq7o+qh4v2SfTuhEIeTjlMiQ6i3Sj5sVG7UJZU7vU1YAP qNDZr7dHTo74owuT6o7RnJfaXU1ZVUgbUq7kEvxhze/zzPTWRAZatDQupSvOCdUEUK lzf9qpIMLh7BAAdGj/XgzSn62HXq8xAocxuBl8dczoBxLD38OPR5UWolHObR8tJXgJ QEfDY5VwniOZXV0AHUId1DCIgZUQ/8+PTjnjoPQNITR+eW8YLtTgD6/sOeL03whILU 29ybMzYu7aXMQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4219818005A for ; Fri, 19 Jan 2024 12:43:40 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Jan 2024 12:43:33 -0800 (PST) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6ddf05b1922so750952a34.2 for ; Fri, 19 Jan 2024 12:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705696972; x=1706301772; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qmv4a9VL31bk8NRa9ouBBkYlS43o3Mi+dG2Kn8mCAlU=; b=Dj579+paKRyIZ33CAzzTewGTWfoy5vWfHKtX/MIKs7pV7N6tZHNyQldOpYMmk1cQHQ Ad0Xlejr/hhVE9/TytgMS187FC1F5WYFbXW1COAGCA7LLvNuRwL2wLYweNuS3u3ityxO Y9Xru6jNDS3wyrvRY8GEfoyRxCfTLWfQ0FL/7mBbVu3uAMndRLbgbARKRqJ/OU4jWwMx VnmdtI1e8Y8SOUqCm5O9cJt5k2TUc74iJrKix0mxrybFfgNRSLkHlX+2YeNUZFmnDfiH yMBelGTgH1sT1fa/8QJs5UstMp3p16IBEeDvIPNgpHau4d92kH7LpSjXAN6k5kLs0nVr viyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705696972; x=1706301772; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qmv4a9VL31bk8NRa9ouBBkYlS43o3Mi+dG2Kn8mCAlU=; b=mw2/g26EIfNTg1NqYfny09LIClwBU0bwvl1RWAGoraMPyuR+T7GXdSUwEFiE4Z+dY0 tq/CjZKsxtmBirOirWpphxbzdY1mCFuEMK40+bXddHKnB+ulkd/EyOZTgFnnueVYu+LP YUU5wD26sDwPPj5vAEPZg34HKXDf6h2TBvWu1QEmv2wWXXFdksnxVWl22r1tnljKd7aV scxaFSVm11XaCto7hVHyeKcYZqegTHEQWzxUKqUp/G+5hPPpzG+6f6rww3C5syYVxId2 z+HlMGEafl2jBct17zUn3teSMTkJAKGDEXxbYJ/uxgpGif/yWE26e7IIJscC0x1tzyU4 DBVQ== X-Gm-Message-State: AOJu0YwMRFix+X8quSxgf7DKbN74VGR4J24CANLAWPOh8YFNTXQkXG15 PZ074H7aN4EpmFDjifUtxLM07NgUWARjpK7jRdfKJzyHWGIZo0/+fx9RN4+/gQqXUWqf+h39LMu Wz19q6DlQs7lY65Dv8OyV8g/liY4= X-Google-Smtp-Source: AGHT+IFu6RRX3BLeWMvonbGmHLFlskDtHJfEP9cZasuhAN0T59/7cJpW8uxxTuNyG5TMQymz2xECX6lNYDBYNus0uTI= X-Received: by 2002:a05:6870:7187:b0:213:6a28:9c5e with SMTP id d7-20020a056870718700b002136a289c5emr278941oah.20.1705696971642; Fri, 19 Jan 2024 12:42:51 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Jan 2024 21:42:15 +0100 Message-ID: To: tag Knife Cc: Hans Henrik Bergan , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] BLAKE3 hash From: divinity76@gmail.com (Hans Henrik Bergan) >BLAKE3 has 2 default sizes Nope, only 1 canonical size, 256 bits. *BUT* BLAKE3 is XOF, it can be exactly as long as you want it to be: $ echo test | b3sum --length 5 dea2b412aa - $ echo test | b3sum --length 10 dea2b412aa90f1b43a06 - $ echo test | b3sum --length 32 dea2b412aa90f1b43a06ca5e8b8feafec45ae1357971322749480f4e1572eaa2 - $ echo test | b3sum --length 64 dea2b412aa90f1b43a06ca5e8b8feafec45ae1357971322749480f4e1572eaa2ea67cf3c73a= 3acbfa2bdab694345d8ecf5e353dd1a3d5a9628aec9bffc3e4cca - $ echo test | b3sum --length 999 dea2b412aa90f1b43a06ca5e8b8feafec45ae1357971322749480f4e1572eaa2ea67cf3c73a= 3acbfa2bdab694345d8ecf5e353dd1a3d5a9628aec9bffc3e4ccaa32f434df18da6161cabb0= 8b6278dcebca9833fe8d9f65d64db922cecf78c55b521f60dbd77d8ad8378a8f481f2941fed= c817d7e1fdeb9c9c9915f3e0a8a8b3cbd4849e21dbe4e359b21224dee5b75bcee0f2083bb8c= 25559b109727d23b02bde4d2e212529106a1b23be564007909fa23e39c8fdca42a86e75f156= 8d77a85b0efb0acfa0258907f6d9bfae259234d782d53276f823fe32e29b7165818cbc75e48= 60188d60f6bb31b00308b1a7293b75e007eaf2de846709bb1856ed398e1c354a093b4f4853b= 9127ba2e9d85b5336b3e09eb802eef8168f1954c34cc9c61bb933de56790caaff3e03b43f85= febfc175e3534e687527a757c2b2e5474efa6db51873da140f5ebc65dca5545b73dd64ac758= 5fe1d123475e128878962ff8952cd2c8372c4808c4893c8038e6ffb52ef7cf9416ad71588d7= 79c8d60d19c997524b6f756b1d0d5934d41a8e3644fb3fc23e2403bf8b94b95a36f66fb108b= 6ed824b117f3de9314566bd7042bdd5116e096f0846121ba7034559b234074eac403d2d0f9a= 4386745375c54d2c22cc970a1cd9836cc9ad1bc3b8c511e5674f05cd5cb8d844c3e802199f0= d8b9f3b6e2abd8e830b5768c1539b2d445181fbdcf77c51c330c67aa7b62691d18ecdb7d312= 4ac4e5fd83a8251ec072740aa4029624ad0a51ebfc8281a5e098ceda2b468e0f936a93b3498= b0f11484c4e04cd7be657614ddebe9c08eb0c912431239605e1924009d32afeb965e9c7bbde= 77bc8efc2ebbc7eb3555286bb7b97fc30fe33806b36aef129d975251a737f0a285fd7cb617b= 9326211d22924704a2760e235ffa0c125eabb556698120229880b3af0f6dc81336af17fc90f= 3e889142a5e338a28816c0b6b3944d2f05b7a70189d3e8a19a1e6f6ca0041d4eb165ab4e4aa= d2f6ec87dc2986263e395c5a5d626bf8847d8b4a70126858f6adda1f39ce0cacf266895856c= 9ea118418b80c1a37260c7ef73598beb6b2cb3665eece981e249fec4ab8ad2424f1243b0835= a7f079a3a9e9c288395a88e70f75eb5610251a416a7189d6e1c3c25a6729d3c9bae65970f8f= a48d3ef8f8469ab62c19c3adc04a5c7debea10a910df7d389b183c18cd33fe6b946ebfc5b8a= 0505968a63122fe0f618e8cf07a978777381bdbafac8024226eee532b76d63ee4a0b45f1f62= 3928afcce21977284868747d7949dd912c8b0894b6a782d2985085f0e629c0c7be7ab19b37e= 4c5f01a1636f62ee55783b86df8d53698e8b4bbe03fd69322609bb6fdee35cb433d44ec7322= d6f1d040f87072bba06ab793bd857c7f754b080b8b04b28c - And what's more, thanks to PHP8.1.0's new $options argument for hash() we can expose blake3's XOF like hash("blake3", "test", options: ["length"=3D>512/8]): blake3_512 hash("blake3", "test", options: ["length"=3D>256/8]): blake3_256 hash("blake3", "test", options: ["length"=3D>8/8]): blake3_8 hash("blake3", "test", options: ["length"=3D>1000]): blake3_8000 that shouldn't be too difficult to implement either! good idea On Fri, 19 Jan 2024 at 20:20, tag Knife wrote: > > On Fri, 19 Jan 2024 at 18:43, Hans Henrik Bergan wrote: > > > Can we add the BLAKE3 hash? > > > > Created a PR here: https://github.com/php/php-src/pull/13194 > > > > BLAKE3 is a very fast ("blazing fast") cryptographically secure hash. I= t is > > the latest iteration of the BLAKE hash, which was a SHA3 finalist~ see > > https://github.com/BLAKE3-team/BLAKE3 for more info on BLAKE3. > > > > In the PR is a portable C implementation, along with optimized ARM-neon= and > > x86_64 SSE2, SSE41, AVX2, and AVX512 implementations for GCC+unix and > > GCC+windows and MSVC (*MSVC is currently only using the portable > > implementation, but it should be easy for a developer equipped with MSV= C to > > enable the optimized implementations. I don't have MSVC personally) > > > > That means the PR includes ~35 copies of the same algorithm, in > > hand-written assembly, optimized for various CPU/compiler/OS combinatio= ns. > > Which means the PR is hug*e.* > > > > It would be possible to only ship a subset of them (For example, keepin= g > > just the gcc+unix+SSE2 and gcc+unix+AVX2 and ARM-neon and trash the res= t, > > would benefit a lot systems in-the-wild, and reduce the size of the PR > > substantially) > > > > It would also be possible to only ship the portable pure C implementati= on, > > but that would also be detrimental to the performance, which is the mai= n > > motivator for adding BLAKE3 in the first place. > > > > But the groundwork to ship them all is already done (see the PR) > > > > Thoughts? > > > > BLAKE3 has 2 default sizes, BLAKE3_256 and BLAKE3_512. Internally the > hashblock size is 512, > With other algo's we have added these different hash sizes, would it be > possible for you to expose the 2 hash sizes.