ellite/Wallos · error · InvalidArgumentException

The " " digest is not supported.

Error message

The "%s" digest is not supported.

What it means

The 'algorithm' entry of the parameter map lowercases the value and checks it against hash_algos(). If the requested HMAC digest is not provided by the installed PHP hash extension, setParameter('algorithm', ...) throws this InvalidArgumentException.

Solutions

  1. Use a standard digest: 'sha1', 'sha256', or 'sha512'
  2. Verify with in_array($algo, hash_algos(), true) before setting
  3. If the algorithm must exist, install/enable the PHP hash extension providing it

Example fix

// before
$otp->setParameter('algorithm', 'HMAC-SHA256');
// after
$otp->setParameter('algorithm', 'sha256');
Defensive patterns

Strategy: validation

Validate before calling

$algo = strtolower($config['algorithm'] ?? 'sha1');
if (!in_array($algo, hash_algos(), true)) {
    $algo = 'sha1';
}
$otp->setParameter('algorithm', $algo);

Try / catch

try {
    $otp->setParameter('algorithm', $config['algorithm']);
} catch (\InvalidArgumentException $e) {
    $otp->setParameter('algorithm', 'sha1');
}

Prevention

When it happens

Trigger: Calling setParameter('algorithm', 'sha3-256') or any algorithm name not present in hash_algos(); also misspelled names like 'sha257' or legacy names like 'hmac-sha1'.

Common situations: Using an algorithm an authenticator app supports but the PHP build does not (or vice versa); running on a PHP compiled without certain hash algorithms; typos in algorithm names in config files.

Related errors


AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13). Data as JSON: /api/errors/21cead502ae31189. Report an issue: GitHub.

Appendix: source

Thrown at libs/OTPHP/ParameterTrait.php:163

    /**
     * @return array<non-empty-string, callable>
     */
    protected function getParameterMap(): array
    {
        return [
            'label' => function (string $value): string {
                assert($value !== '');
                $this->hasColon($value) === false || throw new InvalidArgumentException(
                    'Label must not contain a colon.'
                );

                return $value;
            },
            'secret' => static fn (string $value): string => strtoupper(trim($value, '=')),
            'algorithm' => static function (string $value): string {
                $value = strtolower($value);
                in_array($value, hash_algos(), true) || throw new InvalidArgumentException(sprintf(
                    'The "%s" digest is not supported.',
                    $value
                ));

                return $value;
            },
            'digits' => static function ($value): int {
                $value > 0 || throw new InvalidArgumentException('Digits must be at least 1.');

                return (int) $value;
            },
            'issuer' => function (string $value): string {
                assert($value !== '');
                $this->hasColon($value) === false || throw new InvalidArgumentException(
                    'Issuer must not contain a colon.'
                );

                return $value;

View on GitHub (pinned to 52820e87ca)