pySim-shell_test/utils: print logfile on all types of errors
When pySim-shell has problems starting up, it exits with an error code. This is detected by the testsuite, but it also causes an early exit, so that the log file content are not printed.
The tests that check the establishment of a secure channel currently only test security level 3. Also the get_data command after it only tests data reception from the card.
Let's extend the test coverage and test the SCP establishment for security level 1 as well. Let's also add a get_status command to make sure sending data to the card also works (without exceptions).
when we sign and encrypt the APDU in _wrap_cmd_apdu (SCP03) we return an "mapdu" at the end. However, in the (unlikely?) case where self.do_cencand self.do_cmac are false, mapdu will be undeclared. In _wrap_cmd_apdu for SCP02 we just re-use the apdu variable and return it at the end, so when no encryption and no signing is applied, the APDU falls just through without any modifications. We should have the same mechanism for the SCP03 wrapping as well.
The "apdu" command allows us to send custom APDUs to a card. This command is often used in low level initialization scripts or tests. To stop the script execution in case of an error, the command allows us to specify a status word that must match the status word of the response. But we have no such mechanism for the response itsself. Let's add another parameter where we can pass a regex that the response must match.
pySim-shell: fix reset command for no-profile mode
There are situations where no card profile can be determined. In this case no RuntimeState will be present. This is in particular the case when pySim-shell is used on a card that is not provisioned/initialized yet. In those cases we have to go the direct route and reset the card directly.
by default pySim-shell does all kinds of probing and file selection on startup. This is to determine the card type and to find a suitable card profile. However, in case the card is non yet provisioned this probing may cause a error messages and even might upset the cards internal state. So let's have a commandline option thrugh which we can instruct pySim-shell to skip any initialization and to give us a prompt immediately, so that we can enter custom APDUs
pySim/transport add support for T=1 protocol and fix APDU/TPDU layer conflicts
ETSI TS 102 221, section 7.3 specifies that UICCs (and eUICCs) may support two different transport protocols: T=0 or T=1 or both. The spec also says that the terminal must support both protocols.
This patch adds the necessary functionality to support the T=1 protocol alongside the T=0 protocol. However, this also means that we have to sharpen the lines between APDUs and TPDUs.