Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1375 → Rev 1376

/trunk/vendor/composer/installed.json
392,18 → 392,18
"source": {
"type": "git",
"url": "https://github.com/danielmarschall/uuid_mac_utils.git",
"reference": "ce6991c9c2a06c4fbc616b91664187e1f797a3b9"
"reference": "d85c3e45b92ab4ca3a5ef7376016fa05392f10eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/danielmarschall/uuid_mac_utils/zipball/ce6991c9c2a06c4fbc616b91664187e1f797a3b9",
"reference": "ce6991c9c2a06c4fbc616b91664187e1f797a3b9",
"url": "https://api.github.com/repos/danielmarschall/uuid_mac_utils/zipball/d85c3e45b92ab4ca3a5ef7376016fa05392f10eb",
"reference": "d85c3e45b92ab4ca3a5ef7376016fa05392f10eb",
"shasum": ""
},
"require": {
"php": ">=7.0"
},
"time": "2023-07-29T18:27:37+00:00",
"time": "2023-08-04T09:31:58+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
/trunk/vendor/composer/installed.php
95,7 → 95,7
'danielmarschall/uuid_mac_utils' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'ce6991c9c2a06c4fbc616b91664187e1f797a3b9',
'reference' => 'd85c3e45b92ab4ca3a5ef7376016fa05392f10eb',
'type' => 'library',
'install_path' => __DIR__ . '/../danielmarschall/uuid_mac_utils',
'aliases' => array(
/trunk/vendor/danielmarschall/uuid_mac_utils/includes/SHA3.php
0,0 → 1,349
<?php /* -*- coding: utf-8; indent-tabs-mode: t; tab-width: 4 -*-
vim: ts=4 noet ai */
 
/**
Streamable SHA-3 for PHP 5.2+, with no lib/ext dependencies!
 
Copyright © 2018 Desktopd Developers
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
 
@license LGPL-3+
@file
*/
 
// Fixed small issues found by PHPstan by Daniel Marschall 02 August 2023
 
 
/**
SHA-3 (FIPS-202) for PHP strings (byte arrays) (PHP 5.2.1+)
PHP 7.0 computes SHA-3 about 4 times faster than PHP 5.2 - 5.6 (on x86_64)
 
Based on the reference implementations, which are under CC-0
Reference: http://keccak.noekeon.org/
 
This uses PHP's native byte strings. Supports 32-bit as well as 64-bit
systems. Also for LE vs. BE systems.
*/
class SHA3 {
const SHA3_224 = 1;
const SHA3_256 = 2;
const SHA3_384 = 3;
const SHA3_512 = 4;
 
const SHAKE128 = 5;
const SHAKE256 = 6;
 
private $blockSize = null; // added DM 2 Aug 2023
 
 
public static function init ($type = null) {
switch ($type) {
case self::SHA3_224: return new self (1152, 448, 0x06, 28);
case self::SHA3_256: return new self (1088, 512, 0x06, 32);
case self::SHA3_384: return new self (832, 768, 0x06, 48);
case self::SHA3_512: return new self (576, 1024, 0x06, 64);
case self::SHAKE128: return new self (1344, 256, 0x1f);
case self::SHAKE256: return new self (1088, 512, 0x1f);
}
 
throw new Exception ('Invalid operation type');
}
 
 
/**
Feed input to SHA-3 "sponge"
*/
public function absorb ($data) {
if (self::PHASE_INPUT != $this->phase) {
throw new Exception ('No more input accepted');
}
 
$rateInBytes = $this->rateInBytes;
$this->inputBuffer .= $data;
while (strlen ($this->inputBuffer) >= $rateInBytes) {
list ($input, $this->inputBuffer) = array (
substr ($this->inputBuffer, 0, $rateInBytes)
, substr ($this->inputBuffer, $rateInBytes));
 
$blockSize = $rateInBytes;
for ($i = 0; $i < $blockSize; $i++) {
$this->state[$i] = $this->state[$i] ^ $input[$i];
}
 
$this->state = self::keccakF1600Permute ($this->state);
$this->blockSize = 0;
}
 
return $this;
}
 
/**
Get hash output
*/
public function squeeze ($length = null) {
$outputLength = $this->outputLength; // fixed length output
if ($length && 0 < $outputLength && $outputLength != $length) {
throw new Exception ('Invalid length');
}
 
if (self::PHASE_INPUT == $this->phase) {
$this->finalizeInput ();
}
 
if (self::PHASE_OUTPUT != $this->phase) {
throw new Exception ('No more output allowed');
}
if (0 < $outputLength) {
$this->phase = self::PHASE_DONE;
return $this->getOutputBytes ($outputLength);
}
 
$blockLength = $this->rateInBytes;
list ($output, $this->outputBuffer) = array (
substr ($this->outputBuffer, 0, $length)
, substr ($this->outputBuffer, $length));
$neededLength = $length - strlen ($output);
$diff = $neededLength % $blockLength;
if ($diff) {
$readLength = (($neededLength - $diff) / $blockLength + 1)
* $blockLength;
} else {
$readLength = $neededLength;
}
 
$read = $this->getOutputBytes ($readLength);
$this->outputBuffer .= substr ($read, $neededLength);
return $output . substr ($read, 0, $neededLength);
}
 
 
// internally used
const PHASE_INIT = 1;
const PHASE_INPUT = 2;
const PHASE_OUTPUT = 3;
const PHASE_DONE = 4;
 
private $phase = self::PHASE_INIT;
private $state; // byte array (string)
private $rateInBytes; // positive integer
private $suffix; // 8-bit unsigned integer
private $inputBuffer = ''; // byte array (string): max length = rateInBytes
private $outputLength = 0;
private $outputBuffer = '';
 
 
/**
* @param int $rate
* @param int $capacity
* @param int $suffix
* @param int $length
*/
public function __construct ($rate, $capacity, $suffix, $length = 0) {
if (1600 != ($rate + $capacity)) {
throw new Error ('Invalid parameters');
}
if (0 != ($rate % 8)) {
throw new Error ('Invalid rate');
}
 
$this->suffix = $suffix;
$this->state = str_repeat ("\0", 200);
$this->blockSize = 0;
 
$this->rateInBytes = $rate / 8;
$this->outputLength = $length;
$this->phase = self::PHASE_INPUT;
return;
}
 
protected function finalizeInput () {
$this->phase = self::PHASE_OUTPUT;
 
$input = $this->inputBuffer;
$inputLength = strlen ($input);
if (0 < $inputLength) {
$blockSize = $inputLength;
for ($i = 0; $i < $blockSize; $i++) {
$this->state[$i] = $this->state[$i] ^ $input[$i];
}
 
$this->blockSize = $blockSize;
}
 
// Padding
$rateInBytes = $this->rateInBytes;
$this->state[$this->blockSize] = $this->state[$this->blockSize]
^ chr ($this->suffix);
if (($this->suffix & 0x80) != 0
&& $this->blockSize == ($rateInBytes - 1)) {
$this->state = self::keccakF1600Permute ($this->state);
}
$this->state[$rateInBytes - 1] = $this->state[$rateInBytes - 1] ^ "\x80";
$this->state = self::keccakF1600Permute ($this->state);
}
 
protected function getOutputBytes ($outputLength) {
// Squeeze
$output = '';
while (0 < $outputLength) {
$blockSize = min ($outputLength, $this->rateInBytes);
$output .= substr ($this->state, 0, $blockSize);
$outputLength -= $blockSize;
if (0 < $outputLength) {
$this->state = self::keccakF1600Permute ($this->state);
}
}
 
return $output;
}
 
/**
1600-bit state version of Keccak's permutation
*/
protected static function keccakF1600Permute ($state) {
$lanes = str_split ($state, 8);
$R = 1;
$values = "\1\2\4\10\20\40\100\200";
 
for ($round = 0; $round < 24; $round++) {
// θ step
$C = array ();
for ($x = 0; $x < 5; $x++) {
// (x, 0) (x, 1) (x, 2) (x, 3) (x, 4)
$C[$x] = $lanes[$x] ^ $lanes[$x + 5] ^ $lanes[$x + 10]
^ $lanes[$x + 15] ^ $lanes[$x + 20];
}
for ($x = 0; $x < 5; $x++) {
//$D = $C[($x + 4) % 5] ^ self::rotL64 ($C[($x + 1) % 5], 1);
$D = $C[($x + 4) % 5] ^ self::rotL64One ($C[($x + 1) % 5]);
for ($y = 0; $y < 5; $y++) {
$idx = $x + 5 * $y; // x, y
$lanes[$idx] = $lanes[$idx] ^ $D;
}
}
unset ($C, $D);
 
// ρ and π steps
$x = 1;
$y = 0;
$current = $lanes[1]; // x, y
for ($t = 0; $t < 24; $t++) {
list ($x, $y) = array ($y, (2 * $x + 3 * $y) % 5);
$idx = $x + 5 * $y;
list ($current, $lanes[$idx]) = array ($lanes[$idx]
, self::rotL64 ($current
, (($t + 1) * ($t + 2) / 2) % 64));
}
unset ($current);
 
// χ step
$temp = array ();
for ($y = 0; $y < 5; $y++) {
for ($x = 0; $x < 5; $x++) {
$temp[$x] = $lanes[$x + 5 * $y];
}
for ($x = 0; $x < 5; $x++) {
$lanes[$x + 5 * $y] = $temp[$x]
^ ((~ (string)$temp[($x + 1) % 5]) & $temp[($x + 2) % 5]);
 
}
}
unset ($temp);
 
// ι step
for ($j = 0; $j < 7; $j++) {
$R = (($R << 1) ^ (($R >> 7) * 0x71)) & 0xff;
if ($R & 2) {
$offset = (1 << $j) - 1;
$shift = $offset % 8;
$octetShift = ($offset - $shift) / 8;
$n = "\0\0\0\0\0\0\0\0";
$n[$octetShift] = $values[$shift];
 
$lanes[0] = $lanes[0]
^ $n;
//^ self::rotL64 ("\1\0\0\0\0\0\0\0", (1 << $j) - 1);
}
}
}
 
return implode ($lanes);
}
 
protected static function rotL64_64 ($n, $offset) {
return ($n << $offset) & ($n >> (64 - $offset));
}
 
/**
64-bit bitwise left rotation (Little endian)
*/
protected static function rotL64 ($n, $offset) {
 
//$n = (binary) $n;
//$offset = ((int) $offset) % 64;
//if (8 != strlen ($n)) throw new Exception ('Invalid number');
//if ($offset < 0) throw new Exception ('Invalid offset');
 
$shift = $offset % 8;
$octetShift = ($offset - $shift) / 8;
$n = substr ($n, - $octetShift) . substr ($n, 0, - $octetShift);
 
$overflow = 0x00;
for ($i = 0; $i < 8; $i++) {
$a = ord ($n[$i]) << $shift;
$n[$i] = chr (0xff & $a | $overflow);
$overflow = $a >> 8;
}
$n[0] = chr (ord ($n[0]) | $overflow);
return $n;
}
 
/**
64-bit bitwise left rotation (Little endian)
*/
protected static function rotL64One ($n) {
list ($n[0], $n[1], $n[2], $n[3], $n[4], $n[5], $n[6], $n[7])
= array (
chr (((ord ($n[0]) << 1) & 0xff) ^ (ord ($n[7]) >> 7))
,chr (((ord ($n[1]) << 1) & 0xff) ^ (ord ($n[0]) >> 7))
,chr (((ord ($n[2]) << 1) & 0xff) ^ (ord ($n[1]) >> 7))
,chr (((ord ($n[3]) << 1) & 0xff) ^ (ord ($n[2]) >> 7))
,chr (((ord ($n[4]) << 1) & 0xff) ^ (ord ($n[3]) >> 7))
,chr (((ord ($n[5]) << 1) & 0xff) ^ (ord ($n[4]) >> 7))
,chr (((ord ($n[6]) << 1) & 0xff) ^ (ord ($n[5]) >> 7))
,chr (((ord ($n[7]) << 1) & 0xff) ^ (ord ($n[6]) >> 7)));
return $n;
}
}
 
 
/*
$hexMsg = '7c815c384eee0f288ece27cced52a01603127b079c007378bc5d1e6c5e9e6d1c735723acbbd5801ac49854b2b569d4472d33f40bbb8882956245c366dc3582d71696a97a4e19557e41e54dee482a14229005f93afd2c4a7d8614d10a97a9dfa07f7cd946fa45263063ddd29db8f9e34db60daa32684f0072ea2a9426ecebfa5239fb67f29c18cbaa2af6ed4bf4283936823ac1790164fec5457a9cba7c767ca59392d94cab7448f50eb34e9a93a80027471ce59736f099c886dea1ab4cba4d89f5fc7ae2f21ccd27f611eca4626b2d08dc22382e92c1efb2f6afdc8fdc3d2172604f5035c46b8197d3';
$hexResult = 'dc2038c613a5f836bd3d7a4881b5b3bff3023da72d253e1b520bcad5162e181685662d40252bee982eb3214aa70ddf0a95c5d1031de9781266b1e0972fc9777d4a74164da68a5d4585f7a8e7438fe28d8af577306b8e2cbf6863c83431cc4c898dda50c94efd4925432fca36a6304790fbf4fefaeee279c01b8b6a8d1c275e3cb4e8bf17d880903fbaf27bfa65a2e3db8e285878a94955f6fc14f05a0fa2556994b8612bb7a494b4dd8b3cf1bc9e4bf833d4bfbf878c4d3bdc8fc70d26d7b7edaf0afe2f963dc6884c871c1475f4b92378b9824970e40da0a59780e84ac5138aa1efa46c1b50c3b045be59037c6a0c89e1d3cf246f1362794e8107b7cba74888f0bf4b905cfb9c33517f472bac16259809797f2fc883ffbdd7cede9518f891b9117de5ddc6d3e29fa56eb617f25e9eb1b66f7e46ed54c1d43ac07471d35c57b8c73bc68f5612ed042bff5e68634a4fb81e2ef0d92fff1e11e43fd6d9a935678d2fdd04e06061da3ba7de415b93c5a8db1653cf08de1866f5c3d33be32a3b8d2b7bb39e9745c6e88c782f220c367f945828b9b9250de71e8a14ec847bbeec2b1a486ce61731cef21b4a3a6353c2c705759fafa50ad33fb6abc23b45f28ee7736df6f59aaf38d59881547274cf9af2cfc8fc1ecadf81ab72e38abccd281df956f279bacc1796ad1f90d6930a5829bb95e94a8682a51a6743ae91b6c12c08e1465a';
$msg = pack ('H*', $hexMsg);
$result = pack ('H*', $hexResult);
$sponge = SHA3::init (SHA3::SHAKE128);
$sponge->absorb($msg);
assert($result == $sponge->squeeze($outputLength = strlen($result)));
 
$hexMsg = 'fc424eeb27c18a11c01f39c555d8b78a805b88dba1dc2a42ed5e2c0ec737ff68b2456d80eb85e11714fa3f8eabfb906d3c17964cb4f5e76b29c1765db03d91be37fc';
$hexResult = '66126e27da8c1600b68d0ed65e9f47c4165faa43dc4eb1b99ffeddc33e61e20b01b160c84740b0f9fe29fda1fb5eff2819d98c047cdd0cf8a0d396864e54a34657bd0c0355c75c77e5c3d9ad203e71fc2785a83d254b953277b262ee0a5bb7d0c24ed57faed4fdb96d5fd7820e6efeeb5a9e9df48c619c4872cf3b2516dbb28073273e2693544e271d6f0f64be8dc236ecd021c00039fd362a843dc3681b166cbc2407495e18903e469403807fe623f3648f799f18fbd60fff7705d07464e801e0aed4f2f0642b9a2c5cdd0c902b59b1da19a09375c1c13175b618091b8882a0e7205ee63a9219ecbcfa943a10d2d9a50c8c0b5d43b003f67ef0d52adbf9f659bb62fa6e00678bb8d4449648872a99eecdbb3dc381b5199fd500912afa93c63a6b23d00d0a416468fdab93aedd9115265be3a4440dd4029ff7f88d9755623e77f9430b934dae529be9a6b307b1b292ab5918eb24b14598554b4cc6269419c701494b7cba5b3d69f6cdcd5181fd03e0748d08e1e0aa5c4ec62c47877c1085873c016ef24e7e45da71d3db9db23b153cceda9a9ab5ccd8c5466cef29810098e976e4867075601f83a2d2cda1a476a1e990ce04c4567ffb99aac428922d9d8b25af68c36463d3aa4f689cd778f79e743e0bb5f935e6d45f978dcb2aed12dfcdca469556556e19f25d4c959c98785fb471d4bd1675d3b84742766d5ba4bff2a3f912';
$msg = pack ('H*', $hexMsg);
$result = pack ('H*', $hexResult);
$sponge = SHA3::init (SHA3::SHAKE256);
$sponge->absorb($msg);
assert($result == $sponge->squeeze($outputLength = strlen($result)));
*/
 
/trunk/vendor/danielmarschall/uuid_mac_utils/includes/uuid_utils.inc.php
3,7 → 3,7
/*
* UUID utils for PHP
* Copyright 2011 - 2023 Daniel Marschall, ViaThinkSoft
* Version 2023-07-29
* Version 2023-08-04
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
58,6 → 58,14
return ($uuid == '');
}
 
function uuid_equal($uuid1, $uuid2) {
$uuid1 = uuid_canonize($uuid1);
if (!$uuid1) return false;
$uuid2 = uuid_canonize($uuid2);
if (!$uuid2) return false;
return $uuid1 === $uuid2;
}
 
function uuid_version($uuid) {
$uuid = uuid_canonize($uuid);
if (!$uuid) return false;
629,11 → 637,11
case 8:
/*
Variant 1, Version 8 UUID
- 48 bit Custom data
- 48 bit Custom data [Block 1+2]
- 4 bit Version (fix 0x8)
- 12 bit Custom data
- 12 bit Custom data [Block 3]
- 2 bit Variant (fix 0b10)
- 62 bit Custom data
- 62 bit Custom data [Block 4+5]
*/
 
echo sprintf("%-32s %s\n", "Version:", "[0x8] Custom implementation");
1025,11 → 1033,11
function gen_uuid_dce($domain, $id) {
if (($domain ?? '') === '') throw new Exception("Domain ID missing");
if (!is_numeric($domain)) throw new Exception("Invalid Domain ID");
if (($domain < 0) || ($domain > 255)) throw new Exception("Domain ID must be in range 0..255");
if (($domain < 0) || ($domain > 0xFF)) throw new Exception("Domain ID must be in range 0..255");
 
if (($id ?? '') === '') throw new Exception("ID value missing");
if (!is_numeric($id)) throw new Exception("Invalid ID value");
if (($id < 0) || ($id > 4294967295)) throw new Exception("ID value must be in range 0..4294967295");
if (($id < 0) || ($id > 0xFFFFFFFF)) throw new Exception("ID value must be in range 0..4294967295");
 
# Start with a version 1 UUID
$uuid = gen_uuid_timebased();
1265,6 → 1273,103
return strtolower($block1.'-'.$block2.'-'.$block3.'-'.$block4.'-'.$block5);
}
 
function gen_uuid_v8_namebased($hash_uuid, $namespace_uuid, $name) {
if (($hash_uuid ?? '') === '') throw new Exception("Hash space UUID missing");
if (!uuid_valid($hash_uuid)) throw new Exception("Invalid hash space ID '$hash_uuid'");
 
if (($namespace_uuid ?? '') === '') throw new Exception("Namespace UUID missing");
if (!uuid_valid($namespace_uuid)) throw new Exception("Invalid namespace UUID '$namespace_uuid'");
 
$uuid1 = hex2bin(str_replace('-','',uuid_canonize($hash_uuid)));
$uuid2 = hex2bin(str_replace('-','',uuid_canonize($namespace_uuid)));
$payload = $uuid1 . $uuid2 . $name;
 
$hash = null;
foreach (get_uuidv8_hash_space_ids() as list($algo,$space,$friendlyName,$author,$available)) {
if (uuid_equal($hash_uuid,$space)) {
if (!$available) {
throw new Exception("Algorithm $algo is not available on this system (PHP version too old)");
}
 
if ($algo == 'shake128') $hash = shake128($payload, 16/*min. required bytes*/, false);
else if ($algo == 'shake256') $hash = shake256($payload, 16/*min. required bytes*/, false);
else $hash = hash($algo, $payload, false);
break;
}
}
 
if ($hash == null) {
throw new Exception("Unknown Hash Space UUID $hash_uuid");
}
 
$hash[12] = '8'; // Set version: 8 = Custom
$hash[16] = dechex(hexdec($hash[16]) & 0b0011 | 0b1000); // Set variant to "0b10__" (RFC4122/DCE1.1)
 
return substr($hash, 0, 8).'-'.
substr($hash, 8, 4).'-'.
substr($hash, 12, 4).'-'.
substr($hash, 16, 4).'-'.
substr($hash, 20, 12);
}
 
/**
* Collection of Namebased UUIDv8 Hash Space IDs
* @return array An array containing tuples of [PHP Algo Name, Hash Space UUID, Human friendly name, Hash Space Author, Available]
*/
function get_uuidv8_hash_space_ids(): array {
$out = array();
 
// The following Hash Space UUIDs are defined in the RFC4122bis as Example for Namebased UUIDv8
$out[] = ['sha224', '59031ca3-fbdb-47fb-9f6c-0f30e2e83145', 'SHA2-224', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha256', '3fb32780-953c-4464-9cfd-e85dbbe9843d', 'SHA2-256', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha384', 'e6800581-f333-484b-8778-601ff2b58da8', 'SHA2-384', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha512', '0fde22f2-e7ba-4fd1-9753-9c2ea88fa3f9', 'SHA2-512', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha512/224', '003c2038-c4fe-4b95-a672-0c26c1b79542', 'SHA2-512/224', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha512/256', '9475ad00-3769-4c07-9642-5e7383732306', 'SHA2-512/256', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha3-224', '9768761f-ac5a-419e-a180-7ca239e8025a', 'SHA3-224', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha3-256', '2034d66b-4047-4553-8f80-70e593176877', 'SHA3-256', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha3-384', '872fb339-2636-4bdd-bda6-b6dc2a82b1b3', 'SHA3-384', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['sha3-512', 'a4920a5d-a8a6-426c-8d14-a6cafbe64c7b', 'SHA3-512', 'RFC Example', PHP_VERSION_ID >= 70100];
$out[] = ['shake128'/*Currently no PHP core algorithm!*/, '7ea218f6-629a-425f-9f88-7439d63296bb', 'SHAKE-128', 'RFC Example', file_exists(__DIR__.'/SHA3.php')];
$out[] = ['shake256'/*Currently no PHP core algorithm!*/, '2e7fc6a4-2919-4edc-b0ba-7d7062ce4f0a', 'SHAKE-256', 'RFC Example', file_exists(__DIR__.'/SHA3.php')];
 
// The following Hash Space UUIDs are defined by ViaThinkSoft
// These Hash Spaces can be calculated as follows:
// UUIDv8_NamebasedViaThinkSoft := <HashAlgo>_AsUUIDv8( BinaryHashSpaceUUID + BinaryNamespaceUUID + Data )
// BinaryHashSpaceUUID := SHA1_AsUUIDv5( hex2bin('1ee317e2-1853-64b2-8fe9-3c4a92df8582') + PhpHashAlgoName )
foreach (hash_algos() as $algo) {
if ($algo == 'md5') continue; // MD5 is already used in UUIDv3
if ($algo == 'sha1') continue; // MD5 is already used in UUIDv5
foreach ($out as list($algo2,$space,$friendlyName,$author)) {
if ($algo == $algo2) continue 2; // UUID is already defined by RFC, don't need a VTS Hash Space UUID
}
if (strlen(hash($algo,'',false)) < 32) continue; // Hash too short (needs at least 16 bytes)
$out[] = [$algo, gen_uuid_v5('1ee317e2-1853-64b2-8fe9-3c4a92df8582', $algo), strtoupper($algo), 'ViaThinkSoft', true];
}
 
// How to update this list $unavailable_algos:
// 1. Look if new hashes are listed in the PHP documentation: https://www.php.net/manual/de/function.hash-algos.php
// 2. If the required version is lower than our server version, then you don't need to do anything
// 3. Otherwise, run this command on a different machine (where the algorithms are implemented) to check if the hashes have the correct length
// foreach (hash_algos() as $algo) {
// $len = strlen(hash($algo, '', false));
// if ($len >= 32) echo "$algo, length $len\n";
// }
// 4. Then, include all fitting hashes here
// 5. Please publish the new hash space IDs here: https://oidplus.viathinksoft.com/oidplus/?goto=guid%3Auuid_mac_utils%2Fuuidv8_hash_space_vts
$unavailable_algos = [];
if (PHP_VERSION_ID < 80100/*8.1.0*/) {
$unavailable_algos[] = 'murmur3c'; // length: 16 bytes
$unavailable_algos[] = 'murmur3f'; // length: 16 bytes
$unavailable_algos[] = 'xxh128'; // length: 16 bytes
}
foreach ($unavailable_algos as $algo) {
$out[] = [$algo, gen_uuid_v5('1ee317e2-1853-64b2-8fe9-3c4a92df8582', $algo), strtoupper($algo), 'ViaThinkSoft', false];
}
 
return $out;
}
 
# --------------------------------------
 
// http://php.net/manual/de/function.hex2bin.php#113057
1291,3 → 1396,19
return(gmp_div_q($x,gmp_pow(2,$n)));
}
}
 
