Skip to content

Commit 2baa4d3

Browse files
committed
Public: add function to access SymmetricDefinitionObject
Signed-off-by: Thore Sommer <mail@thson.de>
1 parent b3eb462 commit 2baa4d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tss-esapi/src/structures/tagged/public.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use log::error;
2121
use std::convert::{TryFrom, TryInto};
2222
use tss_esapi_sys::{TPMU_PUBLIC_ID, TPMU_PUBLIC_PARMS};
2323

24+
use super::symmetric::SymmetricDefinitionObject;
25+
2426
/// A builder for the [Public] type.
2527
#[derive(Debug, Clone)]
2628
pub struct PublicBuilder {
@@ -374,6 +376,16 @@ impl Public {
374376
}
375377
}
376378

379+
/// Returns the name symmetric definition object if available
380+
pub fn symmetric_algorithm(&self) -> Result<SymmetricDefinitionObject> {
381+
match self {
382+
Public::Rsa { parameters, .. } => Ok(parameters.symmetric_definition_object()),
383+
Public::KeyedHash { .. } => Err(Error::local_error(WrapperErrorKind::InvalidParam)),
384+
Public::Ecc { parameters, .. } => Ok(parameters.symmetric_definition_object()),
385+
Public::SymCipher { parameters, .. } => Ok(parameters.symmetric_definition_object()),
386+
}
387+
}
388+
377389
/// Returns the auth policy digest.
378390
pub fn auth_policy(&self) -> &Digest {
379391
match self {

0 commit comments

Comments
 (0)