Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe Hash

Fonctions membres publiques

 __construct ($hash='sha256')
 
 setKey ($key=false)
 
 setNonce ($nonce=false)
 
 getHash ()
 
 setHash ($hash)
 
 hash ($text)
 
 getLength ()
 
 getLengthInBytes ()
 
 getBlockLength ()
 
 getBlockLengthInBytes ()
 
 __toString ()
 

Champs de données

const PADDING_KECCAK = 1
 
const PADDING_SHA3 = 2
 
const PADDING_SHAKE = 3
 

Fonctions membres privées

 computeKey ()
 
 kdf ($index, $numbytes)
 
 pdf ()
 
 uhash ($m, $taglen)
 

Fonctions membres privées statiques

static L1Hash ($k, $m)
 
static nh ($k, $m, $length)
 
static L2Hash ($k, $m)
 
static poly ($wordbits, $maxwordrange, $k, $m)
 
static L3Hash ($k1, $k2, $m)
 
static sha3_pad ($padLength, $padType)
 
static sha3_32 ($p, $c, $r, $d, $padType)
 
static processSHA3Block32 (&$s)
 
static rotateLeft32 ($x, $shift)
 
static sha3_64 ($p, $c, $r, $d, $padType)
 
static processSHA3Block64 (&$s)
 
static rotateLeft64 ($x, $shift)
 
static sha512 ($m, $hash)
 

Attributs privés

 $paddingType = 0
 
 $hashParam
 
 $length
 
 $algo
 
 $key = false
 
 $nonce = false
 
 $parameters = []
 
 $computedKey = false
 
 $opad
 
 $ipad
 
 $recomputeAESKey
 
 $c
 
 $pad
 

Attributs privés statiques

static $factory36
 
static $factory64
 
static $factory128
 
static $offset64
 
static $offset128
 
static $marker64
 
static $marker128
 
static $maxwordrange64
 
static $maxwordrange128
 

Documentation des constructeurs et destructeur

◆ __construct()

__construct (   $hash = 'sha256')

#- Default Constructor.

Paramètres
string$hashpublic

Références $hash, et Hash\setHash().

Documentation des fonctions membres

◆ __toString()

__toString ( )

__toString() magic method

Références Hash\getHash().

◆ computeKey()

computeKey ( )
private

Pre-compute the key used by the HMAC

Quoting http://tools.ietf.org/html/rfc2104#section-2, "Applications that use keys longer than B bytes will first hash the key using H and then use the resultant L byte string as the actual key to HMAC."

As documented in https://www.reddit.com/r/PHP/comments/9nct2l/symfonypolyfill_hash_pbkdf2_correct_fix_for/ when doing an HMAC multiple times it's faster to compute the hash once instead of computing it during every call

private

Références Hash\$key, Hash\getBlockLengthInBytes(), et Hash\hash().

Référencé par Hash\setHash(), et Hash\setKey().

◆ getBlockLength()

getBlockLength ( )

Returns the block length (in bits)

public

Renvoie
int

◆ getBlockLengthInBytes()

getBlockLengthInBytes ( )

Returns the block length (in bytes)

public

Renvoie
int

Référencé par Hash\computeKey().

◆ getHash()

getHash ( )

Gets the hash function.

As set by the constructor or by the setHash() method.

public

Renvoie
string

Références Hash\$hashParam.

Référencé par Hash\__toString().

◆ getLength()

getLength ( )

Returns the hash length (in bits)

public

Renvoie
int

◆ getLengthInBytes()

getLengthInBytes ( )

Returns the hash length (in bytes)

public

Renvoie
int

Références Hash\$length.

◆ hash()

hash (   $text)

Compute the Hash / HMAC / UMAC.

public

Paramètres
string$text
Renvoie
string

Références Hash\$algo, $b, Hash\$key, Hash\$maxwordrange128, Hash\$maxwordrange64, $output, Hash\$pad, $temp, $text, Hash\pdf(), et Hash\uhash().

Référencé par Hash\computeKey().

◆ kdf()

kdf (   $index,
  $numbytes 
)
private

KDF: Key-Derivation Function

The key-derivation function generates pseudorandom bits used to key the hash functions.

