mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-08-27 23:28:12 +01:00
GENERAL AUTHENTICATE rejects truncated/inconsistent envelopes before TLV parsing.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -26,7 +26,13 @@
|
||||
|
||||
int cmd_general_authenticate(void) {
|
||||
if (P1(apdu) == 0x0 && P2(apdu) == 0x0) {
|
||||
if (apdu.nc < 2) {
|
||||
return SW_WRONG_LENGTH();
|
||||
}
|
||||
if (apdu.data[0] == 0x7C) {
|
||||
if (apdu.data[1] != apdu.nc - 2) {
|
||||
return SW_WRONG_DATA();
|
||||
}
|
||||
int r = 0;
|
||||
uint16_t pubkey_len = 0;
|
||||
const uint8_t *pubkey = NULL;
|
||||
@@ -41,6 +47,9 @@ int cmd_general_authenticate(void) {
|
||||
pubkey_len = tag_len + 1;
|
||||
}
|
||||
}
|
||||
if (!pubkey) {
|
||||
return SW_WRONG_DATA();
|
||||
}
|
||||
file_t *fkey = file_search(EF_KEY_DEV);
|
||||
if (!fkey) {
|
||||
return SW_EXEC_ERROR();
|
||||
|
||||
Reference in New Issue
Block a user