parallaxsecond / rust-tss-esapi

TSS 2.0 Enhanced System API (ESAPI) Rust wrapper
https://docs.rs/tss-esapi/
Apache License 2.0
88 stars 52 forks source link

Support Created Loaded #506

Open Firstyear opened 8 months ago

Firstyear commented 8 months ago

CreateLoaded is required for key derivation. We should add it to this library to allow KDF usage for applications.

Firstyear commented 5 months ago

So let's say I wanted to implement this. Looking at other parts of the code I'm thinking that it's going to be a call to:

extern "C" {
    pub fn Esys_CreateLoaded(
        esysContext: *mut ESYS_CONTEXT,
        parentHandle: ESYS_TR,
        shandle1: ESYS_TR,
        shandle2: ESYS_TR,
        shandle3: ESYS_TR,
        inSensitive: *const TPM2B_SENSITIVE_CREATE,
        inPublic: *const TPM2B_TEMPLATE,
        objectHandle: *mut ESYS_TR,
        outPrivate: *mut *mut TPM2B_PRIVATE,
        outPublic: *mut *mut TPM2B_PUBLIC,
    ) -> TSS2_RC;
}

This would go in tss-esapi/src/context/tpm_commands/object_commands.rs along with fn create / fn load since we are deriving a new object. Does this seem like that right start?

I'll need to figure out what to do with tests too.

Superhepper commented 5 months ago

The commands or APIs are usually structured after in what section they appear in the TPM specification (if I am not mistaken).

Superhepper commented 5 months ago

That seems correct. There is even a comment at the bottom of that file indicating that that API has not been implemented yet.

ionut-arm commented 5 months ago

Luckily this seems to not involve any new structures that need native implementations, which is usually 80% of the work for new commands..

Firstyear commented 5 months ago

Thanks, I've started to work on this now :)