phalcon/cphalcon · error · UnsupportedHmacAlgorithm

Unsupported HMAC algorithm

Error message

Unsupported HMAC algorithm

What it means

Thrown by the Hmac signer constructor when the algo argument is not one of the supported hash algorithms ('sha512', 'sha384', 'sha256'). Any other hash name passed to new Hmac() is rejected. Use one of the three supported algorithms.

Solutions

  1. Use one of sha512, sha384 or sha256 when constructing the HMAC signer
  2. Pick a different signer class (e.g. OpenSSL-based) for other algorithms
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Encryption/Security/JWT/Signer/Hmac.zep:42 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/e0e93adc2ad01719. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Encryption/Security/JWT/Signer/Hmac.zep:42

    /**
     * Hmac constructor.
     *
     * @param string $algo
     *
     * @throws UnsupportedAlgorithmException
     */
    public function __construct( string algo = "sha512")
    {
        array supported;

        let supported = [
            "sha512" : 1,
            "sha384" : 1,
            "sha256" : 1
        ];

        if !isset supported[algo] {
            throw new UnsupportedHmacAlgorithm();
        }

        let this->algorithm = algo;
    }

    /**
     * Return the value that is used for the "alg" header
     *
     * @return string
     */
    public function getAlgHeader() -> string
    {
        return "HS" . str_replace("sha", "", this->algorithm);
    }

    /**
     * Sign a payload using the passphrase
     *

View on GitHub (pinned to b7419de9cd)