mgmt/osdp: phy: Allow non-conformant, 0 length, encrypted data blocks
If command or reply has no data, PD "should" use secure message types SCS_15 or SCS_16. But some PD seem to not implement this correctly. We will be tolerant towards those faulty implementations. Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
This commit is contained in:
parent
1648e86f4b
commit
a1edd3e74d
|
@ -482,13 +482,22 @@ int osdp_phy_decode_packet(struct osdp_pd *pd, uint8_t *buf, int len,
|
|||
* ID (data[0]) when calling osdp_decrypt_data().
|
||||
*/
|
||||
len = osdp_decrypt_data(pd, is_cmd, data + 1, len - 1);
|
||||
if (len <= 0) {
|
||||
if (len < 0) {
|
||||
LOG_ERR("Failed at decrypt; discarding SC");
|
||||
sc_deactivate(pd);
|
||||
pd->reply_id = REPLY_NAK;
|
||||
pd->ephemeral_data[0] = OSDP_PD_NAK_SC_COND;
|
||||
return OSDP_ERR_PKT_NACK;
|
||||
}
|
||||
if (len == 0) {
|
||||
/**
|
||||
* If cmd/reply has no data, PD "should" have
|
||||
* used SCS_15/SCS_16 but we will be tolerant
|
||||
* towards those faulty implementations.
|
||||
*/
|
||||
LOG_INF("Received encrypted data block with 0 "
|
||||
"length; tolerating non-conformance!");
|
||||
}
|
||||
len += 1; /* put back cmd/reply ID */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue