commit ed3c238aebfc31d4c19a140d563aa70fdac0b25e
parent 95c1f8838a54478a60fb4b205b31a676af2a7d94
Author: mauricefisher64 <92736594+mauricefisher64@users.noreply.github.com>
Date: Tue, 7 Mar 2023 17:02:30 -0500
Fix async path to support ingredient box hashing (#201)
Fix asyn path to support ingredient box hashing
Diffstat:
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/sdk/src/store.rs b/sdk/src/store.rs
@@ -1213,12 +1213,22 @@ impl Store {
let label = Store::manifest_label_from_path(&c2pa_manifest.url());
if let Some(ingredient) = store.get_claim(&label) {
- if !verify_by_alg(
- ingredient.alg(),
- &c2pa_manifest.hash(),
- &ingredient.data()?,
- None,
- ) {
+ let alg = match c2pa_manifest.alg() {
+ Some(a) => a,
+ None => ingredient.alg().to_owned(),
+ };
+
+ // get the 1.1-1.2 box hash
+ let no_hash: Vec<u8> = Vec::new();
+ let box_hash = store
+ .manifest_box_hash_cache
+ .get(&label)
+ .unwrap_or(&no_hash);
+
+ // test for 1.1 hash then 1.0 version
+ if !vec_compare(&c2pa_manifest.hash(), box_hash)
+ && !verify_by_alg(&alg, &c2pa_manifest.hash(), &ingredient.data()?, None)
+ {
let log_item = log_item!(
&c2pa_manifest.url(),
"ingredient hash incorrect",