Skip to content

Commit

Permalink
fixes issue #92 support for install params > 128 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaoh committed Mar 17, 2024
1 parent 0a40511 commit c556794
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions globalplatform/src/globalplatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,8 @@ OPGP_ERROR_STATUS get_install_data(BYTE P1, PBYTE executableLoadFileAID, DWORD e
BYTE buf[256];
DWORD i=0;
DWORD hiByte, loByte;
DWORD installParametersLengthSize;
DWORD installParameterFieldLengthSize;
DWORD installParameterFieldLength;
OPGP_ERROR_STATUS status;

OPGP_LOG_START(_T("get_install_data"));
Expand All @@ -3289,42 +3290,40 @@ OPGP_ERROR_STATUS get_install_data(BYTE P1, PBYTE executableLoadFileAID, DWORD e
buf[i++] = 0x01;
buf[i++] = applicationPrivileges; // application privileges

buf[i++] = 0x02; // install parameter field length
installParameterFieldLength = 0x02; // install parameter field length tag C9 + length byte (C9LL)
if (installParametersLength > 0) {
buf[i-1] += (BYTE)installParametersLength;
installParameterFieldLength += (BYTE)installParametersLength;
}
if (uiccSystemSpecParamsLength > 0) {
buf[i-1] += 2;
buf[i-1] += (BYTE)uiccSystemSpecParamsLength;
installParameterFieldLength += 2;
installParameterFieldLength += (BYTE)uiccSystemSpecParamsLength;
}

if (nonVolatileDataSpaceLimit > 0 || volatileDataSpaceLimit > 0 || simSpecParamsLength > 0) {
buf[i-1] += 2; // 0xEF LL
installParameterFieldLength += 2; // 0xEF LL
}
if (nonVolatileDataSpaceLimit > 0) {
buf[i-1] += 4;
installParameterFieldLength += 4;
}
if (volatileDataSpaceLimit > 0) {
buf[i-1] += 4;
installParameterFieldLength += 4;
}
if (simSpecParamsLength > 0) {
buf[i-1] += (BYTE)simSpecParamsLength + 2;
installParameterFieldLength += (BYTE)simSpecParamsLength + 2;
}

buf[i++] = 0xC9; // application install parameters
if (installParametersLength < 128L) {
installParametersLengthSize=1;
if (installParameterFieldLength < 128L) {
installParameterFieldLengthSize=1;
}
else if (installParametersLength < 256L) {
installParametersLengthSize=2;
else if (installParameterFieldLength < 256L) {
installParameterFieldLengthSize=2;
}
else if (installParametersLength < 65536L) {
installParametersLengthSize=3;
else if (installParameterFieldLength < 65536L) {
installParameterFieldLengthSize=3;
}
else {
{ OPGP_ERROR_CREATE_ERROR(status, OPGP_ERROR_INSTALL_PARAMETERS_TOO_LARGE, OPGP_stringify_error(OPGP_ERROR_INSTALL_PARAMETERS_TOO_LARGE)); goto end; }
}
switch (installParametersLengthSize) {
switch (installParameterFieldLengthSize) {
case 1: {
buf[i++] = (BYTE)installParametersLength;
break;
Expand All @@ -3340,6 +3339,7 @@ OPGP_ERROR_STATUS get_install_data(BYTE P1, PBYTE executableLoadFileAID, DWORD e
buf[i++] = (BYTE)(installParametersLength - (buf[i-1] << 8));
}
}
buf[i++] = 0xC9; // application install parameters
memcpy(buf+i, installParameters, installParametersLength);
i+=installParametersLength;

Expand Down

0 comments on commit c556794

Please sign in to comment.