Skip to content

HashAgile: expose the algorithm and the content#658

Open
baloo wants to merge 1 commit into
parallaxsecond:mainfrom
baloo:baloo/push-quoqzunqrzxy
Open

HashAgile: expose the algorithm and the content#658
baloo wants to merge 1 commit into
parallaxsecond:mainfrom
baloo:baloo/push-quoqzunqrzxy

Conversation

@baloo

@baloo baloo commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This allows to verify an hmac signature emitted by a TPM.

@baloo
baloo force-pushed the baloo/push-quoqzunqrzxy branch 3 times, most recently from d14caf0 to 1307816 Compare July 11, 2026 23:12
@baloo

baloo commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

missing clippy lints are fixed in #657, i'll rebase once that merges.

@Superhepper

Copy link
Copy Markdown
Collaborator

Question: Is there any way to reverse the dependency, so that the abstraction stuff remains in the abstraction module, without making things very awkward?

@baloo
baloo force-pushed the baloo/push-quoqzunqrzxy branch from 1307816 to 455334f Compare July 12, 2026 22:48
@baloo

baloo commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

I've moved the implementation in tss-esapi/src/abstraction/hashing.rs, I had to massage the visibility of the fields a bit, but let me know if that's an acceptable alternative.

@baloo
baloo force-pushed the baloo/push-quoqzunqrzxy branch from 455334f to e66a968 Compare July 13, 2026 15:55
@Superhepper

Copy link
Copy Markdown
Collaborator

Yeah, I think its fine. How would the use statements end up looking if I would want to use the functionality?

use tss_esapi::{structures::HashAgile, abstractions::*};

?

Or can it be narrowed down? I mean if this is the case I still think it is reasonable.

@baloo

baloo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

You don't need any use imports.

    let tss_esapi::structures::Signature::Hmac(hmac_sig) = signature else {
        return Err(io::Error::other("expected HMAC signature").into());
    };

    let sig_slice = hmac_sig
        .to_output::<sha2::Sha256>()
        .map_err(|e| io::Error::other(format!("failed to convert HMAC signature: {e}")))?;

You will need to enable abstractions, and rustcrypto features though.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends HashAgile to better support validating TPM-produced HMACs by exposing the hashing algorithm and providing a conversion helper for the digest when using RustCrypto.

Changes:

  • Made HashAgile’s internal fields crate-visible and added a public hashing_algorithm() accessor.
  • Added a RustCrypto-only HashAgile::to_output() helper to convert the stored digest into a digest::Output<H> for a selected RustCrypto hash type.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tss-esapi/src/structures/hash/agile.rs Exposes the stored hashing algorithm via a new accessor and relaxes field visibility for internal use.
tss-esapi/src/abstraction/hashing.rs Adds RustCrypto interoperability (to_output) for extracting HashAgile digest content as a typed RustCrypto output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tss-esapi/src/abstraction/hashing.rs
Comment thread tss-esapi/src/structures/hash/agile.rs Outdated
This allows to verify an hmac signature emitted by a TPM.

Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
@baloo
baloo force-pushed the baloo/push-quoqzunqrzxy branch from e66a968 to 3cd67f9 Compare July 15, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants