bZRTP
bZRTP is an opensource implementation of ZRTP keys exchange protocol
stateMachine.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2019 Belledonne Communications SARL.
3  *
4  * This file is part of bzrtp.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef STATEMACHINE_H
20 #define STATEMACHINE_H
21 
22 #include "typedef.h"
23 
24 /* types definition for event and state function */
25 /* the INIT event type is used to run some state for the firt time : create packet and send it */
26 #define BZRTP_EVENT_INIT 0
27 #define BZRTP_EVENT_MESSAGE 1
28 #define BZRTP_EVENT_TIMER 2
29 #define BZRTP_EVENT_GOCLEAR 3
30 #define BZRTP_EVENT_ACCEPT_GOCLEAR 4
31 #define BZRTP_EVENT_BACKTOSECURE 5
32 
33 /* error code definition */
34 #define BZRTP_ERROR_UNSUPPORTEDZRTPVERSION 0xe001
35 #define BZRTP_ERROR_UNMATCHINGPACKETREPETITION 0xe002
36 #define BZRTP_ERROR_CACHEMISMATCH 0xe004
37 
38 #ifdef __cplusplus
39 extern "C"{
40 #endif
41 
45 typedef struct bzrtpEvent_struct {
52 } bzrtpEvent_t;
53 
58 
59 
60 /* state functions prototypes, split in categories corresponding to the differents protocol phases: discovery, key agreement, confirmation */
74 
75 
88 
89 
105 
106 
124 
138 
151 
152 
167 
168 
182 
197 int state_secure(bzrtpEvent_t event);
198 
211 
224 int state_clear(bzrtpEvent_t event);
225 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* STATEMACHINE_H */
uint8_t eventType
Definition: stateMachine.h:46
int state_keyAgreement_responderSendingDHPart1(bzrtpEvent_t event)
For DHM mode only, responder send DHPart1 packet.
Definition: stateMachine.c:691
struct bzrtpEvent_struct bzrtpEvent_t
The event type, used as a parameter for the state function.
int state_keyAgreement_sendingCommit(bzrtpEvent_t event)
For any kind of key agreement (DHM, Mult, PreShared), we keep sending commit.
Definition: stateMachine.c:381
unsigned short uint16_t
Definition: stdint.h:79
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
Definition: packetParser.h:134
unsigned char uint8_t
Definition: stdint.h:78
int state_sending_GoClear(bzrtpEvent_t event)
GoClear initiator send a GoClear message.
Definition: stateMachine.c:1648
bzrtpPacket_t * bzrtpPacket
Definition: stateMachine.h:49
structure of the ZRTP engine context Store current state, timers, HMAC and encryption keys ...
Definition: typedef.h:235
int state_confirmation_initiatorSendingConfirm2(bzrtpEvent_t event)
Initiator send the confirm2 message.
Definition: stateMachine.c:1264
The event type, used as a parameter for the state function.
Definition: stateMachine.h:45
int state_confirmation_responderSendingConfirm1(bzrtpEvent_t event)
Responder send the confirm1 message.
Definition: stateMachine.c:1043
int state_discovery_waitingForHelloAck(bzrtpEvent_t event)
We are now waiting for the HelloACK packet from peer or a Commit packet.
Definition: stateMachine.c:245
int state_secure(bzrtpEvent_t event)
We are in secure state.
Definition: stateMachine.c:1428
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. ...
Definition: stateMachine.c:2751
int state_keyAgreement_initiatorSendingDHPart2(bzrtpEvent_t event)
For DHM mode only, initiator send DHPart2 packet.
Definition: stateMachine.c:905
uint16_t bzrtpPacketStringLength
Definition: stateMachine.h:48
The zrtp context of a channel.
Definition: typedef.h:157
uint8_t * bzrtpPacketString
Definition: stateMachine.h:47
int(* bzrtpStateMachine_t)(bzrtpEvent_t)
the state function pointer definition
Definition: stateMachine.h:57
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 ...
Definition: stateMachine.c:51
bzrtpChannelContext_t * zrtpChannelContext
Definition: stateMachine.h:51
bzrtpContext_t * zrtpContext
Definition: stateMachine.h:50
int state_clear(bzrtpEvent_t event)
We are in clear state.
Definition: stateMachine.c:1860
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 ...
Definition: stateMachine.c:175