c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

commit 48df00c7ac5d81557c8f4c8bcc2a281555daf2ab
parent a9598cb1ae291324b2ba8bed77fbf79ed78e1d00
Author: Dave Kozma <dkozma@adobe.com>
Date:   Fri, 10 Mar 2023 10:05:12 -0500

Fix hash algo warning in Wasm and hashing for RSA-PSS SHA-384/512 (#206)


Diffstat:
Msdk/src/wasm/webcrypto_validator.rs | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sdk/src/wasm/webcrypto_validator.rs b/sdk/src/wasm/webcrypto_validator.rs @@ -154,7 +154,10 @@ async fn async_validate( .map_err(|err| Error::WasmRsaKeyImport(err.to_string()))?; let (_, seq) = parse_ber_sequence(spki.subject_public_key) .map_err(|err| Error::WasmRsaKeyImport(err.to_string()))?; - let hashed_data = hash_by_alg(&hash, &data, None); + // We need to normalize this from SHA-256 (the format WebCrypto uses) to sha256 + // (the format the util function expects) so that it maps correctly + let normalized_hash = hash.clone().replace("-", "").to_lowercase(); + let hashed_data = hash_by_alg(&normalized_hash, &data, None); let modulus = biguint_val(&seq[0]); let exp = biguint_val(&seq[1]); let public_key = RsaPublicKey::new(modulus, exp)