Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large STORE DATA impossible to send #94

Open
antonio-fr opened this issue Apr 11, 2024 · 5 comments
Open

Large STORE DATA impossible to send #94

antonio-fr opened this issue Apr 11, 2024 · 5 comments

Comments

@antonio-fr
Copy link

Since a line is limited to 1024, and data is hex encoded, it is not possible to send data larger than ~490 bytes. The buffer size is defined at compile time, and hardcoded.

One of our own applet uses direct personalization and STORE DATA to setup a x509 certificate, which is around 600 bytes large. This is not possible to use a store_data command line to upload it using this software. This is sad, as this software correctly -and automatically- performs the commands chaining to send multiple data blocks. Also, the data buffer is set to 4096 bytes. But this is limited by this hard limit of 1024 bytes per command line.

We are using the standard input to send command lines to the binary exe. The issue is that it cuts the lines which are greater to 1024 bytes. What is after 1024 bytes, is seen as new line.

I think of several ways to solve this issue:

  • Add some note in the documentation to tell about this limitation
  • Increase the buffer size to a value large enough for smartcards = 16384 bytes ?
  • Only enlarge the buffer for data and a command line
  • Make the BUFLEN a customizable parameter for the user : CLI argument, env var, ... So this value would be defined at startup.

Technically, the main culprit seems to be here:

static TCHAR dummy[BUFLEN];

This is used in handleCommands, and also in handleOptions.

@antonio-fr
Copy link
Author

It may also come from this part:

TCHAR buf[BUFLEN + 1], commandLine[BUFLEN + 1];

The parsed buffer "buf" is limited in size.

@koh-osug
Copy link

Hi Antonio, you are using the install_for_personalization and store_data -dataFormat format -dataEncryption encryption -data data command? I can look into increasing the buffer size then. Can you try to make your suggested changes (increase BUFLEN) and give it a try?

@antonio-fr
Copy link
Author

No. I'm using direct perso store_data. More precisely, after selecting the applet (not SD), and opening a secure channel with it:
store_data -dataFormat 0x08 -data xxxx

I didn't want to spend time to compile, I can give a quick try bc I have the VC tools and cmake already.

@antonio-fr
Copy link
Author

I modified to #define BUFLEN 8192 and compiled (was not so hard). And store_data works with the 550 bytes payload (1200 bytes command line).

@koh-osug
Copy link

Great! I have pushed an update to main and the next release will contain the enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants