src/site/php/argon2 fix.php

Functions

cfw_argon2_available()

cfw_argon2_available() : bool

Returns

bool —

cfw_argon2_b64()

cfw_argon2_b64(string  $raw) : string

unpadded base64, which is what PHP's own argon2 encoding uses

Parameters

string $raw

The bytes to encode.

Returns

string —

cfw_argon2_raw()

cfw_argon2_raw(string  $password, string  $salt, int  $m, int  $t, int  $p, int  $tagLen = 32) : string|false|null

Parameters

string $password

The password bytes.

string $salt

The salt bytes.

int $m

Memory cost in KiB.

int $t

Time cost.

int $p

Lanes.

int $tagLen

Output length in bytes.

Returns

string|false|null —

The raw tag, FALSE when the reply was not base64, or NULL when the host refused.

cfw_argon2_hash()

cfw_argon2_hash(string  $password, int  $m = 19456, int  $t = 2, int  $p = 1) : string|null

Hashes into PHP's own encoded form.

Parameters

string $password

The password to hash.

int $m

Memory cost in KiB.

int $t

Time cost.

int $p

Lanes.

Returns

string|null —

The encoded hash, or NULL when the host refused.

cfw_argon2_verify()

cfw_argon2_verify(string  $password, string  $encoded) : bool

Verifies against an encoded hash, in constant time.

hash_equals() rather than ===, because a byte-at-a-time comparison of a password digest is a timing oracle even when the digest itself is memory-hard.

Parameters

string $password

The password to check.

string $encoded

A hash cfw_argon2_hash() or PHP's own password_hash() wrote.

Returns

bool —

cfw_argon2_needs_rehash()

cfw_argon2_needs_rehash(string  $encoded, int  $m = 19456, int  $t = 2, int  $p = 1) : bool

whether an existing encoded hash was written with weaker parameters than today's

Parameters

string $encoded

The stored hash.

int $m

Memory cost in KiB.

int $t

Time cost.

int $p

Lanes.

Returns

bool —