Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Data hash verification does not respect assertion's alg field #574

Closed
cyraxx opened this issue Aug 30, 2024 · 1 comment · Fixed by #613
Closed

Data hash verification does not respect assertion's alg field #574

cyraxx opened this issue Aug 30, 2024 · 1 comment · Fixed by #613

Comments

@cyraxx
Copy link

cyraxx commented Aug 30, 2024

Taken from the spec regarding the alg field in data-hash-map: (emphasis mine)

? "alg":tstr .size (1..max-tstr-length) ; A string identifying the cryptographic hash algorithm used to compute the hash in this assertion, taken from the C2PA hash algorithm identifier list. If this field is absent, the hash algorithm is taken the alg value of the enclosing structure. If both are present, the field in this structure is used. If no value is present in any of these places, this structure is invalid; there is no default.

However, data_hash.verify_hash() only uses the supplied alg parameter from the claim, not self.alg:

let curr_alg = alg.unwrap_or("sha256");

Notably, verify_stream_hash() seems to do it correctly:

let curr_alg = match &self.alg {
Some(a) => a.clone(),
None => match alg {
Some(a) => a.to_owned(),
None => "sha256".to_string(),
},
};

@mauricefisher64
Copy link
Collaborator

Thanks, I will take a look.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants