commit 73574804b62be68e06d8b9c4ceacfba8b08dfca0
parent aa2b5d69bbbaca8b8be180435d4fb2dbd048883c
Author: mauricefisher64 <92736594+mauricefisher64@users.noreply.github.com>
Date: Thu, 21 Dec 2023 11:16:54 -0500
Fix response strings for BMFF and Box hash statuses (#360)
* Fix response strings for BMFF and Box hash statuses
* Add boxhash match to list of success code
Diffstat:
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/sdk/src/assertions/box_hash.rs b/sdk/src/assertions/box_hash.rs
@@ -22,6 +22,7 @@ use crate::{
asset_io::{AssetBoxHash, CAIRead},
error::{Error, Result},
utils::hash_utils::{hash_stream_by_alg, verify_stream_by_alg, HashRange},
+ validation_status::ASSERTION_BOXHASH_UNKNOWN,
};
const ASSERTION_CREATION_VERSION: usize = 1;
@@ -132,12 +133,10 @@ impl BoxHash {
inclusion.set_length(len_to_this_seg + next_source_bm.range_len);
}
} else {
- return Err(Error::HashMismatch(
- "Box hash name out of order".to_owned(),
- ));
+ return Err(Error::HashMismatch(ASSERTION_BOXHASH_UNKNOWN.to_owned()));
}
}
- None => return Err(Error::HashMismatch("Box hash name not found".to_owned())),
+ None => return Err(Error::HashMismatch(ASSERTION_BOXHASH_UNKNOWN.to_owned())),
}
source_index += 1;
}
diff --git a/sdk/src/claim.rs b/sdk/src/claim.rs
@@ -1354,7 +1354,7 @@ impl Claim {
"data hash valid",
"verify_internal"
)
- .validation_status(validation_status::ASSERTION_DATAHASH_MATCH);
+ .validation_status(validation_status::ASSERTION_BMFFHASH_MATCH);
validation_log.log_silent(log_item);
continue;
@@ -1366,7 +1366,7 @@ impl Claim {
"verify_internal"
)
.error(Error::HashMismatch(format!("Asset hash failure: {e}")))
- .validation_status(validation_status::ASSERTION_DATAHASH_MISMATCH);
+ .validation_status(validation_status::ASSERTION_BMFFHASH_MISMATCH);
validation_log.log(
log_item,
@@ -1426,7 +1426,7 @@ impl Claim {
"data hash valid",
"verify_internal"
)
- .validation_status(validation_status::ASSERTION_DATAHASH_MATCH);
+ .validation_status(validation_status::ASSERTION_BOXHASH_MATCH);
validation_log.log_silent(log_item);
continue;
@@ -1438,7 +1438,7 @@ impl Claim {
"verify_internal"
)
.error(Error::HashMismatch(format!("Asset hash failure: {e}")))
- .validation_status(validation_status::ASSERTION_DATAHASH_MISMATCH);
+ .validation_status(validation_status::ASSERTION_BOXHASH_MISMATCH);
validation_log.log(
log_item,
diff --git a/sdk/src/validation_status.rs b/sdk/src/validation_status.rs
@@ -245,6 +245,12 @@ pub const ASSERTION_DATAHASH_MATCH: &str = "assertion.dataHash.match";
/// `ValidationStatus.url()` will point to a C2PA assertion.
pub const ASSERTION_BMFFHASH_MATCH: &str = "assertion.bmffHash.match";
+/// Hash of a box-based asset matches the hash declared in the General Box
+/// Hash assertion.
+///
+/// `ValidationStatus.url()` will point to a C2PA assertion.
+pub const ASSERTION_BOXHASH_MATCH: &str = "assertion.boxesHash.match";
+
/// A non-embedded (remote) assertion was accessible at the time of
/// validation.
///
@@ -432,6 +438,18 @@ pub const ASSERTION_DATAHASH_MISMATCH: &str = "assertion.dataHash.mismatch";
/// `ValidationStatus.url()` will point to a C2PA assertion.
pub const ASSERTION_BMFFHASH_MISMATCH: &str = "assertion.bmffHash.mismatch";
+/// The hash of a box-based asset does not match the hash declared
+/// in the General Boxes hash assertion.
+///
+/// `ValidationStatus.url()` will point to a C2PA assertion.
+pub const ASSERTION_BOXHASH_MISMATCH: &str = "assertion.boxesHash.mismatch";
+
+/// The hash of a box-based asset does not contain boxes in the expected order for
+/// the General Boxes hash assertion.
+///
+/// `ValidationStatus.url()` will point to a C2PA assertion.
+pub const ASSERTION_BOXHASH_UNKNOWN: &str = "assertion.boxesHash.";
+
/// A hard binding assertion is in a cloud data assertion.
///
/// `ValidationStatus.url()` will point to a C2PA assertion.
@@ -482,5 +500,6 @@ pub fn is_success(status_code: &str) -> bool {
| ASSERTION_DATAHASH_MATCH
| ASSERTION_BMFFHASH_MATCH
| ASSERTION_ACCESSIBLE
+ | ASSERTION_BOXHASH_MATCH
)
}