mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-25 08:31:04 +03:00
OSCORE: Roll back replay window on decryption failure
oscore_validate_sender_seq() moves the replay window on before the message has been decrypted, and oscore_roll_back_seq() is meant to undo that when decryption fails. It only restored last_seq and sliding_window when the saved values were non zero, and never restored initial_state. For a recipient context still in its initial state (rfc8613_b_1_2 false), or one whose last_seq is 0, a single request with a forged Partial IV and an invalid tag left last_seq at the sender's chosen value, so the genuine peer's following requests were rejected as outside the replay window. The client did not roll back at all when a response failed decryption, and the server called oscore_update_seq_num_cb() with the new window before decrypting the request, so credential storage could be updated with a forged sequence number even when the in memory window was restored. Record whether there is a window update to undo and restore initial_state with it, roll back on response decryption failure as well, and only call oscore_update_seq_num_cb() once the request has been decrypted. Add a unit test.
This commit is contained in:
1 parent
7a7336aa89
commit
537d06f593
4 files changed
+74
-12
No files matched your search
@@ -131,6 +131,8 @@ struct oscore_recipient_ctx_t {
|
||||
uint64_t rollback_last_seq;
|
||||
uint8_t echo_value[8];
|
||||
uint8_t initial_state;
|
||||
uint8_t rollback_initial_state;
|
||||
uint8_t rollback_valid;
|
||||
uint8_t silent_server;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user