diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2019-10-09 14:43:46 -0700 |
---|---|---|
committer | Tadeusz Struk <tadeusz.struk@intel.com> | 2019-10-15 14:56:54 -0700 |
commit | ece734f40413bf2995ebe9c496cbe169f90d8231 (patch) | |
tree | 1d7901677e852fb7b5782e7d7f6438b375f1aa50 | |
parent | 8b635f806f002fac0167fa730f4f761cb3ada724 (diff) | |
download | tpm2-tss-ece734f40413bf2995ebe9c496cbe169f90d8231.tar.gz |
esys: add a new function to retrieve sys context from esys
In some cases it can be necessary to call the underlining
sys function before invoking esys function. One example
would be to retrieve cpHash buffer of a command that needs
to be fed to Esys_PolicySigned or Esys_PolicySecret calls.
This can be done by using the Tss2_Sys_GetCpBuffer()
sys call as long as the user can access the sys context.
Fixes: #1533
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
-rw-r--r-- | include/tss2/tss2_esys.h | 5 | ||||
-rw-r--r-- | lib/tss2-esys.def | 3 | ||||
-rw-r--r-- | lib/tss2-esys.map | 1 | ||||
-rw-r--r-- | src/tss2-esys/esys_context.c | 19 |
4 files changed, 27 insertions, 1 deletions
diff --git a/include/tss2/tss2_esys.h b/include/tss2/tss2_esys.h index 880b829d..e70222e9 100644 --- a/include/tss2/tss2_esys.h +++ b/include/tss2/tss2_esys.h @@ -3228,6 +3228,11 @@ void Esys_Free( void *__ptr); +TSS2_RC +Esys_GetSysContext( + ESYS_CONTEXT *esys_context, + TSS2_SYS_CONTEXT **sys_context); + #ifdef __cplusplus } #endif diff --git a/lib/tss2-esys.def b/lib/tss2-esys.def index ab54aec8..f39a4e7d 100644 --- a/lib/tss2-esys.def +++ b/lib/tss2-esys.def @@ -112,6 +112,7 @@ EXPORTS Esys_GetTime Esys_GetTime_Async Esys_GetTime_Finish + Esys_GetSysContext Esys_HMAC Esys_HMAC_Async Esys_HMAC_Finish @@ -352,4 +353,4 @@ EXPORTS Esys_VerifySignature_Finish Esys_ZGen_2Phase Esys_ZGen_2Phase_Async - Esys_ZGen_2Phase_Finish
\ No newline at end of file + Esys_ZGen_2Phase_Finish diff --git a/lib/tss2-esys.map b/lib/tss2-esys.map index 2c2f8e23..e800833b 100644 --- a/lib/tss2-esys.map +++ b/lib/tss2-esys.map @@ -110,6 +110,7 @@ Esys_GetTime; Esys_GetTime_Async; Esys_GetTime_Finish; + Esys_GetSysContext; Esys_Hash; Esys_Hash_Async; Esys_Hash_Finish; diff --git a/src/tss2-esys/esys_context.c b/src/tss2-esys/esys_context.c index b912a688..e16fd42f 100644 --- a/src/tss2-esys/esys_context.c +++ b/src/tss2-esys/esys_context.c @@ -219,3 +219,22 @@ Esys_SetTimeout(ESYS_CONTEXT * esys_context, int32_t timeout) esys_context->timeout = timeout; return TSS2_RC_SUCCESS; } + +/** Helper function that returns sys contest from the give esys context. + * + * Function returns sys contest from the give esys context. + * @param esys_context [in] ESYS context. + * @param sys_context [out] SYS context. + * @retval TSS2_RC_SUCCESS on Success. + * @retval TSS2_ESYS_RC_BAD_REFERENCE if esys_context of sys_context are NULL. + */ +TSS2_RC +Esys_GetSysContext(ESYS_CONTEXT *esys_context, TSS2_SYS_CONTEXT **sys_context) +{ + if (esys_context == NULL || sys_context == NULL) + return TSS2_ESYS_RC_BAD_REFERENCE; + + *sys_context = esys_context->sys; + + return TSS2_RC_SUCCESS; +} |