Skip to content

Commit 8d39380

Browse files
authored
fix: populates claim signature field in ingredient v3. (#1027)
1 parent 926abc8 commit 8d39380

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

sdk/src/ingredient.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ impl Ingredient {
11521152

11531153
// add the ingredient manifest_data to the claim
11541154
// this is how any existing claims are added to the new store
1155-
let c2pa_manifest = match self.manifest_data_ref() {
1155+
let (active_manifest, claim_signature) = match self.manifest_data_ref() {
11561156
Some(resource_ref) => {
11571157
let manifest_label = self
11581158
.active_manifest
@@ -1191,14 +1191,13 @@ impl Ingredient {
11911191
{
11921192
let hash = ingredient_store
11931193
.get_manifest_box_hashes(ingredient_active_claim)
1194-
.manifest_box_hash; // get C2PA 1.2 JUMBF box hash
1195-
1196-
// todo: must use this when making v3
1197-
let _sig_hash = ingredient_store
1194+
.manifest_box_hash; // get C2PA 1.2 JUMBF box
1195+
let sig_hash = ingredient_store
11981196
.get_manifest_box_hashes(ingredient_active_claim)
11991197
.signature_box_hash; // needed for v3 ingredients
12001198

12011199
let uri = jumbf::labels::to_manifest_uri(&manifest_label);
1200+
let signature_uri = jumbf::labels::to_signature_uri(&manifest_label);
12021201

12031202
// if there are validations and they have all passed, then use the parent claim thumbnail if available
12041203
if let Some(validation_status) = self.validation_status.as_ref() {
@@ -1221,19 +1220,26 @@ impl Ingredient {
12211220
}
12221221
}
12231222
// generate c2pa_manifest hashed_uri
1224-
Some(crate::hashed_uri::HashedUri::new(
1225-
uri,
1226-
Some(ingredient_active_claim.alg().to_owned()),
1227-
hash.as_ref(),
1228-
))
1223+
(
1224+
Some(crate::hashed_uri::HashedUri::new(
1225+
uri,
1226+
Some(ingredient_active_claim.alg().to_owned()),
1227+
hash.as_ref(),
1228+
)),
1229+
Some(crate::hashed_uri::HashedUri::new(
1230+
signature_uri,
1231+
Some(ingredient_active_claim.alg().to_owned()),
1232+
sig_hash.as_ref(),
1233+
)),
1234+
)
12291235
} else {
1230-
None
1236+
(None, None)
12311237
}
12321238
}
1233-
None => None,
1239+
None => (None, None),
12341240
}
12351241
}
1236-
None => None,
1242+
None => (None, None),
12371243
};
12381244

12391245
// if the ingredient defines a thumbnail, add it to the claim
@@ -1321,13 +1327,14 @@ impl Ingredient {
13211327
match claim.version() {
13221328
1 => {
13231329
ingredient_assertion.document_id = self.document_id.clone();
1324-
ingredient_assertion.c2pa_manifest = c2pa_manifest;
1330+
ingredient_assertion.c2pa_manifest = active_manifest;
13251331
ingredient_assertion
13261332
.validation_status
13271333
.clone_from(&self.validation_status);
13281334
}
13291335
2 => {
1330-
ingredient_assertion.active_manifest = c2pa_manifest;
1336+
ingredient_assertion.active_manifest = active_manifest;
1337+
ingredient_assertion.claim_signature = claim_signature;
13311338
ingredient_assertion.validation_results = self.validation_results.clone();
13321339
}
13331340
_ => {}

0 commit comments

Comments
 (0)