bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
Loading...
Searching...
No Matches
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_EVENT_GOCLEAR   3
 
#define BZRTP_EVENT_ACCEPT_GOCLEAR   4
 
#define BZRTP_EVENT_BACKTOSECURE   5
 
#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.
 
typedef int(* bzrtpStateMachine_t) (bzrtpEvent_t)
 the state function pointer definition
 

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.
 
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.
 
int state_discovery_waitingForHelloAck (bzrtpEvent_t event)
 We are now waiting for the HelloACK packet from peer or a Commit packet.
 
int state_keyAgreement_sendingCommit (bzrtpEvent_t event)
 For any kind of key agreement (DHM, Mult, PreShared), we keep sending commit.
 
int state_keyAgreement_responderSendingDHPart1 (bzrtpEvent_t event)
 For DHM mode only, responder send DHPart1 packet.
 
int state_keyAgreement_initiatorSendingDHPart2 (bzrtpEvent_t event)
 For DHM mode only, initiator send DHPart2 packet.
 
int state_confirmation_responderSendingConfirm1 (bzrtpEvent_t event)
 Responder send the confirm1 message.
 
int state_confirmation_initiatorSendingConfirm2 (bzrtpEvent_t event)
 Initiator send the confirm2 message.
 
int state_secure (bzrtpEvent_t event)
 We are in secure state.
 
int state_sending_GoClear (bzrtpEvent_t event)
 GoClear initiator send a GoClear message.
 
int state_clear (bzrtpEvent_t event)
 We are in clear state.
 
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.
 

Macro Definition Documentation

◆ BZRTP_ERROR_CACHEMISMATCH

#define BZRTP_ERROR_CACHEMISMATCH   0xe004

◆ BZRTP_ERROR_UNMATCHINGPACKETREPETITION

#define BZRTP_ERROR_UNMATCHINGPACKETREPETITION   0xe002

◆ BZRTP_ERROR_UNSUPPORTEDZRTPVERSION

#define BZRTP_ERROR_UNSUPPORTEDZRTPVERSION   0xe001

◆ BZRTP_EVENT_ACCEPT_GOCLEAR

#define BZRTP_EVENT_ACCEPT_GOCLEAR   4

◆ BZRTP_EVENT_BACKTOSECURE

#define BZRTP_EVENT_BACKTOSECURE   5

◆ BZRTP_EVENT_GOCLEAR

#define BZRTP_EVENT_GOCLEAR   3

◆ BZRTP_EVENT_INIT

#define BZRTP_EVENT_INIT   0

◆ BZRTP_EVENT_MESSAGE

#define BZRTP_EVENT_MESSAGE   1

◆ BZRTP_EVENT_TIMER

#define BZRTP_EVENT_TIMER   2

Typedef Documentation

◆ bzrtpEvent_t

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

◆ bzrtpStateMachine_t

typedef int(* bzrtpStateMachine_t) (bzrtpEvent_t)

the state function pointer definition

Function Documentation

◆ bzrtp_updateCachedSecrets()

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

◆ state_clear()

int state_clear ( bzrtpEvent_t  event)

We are in clear state.

Arrives from:

  • state_sending_GoClear on ClearACK reception

state_secure on GoClear reception

  • state_clear on manuel confirmation of the responder (of the GoClear) Goes to:
    • state_keyAgreement_sendingCommit when user pressed a button to indicate that he wants to back to secure mode
    • state_confirmation_responderSendingConfirm1 on commit reception

◆ state_confirmation_initiatorSendingConfirm2()

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

◆ state_confirmation_responderSendingConfirm1()

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

◆ state_discovery_init()

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

◆ state_discovery_waitingForHello()

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

◆ state_discovery_waitingForHelloAck()

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

◆ state_keyAgreement_initiatorSendingDHPart2()

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

◆ state_keyAgreement_responderSendingDHPart1()

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

◆ state_keyAgreement_sendingCommit()

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

◆ state_secure()

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:
  • state_sending_GoClear when user pressed a button to indicate that he wants to change the encryption mode
  • state_clear on GoClear reception Send :
  • Conf2ACK on Confirm2 reception

ClearACK on GoClear reception (+ destroy all key materials)

◆ state_sending_GoClear()

int state_sending_GoClear ( bzrtpEvent_t  event)

GoClear initiator send a GoClear message.

Arrives from:

  • state_secure when user pressed a button to indicate that he wants to change the encryption mode Goes to:
  • state_clear on ClearACK reception Send :
  • GoClear message (+ destroy all key materials on ClearACK reception)