Skip to content

Commit

Permalink
wasm impl
Browse files Browse the repository at this point in the history
  • Loading branch information
UMR1352 committed Oct 16, 2024
1 parent 8e38a34 commit a64f1d4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bindings/wasm/src/verification/jws_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,28 @@ impl WasmEcDSAJwsVerifier {
};
EcDSAJwsVerifier::default().verify(input, &publicKey.0).wasm_result()
}

/// Pre-hashed version of {@link EcDSAJwsVerifier.verify}.
/// # Warning
/// Users of this function **MUST** make sure `signingInput` is the result
/// of a cryptographically-secure hashing algorithm.
#[wasm_bindgen(js_name = verifyPrehashed)]
#[allow(non_snake_case)]
pub fn verify_prehashed(
&self,
alg: WasmJwsAlgorithm,
signingInput: &[u8],
decodedSignature: &[u8],
publicKey: &WasmJwk,
) -> Result<(), JsValue> {
let alg = JwsAlgorithm::try_from(alg)?;
let input = VerificationInput {
alg,
signing_input: signingInput.into(),
decoded_signature: decodedSignature.into(),
};
EcDSAJwsVerifier::default()
.verify_prehashed(input, &publicKey.0)
.wasm_result()
}
}

0 comments on commit a64f1d4

Please sign in to comment.