-
Notifications
You must be signed in to change notification settings - Fork 803
epass2003: SM checking (MAC and SW) #2772
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
Conversation
|
Just for completeness: AES-CBC-MAC was tested on a real epass2003 token. I don't have a real token using DES, so the code for DES was written according to the construct_mac_tlv() function. This code was verified only in the simulation - (the simulator could be used as part of OpenSC CI tests, functionality example: https://github.com/popovec/OpenSC/actions/runs/4891381567) |
src/libopensc/card-epass2003.c
Outdated
|
|
||
| /* copy response to buffer and append padding */ | ||
| memcpy(data, in, mac_len); | ||
| memset(data + mac_len, 0, blocksize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use calloc instead of malloc above and you don't need to memset here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best to use alloca (let's save free maintenance). However, I did not find `alloc' anywhere in the OpenSC code, I understand that there may be a problem with portability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alloca is not supported on Windows, afaik. Also, I don't like it personally because you can't do any error handling (a failure in memory allocation with alloca is just undefined behavior).
This patch introduces basic verification of data coming from the token in the secure messaging mode: 1. compare raw SW and SW encoded in SM 2. verify MAC MAC verification is working only for DES and AES-CBC-MAC. Code for checking MAC in FIPS mode is still missing. modified: src/libopensc/card-epass2003.c
cb81904 to
2d2f57f
Compare
|
Rebased. Access outside the input buffer fixed by checking the |
This patch introduces basic verification of data coming from the token in the secure messaging mode:
MAC verification is working only for DES and AES-CBC-MAC. Code for checking MAC in FIPS mode is still missing.