bytedreamer / OSDP.Net

A .NET Core control panel implementation of the Open Supervised Device Protocol(OSDP)
Apache License 2.0
47 stars 19 forks source link

retry for CHLNG not resetting sequence? #95

Closed rsgmodelworks closed 1 year ago

rsgmodelworks commented 2 years ago

With osdp.net configured for 3 PD's (at 0, 3, and 7) It appears that it does not reset the sequence number if it gets a NAK 0 and it was attempting to set up a secure channel. See attached log, packet 11 (a nak-0/s0/a=3) and packet 14 (a chlng/s1/a=3). IMO while this PD has issues the ACU code should be going back to sequence number 0 when it receives a NAK 0. 21.log

bytedreamer commented 1 year ago

The assumption is made that only the ACU set the sequence cadence. The PD should only reply to the sequence number value it was sent be the ACU command.

bytedreamer commented 1 year ago

Are we assuming that a sequence zero that is sent from PD is a request to reset the connection?

rsgmodelworks commented 1 year ago

A sequence number of 0 from a PD means the PD thinks the sequencing is screwed up and the ACU should go back to sequence 0. If this happens inside a secure channel the ACU should additionally discard the current secure channel connection because if you can't trust the link layer (i.e frame header/sequence number) then you can't trust the rolling MAC value. And you might be under attack by an intercept-in-the-middle attack.

rsgmodelworks commented 1 year ago

{"command":"polling","action":"reset"} will make libosdp-conformance as a PD reset the sequence number to zero. Useful for testing this?