mirror of
https://github.com/estkme-group/lpac
synced 2024-09-11 19:40:49 +02:00
fix the public keys don't show correctly (#30)
This commit is contained in:
parent
d36479e9b9
commit
003fd33d27
|
@ -891,7 +891,7 @@ int es10b_authenticate_server(struct euicc_ctx *ctx, char **b64_response, struct
|
|||
|
||||
if (!param->tac)
|
||||
{
|
||||
param->tac = "\x35\x29\x06\x11";
|
||||
param->tac = (const uint8_t *)"\x35\x29\x06\x11";
|
||||
}
|
||||
if (OCTET_STRING_fromBuf(&ctx_params1->choice.ctxParamsForCommonAuthentication.deviceInfo.tac, (const char *)param->tac, 4) < 0)
|
||||
{
|
||||
|
|
|
@ -91,28 +91,33 @@ int es10cex_get_euiccinfo2(struct euicc_ctx *ctx, struct es10cex_euiccinfo2 *inf
|
|||
_versiontype_to_string(info->uicc_firmware_version, sizeof(info->uicc_firmware_version),
|
||||
*asn1resp->javacardVersion);
|
||||
}
|
||||
|
||||
if (asn1resp->globalplatformVersion)
|
||||
{
|
||||
_versiontype_to_string(info->global_platform_version, sizeof(info->global_platform_version),
|
||||
*asn1resp->globalplatformVersion);
|
||||
}
|
||||
|
||||
if (asn1resp->euiccCiPKIdListForVerification.list.count)
|
||||
{
|
||||
info->euicc_ci_public_key_id_list_for_verification = (char **)malloc(sizeof(char*) * (asn1resp->euiccCiPKIdListForVerification.list.count + 1));
|
||||
info->euicc_ci_public_key_id_list_for_verification = (char **)malloc(sizeof(char *) * (asn1resp->euiccCiPKIdListForVerification.list.count + 1));
|
||||
for (int i = 0; i < asn1resp->euiccCiPKIdListForVerification.list.count; i++)
|
||||
{
|
||||
info->euicc_ci_public_key_id_list_for_verification[i] = (char *)malloc((asn1resp->euiccCiPKIdListForVerification.list.array[i]->size * 2 + 1) * sizeof(char));
|
||||
euicc_hexutil_bin2hex(info->euicc_ci_public_key_id_list_for_verification[i], asn1resp->euiccCiPKIdListForVerification.list.array[i]->size * 2 + 1,
|
||||
asn1resp->euiccCiPKIdListForVerification.list.array[i]->buf, asn1resp->euiccCiPKIdListForVerification.list.array[i]->size);
|
||||
asn1resp->euiccCiPKIdListForVerification.list.array[i]->buf, asn1resp->euiccCiPKIdListForVerification.list.array[i]->size);
|
||||
}
|
||||
info->euicc_ci_public_key_id_list_for_verification[asn1resp->euiccCiPKIdListForVerification.list.count] = NULL;
|
||||
}
|
||||
|
||||
if (asn1resp->euiccCiPKIdListForSigning.list.count)
|
||||
{
|
||||
info->euicc_ci_public_key_id_list_for_signing = (char **)malloc(sizeof(char*) * (asn1resp->euiccCiPKIdListForSigning.list.count + 1));
|
||||
info->euicc_ci_public_key_id_list_for_signing = (char **)malloc(sizeof(char *) * (asn1resp->euiccCiPKIdListForSigning.list.count + 1));
|
||||
for (int i = 0; i < asn1resp->euiccCiPKIdListForSigning.list.count; i++)
|
||||
{
|
||||
info->euicc_ci_public_key_id_list_for_signing[i] = (char *)malloc((asn1resp->euiccCiPKIdListForSigning.list.array[i]->size * 2 + 1) * sizeof(char));
|
||||
euicc_hexutil_bin2hex(info->euicc_ci_public_key_id_list_for_signing[i], asn1resp->euiccCiPKIdListForSigning.list.array[i]->size * 2 + 1,
|
||||
asn1resp->euiccCiPKIdListForSigning.list.array[i]->buf, asn1resp->euiccCiPKIdListForSigning.list.array[i]->size);
|
||||
asn1resp->euiccCiPKIdListForSigning.list.array[i]->buf, asn1resp->euiccCiPKIdListForSigning.list.array[i]->size);
|
||||
}
|
||||
info->euicc_ci_public_key_id_list_for_signing[asn1resp->euiccCiPKIdListForSigning.list.count] = NULL;
|
||||
}
|
||||
|
@ -133,24 +138,21 @@ exit:
|
|||
return fret;
|
||||
}
|
||||
|
||||
int es10cex_free_euiccinfo2(struct es10cex_euiccinfo2 *info)
|
||||
void es10cex_free_euiccinfo2(struct es10cex_euiccinfo2 *info)
|
||||
{
|
||||
if (info->euicc_ci_public_key_id_list_for_verification)
|
||||
{
|
||||
char **p = info->euicc_ci_public_key_id_list_for_verification;
|
||||
while (*p)
|
||||
{
|
||||
free(*p++);
|
||||
}
|
||||
for (int i = 0; info->euicc_ci_public_key_id_list_for_verification[i] != NULL; i++)
|
||||
free(info->euicc_ci_public_key_id_list_for_verification[i]);
|
||||
|
||||
free(info->euicc_ci_public_key_id_list_for_verification);
|
||||
}
|
||||
|
||||
if (info->euicc_ci_public_key_id_list_for_signing)
|
||||
{
|
||||
char **p = info->euicc_ci_public_key_id_list_for_signing;
|
||||
while (*p)
|
||||
{
|
||||
free(*p++);
|
||||
}
|
||||
for (int i = 0; info->euicc_ci_public_key_id_list_for_signing[i] != NULL; i++)
|
||||
free(info->euicc_ci_public_key_id_list_for_signing[i]);
|
||||
|
||||
free(info->euicc_ci_public_key_id_list_for_signing);
|
||||
}
|
||||
free(info);
|
||||
|
|
|
@ -18,4 +18,4 @@ struct es10cex_euiccinfo2
|
|||
};
|
||||
|
||||
int es10cex_get_euiccinfo2(struct euicc_ctx *ctx, struct es10cex_euiccinfo2 *info);
|
||||
int es10cex_free_euiccinfo2(struct es10cex_euiccinfo2 *info);
|
||||
void es10cex_free_euiccinfo2(struct es10cex_euiccinfo2 *info);
|
||||
|
|
|
@ -179,7 +179,7 @@ int es10x_init(struct euicc_ctx *ctx)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((ctx->es10x_logic_channel = ctx->interface.apdu->logic_channel_open(ctx, ISD_R_AID, sizeof(ISD_R_AID) - 1)) < 0)
|
||||
if ((ctx->es10x_logic_channel = ctx->interface.apdu->logic_channel_open(ctx, (const uint8_t *)ISD_R_AID, sizeof(ISD_R_AID) - 1)) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -49,30 +49,27 @@ static int applet_main(int argc, char **argv)
|
|||
cJSON_AddNumberToObject(jeuiccinfo2, "free_ram", euiccinfo2.free_ram);
|
||||
if (euiccinfo2.euicc_ci_public_key_id_list_for_verification)
|
||||
{
|
||||
cJSON *a = cJSON_CreateArray();
|
||||
char **p = euiccinfo2.euicc_ci_public_key_id_list_for_verification;
|
||||
while (*p)
|
||||
cJSON *verification_keys = cJSON_CreateArray();
|
||||
for (int i = 0; euiccinfo2.euicc_ci_public_key_id_list_for_verification[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(a, cJSON_CreateString(*p));
|
||||
free(*p++);
|
||||
cJSON_AddItemToArray(verification_keys, cJSON_CreateString(euiccinfo2.euicc_ci_public_key_id_list_for_verification[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jeuiccinfo2, "euicc_ci_public_key_id_list_for_verification", a);
|
||||
cJSON_AddItemToObject(jeuiccinfo2, "euicc_ci_public_key_id_list_for_verification", verification_keys);
|
||||
free(euiccinfo2.euicc_ci_public_key_id_list_for_verification);
|
||||
}
|
||||
else
|
||||
{
|
||||
cJSON_AddNullToObject(jeuiccinfo2, "euicc_ci_public_key_id_list_for_verification");
|
||||
}
|
||||
|
||||
if (euiccinfo2.euicc_ci_public_key_id_list_for_signing)
|
||||
{
|
||||
cJSON *a = cJSON_CreateArray();
|
||||
char **p = euiccinfo2.euicc_ci_public_key_id_list_for_signing;
|
||||
while (*p)
|
||||
cJSON *signing_keys = cJSON_CreateArray();
|
||||
for (int i = 0; euiccinfo2.euicc_ci_public_key_id_list_for_signing[i] != NULL; i++)
|
||||
{
|
||||
cJSON_AddItemToArray(a, cJSON_CreateString(*p));
|
||||
free(*p++);
|
||||
cJSON_AddItemToArray(signing_keys, cJSON_CreateString(euiccinfo2.euicc_ci_public_key_id_list_for_signing[i]));
|
||||
}
|
||||
cJSON_AddItemToObject(jeuiccinfo2, "euicc_ci_public_key_id_list_for_signing", a);
|
||||
cJSON_AddItemToObject(jeuiccinfo2, "euicc_ci_public_key_id_list_for_signing", signing_keys);
|
||||
free(euiccinfo2.euicc_ci_public_key_id_list_for_signing);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue