diff options
author | Ritu Sood <ritu.sood@intel.com> | 2018-05-22 14:17:11 +0000 |
---|---|---|
committer | Ritu Sood <ritu.sood@intel.com> | 2018-05-22 14:18:52 +0000 |
commit | c0d83014c92cacd461cec72e2904bea525e1c6cd (patch) | |
tree | 4fa403666a9ceda3c0f81b05c90b3c79a6f585f7 /TPM2-Plugin/lib | |
parent | c1c9bfcabc4a5e4147d19c599de7d9bf925fa98b (diff) |
Allocating memory for modulus and exponent
SoftHsm expects memory to be allocated by
the plugin
Issue-ID: AAF-260
Change-Id: I4ef93918a91971680f1f46517a46a29717a096b2
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Diffstat (limited to 'TPM2-Plugin/lib')
-rw-r--r-- | TPM2-Plugin/lib/tpm2_plugin_api.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/TPM2-Plugin/lib/tpm2_plugin_api.c b/TPM2-Plugin/lib/tpm2_plugin_api.c index 356ce7b..b949e48 100644 --- a/TPM2-Plugin/lib/tpm2_plugin_api.c +++ b/TPM2-Plugin/lib/tpm2_plugin_api.c @@ -384,11 +384,18 @@ int read_public(TSS2_SYS_CONTEXT *sapi_context, importkey_info->modulus_size = public.t.publicArea.unique.rsa.t.size; printf("importkey_info->modulus_size = %ld \n", importkey_info->modulus_size); - memcpy(importkey_info->modulus, &public.t.publicArea.unique.rsa.t.buffer, importkey_info->modulus_size); + importkey_info->modulus = (unsigned char *) malloc(importkey_info->modulus_size); + if (importkey_info->modulus != NULL) { + memcpy(importkey_info->modulus, &public.t.publicArea.unique.rsa.t.buffer, importkey_info->modulus_size); + } importkey_info->exponent_size = sizeof(public.t.publicArea.parameters.rsaDetail.exponent); printf("importkey_info->exponent_size = %ld \n", importkey_info->exponent_size); - memcpy(importkey_info->exponent, &public.t.publicArea.parameters.rsaDetail.exponent, importkey_info->exponent_size); + importkey_info->exponent = (unsigned char *) malloc(importkey_info->exponent_size); + if (importkey_info->exponent != NULL) { + memcpy(importkey_info->exponent, &public.t.publicArea.parameters.rsaDetail.exponent, importkey_info->exponent_size); + } + //*importkey_info->exponent = public.t.publicArea.parameters.rsaDetail.exponent; return 0; |