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

Improvements of SM implementation #67

Closed
wants to merge 2 commits into from

Conversation

frankmorgner
Copy link
Member

Needs to be tested with real cards.

@viktorTarasov
Copy link
Member

Cherry-picked into 'staging' your commit 'use error code if no SM ...', thank you.
31bdbd6

As for the commit 'avoid manual memory ...':

  • static buffers of 0xFFFF length makes me scare -- 'MEM05-C: Avoid large stack allocations' .
  • your thesis that 'manual', as you call it, memory allocation breaks the OpenSC habits is not relevant:
    Look onto sc_connect_card(), sc_select_file(), pkcs15 bind and get-object functions.
  • anyway, for the sm-apdu the card specific 'get-apdu' and 'free-apdu' handlers are called,
    and I prefer to let these handlers to (de)allocate the memory -- they know better how much they need and how to deal with it.

Let me know if 'manual' allocation makes impossible the implementation of the support for your card -- we will try to find solution .

@frankmorgner
Copy link
Member Author

Hi!

As for the commit 'avoid manual memory ...':

  • static buffers of 0xFFFF length makes me scare -- 'MEM05-C: Avoid large stack allocations' .

Memory is cheap. 0xffff+0xffff is 128 kB.

MEM05-C doesn't apply here:
The growth of the stack can not be controlled or influenced by an
attacker. 128 kB are always allocated.

Even if MEM05-C would apply, OpenSC is not a secure software by any
means. Not having to handle malloc, calloc, free and their errors
reduces complexity and potential errors of the programmer.

  • your thesis that 'manual', as you call it, memory allocation breaks the OpenSC habits is not relevant:
    Look onto sc_connect_card(), sc_select_file(), pkcs15 bind and get-object functions.

I didn't say that OpenSC consistently follows its own design goals.

  • anyway, for the sm-apdu the card specific 'get-apdu' and 'free-apdu' handlers are called,
    and I prefer to let these handlers to (de)allocate the memory -- they know better how much they need and how to deal with it.

Let me know if 'manual' allocation makes impossible the implementation of the support for your card -- we will try to find solution .

Cheers, Frank.

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

Successfully merging this pull request may close these issues.

None yet

2 participants