bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
Data Structures | Macros | Typedefs | Functions
stateMachine.h File Reference

Go to the source code of this file.

Data Structures

struct  bzrtpEvent_struct
 The event type, used as a parameter for the state function. More...
 

Macros

#define BZRTP_EVENT_INIT   0
 
#define BZRTP_EVENT_MESSAGE   1
 
#define BZRTP_EVENT_TIMER   2
 
#define BZRTP_ERROR_UNSUPPORTEDZRTPVERSION   0xe001
 
#define BZRTP_ERROR_UNMATCHINGPACKETREPETITION   0xe002
 
#define BZRTP_ERROR_CACHEMISMATCH   0xe004
 

Typedefs

typedef struct bzrtpEvent_struct bzrtpEvent_t
 The event type, used as a parameter for the state function. More...
 
typedef int(* bzrtpStateMachine_t) (bzrtpEvent_t)
 the state function pointer definition More...
 

Functions

int state_discovery_init (bzrtpEvent_t event)
 This is the initial state On first call, we will create the Hello message and start sending it until we receive an helloACK or a hello message from peer. More...
 
int state_discovery_waitingForHello (bzrtpEvent_t event)
 Arrives in this state coming from init upon reception on Hello ACK, we are now waiting for the Hello packet from peer. More...
 
int state_discovery_waitingForHelloAck (bzrtpEvent_t event)
 We are now waiting for the HelloACK packet from peer or a Commit packet. More...
 
int state_keyAgreement_sendingCommit (bzrtpEvent_t event)
 For any kind of key agreement (DHM, Mult, PreShared), we keep sending commit. More...
 
int state_keyAgreement_responderSendingDHPart1 (bzrtpEvent_t event)
 For DHM mode only, responder send DHPart1 packet. More...
 
int state_keyAgreement_initiatorSendingDHPart2 (bzrtpEvent_t event)
 For DHM mode only, initiator send DHPart2 packet. More...
 
int state_confirmation_responderSendingConfirm1 (bzrtpEvent_t event)
 Responder send the confirm1 message. More...
 
int state_confirmation_initiatorSendingConfirm2 (bzrtpEvent_t event)
 Initiator send the confirm2 message. More...
 
int state_secure (bzrtpEvent_t event)
 We are in secure state. More...
 
int bzrtp_updateCachedSecrets (bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext)
 Compute the new rs1 and update the cached secrets according to rfc section 4.6.1. More...
 

Macro Definition Documentation

#define BZRTP_ERROR_CACHEMISMATCH   0xe004
#define BZRTP_ERROR_UNMATCHINGPACKETREPETITION   0xe002
#define BZRTP_ERROR_UNSUPPORTEDZRTPVERSION   0xe001
#define BZRTP_EVENT_INIT   0
#define BZRTP_EVENT_MESSAGE   1
#define BZRTP_EVENT_TIMER   2

Typedef Documentation

The event type, used as a parameter for the state function.

typedef int(* bzrtpStateMachine_t) (bzrtpEvent_t)

the state function pointer definition

Function Documentation

int bzrtp_updateCachedSecrets ( bzrtpContext_t zrtpContext,
bzrtpChannelContext_t zrtpChannelContext 
)

Compute the new rs1 and update the cached secrets according to rfc section 4.6.1.

param[in] zrtpContext The context we are operation on param[in/out] zrtpChannelContext The channel context we are operation on(contains s0)

return 0 on success, error code otherwise

int state_confirmation_initiatorSendingConfirm2 ( bzrtpEvent_t  event)

Initiator send the confirm2 message.

Arrives from:

  • state_keyAgreement_initiatorSendingDHPart2 upon confirm1 reception
  • state_keyAgreement_sendingCommit upon Confirm1 reception in non DHM mode Goes to:
  • state_secure on Conf2ACK reception or first SRTP message Send :
  • Confirm2 until timer's end or transition
