ns_crypto::JWT method jwk_supports_alg (protected)

 <instance of ns_crypto::JWT[i]> jwk_supports_alg jwk alg

Defined in

Conservative compatibility check. If "alg" is present in the JWK, require exact match. Otherwise infer from kty/crv.

Parameters:
jwk (required)
alg (required)

Testcases:
No testcase defined.
Source code:
if {[dict exists $jwk alg]} {
    return [string equal [dict get $jwk alg] $alg]
}

dict with jwk {
    switch -- $alg {
        ES256  {return [expr {$kty eq "EC"  && $crv eq "P-256"     }]}
        ES256K {return [expr {$kty eq "EC"  && $crv eq "secp256k1" }]}
        ES384  {return [expr {$kty eq "EC"  && $crv eq "P-384"     }]}
        ES512  {return [expr {$kty eq "EC"  && $crv eq "P-521"     }]}
        RS256 -
        RS384 -
        RS512  {return [expr {$kty eq "RSA"}]}
        EdDSA  {return [expr {$kty eq "OKP" && $crv in {"Ed25519" "Ed448"}}]}
        default {
            return 0
        }
    }
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: