pub fn build_verify_algorithm(alg: &Algorithm) -> Result<Object>Available on crate feature
web-crypto and WebAssembly only.Expand description
Builds a WebCrypto algorithm object for use with SubtleCrypto.verify().
This is different from the import algorithm: verify() requires algorithm-specific
parameters like saltLength (RSA-PSS) or hash (ECDSA), while not needing
parameters like namedCurve that are only needed during import.
§Supported Algorithms
| Algorithm | Verify Object |
|---|---|
| RS256/384/512 | { name: "RSASSA-PKCS1-v1_5" } |
| PS256/384/512 | { name: "RSA-PSS", saltLength } |
| ES256/384/512 | { name: "ECDSA", hash } |
| HS256/384/512 | { name: "HMAC" } |
§Errors
Returns Error::UnsupportedForWebCrypto if the algorithm is not supported
by WebCrypto (e.g., EdDSA, Ed25519, Ed448, ES256K).
§Examples
ⓘ
use jwk_simple::{Algorithm, web_crypto};
let alg = Algorithm::Rs256;
let verify_algo = web_crypto::build_verify_algorithm(&alg)?;
// Use with SubtleCrypto.verify()
let subtle = web_crypto::get_subtle_crypto()?;
let result = subtle.verify_with_object_and_buffer_source_and_buffer_source(
&verify_algo, &crypto_key, &signature, &data,
)?;