Paramètres
int$indexa non-negative integer less than 2^64
int$numbytesa non-negative integer less than 2^64
Renvoie
string string of length numbytes bytes

Référencé par Hash\pdf(), et Hash\uhash().

◆ L1Hash()

static L1Hash (   $k,
  $m 
)
staticprivate

L1-HASH Algorithm

The first-layer hash breaks the message into 1024-byte chunks and hashes each with a function called NH. Concatenating the results forms a string, which is up to 128 times shorter than the original.

Paramètres
string$kstring of length 1024 bytes.
string$mstring of length less than 2^67 bits.
Renvoie
string string of length (8 * ceil(bitlength(M)/8192)) bytes.

Références $i, Hash\$length, et Hash\$pad.

◆ L2Hash()

static L2Hash (   $k,
  $m 
)
staticprivate

L2-HASH: Second-Layer Hash

The second-layer rehashes the L1-HASH output using a polynomial hash called POLY. If the L1-HASH output is long, then POLY is called once on a prefix of the L1-HASH output and called using different settings on the remainder. (This two-step hashing of the L1-HASH output is needed only if the message length is greater than 16 megabytes.) Careful implementation of POLY is necessary to avoid a possible timing attack (see Section 6.6 for more information).

Paramètres
string$kstring of length 24 bytes.
string$mstring of length less than 2^64 bytes.
Renvoie
string string of length 16 bytes.

Références Hash\$length, et Hash\$pad.

◆ L3Hash()

static L3Hash (   $k1,
  $k2,
  $m 
)
staticprivate

L3-HASH: Third-Layer Hash

The output from L2-HASH is 16 bytes long. This final hash function hashes the 16-byte string to a fixed length of 4 bytes.

Paramètres
string$k1string of length 64 bytes.
string$k2string of length 4 bytes.
string$mstring of length 16 bytes.
Renvoie
string string of length 4 bytes.

Références $i.

◆ nh()

static nh (   $k,
  $m,
  $length 
)
staticprivate

NH Algorithm

Paramètres
string$kstring of length 1024 bytes.
string$mstring with length divisible by 32 bytes.
Renvoie
string string of length 8 bytes.

Références $i, Hash\$length, et $temp.

◆ pdf()

pdf ( )
private

PDF Algorithm

Renvoie
string string of length taglen bytes.

Références Hash\$c, Hash\$key, $last, Hash\$length, Hash\$nonce, et Hash\kdf().

Référencé par Hash\hash().

◆ poly()

static poly (   $wordbits,
  $maxwordrange,
  $k,
  $m 
)
staticprivate

POLY Algorithm

Paramètres
int$wordbitsthe integer 64 or 128.
BigInteger$maxwordrangepositive integer less than 2^wordbits.
BigInteger$kinteger in the range 0 ... prime(wordbits) - 1.
string$mstring with length divisible by (wordbits / 8) bytes.
Renvoie
integer in the range 0 ... prime(wordbits) - 1.

Références Joomla\Database\Query\$offset.

◆ processSHA3Block32()

static processSHA3Block32 ( $s)
staticprivate

32-bit block processing method for SHA3

private

Paramètres
array$s

Références $i, et $temp.

◆ processSHA3Block64()

static processSHA3Block64 ( $s)
staticprivate

64-bit block processing method for SHA3

private

Paramètres
array$s

Références $i, et $temp.

◆ rotateLeft32()

static rotateLeft32 (   $x,
  $shift 
)
staticprivate

Rotate 32-bit int

private

Paramètres
array$x
int$shift

◆ rotateLeft64()

static rotateLeft64 (   $x,
  $shift 
)
staticprivate

Rotate 64-bit int

private

Paramètres
int$x
int$shift

◆ setHash()

setHash (   $hash)

Sets the hash function.

public

Paramètres
string$hash

Références $b, $hash, $i, Hash\$length, Hash\$paddingType, et Hash\computeKey().

Référencé par Hash\__construct().

◆ setKey()

setKey (   $key = false)

Sets the key for HMACs

Keys can be of any length.

public

Paramètres
string$key

Références Hash\$key, et Hash\computeKey().

◆ setNonce()

setNonce (   $nonce = false)

Sets the nonce for UMACs

Keys can be of any length.

public

Paramètres
string$nonce

Références Hash\$nonce.

◆ sha3_32()

static sha3_32 (   $p,
  $c,
  $r,
  $d,
  $padType 
)
staticprivate

Pure-PHP 32-bit implementation of SHA3

Whereas BigInteger.php's 32-bit engine works on PHP 64-bit this 32-bit implementation of SHA3 will not work on PHP 64-bit. This is because this implementation employees bitwise NOTs and bitwise left shifts. And the round constants only work on 32-bit PHP. eg. dechex(-2147483648) returns 80000000 on 32-bit PHP and FFFFFFFF80000000 on 64-bit PHP. Sure, we could do bitwise ANDs but that would slow things down.

SHA512 requires BigInteger to simulate 64-bit unsigned integers because SHA2 employees addition whereas SHA3 just employees bitwise operators. PHP64 only supports signed 64-bit integers, which complicates addition, whereas that limitation isn't an issue for SHA3.

In https://ws680.nist.gov/publication/get_pdf.cfm?pub_id=919061#page=16 KECCAK[C] is defined as "the KECCAK instance with KECCAK-f[1600] as the underlying permutation and capacity c". This is relevant because, altho the KECCAK standard defines a mode (KECCAK-f[800]) designed for 32-bit machines that mode is incompatible with SHA3

private

Paramètres
string$p
int$c
int$r
int$d
int$padType

Références $i, $n, et $r.

◆ sha3_64()

static sha3_64 (   $p,
  $c,
  $r,
  $d,
  $padType 
)
staticprivate

Pure-PHP 64-bit implementation of SHA3

private

Paramètres
string$p
int$c
int$r
int$d
int$padType

Références $i, $n, et $r.

◆ sha3_pad()

static sha3_pad (   $padLength,
  $padType 
)
staticprivate

Pads SHA3 based on the mode

private

Paramètres
int$padLength
int$padType
Renvoie
string

Références $temp.

◆ sha512()

static sha512 (   $m,
  $hash 
)
staticprivate

Pure-PHP implementation of SHA512

private

Paramètres
string$m
array$hash
Renvoie
string

Références $b, Hash\$c, $g, $hash, $i, Hash\$length, $temp, et Strings\shift().

◆ uhash()

uhash (   $m,
  $taglen 
)
private

UHASH Algorithm

Paramètres
string$mstring of length less than 2^67 bits.
int$taglenthe integer 4, 8, 12 or 16.
Renvoie
string string of length taglen bytes.

Références $b, Hash\$c, $i, et Hash\kdf().

Référencé par Hash\hash().

Documentation des champs

◆ $algo

$algo
private

Référencé par Hash\hash().

◆ $c

$c
private

Référencé par Hash\pdf(), Hash\sha512(), et Hash\uhash().

◆ $computedKey

$computedKey = false
private

◆ $factory128

$factory128
staticprivate

◆ $factory36

$factory36
staticprivate

◆ $factory64

$factory64
staticprivate

◆ $hashParam

$hashParam
private

Référencé par Hash\getHash().

◆ $ipad

$ipad
private

◆ $key

$key = false
private

◆ $length

◆ $marker128

$marker128
staticprivate

◆ $marker64

$marker64
staticprivate

◆ $maxwordrange128

$maxwordrange128
staticprivate

Référencé par Hash\hash().

◆ $maxwordrange64

$maxwordrange64
staticprivate

Référencé par Hash\hash().

◆ $nonce

$nonce = false
private

Référencé par Hash\pdf(), et Hash\setNonce().

◆ $offset128

$offset128
staticprivate

◆ $offset64

$offset64
staticprivate

◆ $opad

$opad
private

◆ $pad

$pad
private

Référencé par Hash\hash(), Hash\L1Hash(), et Hash\L2Hash().

◆ $paddingType

$paddingType = 0
private

Référencé par Hash\setHash().

◆ $parameters

$parameters = []
private

◆ $recomputeAESKey

$recomputeAESKey
private

◆ PADDING_KECCAK

const PADDING_KECCAK = 1

Padding Types

private

◆ PADDING_SHA3

const PADDING_SHA3 = 2

Padding Types

private

◆ PADDING_SHAKE

const PADDING_SHAKE = 3

Padding Types

private


La documentation de cette classe a été générée à partir du fichier suivant :