Skip to content

Commit

Permalink
mkm: add state machine to client_event spec
Browse files Browse the repository at this point in the history
  • Loading branch information
septract committed Dec 21, 2024
1 parent c7f87d3 commit 093dd29
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions components/mission_key_management/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#endif

/* TODO list:
- Fix some of the TODOs
- Run the test generator on the code
- make the key access table into a global??
- Start to impose state machine properties on the protocol
*/

/*$ predicate (map<u64,u8>) KeyPred (pointer p)
Expand All @@ -50,9 +51,19 @@ predicate (struct client) ClientPred (pointer p)
{
take C = Owned<struct client>(p);
assert ( ValidState(C.state) ) ;
take K = KeyPred(C.key); // Discard the key, for now
take K = KeyPred(C.key); // Discard the key
return C;
}
function (boolean) ValidTransition (u32 pre, u32 post) {
(
( pre == post )
|| ( (pre == (u32) CS_RECV_KEY_ID) && (post == (u32) CS_SEND_CHALLENGE) )
|| ( (pre == (u32) CS_SEND_CHALLENGE) && (post == (u32) CS_RECV_RESPONSE) )
|| ( (pre == (u32) CS_RECV_RESPONSE) && (post == (u32) CS_SEND_KEY) )
|| ( ValidState(pre) && (post == (u32) CS_DONE) )
)
}
$*/


Expand Down Expand Up @@ -303,6 +314,7 @@ requires
! is_null(Client_in.key);
ensures
take Client_out = ClientPred(c);
Client_out.state == Client_in.state;
$*/
{
const uint8_t* buf = client_write_buffer(c);
Expand Down Expand Up @@ -373,6 +385,7 @@ requires
! is_null(Client_in.key); // TODO: should depend on state machine state
ensures
take Client_out = ClientPred(c);
ValidTransition(Client_in.state, Client_out.state);
$*/
{
if (events & EPOLLIN) {
Expand Down

0 comments on commit 093dd29

Please sign in to comment.