Skip to content

Commit

Permalink
Support operation with jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear committed Feb 13, 2024
1 parent dafa523 commit 7812cfd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ pub enum TpmError {
TpmIdentityKeyBuilderInvalid,
TpmIdentityKeyCreate,
TpmIdentityKeySign,
TpmIdentityKeyId,
TpmIdentityKeySignatureInvalid,
TpmIdentityKeyEcdsaSigRInvalid,
TpmIdentityKeyEcdsaSigSInvalid,
Expand Down
25 changes: 23 additions & 2 deletions src/tpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,29 @@ impl Tpm for TpmTss {
})
}

fn identity_key_id(&mut self, _key: &IdentityKey) -> Result<Vec<u8>, TpmError> {
Err(TpmError::TpmOperationUnsupported)
fn identity_key_id(&mut self, key: &IdentityKey) -> Result<Vec<u8>, TpmError> {
let key_context = match key {
IdentityKey::TpmEcdsa256 {
key_context,
x509: _,
} => key_context.clone(),
IdentityKey::TpmRsa2048 {
key_context,
x509: _,
} => key_context.clone(),
_ => return Err(TpmError::IncorrectKeyType),
};

self.execute_with_temporary_object_context(key_context, |hsm_ctx, key_handle| {
hsm_ctx
.tpm_ctx
.read_public(key_handle.into())
.map(|(_, name, _qualified_name)| name.value().to_vec())
.map_err(|tpm_err| {
error!(?tpm_err);
TpmError::TpmIdentityKeyId
})
})
}

fn identity_key_sign(&mut self, key: &IdentityKey, input: &[u8]) -> Result<Vec<u8>, TpmError> {
Expand Down

0 comments on commit 7812cfd

Please sign in to comment.