smart raw: make --t1 switch the card to T=1 by itself
A card runs the protocol its TD1 names until a PPS changes it. --t1 only picked the module's T=1 send opcode, so on a card whose ATR offers T=0 first the APDU went out as T=1 blocks to a card still speaking T=0 and got no answer at all: smart raw --t1 -s -d 00a4040007a000000004101000 [!] smart card response failed 'smart pps --t1' in the same client session made it work, which is what the help for 'smart pps' already promised was unnecessary: Note 'smart raw --t1' already switches a card to T=1 by itself when the ATR offers it; this is for negotiating Fi/Di explicitly. Do it for real. SmartCardRaw() now runs the PPS when T=1 is asked for and nothing has selected it yet, taking the ATR it needs first because PPS is only legal in that window. It fires once per activation: a second --t1 apdu sees the protocol already in force and sends straight away. A card that does not offer T=1 is left alone and the apdu still goes out, as before. Also fix the flag names in the docs and in the error path. 'smart raw's first example and both 'Choose either' messages said -0 / -1, which have never existed. tools/pm3_online_tests.sh had copied the example, so its T=0 checks failed with 'invalid option' on every run; its T=1 checks needed no change beyond dropping the now unnecessary reset. Co-Authored-By: Claude Opus 5 (1M context)
This commit is contained in:
1 parent
3853540d31
commit
971c318d78
4 files changed
+32
-11
No files matched your search
@@ -475,12 +475,12 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "smart raw",
|
||||
"Sends raw bytes to card",
|
||||
"smart raw -s -0 -d 00a404000e315041592e5359532e4444463031 -> `1PAY.SYS.DDF01` PPSE directory with get ATR\n"
|
||||
"smart raw --t0 -d 00a404000e325041592e5359532e4444463031 -> `2PAY.SYS.DDF01` PPSE directory\n"
|
||||
"smart raw --t0 -t -d 00a4040007a0000000041010 -> Mastercard\n"
|
||||
"smart raw --t0 -t -d 00a4040007a0000000031010 -> Visa\n"
|
||||
"smart raw --t0 -s -d 00a404000e315041592e5359532e4444463031 -> `1PAY.SYS.DDF01` PPSE directory with get ATR\n"
|
||||
"smart raw --t0 -d 00a404000e325041592e5359532e4444463031 -> `2PAY.SYS.DDF01` PPSE directory\n"
|
||||
"smart raw --t0 -t -d 00a4040007a0000000041010 -> Mastercard\n"
|
||||
"smart raw --t0 -t -d 00a4040007a0000000031010 -> Visa\n"
|
||||
"smart raw --t1 -s -d 00a404000e325041592e5359532e444446303100 -> PPSE over T=1\n"
|
||||
" (T=1 carries the whole APDU, so case 4 needs its Le)"
|
||||
" (T=1 carries the whole APDU, so case 4 needs its Le)"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
@@ -516,7 +516,7 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (use_t0 && use_t1) {
|
||||
PrintAndLogEx(FAILED, "Choose either -0 or -1, not both");
|
||||
PrintAndLogEx(FAILED, "Choose either --t0 or --t1, not both");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
@@ -968,7 +968,7 @@ static int CmdSmartPPS(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (use_t0 && use_t1) {
|
||||
PrintAndLogEx(FAILED, "Choose either -0 or -1, not both");
|
||||
PrintAndLogEx(FAILED, "Choose either --t0 or --t1, not both");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user