aboutsummaryrefslogtreecommitdiffstats
path: root/TPM2-Plugin/lib
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-05-25 04:27:27 +0000
committerGerrit Code Review <gerrit@onap.org>2018-05-25 04:27:27 +0000
commit6555a5b1d73768aedd78bb51fd5e5403c9b120a4 (patch)
tree46b930797e43387d0b069f14467d10ea538162a8 /TPM2-Plugin/lib
parent51c023f164c10a79e1572faacfc4bc4512daf233 (diff)
parentc0d83014c92cacd461cec72e2904bea525e1c6cd (diff)
Merge "Allocating memory for modulus and exponent"
Diffstat (limited to 'TPM2-Plugin/lib')
-rw-r--r--TPM2-Plugin/lib/tpm2_plugin_api.c11
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 861c2aa..75e4fc1 100644
--- a/TPM2-Plugin/lib/tpm2_plugin_api.c
+++ b/TPM2-Plugin/lib/tpm2_plugin_api.c
@@ -383,11 +383,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;