otrv4.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. --------------------------------------------------------------------------------
  2. --
  3. -- Murphi Model of the OTRv4 Draft Protocol State Machine
  4. --
  5. --------------------------------------------------------------------------------
  6. --
  7. -- Written by Nik Unger in 2018
  8. --
  9. -- This is free and unencumbered software released into the public domain.
  10. -- See the UNLICENSE file for the full license / public domain declaration.
  11. --
  12. -- The structure of this Murphi description is heavily inspired by the
  13. -- Needham-Schroeder description by Ulrich Stern, 1998 (bundled with CMurphi),
  14. -- and the OTRv2 description by Andrew Morrison and Joe Bonneau, 2006.
  15. --
  16. --------------------------------------------------------------------------------
  17. --------------------------------------------------------------------------------
  18. -- Declarations
  19. --------------------------------------------------------------------------------
  20. const
  21. NumParticipants: 2; -- number of participants in the system
  22. NetworkSize: 1; -- max. number of outstanding messages in network
  23. MaxKnowledge: 10; -- max. number of messages intruder can remember
  24. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  25. type
  26. ParticipantId: scalarset (NumParticipants);
  27. MessageType : enum { -- Types of messages that can be sent
  28. M_Plaintext, -- Ordinary plaintext without special values
  29. M_WSpTaggedPlaintext, -- Plaintext with a whitespace tag
  30. M_QueryMessage, -- OTR query message
  31. M_ErrorMessage, -- OTR error message
  32. M_IdentityMessage, -- Identity message (DAKEZ flow 1)
  33. M_AuthR, -- Auth-R message (DAKEZ flow 2)
  34. M_AuthI, -- Auth-I message (DAKEZ flow 3)
  35. M_NonInteractiveAuth, -- Non-Interactive-Auth message (XZDH flow 2)
  36. M_DAKEData, -- Mandatory encrypted message reply to an Auth-I
  37. M_DataMessage -- Encrypted message with text and optionally TLV(s)
  38. };
  39. TLVType : enum { -- Types of encoded TLVs inside data messages
  40. T_Padding, -- Data to ignore (to hide message lengths)
  41. T_Disconnected, -- States that the conversation is over
  42. T_SMP1, -- SMP flow 1
  43. T_SMP2, -- SMP flow 2
  44. T_SMP3, -- SMP flow 3
  45. T_SMP4, -- SMP flow 4
  46. T_SMPAbort, -- States that the SMP has failed
  47. T_ExtraSymmetric -- Request for an extra symmetric key
  48. };
  49. Message : record
  50. src, dst: ParticipantId;
  51. msgType: MessageType;
  52. -- TODO
  53. endrecord;
  54. -- Not modeled: fragmented messages
  55. -- Not modeled: OTRv3 transitions
  56. ProtocolState : enum { -- Main protocol states for OTRv4 clients
  57. S_Start, -- Initial client state
  58. S_WaitingAuthR, -- Waiting for M_AuthR
  59. S_WaitingAuthI, -- Waiting for M_AuthI
  60. S_WaitingDAKEData, -- Waiting for M_DAKEData
  61. S_EncryptedMessages, -- DAKE is finished, ready for encrypted messages
  62. S_Finished -- Received a disconnected message
  63. };
  64. SMPState : enum { -- SMP state, which expects an S_EncryptedMessages state
  65. SMP_Expect1, -- Initial SMP state, waiting for a T_SMP1 TLV
  66. SMP_Expect2, -- Waiting for a T_SMP2 TLV
  67. SMP_Expect3, -- Waiting for a T_SMP3 TLV
  68. SMP_Expect4 -- Waiting for a T_SMP4 TLV
  69. };
  70. Participant : record
  71. protoState: ProtocolState; -- Overall protocol state machine
  72. smpState: SMPState; -- SMP state machine
  73. -- TODO
  74. endrecord;
  75. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  76. -- The global state of the system
  77. var
  78. net: multiset[NetworkSize] of Message; -- In-flight messages
  79. agents: array[ParticipantId] of Participant; -- Honest clients
  80. -- Adversarial knowledge:
  81. -- TODO
  82. --------------------------------------------------------------------------------
  83. -- Rules
  84. --------------------------------------------------------------------------------