|
cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
|
What a tapped card is missing, read from its SELECT response. More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | CARD_SELECT_APDU |
| SELECT for the Cryptnox applet: CLA INS P1 P2 Lc || AID. | |
| #define | CARD_FLAGS_OFF 5U |
| Offset of the flags byte in a SELECT response. | |
| #define | CARD_SELECT_MIN 8U |
| Shortest SELECT response this can read: flags plus the status word. | |
| #define | CARD_FLAG_PIN_SET 0x40U |
| #define | CARD_FLAG_SEEDED 0x20U |
Enumerations | |
| enum | card_state_t { CARD_READY = 0 , CARD_UNKNOWN , CARD_NO_PIN , CARD_NO_KEY } |
| What a tapped card is missing. More... | |
Functions | |
| static card_state_t | card_state (const uint8_t *r, size_t n) |
| Judge a card from its SELECT response. | |
| static const char * | card_state_text (card_state_t s) |
| The line to put in front of the operator, or NULL if there is none. | |
What a tapped card is missing, read from its SELECT response.
A card straight out of its envelope has no PIN and no key on it. Neither the payment path nor the payout read can do anything with one, and without this both find out three APDUs later — as "Wrong card PIN" or as a sign error — which sends the operator looking for a fault that is not there. The applet publishes both facts in the clear in its SELECT response, before any secure channel or PIN is involved, so the terminal can simply say which.
Header-only and free of ESP-IDF, for the same reason addr_check.h is: it is a parser over bytes a card sent, so it is kept where a host test can reach it (tests/units/test_card_status.cpp).
The layout is the one cryptnox-sdk-py's factory._select() reads:
r[0] card type, 'B' (Basic) or 'N' (NFT) r[1..3] applet version r[4..35] the 32 data bytes; r[5] is the flags byte r[n-2..] SW1 SW2
and the two flags are the ones it exposes as card.initialized and card.seeded.
Definition in file card_status.h.
| #define CARD_FLAG_PIN_SET 0x40U |
Initialised: PIN and PUK are set.
Definition at line 48 of file card_status.h.
Referenced by card_state().
| #define CARD_FLAG_SEEDED 0x20U |
A key has been generated or loaded.
Definition at line 49 of file card_status.h.
Referenced by card_state().
| #define CARD_FLAGS_OFF 5U |
Offset of the flags byte in a SELECT response.
Definition at line 43 of file card_status.h.
Referenced by card_state().
| #define CARD_SELECT_APDU |
SELECT for the Cryptnox applet: CLA INS P1 P2 Lc || AID.
Definition at line 39 of file card_status.h.
Referenced by card_fault(), and pin_fail_text().
| #define CARD_SELECT_MIN 8U |
Shortest SELECT response this can read: flags plus the status word.
Definition at line 46 of file card_status.h.
Referenced by card_state().
| enum card_state_t |
What a tapped card is missing.
Definition at line 52 of file card_status.h.
|
inlinestatic |
Judge a card from its SELECT response.
| [in] | r | Response bytes as the card sent them, status word included. |
| [in] | n | Number of bytes in r. |
Definition at line 70 of file card_status.h.
References CARD_FLAG_PIN_SET, CARD_FLAG_SEEDED, CARD_FLAGS_OFF, CARD_NO_KEY, CARD_NO_PIN, CARD_READY, CARD_SELECT_MIN, and CARD_UNKNOWN.
Referenced by card_fault().
|
inlinestatic |
The line to put in front of the operator, or NULL if there is none.
Short enough for the panel's failure line and the config page's note, and it names the fix rather than the flag: whoever is holding a blank card needs to be told to set it up, not told about bit 6.
Definition at line 94 of file card_status.h.
References CARD_NO_KEY, and CARD_NO_PIN.
Referenced by card_fault().