int state_confirmation_responderSendingConfirm1 ( bzrtpEvent_t  event)

Responder send the confirm1 message.

Arrives from:

  • state_keyAgreement_responderSendingDHPart1 upon DHPart2 reception
  • state_keyAgreement_sendingCommit upon Commit reception in non DHM mode and commit contention gives us the responder role
  • state_discovery_waitingForHelloAck upon Commit reception in non DHM mode Goes to:
  • state_secure on Confirm2 reception Send :
  • Confirm1 on Commit or DHPart2 reception
int state_discovery_init ( bzrtpEvent_t  event)

This is the initial state On first call, we will create the Hello message and start sending it until we receive an helloACK or a hello message from peer.

Arrives from :

  • This is the initial state Goes to:
  • state_discovery_waitingForHello upon HelloACK reception
  • state_discovery_waitingForHelloAck upon Hello reception Send :
  • Hello until timer's end or transition
int state_discovery_waitingForHello ( bzrtpEvent_t  event)

Arrives in this state coming from init upon reception on Hello ACK, we are now waiting for the Hello packet from peer.

Arrives from :

  • state_discovery_init upon HelloACK reception Goes to:
    • state_keyAgreement_sendingCommit upon Hello reception Send :
    • HelloACK on Hello reception
int state_discovery_waitingForHelloAck ( bzrtpEvent_t  event)

We are now waiting for the HelloACK packet from peer or a Commit packet.

Arrives from :

  • state_discovery_init upon Hello reception Goes to:
  • state_keyAgreement_sendingCommit upon HelloACK reception
  • state_keyAgreement_responderSendingDHPart1 upon Commit reception in DHM mode
  • state_confirmation_responderSendingConfirm1 upon Commit reception in non DHM mode Send :
  • Hello until timer's end or transition
  • HelloACK on Hello reception
int state_keyAgreement_initiatorSendingDHPart2 ( bzrtpEvent_t  event)

For DHM mode only, initiator send DHPart2 packet.

Arrives from:

  • state_keyAgreement_sendingCommit upon DHPart1 reception Goes to:
    • state_confirmation_initiatorSendingConfirm2 upon reception of Confirm1 Send :
    • DHPart2 until timer's end or transition
int state_keyAgreement_responderSendingDHPart1 ( bzrtpEvent_t  event)

For DHM mode only, responder send DHPart1 packet.

Arrives from:

  • state_discovery_waitingForHelloAck upon Commit reception in DHM mode
  • state_keyAgreement_sendingCommit upon Commit reception in DHM mode and commit contention gives us the responder role Goes to:
    • state_confirmation_responderSendingConfirm1 upon DHPart2 reception Send :
    • DHPart1 on Commit reception
int state_keyAgreement_sendingCommit ( bzrtpEvent_t  event)

For any kind of key agreement (DHM, Mult, PreShared), we keep sending commit.

Arrives from :

  • state_discovery_waitingForHello upon Hello received
  • state_discovery_waitingForHelloAck upon HelloACK received Goes to:
  • state_keyAgreement_initiatorSendingDHPart2 upon DHPart1 reception in DHM mode
  • state_confirmation_initiatorSendingConfirm2 upon Confirm1 reception in non DHM mode
  • state_keyAgreement_responderSendingDHPart1 upon Commit reception in DHM mode and commit contention gives us the responder role
  • state_confirmation_responderSendingConfirm1 upon Commit reception in non DHM mode and commit contention gives us the responder role Send :
  • Commit until timer's end or transition
  • HelloACK on Hello reception
int state_secure ( bzrtpEvent_t  event)

We are in secure state.

Arrives from:

  • state_confirmation_responderSendingConfirm1 on Confirm2 reception
  • state_confirmation_initiatorSendingConfirm2 on conf2ACK or first SRTP message Goes to:
  • This is the end(we do not support GoClear message), state machine may be destroyed after going to secure mode Send :
  • Conf2ACK on Confirm2 reception