function shake128(string $msg, int $outputLength=512, bool $binary=false): string {
include_once __DIR__.'/SHA3.php';
$sponge = SHA3::init(SHA3::SHAKE128);
$sponge->absorb($msg);
$bin = $sponge->squeeze($outputLength);
return $binary ? $bin : bin2hex($bin);
}
 
function shake256(string $msg, int $outputLength=512, bool $binary=false): string {
include_once __DIR__.'/SHA3.php';
$sponge = SHA3::init(SHA3::SHAKE256);
$sponge->absorb($msg);
$bin = $sponge->squeeze($outputLength);
return $binary ? $bin : bin2hex($bin);
}
/trunk/vendor/licenses
16,8 → 16,8
danielmarschall/php-sha3 dev-master 5605bd5 MIT
danielmarschall/php_utils 9999999-dev 2f698ec Apache-2.0
danielmarschall/php_utils dev-master 2f698ec Apache-2.0
danielmarschall/uuid_mac_utils 9999999-dev ce6991c Apache-2.0
danielmarschall/uuid_mac_utils dev-master ce6991c Apache-2.0
danielmarschall/uuid_mac_utils 9999999-dev d85c3e4 Apache-2.0
danielmarschall/uuid_mac_utils dev-master d85c3e4 Apache-2.0
danielmarschall/vnag 9999999-dev 1c01739 Apache-2.0
danielmarschall/vnag dev-master 1c01739 Apache-2.0
dcodeio/bcrypt.js master master BSD-3-Clause, MIT